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.Pdb.checkline() throws AttributeError if called before starting a debug session
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: __Vano, georg.brandl, r.david.murray
Priority: normal Keywords: patch

Created on 2010-07-12 03:56 by __Vano, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pdb_checkline.patch __Vano, 2010-07-12 03:56 bugfix
Messages (2)
msg110065 - (view) Author: Ivan Pozdeev (__Vano) Date: 2010-07-12 03:56
pdb.Pdb.checkline() throws AttributeError at pdb.py:470 if invoked before starting a debugging session because self.curframe doesn't exist at that time.

This breaks IPython's %run magic command (v0.10, Magic.py:1663). The command sets a breakpoint before running the script and scans the file before that to make sure the breakpoint is set on an executable line. 

This is a reasonable thing to do: setting a breakpoint and making sure it is set correctly shouldn't require a running debug session. So i conclude it is pdb, not IPython, that shall be fixed.

The patch attached gives linecache.getline() None as module_globals if self.curframe doesn't exist.

The rationale is: even if the script does use PEP302 import stuff, we can't know or use that before running it. So it's ok if we stay limited with usual paths.
msg112045 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-07-30 07:21
Thanks, fixed in r83261.
History
Date User Action Args
2022-04-11 14:57:03adminsetgithub: 53476
2010-07-30 07:21:33georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg112045

resolution: fixed
2010-07-12 13:00:32r.david.murraysetnosy: + r.david.murray
2010-07-12 03:56:28__Vanocreate