[issue1429539] pdb: fix for 1326406 (import __main__ pdb failure)

Alexander Belopolsky report at bugs.python.org
Sat Nov 8 00:15:43 CET 2008


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

I am not sure whether it is appropriate to comment on a closed issue, 
but if the tracker will take this comment, hopefully it will find the 
right audience.

I have recently stumbled on this bug running python 2.5.  While tracking 
the problem down, I've noticed that some of the script running logic in 
pdb and runpy is replicated in some aspects and slightly different in 
others.

Thus both pdb and runpy pop sys.argv[0], but (after this patch) pdb 
cleans __main__.__dict__ and repopulates it by executing the script 
while runpy replaces sys.modules['__main__'] with a fresh module and 
uses that module's namespace to run the script in.

Furthemore, runpy injects __loader__ in the "main" namespace while pdb 
does not.

While I cannot point out any specific problems (other than inability to 
debug applications in zipped packages with python -m pdb app.zip), I 
believe pdb should use the same logic and preferably the same code as 
runpy.  

Finally a nit: why does _runscript use run("execfile(filename)") instead 
of runcall(execfile, filename, gloabals_, locals_)?

----------
nosy: +belopolsky

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1429539>
_______________________________________


More information about the Python-bugs-list mailing list