Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-133349: Enable auto-indent for pdb's multi-line mode#133350
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Sorry for trying to squeeze this in 3.14 before beta freeze :) I think this should be pretty straightforward to review and it could help user experiences. |
Hey@iritkatriel , do you think we still have a chance to merge this before beta freeze? |
last_line = last_line.rstrip('\r\n') | ||
indent = len(last_line) - len(last_line.lstrip()) | ||
if last_line.endswith(":"): | ||
indent += 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Is indent always 4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We kind of dictated there, it is consistent with how we auto-fill the space when we hit<tab>
. However, we can be smart and search for the history for the last indent. I have the time to do it and it should not be rocket science. Do you want me to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Up to you. This is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Let's land this today and if people are complaining, we can treat that as a bug and fix it later :)
0eeaa0e
intopython:mainUh oh!
There was an error while loading.Please reload this page.
test_pdb.test_multiline_auto_indent() fails on FreeBSD:
Reformatted output (the bytearray):
And then test_multiline_indent_completion() hangs. |
I think the easy way is just to skip these tests on freebsd. This is a test issue, where freebsd does not consider |
I have a FreeBSD machine, I can try some changes if you want. But if I have no clue why \x08 is not treated as backspace. I would also be fine with skipping the test on FreeBSD. |
Could you try |
test_multiline_auto_indent() still fails if I replace \x08 with \x7f. |
I wrote#133566 to skip the two tests on FreeBSD. |
tanloong commentedMay 8, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Just a remark, I tried and found that FreeBSD does interpret """ test-pdb-auto-indent.py """importtextwrapfromtest.support.pty_helperimportrun_ptyscript=textwrap.dedent(""" import pdb; pdb.Pdb().set_trace()""")input=b"def g\x08f(x): # g is successfully deleted and replaced by f:\n"input+=b"if x > 0:\n"input+=b"x += 1\n"input+=b"return x\n"input+=b"\x08\x08\x08\x08else: # fails to delete the auto-indented whitespaces:\n"input+=b"return -x\n"input+=b"\n"input+=b"f(-21-21)\n"input+=b"c\n"output=run_pty(script,input)print(output) $ ./python ./test-pdb-auto-indent.py| sed -E's/\\r\\n/\n/g'bytearray(b"def g\x08 \x08f(x): # g is successfully deleted and replaced by f:if x > 0:x += 1return xelse: # fails to delete the auto-indented whitespaces:return -xf(-21-21)c> <string>(2)<module>()(Pdb) def f(x): # g is successfully deleted and replaced by f:... if x > 0:... x += 1... return x... else: # fails to delete the auto-indented whitespaces:*** SyntaxError: invalid syntax(Pdb) return -x*** Invalid argument: -x Usage: r(eturn)(Pdb)*** Invalid argument: -x Usage: r(eturn)(Pdb) f(-21-21)*** NameError: name \'f\' is not defined(Pdb) c") The weird thing is that it happens only in the pseudo-terminal opened by simplescreenrecorder-2025-05-08_19.03.22.mp4 |
Uh oh!
There was an error while loading.Please reload this page.