Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

pdb fails when setting a breakpoint to function names with return-type annotations #125884

Closed
Assignees
gaogaotiantian
Labels
stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@baco

Description

@baco

Bug report

Bug description:

When having return-type annotations on a function:

deffoo()->int:return0

and trying to establish a breakpoint on the name of the function:

(Pdb) break foo

PDB raises the following exception (snipped):

Traceback (most recent call last):  File "/usr/lib/python3.13/pdb.py", line 1137, in do_break    lineno = int(arg)ValueError: invalid literal for int() with base 10: 'foo'During handling of the above exception, another exception occurred:...SyntaxError: 'return' outside functionUncaught exception. Entering post mortem debuggingRunning 'cont' or 'step' will restart the program> /usr/lib/python3.13/dis.py(76)_try_compile()-> return compile(source, name, 'exec')

This also happens withtemporary breakpoinstbreak. This was tested using Python versions from Debian official repositories. The failure appears in 3.13.0 and was not present in 3.12.6.

Analyzing with@asottile they point out that the following lines:Lib/pdb.py:121,Lib/pdb.py:141 may be causing this behavior. They also provided further probing of the issue:

(Pdb) p compile(funcdef, filename, 'exec').co_consts('return', <code object main at 0x102b73020, file "/private/tmp/y/t3.py", line 1>, None)(Pdb) p funcdef'def main() -> int:\n    pass\n'

I think it's expecting to find the code object there.
it's due to the disassembly

(Pdb) dis.dis(compile('def f() -> int: pass', filename, 'exec'))  0           RESUME                   0  1           LOAD_CONST               0 ('return')              LOAD_NAME                0 (int)              BUILD_TUPLE              2              LOAD_CONST               1 (<code object f at 0x102b73020, file "/private/tmp/y/t3.py", line 1>)              MAKE_FUNCTION              SET_FUNCTION_ATTRIBUTE   4 (annotations)              STORE_NAME               1 (f)              RETURN_CONST             2 (None)Disassembly of <code object f at 0x102b73020, file "/private/tmp/y/t3.py", line 1>:  1           RESUME                   0              RETURN_CONST             0 (None)

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Labels

stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp