You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
xml.sax.parser() doesn't terminate when given a filename #46753
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/benjaminp'closed_at=<Date2008-09-04.02:23:01.849>created_at=<Date2008-03-28.10:15:13.330>labels= ['expert-XML', 'type-bug', 'release-blocker']
title="xml.sax.parser() doesn't terminate when given a filename"updated_at=<Date2012-08-24.08:34:14.926>user='https://github.com/mark-summerfield'
Under 3 it does not terminate:
: python3 sax.py test.xml
+ document+ outer+ inner- inner- outer- document
Traceback (most recent call last):
File "sax.py", line 19, in <module>
parser.parse(sys.argv[1])
File "/home/mark/opt/python30a3/lib/python3.0/xml/sax/expatreader.py",
line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/home/mark/opt/python30a3/lib/python3.0/xml/sax/xmlreader.py",
line 124, in parse
buffer = file.read(self._bufsize)
File "/home/mark/opt/python30a3/lib/python3.0/io.py", line 774, in read
current = self.raw.read(to_read)
KeyboardInterrupt
The xml.sax.parser() function seems to work fine if you give it an open
file object and close the file after the call. But the documentation
says you can give it a filename, but if you do that the parser does not
terminate in Python 3 although it works fine in Python 2.
I had to disable three unit tests in test_sax. We didn't noticed the
problem before because the tests weren't actually run. The three tests
are marked clearly with XXX and FIXME.
Activity
mark-summerfield commentedon Mar 28, 2008
The tiny program at the end of this message runs under Python 2.5 &
30a3. Under 2 it gives the following output:
: python sax.py test.xml
('+', u'document')
('+', u'outer')
('+', u'inner')
('-', u'inner')
('-', u'outer')
('-', u'document')
Done
The xml.sax.parser() function seems to work fine if you give it an open
file object and close the file after the call. But the documentation
says you can give it a filename, but if you do that the parser does not
terminate in Python 3 although it works fine in Python 2.
Here is the test file:
<?xml version="1.0" encoding="UTF-8"?>
<document>
<outer>
<inner>
</inner>
</outer>
</document>
tiran commentedon Mar 28, 2008
I had to disable three unit tests in test_sax. We didn't noticed the
problem before because the tests weren't actually run. The three tests
are marked clearly with XXX and FIXME.
devdanzin commentedon Aug 28, 2008
ISTM that this release blocker can be solved by changing
xml.sax.xmlreader.py line 122 from:
while buffer != "":
to
while buffer != b"":
tiran commentedon Aug 28, 2008
I've a better idea:
It's faster and works for both empty bytes and str.
The patch fixes the issue and re-enables three unit tests.
benjaminp commentedon Sep 1, 2008
The patch looks great. (I love enabling disabled tests!)
devdanzin commentedon Sep 1, 2008
Looks like this is a duplicate of bpo-3590, so this patch fixes two
release blockers ;)
warsaw commentedon Sep 4, 2008
Benjamin will commit this.
benjaminp commentedon Sep 4, 2008
Applied in r66203.