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: global stmt causes breakpoints to be ignored
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jlgijsbers Nosy List: isandler, jlgijsbers, mackal
Priority: normal Keywords:

Created on 2004-01-12 14:52 by mackal, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python_bug.py mackal, 2004-01-12 14:52 simple test case showing the bug
Messages (4)
msg19632 - (view) Author: Maciej Kalisiak (mackal) Date: 2004-01-12 14:52
It seems that having a "global" statement in "main()" 
(perhaps elsewhere too) causes pdb to ignore
breakpoints in the whole application.  See the attached
example small program.

Procedure:
- pdb python_bug.py  # the attached program
- 's', and then 'n' once or twice to make sure prog loaded
- 'break main'
- 'c'

If the "global foo" statement is present, pdb will not
stop at the breakpoint.  If it is commented out (and
"foo = 1" as well, of course), the breakpoint is obeyed.

I'm using
Python 2.3   (from the Debian "sid" distribution)
Tried under Linux 2.2.20, as well as 2.4.*.

Maciej Kalisiak
mac at dgp dot toronto dot edu
msg19633 - (view) Author: Ilya Sandler (isandler) Date: 2004-03-10 22:22
Logged In: YES 
user_id=971153

The same behaviour exists in the CVS version of python

Here is what (I think) happens:

1. When you try to set a break on a function: e.g "b main"
pdb sets a breakpoint not at "def main", but at the next non
comment/non-blank line of code

2. Sample code has "global " as a first
non-comment/non-blank line of code, so that's where pdb sets
the breakpoint

3. But global is a compile-time statement, the line with
global is never reached at run time, so pdb never stops there

Workaround for the original submitter: put any other
executable stmt as the first line of your main(), or set a
bkpt via line number

However, this behaviour is still wrong...The bug could be
probably fixed by adding more logic to pdb.checkline()....

Are there any other compile-time only statements?

I think I could submit a patch for this problem, but does
anyone look at pdb related patches?? My previous pdb patch
#896011 has been sitting in the queue for a month now...


msg19634 - (view) Author: Ilya Sandler (isandler) Date: 2004-08-04 23:26
Logged In: YES 
user_id=971153

Patch 1003640 should fix this problem
msg19635 - (view) Author: Johannes Gijsbers (jlgijsbers) * (Python triager) Date: 2004-08-30 13:32
Logged In: YES 
user_id=469548

Fixed by checking in patch 1003640.
History
Date User Action Args
2022-04-11 14:56:02adminsetgithub: 39804
2004-01-12 14:52:38mackalcreate