Repository navigation
Description
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 12We 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.13I 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
Activity
ZeroIntensity commentedon Oct 12, 2024
cc @gaogaotiantian
gaogaotiantian commentedon Oct 13, 2024
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 ofpython -m pdbshould be the status ofpdb, not the script it's debugging. If your script raise a run-time exception,python -m pdbwon't have a non-zero exit code. I don't believeraise ValueError()andraise SyntaxErrorshould have different return code, or even different behavior topdb.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 commentedon Oct 15, 2024
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 commentedon Oct 15, 2024
Thank you, Tian, and thanks @pelavarre for the report!
pelavarre commentedon Oct 25, 2024
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