Title: Unbounded recursion in modulefinder
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: theller Nosy List: jvr, mhammond, theller
Priority: normal Keywords:

Created on 2004-01-13 18:46 by theller, last changed 2004-05-11 15:12 by theller. This issue is now closed.

File name Uploaded Description Edit
modulefinder.patch theller, 2004-03-30 19:10 Patch againt release23-maint branch
Messages (8)
msg19667 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2004-01-13 18:46
modulefinder goes into unbounded recursion when a
module named '', containing 'import os', is on

Last part of the traceback:
  File "c:\python23\lib\", line 255, in
    m = self.load_module(fqname, fp, pathname, stuff)
  File "c:\python23\lib\", line 285, in
    self.scan_code(co, m)
  File "c:\python23\lib\", line 342, in
    self._safe_import_hook(name, m, fromlist)
  File "c:\python23\lib\", line 300, in
    self.import_hook(name, caller)
  File "c:\python23\lib\", line 124, in
    q, tail = self.find_head_package(parent, name)
  File "c:\python23\lib\", line 166, in
    q = self.import_module(head, qname, parent)
  File "c:\python23\lib\", line 237, in
    self.msgin(3, "import_module", partname, fqname,
RuntimeError: maximum recursion depth exceeded

Running modulefinder with the '-x os.path' command line
option prevents the recursion.

This is not really a contrived situation, there's a
possibly useful module from Jason Orendorff at
msg19668 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2004-01-28 20:36
Logged In: YES 

Just, do you have time to look into this?
msg19669 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2004-03-25 20:06
Logged In: YES 

<ping> Just, do you have time to look into this?
msg19670 - (view) Author: Just van Rossum (jvr) * Date: 2004-03-25 20:53
Logged In: YES 

Hm, not really. Do you have any idea what's causing it?
msg19671 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2004-03-25 21:09
Logged In: YES 

It has something to do with os.path.  Adding 'os.path' to
the excludes list, the problem does not appear.

Adding print statements it seems that mf is looking for 
os.os.os.os.os.......something, it seems that it recurses
without noting that something failed.

If I had to fix this myself, I probably had to first step
through these imports with the C debugger, and then through mf.
msg19672 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2004-03-30 19:10
Logged In: YES 

I think I have found something, but I still have to check if
this cures the original problem.

Imagine an (possibly empty) module  Without this
patch, modulefinder would even find 'import'

The assert in the second hunk is commented out, although I
think it should be correct.

Just, any comments?
msg19673 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2004-04-28 07:11
Logged In: YES 

the patch looks reasonable to me, and I can demonstrate that
it does fix the original problem as described.
msg19674 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2004-05-11 15:12
Logged In: YES 

Thanks, Mark.
Checked in as Lib/ CVS revision and 1.11.
Date User Action Args
2004-01-13 18:46:43thellercreate