Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdb's longlist shows only decorator if that one contains a lambda #68020

Closed
gerritholl mannequin opened this issue Mar 31, 2015 · 3 comments
Closed

pdb's longlist shows only decorator if that one contains a lambda #68020

gerritholl mannequin opened this issue Mar 31, 2015 · 3 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@gerritholl
Copy link
Mannequin

gerritholl mannequin commented Mar 31, 2015

BPO 23832
Nosy @gerritholl, @pablogsal, @iritkatriel

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2020-09-16.14:43:30.740>
created_at = <Date 2015-03-31.20:35:12.690>
labels = ['type-bug', 'library']
title = "pdb's `longlist` shows only decorator if that one contains a lambda"
updated_at = <Date 2020-09-16.14:43:30.740>
user = 'https://github.com/gerritholl'

bugs.python.org fields:

activity = <Date 2020-09-16.14:43:30.740>
actor = 'pablogsal'
assignee = 'none'
closed = True
closed_date = <Date 2020-09-16.14:43:30.740>
closer = 'pablogsal'
components = ['Library (Lib)']
creation = <Date 2015-03-31.20:35:12.690>
creator = 'Gerrit.Holl'
dependencies = []
files = []
hgrepos = []
issue_num = 23832
keywords = []
message_count = 3.0
messages = ['239749', '375776', '375798']
nosy_count = 3.0
nosy_names = ['Gerrit.Holl', 'pablogsal', 'iritkatriel']
pr_nums = []
priority = 'normal'
resolution = 'out of date'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue23832'
versions = ['Python 3.4']

@gerritholl
Copy link
Mannequin Author

gerritholl mannequin commented Mar 31, 2015

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.

@gerritholl gerritholl mannequin added the type-bug An unexpected behavior, bug, or error label Mar 31, 2015
@iritkatriel
Copy link
Member

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)

@iritkatriel iritkatriel added the stdlib Python modules in the Lib dir label Aug 21, 2020
@iritkatriel
Copy link
Member

pdb uses inspect.findsource for this, where this problem was fixed in bpo-1764286.

I believe this ticket can be closed.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants