Author scoder
Recipients brett.cannon, pitrou, scoder
Date 2012-11-03.20:11:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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:

  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.
Date User Action Args
2012-11-03 20:11:51scodersetrecipients: + scoder, brett.cannon, pitrou
2012-11-03 20:11:51scodersetmessageid: <>
2012-11-03 20:11:51scoderlinkissue16392 messages
2012-11-03 20:11:50scodercreate