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.

classification
Title: inspect.py: still infinite recursion inspecting frames
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pje Nosy List: connelly, dq_searchlores, nnorwitz, pje
Priority: normal Keywords:

Created on 2006-07-03 08:39 by dq_searchlores, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (7)
msg29022 - (view) Author: Don Quijote (dq_searchlores) Date: 2006-07-03 08:39
Using python 2.5 beta 1 on Windows XP, and py2exe 0.6.5.

After packing and compressing a project via py2exe,
there's still an infinite recursion involving functions
getsourcefile, getmodule and getabsfile in module
inspect.py.

I was able to fix this infinite recursion by

1) changing the declaration of getabsfile & getmodule to:
def getabsfile(object, filename=None):
def getmodule(object, filename=None):

2) including the "filename" parameter in all calls to
getabsfile inside of function getmodule.

3) having getabsfile return the absolute and normalized
filename if not null.

Perhaps this change helps to clean up the 'ugliness'
introduced in version 45822.

Kind regards,
Don Quijote 
msg29023 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2006-07-05 01:53
Logged In: YES 
user_id=33168

Phillip any comments?
msg29024 - (view) Author: PJ Eby (pje) * (Python committer) Date: 2006-07-10 19:05
Logged In: YES 
user_id=56214

Fixed in revision 50526.
msg29025 - (view) Author: Connelly (connelly) Date: 2006-07-20 06:40
Logged In: YES 
user_id=1039782

I tried pje's Revision 50526 and this still causes infinite recursion with:

>>> inspect.getmodule(compile('a=10','','single'))
msg29026 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2006-07-20 06:59
Logged In: YES 
user_id=33168

Confirmed this is bad: 
inspect.getmodule(compile('a=10','','single'))
msg29027 - (view) Author: Don Quijote (dq_searchlores) Date: 2006-07-20 12:36
Logged In: YES 
user_id=1118684

A possible simple fix:
In function getabsfile(), test _filename explicitly with:
...abspath(_filename is not None or getsourcefile...

In your case, _filename is ''. This is the value returned
from getfile(), when using attribute .co_filename from the
code object.
msg29028 - (view) Author: PJ Eby (pje) * (Python committer) Date: 2006-07-20 15:56
Logged In: YES 
user_id=56214

Added a test for the new issue and fixed in revision 50719.
History
Date User Action Args
2022-04-11 14:56:18adminsetgithub: 43601
2006-07-03 08:39:49dq_searchlorescreate