8000 "python3.13 -m pdb" exits zero on Syntax Error, prints infinite spam nearby · Issue #125367 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

"python3.13 -m pdb" exits zero on Syntax Error, prints infinite spam nearby #125367

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
pelavarre opened this issue Oct 12, 2024 · 5 comments
Closed
Assignees
Labels
3.13 bugs and security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@pelavarre
Copy link
pelavarre commented Oct 12, 2024

Bug report

Bug description:

The meaning of "python3 -m pdb" is slowly going wild on short input files? Step-by-step evolving now with no tests deployed to limit how wild it goes?

Four Notes here = Two wrongs we can repro simply, and then two bits of more context

1 )

The process exit return code wrongly comes back as zero in reply to Syntax-Error's, not the nonzero that used to screen out Syntax-Error's, when I upgrade to Python 13 from 12

For example, this M Pdb test of a short SyntaxError

echo alef = >p.py
echo |python3.13 -m pdb p.py >/dev/null 2>&1; echo + exit $? ' # in 13'
echo |python3.12 -m pdb p.py >/dev/null 2>&1; echo + exit $? ' # in 12'

produces the conflicting outputs

+ exit 0  # in 13
+ exit 1  # in 12

We like the old result much better, yes?

2 )

M Pdb tests hang in a loop producing infinite output, after the upgrade to Python 13 from 10

For example, this test of an empty Input File ran happy quickly and concisely, back in the days of 2021 Python 10

$ echo |python3.10 -m pdb /dev/null
> /dev/null(1)<module>()
(Pdb) (Pdb) 
$ 

But in Python 3.13, this same empty test now produces infinitely many copies of a log line, and hangs until you press Control + \

$ echo |python3.13 -m pdb /dev/null
The program finished and will be restarted
The program finished and will be restarted
...

The effects of pressing Control + C instead are not simple. In some Python's, you get multiple chances to press Control + C. In others, it works only the first time. Sometimes Control + D will exit the process after a Control + C. Sometimes it won't. Here I'm reporting from my own living human memory, I've not written out a carefully reproducible survey of all that

"We like the old result much better, yes?"

3 )

I saw these bugs first in macOS, where I take the Python binary from Python Org as it comes out monthly

To make this report, I've gone and tested Linux too. For these bugs, I see that a Python Version gone wrong at macOS also goes wrong in the same way in the same Python Version at Linux. That's comforting

More specifically, I do also see these same bugs in the Linux Gcloud Gshell of my Gmail, after I toss in a few more Linux Python's from DeadSnakes for comparison

apt-cache search python3.10
apt-cache search python3.11
apt-cache search python3.13
sudo add-apt-repository -y ppa:deadsnakes/ppa
sudo apt update
sudo apt install -y python3.10
sudo apt install -y python3.11
sudo apt install -y python3.13

I haven't tested Python3.10 at macOS myself

4 )

Thank you for believing I could help

Am I helping? Can I help more?

CPython versions tested on:

3.13

Operating systems tested on:

Linux, macOS

@pelavarre pelavarre added the type-bug An unexpected behavior, bug, or error label Oct 12, 2024
@picnixz picnixz added the stdlib Python modules in the Lib dir label Oct 12, 2024
@ZeroIntensity
Copy link
Member

cc @gaogaotiantian

@savannahostrowski savannahostrowski added the 3.13 bugs and security fixes label Oct 12, 2024
@gaogaotiantian
Copy link
Member

For the first issue, no I don't believe the old behavior is better. SyntaxError, like any other exceptions, is just an exception. The exit code of python -m pdb should be the status of pdb, not the script it's debugging. If your script raise a run-time exception, python -m pdb won't have a non-zero exit code. I don't believe raise ValueError() and raise SyntaxError should have different return code, or even different behavior to pdb.

For the second issue, it's a very rare case. I agree the result is not ideal and I'll look into it and see if we can make it better (at least not stuck in an infinite loop).

@gaogaotiantian gaogaotiantian self-assigned this Oct 13, 2024
@gaogaotiantian
Copy link
Member

The infinite spam of empty file is fixed in #125425. As I mentioned above, I believe the exit code is actually more consistent than the previous result. So I'll close this for now, feel free to reopen it or open a new issue if you find other behavior that's not ideal.

@ZeroIntensity
Copy link
Member

Thank you, Tian, and thanks @pelavarre for the report!

@pelavarre
Copy link
Author

You're most welcome for my reporting! My thanks due all around for the considerable work you gave in reply

If people do land here when they first stumble into "python3 -m pdb" exiting zero more often nowadays than years ago . . .

They might next should adopt scraping output from "-m py_compile" instead, as their new gate against SyntaxWarning and SyntaxError

% cat p.py
if False:
    1(123)
% 

% python3.13 -m py_compile p.py
p.py:2: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?
  1(123)
% echo + exit $?
+ exit 0
% 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

5 participants
0