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: pdb breaks programs which import from __main__
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, isandler
Priority: normal Keywords:

Created on 2005-10-14 04:23 by isandler, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg26591 - (view) Author: Ilya Sandler (isandler) Date: 2005-10-14 04:23
The following example illustrates the problem:

  bagira:~/python/dist/src/Lib> cat tt/xx
  hello=None
  import yy
  print "in xx:yy imported"

  bagira:~/python/dist/src/Lib> cat tt/yy.py
  from __main__ import hello
  print "in yy: yy imported "

this works by itself:

  bagira:~/python/dist/src/Lib> ../python tt/xx
  in yy: yy imported 
  in xx:yy imported

But breaks under pdb

 bagira:~/python/dist/src/Lib> ../python -m pdb tt/xx 
 > /home/ilya/python/dist/src/Lib/tt/xx(1)?()
 -> hello=None
  (Pdb) c
  Traceback (most recent call last):
   File "/home/ilya/python/dist/src/Lib/pdb.py", line
1057, in main
    pdb._runscript(mainpyfile)
   File "/home/ilya/python/dist/src/Lib/pdb.py", line
982, in       _runscript
     self.run(statement, globals=globals_, locals=locals_)
   File "/home/ilya/python/dist/src/Lib/bdb.py", line
367, in run
     exec cmd in globals, locals
   File "<string>", line 1, in ?
   File "tt/xx", line 2, in ?
     import yy
   File "/home/ilya/python/dist/src/Lib/tt/yy.py", line
1, in ?
     from __main__ import hello
 ImportError: cannot import name hello
 Uncaught exception. Entering post mortem debugging
 Running 'cont' or 'step' will restart the program
  > /home/ilya/python/dist/src/Lib/tt/yy.py(1)?()
 -> from __main__ import hello


msg26592 - (view) Author: Ilya Sandler (isandler) Date: 2006-05-18 00:53
Logged In: YES 
user_id=971153

I have submitted a patch #1429539 for this
msg26593 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-03-13 22:00
Fixed with said patch.
History
Date User Action Args
2022-04-11 14:56:13adminsetgithub: 42482
2005-10-14 04:23:51isandlercreate