Stefan Behnel added the comment:

Interesting. I didn't know that. The .py file is always installed automatically 
next to the .so file by distutils.

Here's what strace gives me:

Python 2.7:

stat("my_test_package", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
stat("my_test_package/__init__.py", {st_mode=S_IFREG|0664, st_size=557, ...}) = 0
stat("my_test_package/__init__", 0x7fffdc9dd320) = -1 ENOENT (No such file or 
directory)
open("my_test_package/__init__.so", O_RDONLY) = 3
open("my_test_package/__init__.so", O_RDONLY|O_CLOEXEC) = 4

Python 3.2:

stat("my_test_package", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
stat("my_test_package/__init__.py", {st_mode=S_IFREG|0664, st_size=557, ...}) = 0
stat("my_test_package/__init__", 0x7fff9d99d700) = -1 ENOENT (No such file or 
directory)
stat("my_test_package/__init__.cpython-32mu.so", {st_mode=S_IFREG|0775, 
st_size=82517, ...}) = 0
open("my_test_package/__init__.cpython-32mu.so", O_RDONLY) = 3
open("my_test_package/__init__.cpython-32mu.so", O_RDONLY|O_CLOEXEC) = 4

Python 3.3:

stat("./my_test_package", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
stat("./my_test_package/__init__.cpython-33dm.so", {st_mode=S_IFREG|0775, 
st_size=36119, ...}) = 0
open("./my_test_package/__init__.cpython-33dm.so", O_RDONLY|O_CLOEXEC) = 3

That's the difference then.

Ok, I think we'll have to emulate this for older CPython versions as well for 
the case that the .py file is not there. So it's likely best to let Cython 
register the package in sys.modules at init time, right after calling 
AddModule().

Still - can this be implemented in CPython for 3.3? Or 3.4, given that it might 
appear like a new feature? There shouldn't be all that much to change.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15623>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to