PyXB 1.2.3 released

Help
2013-09-18
2014-03-10
  • Peter A. Bigot
    Peter A. Bigot
    2013-09-18

    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 <pab@pabigot.com>
    >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/pdb.py", line 1314, in main
        pdb._runscript(mainpyfile)
      File "/usr/pkg/lib/python2.7/pdb.py", line 1233, in _runscript
        self.run(statement)
      File "/usr/pkg/lib/python2.7/bdb.py", line 400, in run
        exec cmd in globals, locals
      File "<string>", line 1, in <module>
      File "a.py", line 1, in <module>
        import hoge.binding as o
      File "hoge/binding.py", line 62, in CreateFromDocument
        saxer.parse(io.BytesIO(xmld))
      File "/home/takashi/.local/lib/python2.7/site-packages/_xmlplus/sax/expatreader.py", line 109, in parse
        xmlreader.IncrementalParser.parse(self, source)
      File "/home/takashi/.local/lib/python2.7/site-packages/_xmlplus/sax/xmlreader.py", line 123, in parse
        self.feed(buffer)
      File "/home/takashi/.local/lib/python2.7/site-packages/_xmlplus/sax/expatreader.py", line 216, in feed
        self._parser.Parse(data, isFinal)
      File "/home/takashi/.local/lib/python2.7/site-packages/_xmlplus/sax/expatreader.py", line 353, in start_element_ns
        AttributesNSImpl(newattrs, qnames))
      File "/home/takashi/.local/lib/python2.7/site-packages/pyxb/binding/saxer.py", line 330, in startElementNS
        if self.__XSITypeTuple in attrs:
      File "/home/takashi/.local/lib/python2.7/site-packages/_xmlplus/sax/xmlreader.py", 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/xmlreader.py(316)__getitem__()
    -> return self._attrs[name]
    (Pdb) p self
    <xml.sax.xmlreader.AttributesNSImpl instance at 0x7f7ff38a5320>
    (Pdb)
    
     
  • Peter A. Bigot
    Peter A. Bigot
    2013-12-03

    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
    2014-03-10

    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
    2014-03-10

    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.