Stefan Behnel added the comment:

Well, it's not like the setup was all that difficult. 1) Install the latest 
github master of Cython (they provide one-click archives that pip can install 
for you), 2) change into the CPython stdlib directory and run the script I 
attached, 3) execute "import os" in Python. You need to install Cython rather 
than just unpacking it because it uses 2to3 for installation in Py3.

Anyway, I ran gdb on it and it turns out that the exception is correct, there 
is an infinite recursion taking place. According to the (otherwise not very 
interesting) stack trace at the point where it raises the RuntimeError, the 
module init function of the first Cython module (say, "os") calls the builtin 
"__import__()" to import "posixpath". That triggers the load of that shared 
library and the execution of its module init function. Fine so far. However, 
that module init function then executes an import of "os" through 
"__import__()", which then runs the module init function of the "os" module 
again. Bug right here. It shouldn't try to reimport a module that it is already 
importing.

I could reduce the test case down to one line:

  # reimport.py
  import reimport

Compiling that with Cython gives the C code I attached. Build it, import it, 
see it fail. However, remember that fixing only this isn't enough, the import 
cycle might be nested arbitrarily deep.

----------
versions: +Python 3.3
Added file: http://bugs.python.org/file27864/reimport.c

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

Reply via email to