[pypy-dev] Module hijinx

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Sat Jan 9 23:37:49 CET 2010


On a PyPy I translated this morning, I'm seeing weird behavior importing
a module that messes with sys.modules (not a nice thing to do, but I
would still expect it to work):

exarkun at boson:/tmp$ ls -lR trickypackage/
total 4
-rw-r--r-- 1 exarkun exarkun 61 2010-01-09 11:39 foo.py
-rw-r--r-- 1 exarkun exarkun  0 2010-01-09 11:40 __init__.py
exarkun at boson:/tmp$ cat trickypackage/foo.py
import sys
sys.modules['trickypackage.foo'] = "Hello, world"
exarkun at boson:/tmp$ python
Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>from trickypackage import foo
'Hello, world'
exarkun at boson:/tmp$ 
Python 2.5.2 (70469, Jan 09 2010, 15:24:34)
[PyPy 1.1.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``PyPy doesn't change the
fundamental physics constants''
>>>from trickypackage import foo
<module 'trickypackage.foo' from '/tmp/trickypackage/foo.py'>

Anyone have any idea why this might happen?  The real problem this is 
causing for me is with the twisted.internet.reactor module, of course.


More information about the Pypy-dev mailing list