8000 PDB stops on wrong line inside pattern matching block · Issue #99474 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

PDB stops on wrong line inside pattern matching block #99474

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

Closed
EliseevEgor opened this issue Nov 14, 2022 · 5 comments
Closed

PDB stops on wrong line inside pattern matching block #99474

EliseevEgor opened this issue Nov 14, 2022 · 5 comments
Assignees
Labels
3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) triaged The issue has been accepted as valid by a triager. type-bug An unexpected behavior, bug, or error

Comments

@EliseevEgor
Copy link
Contributor

Bug report

If you try to debug code example with pdb and step forward 9 times then pdb stops on 12 line (but it shouldn't go to if statement).
It happens because function trace_dispatch(self, frame, event, arg) gets line event.

Code example (main.py):

def example(i):
    match i % 4:
        case 0:
            if i > 10:
                return 0
        case 1:
            if i > 10:
                return 1
        case 2:
            if i > 10:
                print(f'{i}, {i > 10}')
                return 2
        case 3:
            if i > 10:
                return 3


if __name__ == '__main__':
    print(example(2))

Steps:

python3 -m pdb main.py
> main.py(1)<module>()
-> def example(i):
(Pdb) s
> main.py(18)<module>()
-> if __name__ == '__main__':
(Pdb) s
> main.py(19)<module>()
-> print(example(2))
(Pdb) s
--Call--
> main.py(1)example()
-> def example(i):
(Pdb) s
> main.py(2)example()
-> match i % 4:
(Pdb) s
> main.py(3)example()
-> case 0:
(Pdb) s
> main.py(6)example()
-> case 1:
(Pdb) s
> main.py(9)example()
-> case 2:
(Pdb) s
> main.py(10)example()
-> if i > 10:
(Pdb) s
> main.py(12)example()
-> return 2
...

Environment

Python versions: 3.10, 3.11
OS: MacOS Monterey
CPU: Intel Core i9 2.3 GHz

@EliseevEgor EliseevEgor added the type-bug An unexpected behavior, bug, or error label Nov 14, 2022
@corona10
Copy link
Member

cc @brandtbucher

@brandtbucher
Copy link
Member

Thanks, I'll take a look. Could be that jump out of the end of the case block is incorrectly inheriting the location from the last compiled statement.

@brandtbucher brandtbucher self-assigned this Nov 17, 2022
@artemmukhin
Copy link
Contributor

The issue seems to be fixed at least since 3.12.0a6

(Pdb) s
> main.py(9)example()
-> case 2:
(Pdb) s
> main.py(10)example()
-> if i > 10:
(Pdb) s
--Return--
> main.py(10)example()->None
-> if i > 10:
(Pdb) s
None
--Return--
> main.py(19)<module>()->None
-> print(example(2))

@brandtbucher
Copy link
Member

I think this might be the same issue as #103971.

CC @gaogaotiantian

@brandtbucher brandtbucher added interpreter-core (Objects, Python, Grammar, and Parser dirs) 3.11 only security fixes triaged The issue has been accepted as valid by a triager. labels Apr 28, 2023
@brandtbucher
Copy link
Member

Confirmed duplicate.

@brandtbucher brandtbucher closed this as not planned Won't fix, can't repro, duplicate, stale Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) triaged The issue has been accepted as valid by a triager. type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants
0