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's `longlist` shows only decorator if that one contains a lambda
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Gerrit.Holl, iritkatriel, pablogsal
Priority: normal Keywords:

Created on 2015-03-31 20:35 by Gerrit.Holl, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg239749 - (view) Author: Gerrit Holl (Gerrit.Holl) * Date: 2015-03-31 20:35
When a decorater contains a `lambda` declaration, using the pdb command `longlist` will show only the definition of the decorator.  The definition of the function itself is not shown:


cat mini.py

#!/usr/bin/python3.4

def foo(x, y=None):
    return x

@foo(foo, lambda a:a)
def spam():
    0+0
    1+1
    1/0

spam()
$ python3.4 -mpdb mini.py                                                                                                                                               
> /tmp/mini.py(3)<module>()
-> def foo(x, y=None):
(Pdb) cont
Traceback (most recent call last):
  File "/usr/lib64/python3.4/pdb.py", line 1661, in main
    pdb._runscript(mainpyfile)
  File "/usr/lib64/python3.4/pdb.py", line 1542, in _runscript
    self.run(statement)
  File "/usr/lib64/python3.4/bdb.py", line 431, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "/tmp/mini.py", line 3, in <module>
    def foo(x, y=None):
  File "/tmp/mini.py", line 10, in spam
    1/0
ZeroDivisionError: division by zero
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /tmp/mini.py(10)spam()
-> 1/0
(Pdb) longlist
  6     @foo(foo, lambda a:a)
(Pdb) 


The last line illustrates the problem.  `longlist` should show the definition of `spam`, not just the decorator.
msg375776 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-08-21 23:08
I think this has been fixed by now, because I don't see the problem in Python 3.10:

python.bat -mpdb tmp1.py
Running Release|Win32 interpreter...
> c:\users\user\src\cpython\tmp1.py(2)<module>()
-> def foo(x, y=None):
(Pdb) c
Traceback (most recent call last):
  File "C:\Users\User\src\cpython\lib\pdb.py", line 1740, in main
    pdb._runscript(mainpyfile)
  File "C:\Users\User\src\cpython\lib\pdb.py", line 1609, in _runscript
    self.run(statement)
  File "C:\Users\User\src\cpython\lib\bdb.py", line 580, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "c:\users\user\src\cpython\tmp1.py", line 2, in <module>
    def foo(x, y=None):
  File "c:\users\user\src\cpython\tmp1.py", line 9, in spam
    1/0
ZeroDivisionError: division by zero
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> c:\users\user\src\cpython\tmp1.py(9)spam()
-> 1/0
(Pdb) longlist
  5     @foo(foo, lambda a:a)
  6     def spam():
  7         0+0
  8         1+1
  9  ->     1/0
(Pdb)
msg375798 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-08-22 12:58
pdb uses inspect.findsource for this, where this problem was fixed in issue 1764286.

I believe this ticket can be closed.
History
Date User Action Args
2022-04-11 14:58:14adminsetgithub: 68020
2020-09-16 14:43:30pablogsalsetstatus: open -> closed
resolution: out of date
stage: resolved
2020-09-15 21:17:18iritkatrielsetnosy: + pablogsal
2020-08-22 12:58:20iritkatrielsetmessages: + msg375798
2020-08-21 23:08:01iritkatrielsetnosy: + iritkatriel
messages: + msg375776
components: + Library (Lib)
2015-03-31 20:35:12Gerrit.Hollcreate