[pypy-issue] [issue1476] apparent regression in import in py2.0 b2

Amaury Forgeot d Arc tracker at bugs.pypy.org
Tue May 7 17:17:39 CEST 2013


Amaury Forgeot d Arc <amauryfa at gmail.com> added the comment:

I write my cffi helper modules like this:

xmllib.py::

    ...cffi declarations...
    ffilib = ffi.verify(...)

    for name in dir(ffilib):
        # Export all public declared names
        if name.startswith(('xml', 'xslt')):
            globals()[name] = getattr(ffilib, name)

Then you can simply access functions and defines with code like::
    import xmllib
    xmllib.XML_TEXT_NODE
This used to work with variables.

Of course, the workaround is to do::
    xsltDocDefaultLoader = mylib.xsltDocDefaultLoader
but for each variable.


[Now, I realize that "mylib" is itself a Module... maybe there is nice a pattern which hacks sys.modules.]

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1476>
________________________________________


More information about the pypy-issue mailing list