[New-bugs-announce] [issue17802] html.HTMLParser raises UnboundLocalError:

Baptiste Mispelon report at bugs.python.org
Sat Apr 20 12:58:16 CEST 2013


New submission from Baptiste Mispelon:

When trying to parse the string `a&b`, the parser raises an UnboundLocalError:

{{{
>>> from html.parser import HTMLParser
>>> p = HTMLParser()
>>> p.feed('a&b')
>>> p.close()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.3/html/parser.py", line 149, in close
    self.goahead(1)
  File "/usr/lib/python3.3/html/parser.py", line 252, in goahead
    if k <= i:
UnboundLocalError: local variable 'k' referenced before assignment
}}}

Granted, the HTML is invalid, but this error looks like it might have been an oversight.

----------
components: Library (Lib)
messages: 187414
nosy: bmispelon
priority: normal
severity: normal
status: open
title: html.HTMLParser raises UnboundLocalError:
type: crash
versions: Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17802>
_______________________________________


More information about the New-bugs-announce mailing list