Roundup Robot added the comment:
New changeset 74faca1ac59c by Ned Deily in branch '2.7':
Issue #6676: Ensure a meaningful exception is raised when attempting
http://hg.python.org/cpython/rev/74faca1ac59c
New changeset 9e3fc66ee0b8 by Ned Deily in branch '3.4':
Issue #6676: Ensure a meaningful
Ned Deily added the comment:
Applied for release in 3.5.0, 3.4.1 and 2.7.7. Thanks, everyone!
--
resolution: - fixed
stage: patch review - committed/rejected
status: open - closed
versions: +Python 3.5 -Python 3.3
___
Python tracker
Ned Deily added the comment:
Thanks for the reminder, David. Here are patches for 3.x and 2.7 that include
updated versions of the proposed pyexpat.c and test_pyexpat.py patches along
with a doc update along the lines suggested by David.
--
stage: - patch review
versions: -Python
Changes by Ned Deily n...@acm.org:
Added file: http://bugs.python.org/file34241/issue6676_27.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6676
___
David H. Gutteridge added the comment:
Updating to reflect the Python 3.4 documentation is now also relevant to this
discussion. Perhaps someone could commit a change something like my suggestion
in msg143295?
--
versions: +Python 3.4
___
Python
David H. Gutteridge dhgutteri...@sympatico.ca added the comment:
Ned: My proposed wording is: Note that only one document can be parsed by a
given instance; it is not possible to reuse an instance to parse multiple
files. To provide more detail, one could also add something like: The
isfinal
Ned Deily n...@acm.org added the comment:
I agree that, at a minimum, the documentation should be updated to include a
warning about not reusing a parser instance. Whether it's worth trying to plug
all the holes in the expat library is another issue (see, for instance,
issue12829). David,
Ned Deily n...@acm.org added the comment:
Also, note issue1208730 proposes a feature to expose a binding for
XML_ParserReset and has the start of a patch.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6676
David H. Gutteridge dhgutteri...@sympatico.ca added the comment:
The documentation should definitely be updated to clarify that a parser
instance is not reusable with more than one file. I had a look at the
equivalent documentation for Perl and TCL, and Perl's implementation explicitly
does
Will Grainger willgrain...@gmail.com added the comment:
I don't think this is a python specific problem. I have just seen
the same error when working with the expat library from C, and the cause
is using the same parser to read multiple files.
--
nosy: +willgrainger
Andy Balaam m...@artificialworlds.net added the comment:
I am also seeing this with Python 2.5.2 on Ubuntu.
--
nosy: +andybalaam
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6676
___
Andy Balaam m...@artificialworlds.net added the comment:
Just in case it wasn't obvious - the workaround is to create a new
parser (with xml.parsers.expat.ParserCreate()) for every XML file you
want to parse.
--
___
Python tracker
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment:
I'm not familiar with expat, but we can see what is happening more
clearly with attached adhok patch.
Traceback (most recent call last):
File expat-error.py, line 14, in module
p.ParseFile(file)
xml.parsers.expat.ExpatError:
Amaury Forgeot d'Arc amaur...@gmail.com added the comment:
The patch is good; a test would be appreciated.
The difference now is that in case of true low-memory conditions,
ExpatError(no memory) is raised instead of MemoryError.
This is acceptable IMO.
It seems ParseFile() doesn't support
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment:
Well, I tried to write test like this.
1. Check if xml.parsers.expat.error is raised.
2. Compare *code* attribute of error object with
xml.parsers.expat.errors.XML_ERROR_FINISHED
But I noticed XML_ERROR_FINISHED is not integer but
Amaury Forgeot d'Arc amaur...@gmail.com added the comment:
Looks like an implementation bug to me; far too late to change it, though.
In your test, you could use
pyexpat.ErrorString(e.code) == pyexpat.errors.XML_ERROR_FINISHED
And the docs could mention this trick.
--
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment:
Here is the patch. I'm not confident with my English comment though.
--
Added file: http://bugs.python.org/file15090/pyexpat.patch
___
Python tracker rep...@bugs.python.org
Changes by Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp:
Removed file: http://bugs.python.org/file15089/pyexpat_addhok.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6676
___
Amaury Forgeot d'Arc amaur...@gmail.com added the comment:
Do you know the new context manager feature of assertRaises? it makes
it easier to check for exceptions.
I join a new patch that uses it.
--
Added file: http://bugs.python.org/file15094/pyexpat-2.patch
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment:
I knew existence of that new feature, but didn't know how to use it.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6676
___
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment:
Hmm, looks useful. I think your patch is good. Only one problem is that
we cannot use this new feature in python2.6. If we use my patch in that
branch, I think there is no problem.
--
New submission from Matthew webmas...@adurosolutions.com:
I'm using the Expat python interface to parse multiple XML files in an
application and have found that it throws a Memory Error exception if
multiple calls are made to xmlparser.ParseFile(file) on the same
xmlparser object. This occurs
Matthew webmas...@adurosolutions.com added the comment:
This also occurs with Python 2.5.1 on OS X
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6676
___
23 matches
Mail list logo