Function split_body references variable before assignment

Bug #1710429 reported by Sebastian Pipping
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Fix Released
Low
scoder

Bug Description

Hi!

Function split_body in `lxml/html/_diffcommand.py` may reference variables `pre`, `html`, and/or `post` prior to assignment at https://github.com/lxml/lxml/blob/master/src/lxml/html/_diffcommand.py#L82. This is how to reproduce the bug from the shell:

```
# python2 -m lxml.html.diff /dev/null{,}
Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib64/python2.7/site-packages/lxml/html/diff.py", line 880, in <module>
    _diffcommand.main()
  File "/usr/lib64/python2.7/site-packages/lxml/html/_diffcommand.py", line 43, in main
    body1 = split_body(input1)[1]
  File "/usr/lib64/python2.7/site-packages/lxml/html/_diffcommand.py", line 82, in split_body
    return pre, html, post
UnboundLocalError: local variable 'pre' referenced before assignment
```

Best, Sebastian

Revision history for this message
scoder (scoder) wrote :
Changed in lxml:
assignee: nobody → scoder (scoder)
importance: Undecided → Low
milestone: none → 3.9.0
status: New → Fix Committed
Revision history for this message
Sebastian Pipping (sebastian-pipping) wrote :

Variable `post` has the same problem. That seems unfixed.

Revision history for this message
Sebastian Pipping (sebastian-pipping) wrote :

Edit: I misread "pre = post = ''" as "pre = ''", nevermind.

scoder (scoder)
Changed in lxml:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.