PyXB 1.2.3 released

  • Peter A. Bigot
    Peter A. Bigot

    PyXB 1.2.3 has now been released and is available for download from SourceForge and (supposedly) PyPI. Details of the release are here.

    Those interested in Python 3 support can obtain a translated version from the git repository as documented in the release notes.

  • is the release broken for python 2.7?
    namely, the following change doesn't seem to work for me.
    >commit 8ff6b623c46fd6a117a22603da5048ccdf0c08eb
    >Author: Peter A. Bigot <>
    >Date:   Fri Sep 13 13:18:54 2013 -0500
    >    python3: use x in d rather than has_key
    the following is a trace on my environment.
    AttributesNSImpl (from pyXML 0.8.4) has has_key but no __contains__.
    (Pdb) c
    Traceback (most recent call last):
      File "/usr/pkg/lib/python2.7/", line 1314, in main
      File "/usr/pkg/lib/python2.7/", line 1233, in _runscript
      File "/usr/pkg/lib/python2.7/", line 400, in run
        exec cmd in globals, locals
      File "<string>", line 1, in <module>
      File "", line 1, in <module>
        import hoge.binding as o
      File "hoge/", line 62, in CreateFromDocument
      File "/home/takashi/.local/lib/python2.7/site-packages/_xmlplus/sax/", line 109, in parse
        xmlreader.IncrementalParser.parse(self, source)
      File "/home/takashi/.local/lib/python2.7/site-packages/_xmlplus/sax/", line 123, in parse
      File "/home/takashi/.local/lib/python2.7/site-packages/_xmlplus/sax/", line 216, in feed
        self._parser.Parse(data, isFinal)
      File "/home/takashi/.local/lib/python2.7/site-packages/_xmlplus/sax/", line 353, in start_element_ns
        AttributesNSImpl(newattrs, qnames))
      File "/home/takashi/.local/lib/python2.7/site-packages/pyxb/binding/", line 330, in startElementNS
        if self.__XSITypeTuple in attrs:
      File "/home/takashi/.local/lib/python2.7/site-packages/_xmlplus/sax/", line 316, in __getitem__
        return self._attrs[name]
    KeyError: 0
    Uncaught exception. Entering post mortem debugging
    Running 'cont' or 'step' will restart the program
    > /home/takashi/.local/lib/python2.7/site-packages/_xmlplus/sax/
    -> return self._attrs[name]
    (Pdb) p self
    <xml.sax.xmlreader.AttributesNSImpl instance at 0x7f7ff38a5320>
  • Peter A. Bigot
    Peter A. Bigot

    There are no known problems with PyXB on Python 2.7 that would express in that way. Either the problem comes from running it under pdb, or it's a bug in your program, or it's an unknown problem with PyXB.

    Or it's a problem with whatever _xmlplus is or your python installation; normally I find those modules in /usr/lib/python2.7/xml/sax, not in sitepackages. Looks like you've got pyXML getting in the way.

    Last edit: Peter A. Bigot 2013-12-03
  • indeed, it turned out to be pyXML installation problem.
    (i had two instances of pyXML installed)
    thanks for pointing out.

  • Eric Stadtherr
    Eric Stadtherr

    I am seeing that same KeyError exception (with the same stack trace) even with a single valid installation of PyXML. If I uninstall the PyXML package, my test driver (which simply does a set of "CreateFromDocument" calls on known binding types) works fine. If I install PyXML, I get this KeyError.

    My setup is PyXB 1.2.3 on RHEL 6.4 x86_64 (python 2.6.6, PyXML 0.8.4). PyXB 1.1 is already working correctly on that same platform - I'm just seeing the error trying to upgrade to PyXB 1.2.

    Removing PyXML isn't an option, since I have other code that depends on its xpath implementation. It also doesn't seem like there's a way to tell the builtin "xml" module not to look for _xmlplus (and just use the builtin sax implementation).

    Any suggestions?

  • Peter A. Bigot
    Peter A. Bigot

    Sorry. AFAICT PyXML hasn't been updated since version 0.8.4 in November 2004; it's not available on pypi, and the web site says not to use the version that's still on sourceforge. So I can't reproduce the problem.

    From your description I'm going to guess the issue is related to trac/224. If so, you may be able to fix it by using pyxb.utils.domutils.SetDOMImplementation() as described in the DR or with alternative arguments.

    If that's not it, I'm afraid I can't really help you.