[ python-Bugs-1614387 ] AttributesImpl does not implement __contains__ on Linux

SourceForge.net noreply at sourceforge.net
Sat Dec 16 12:05:58 CET 2006


Bugs item #1614387, was opened at 2006-12-13 00:24
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1614387&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: XML
Group: 3rd Party
Status: Closed
Resolution: Invalid
Priority: 5
Private: No
Submitted By: Jason Briggs (jrbriggs)
Assigned to: Nobody/Anonymous (nobody)
Summary: AttributesImpl does not implement __contains__ on Linux

Initial Comment:
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

----------------------------------------------------------------------

>Comment By: Georg Brandl (gbrandl)
Date: 2006-12-16 11:05

Message:
Logged In: YES 
user_id=849994
Originator: NO

Reported in the PyXML tracker.

----------------------------------------------------------------------

Comment By: Georg Brandl (gbrandl)
Date: 2006-12-15 22:23

Message:
Logged In: YES 
user_id=849994
Originator: NO

It looks like the xmlreader.py doesn't come from the Python distribution,
but from the PyXML library, which is maintained elsewhere.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1614387&group_id=5470


More information about the Python-bugs-list mailing list