foo.py
a = 1
./python -m pdb foo.py
Results in
./python -m pdb foo.py ./foo.py(1)<module>() -> a = 1 (Pdb) longlist 0 a = 1 (Pdb)
The line number should be 1 instead of 0.
1
0
This occurs because the longlist command uses inspect.getsourcelines, which returns 0 as the starting line number for modules.
longlist
inspect.getsourcelines
This bug was introduced in #101674.
main
inspect.getsourcelines()
pythonGH-103225: Fix `inspect.getsourcelines()` to return 1-based lin…
gh-103225: Fixed zero lineno issue for pdb (#103265)
pythongh-103225: Fixed zero lineno issue for pdb (python#103265)
[3.11] gh-103225: Fixed zero lineno issue for pdb (#103265) (#104262)
Thanks for reporting! Closing, since the pdb issue is fixed and #103319 can track whether we want to change behaviour in inspect or not
Activity
pythonGH-103225: Fix `inspect.getsourcelines()` to return 1-based lin…
gh-103225: Fixed zero lineno issue for pdb (#103265)
pythongh-103225: Fixed zero lineno issue for pdb (python#103265)
pythongh-103225: Fixed zero lineno issue for pdb (python#103265)
[3.11] gh-103225: Fixed zero lineno issue for pdb (#103265) (#104262)
hauntsaninja commentedon May 8, 2023
Thanks for reporting! Closing, since the pdb issue is fixed and #103319 can track whether we want to change behaviour in inspect or not