| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
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. |
Sorry, something went wrong.
|
Hey @iritkatriel , do you think we still have a chance to merge this before beta freeze? |
Sorry, something went wrong.
| 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.
Is indent always 4?
Sorry, something went wrong.
There was a problem hiding this comment.
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?
Sorry, something went wrong.
There was a problem hiding this comment.
Up to you. This is fine.
Sorry, something went wrong.
There was a problem hiding this comment.
Let's land this today and if people are complaining, we can treat that as a bug and fix it later :)
Sorry, something went wrong.
|
test_pdb.test_multiline_auto_indent() fails on FreeBSD: FAIL: test_multiline_auto_indent (test.test_pdb.PdbTestReadline.test_multiline_auto_indent)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/home/vstinner/python/main/Lib/test/test_pdb.py", line 4870, in test_multiline_auto_indent
self.assertIn(b'42', output)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^
AssertionError: b'42' not found in bytearray(b"def f(x):\r\nif x > 0:\r\nx += 1\r\nreturn x\r\nelse:\r\nreturn -x\r\n\r\nf(-21-21)\r\nc\r\n> <string>(2)<module>()\r\n(Pdb) def f(x):\r\n... if x > 0:\r\n... x += 1\r\n... return x\r\n... else:\r\n*** SyntaxError: invalid syntax\r\n(Pdb) return -x\r\n*** Invalid argument: -x\r\n Usage: r(eturn)\r\n(Pdb) \r\n*** Invalid argument: -x\r\n Usage: r(eturn)\r\n(Pdb) f(-21-21)\r\n*** NameError: name \'f\' is not defined\r\n(Pdb) c\r\n")
Reformatted output (the bytearray): "def f(x):\r\n
if x > 0:\r\n
x += 1\r\n
return x\r\n
else:\r\n
return -x\r\n
\r\n
f(-21-21)\r\n
c\r\n
> <string>(2)<module>()\r\n
(Pdb) def f(x):\r\n
... if x > 0:\r\n
... x += 1\r\n
... return x\r\n
... else:\r\n
*** SyntaxError: invalid syntax\r\n
(Pdb) return -x\r\n
*** Invalid argument: -x\r\n
Usage: r(eturn)\r\n
(Pdb) \r\n
*** Invalid argument: -x\r\n
Usage: r(eturn)\r\n
(Pdb) f(-21-21)\r\n
*** NameError: name \'f\' is not defined\r\n
(Pdb) c\r\n
"
And then test_multiline_indent_completion() hangs. |
Sorry, something went wrong.
|
I think the easy way is just to skip these tests on freebsd. This is a test issue, where freebsd does not consider \x08 a backspace. We might be able to find a character that actually works on freebsd, but I don't have a machine to test it out. It's a tier3 support so maybe we just let it go? |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
Could you try \x7f and see if that works? |
Sorry, something went wrong.
test_multiline_auto_indent() still fails if I replace \x08 with \x7f. |
Sorry, something went wrong.
|
I wrote #133566 to skip the two tests on FreeBSD. |
Sorry, something went wrong.
Just a remark, I tried and found that FreeBSD does interpret \x08 as backspace. The problem is that the auto-indented whitespaces are undeletable for some reason. """ test-pdb-auto-indent.py """
import textwrap
from test.support.pty_helper import run_pty
script = 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 += 1
return x
else: # fails to delete the auto-indented whitespaces:
return -x
f(-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 run_pty(). In a normal terminal (kitty+bash) it can't be reproduced, the auto-indented whitespaces are deletable by pressing backspaces. simplescreenrecorder-2025-05-08_19.03.22.mp4 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.