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: Interpreter error when running a script under debugger control
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.0, Python 2.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: UnboundLocalError when trying to raise exceptions inside execfile
View: 2378
Assigned To: jhylton Nosy List: amaury.forgeotdarc, georg.brandl, jhylton, nirai
Priority: normal Keywords:

Created on 2008-07-19 05:32 by nirai, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg70005 - (view) Author: Nir Aides (nirai) (Python triager) Date: 2008-07-19 05:32
Interpreter error results in erroneous exception when running a script
under debugger control.

Full repro description:
On Windows System, try to run idle.py under the inspection of pdb.py. 
Note that you must set a breakpoint somewhere otherwise pdb will not
trace the script and the issue will not surface.

You should get the bad exception in line 295 of multicall.py

Python complains that a local variable has been used before being
declared while in effect it has been a couple of lines before that point.

Nir
msg70013 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-07-19 10:31
For reference, here is the output of the pdb session:

gbr@lap ~/devel/python> ./python Lib/pdb.py Lib/idlelib/idle.py
> /home/gbr/devel/python/Lib/idlelib/idle.py(1)<module>()
-> try:
(Pdb) break multicall.py:300
***  'multicall.py' not found from sys.path
(Pdb) break idle.py:10
Breakpoint 1 at /home/gbr/devel/python/Lib/idlelib/idle.py:10
(Pdb) c
Traceback (most recent call last):
  File "/home/gbr/devel/python/Lib/pdb.py", line 1275, in main
    pdb._runscript(mainpyfile)
  File "/home/gbr/devel/python/Lib/pdb.py", line 1192, in _runscript
    self.run(statement)
  File "/home/gbr/devel/python/Lib/bdb.py", line 366, in run
    exec cmd in globals, locals
  File "<string>", line 1, in <module>
  File "Lib/idlelib/idle.py", line 21, in <module>
    idlelib.PyShell.main()
  File "/home/gbr/devel/python/Lib/idlelib/PyShell.py", line 1396, in main
    shell = flist.open_shell()
  File "/home/gbr/devel/python/Lib/idlelib/PyShell.py", line 275, in
open_shell
    self.pyshell = PyShell(self)
  File "/home/gbr/devel/python/Lib/idlelib/PyShell.py", line 816, in
__init__
    OutputWindow.__init__(self, flist, None, None)
  File "/home/gbr/devel/python/Lib/idlelib/OutputWindow.py", line 16, in
__init__
    EditorWindow.__init__(self, *args)
  File "/home/gbr/devel/python/Lib/idlelib/EditorWindow.py", line 108,
in __init__
    self.text = text = MultiCallCreator(Text)(
  File "/home/gbr/devel/python/Lib/idlelib/MultiCall.py", line 294, in
MultiCallCreator
    class MultiCall (widget):
  File "/home/gbr/devel/python/Lib/idlelib/MultiCall.py", line 295, in
MultiCall
    assert issubclass(widget, Tkinter.Misc)
NameError: free variable 'widget' referenced before assignment in
enclosing scope
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /home/gbr/devel/python/Lib/idlelib/MultiCall.py(295)MultiCall()
-> assert issubclass(widget, Tkinter.Misc)
(Pdb) 


I *think* we had some similar issue with trace functions and class
scopes in the past, but can't remember where.
msg70099 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-07-21 09:29
This issue is a duplicate of issue2378; the patch attached there
corrects this problem. I will commit it tonight.
History
Date User Action Args
2022-04-11 14:56:36adminsetgithub: 47665
2008-07-21 09:29:43amaury.forgeotdarcsetstatus: open -> closed
resolution: duplicate
superseder: UnboundLocalError when trying to raise exceptions inside execfile
messages: + msg70099
nosy: + amaury.forgeotdarc
2008-07-19 10:31:53georg.brandlsetassignee: jhylton
messages: + msg70013
nosy: + jhylton, georg.brandl
2008-07-19 05:32:34niraicreate