Message248948
If module's __init__.py contains "__import__('pkg_resources').declare_namespace(__name__)", the module is not loaded, even though it's located in the current directory and should mask other modules.
Originally I stumbled upon this issue while installing a new version of Google Protobuf. But here's a simpler repro:
$ python -c 'import json; print json.__file__'
/usr/lib/python2.7/json/__init__.pyc
$ mkdir json; echo "print 'test'" > json/__init__.py
$ python -c 'import json; print json.__file__'
test
json/__init__.py
$ echo "__import__('pkg_resources').declare_namespace(__name__); print 'test'" > json/__init__.py
$ python -c 'import json; print json.__file__'
test
/usr/lib/python2.7/json/__init__.pyc
For Protobuf, if you build Python bindings from sources, the google/__init__.py will contain exactly "__import__('pkg_resources').declare_namespace(__name__)" and it prevents the freshly-built module from being loaded, even if the module egg is at the first place in sys.path. So an older version gets loaded and it screws things up.
Ubuntu 14.10, Python 2.7.8 |
|
Date |
User |
Action |
Args |
2015-08-21 10:18:53 | Vadim Kantorov | set | recipients:
+ Vadim Kantorov |
2015-08-21 10:18:53 | Vadim Kantorov | set | messageid: <1440152333.17.0.123323582496.issue24907@psf.upfronthosting.co.za> |
2015-08-21 10:18:53 | Vadim Kantorov | link | issue24907 messages |
2015-08-21 10:18:52 | Vadim Kantorov | create | |
|