This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author scoder
Recipients Arfrever, brett.cannon, eric.snow, georg.brandl, meador.inge, scoder
Date 2012-08-13.17:59:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1344880778.62.0.77765058341.issue15623@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-08-13 17:59:38scodersetrecipients: + scoder, brett.cannon, georg.brandl, Arfrever, meador.inge, eric.snow
2012-08-13 17:59:38scodersetmessageid: <1344880778.62.0.77765058341.issue15623@psf.upfronthosting.co.za>
2012-08-13 17:59:38scoderlinkissue15623 messages
2012-08-13 17:59:37scodercreate