[issue15623] Init time relative imports no longer work from __init__.so modules

Stefan Behnel report at bugs.python.org
Sun Aug 12 06:35:33 CEST 2012


Stefan Behnel added the comment:

We are continuously testing Cython against all CPython versions starting from 2.4, so I can assure you that it's still working for all other versions. Here's our CI server:

https://sage.math.washington.edu:8091/hudson/job/cython-devel-tests/618/

I just tried it and it definitely works for me in 3.2 and prints the right module names.

I attached the unfolded test directory. The only changes I applied were to change the setup.py script so that you can build it without Cython, and to replace the absolute paths stored in the C files by relative paths (which happily continue to work). Just run "python3.3 setup.py build_ext -i" and then "PYTHON=python3.3 ./test.sh".

Note that the output for "FILE" will be the original Python source file. Cython sets this at init time because CPython fails to provide the correct import file path at that point. The value is actually written down verbatimly in the C sources.

It prints sys.modules at module init time, so you can see that it contains "my_test_package" in Py<3.3 but does not contain it in Py3.3.

The code for the relative import in __init__.c starts in line 1097. It actually calls "__import__()" internally.

----------
Added file: http://bugs.python.org/file26773/test.tgz

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15623>
_______________________________________


More information about the Python-bugs-list mailing list