Function split_body references variable before assignment

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

Bug Description


Function split_body in `lxml/html/` may reference variables `pre`, `html`, and/or `post` prior to assignment at 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/", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib64/python2.7/site-packages/lxml/html/", line 880, in <module>
  File "/usr/lib64/python2.7/site-packages/lxml/html/", line 43, in main
    body1 = split_body(input1)[1]
  File "/usr/lib64/python2.7/site-packages/lxml/html/", 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