Issue 1614387: AttributesImpl does not implement contains on Linux (original) (raw)

Hi there

Had an odd error trying to run a utility called SVGMath:

File "/home/jason/downloads/SVGMath-0.3.1/svgmath/mathconfig.py", line 54, in startElement elif u"afm" in attributes: File "/usr/lib/python2.5/site-packages/_xmlplus/sax/xmlreader.py", line 316, in getitem return self._attrs[name] KeyError: 0

It appears that AttributesImpl in the sax package (xmlreader.py) doesn't implement contains, so the 'in' operator throws an error. This is on Kubuntu/Linux, so I'm not sure if it's distro-specific or all Linux versions of Python.

In any case, if you add:

def __contains__(self, name):
    return self._attrs.has_key(name)

to AttributesImpl in xmlreader.py (as per the Windows version of Python), the problem goes away.

Kind regards Jason