Message6644
I just encountered this bug as well. It actually affects all attribute names that are exactly 2 characters long.
The dirty workaround is to use -
attrs._attrs.getValue('id')
instead to get values, and remember that that will throw a KeyError exception if it does not exist.
The bug is rather simple - in Lib/xml/sax/drivers2/drv_javasax.py, in the function _fixTuple, on line 241, it checks the length of the first argument, nsTuple, and if it is a length of 2, assumes it is a tuple of (namespace, localName) and proceeds to unpack it.
Unfortunately it doesn't check the type, and other methods (specifically _makeJavaNsTuple and _makePythonNsTuple) pass in a string instead, therefore a string of length 2 is assumed to be a (namespace, localName) tuple as a string is a sequence type as well.
The solution is to enact a type check that specifically excludes strings, e.g.
def _fixTuple(nsTuple, frm, to):
# NOTE the isinstance check that excludes strings
if not isinstance(nsTuple, str) and len(nsTuple) == 2:
nsUri, localName = nsTuple
if nsUri == frm:
nsUri = to
return (nsUri, localName)
return nsTuple
The alternative is to check for a tuple, but that then you would exclude other sequence and sequence-like types.
I hope this is enough information to perform the one-liner fix; I can provide a diff file if necessary. |
|
Date |
User |
Action |
Args |
2011-09-11 05:58:13 | samuel337 | set | messageid: <1315720693.01.0.993493108776.issue1768@psf.upfronthosting.co.za> |
2011-09-11 05:58:13 | samuel337 | set | recipients:
+ samuel337, pekka.klarck |
2011-09-11 05:58:12 | samuel337 | link | issue1768 messages |
2011-09-11 05:58:12 | samuel337 | create | |
|