GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-146044: Fix ctrl-w (unix-word-rubout) to use whitespace word boundaries by kimimgo · Pull Request #146174 · python/cpython Conversation
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Add a check in Parse() to prevent calls when in_callback is true, as this violates expat's requirements and can cause crashes. Now raises RuntimeError with a clear message. Add tests to verify the fix and ensure normal parsing still works.
Add a check in Parse() to prevent calls when in_callback is true, as this violates expat's requirements and can cause crashes. Now raises RuntimeError with a clear message. Add tests to verify the fix and ensure normal parsing still works.
Add a check in Parse() to prevent calls when in_callback is true, as this violates expat's requirements and can cause crashes. Now raises RuntimeError with a clear message. Add tests to verify the fix and ensure normal parsing still works.
Add a check in Parse() to prevent calls when in_callback is true, as this violates expat's requirements and can cause crashes. Now raises RuntimeError with a clear message. Add tests to verify the fix and ensure normal parsing still works.
Add a check in Parse() to prevent calls when in_callback is true, as this violates expat's requirements and can cause crashes. Now raises RuntimeError with a clear message. Add tests to verify the fix and ensure normal parsing still works.
Add a check in Parse() to prevent calls when in_callback is true, as this violates expat's requirements and can cause crashes. Now raises RuntimeError with a clear message. Add tests to verify the fix and ensure normal parsing still works.
Add a check in Parse() to prevent calls when in_callback is true, as this violates expat's requirements and can cause crashes. Now raises RuntimeError with a clear message. Add tests to verify the fix and ensure normal parsing still works.
Add a check in Parse() to prevent calls when in_callback is true, as this violates expat's requirements and can cause crashes. Now raises RuntimeError with a clear message. Add tests to verify the fix and ensure normal parsing still works.
Add a check in Parse() to prevent calls when in_callback is true, as this violates expat's requirements and can cause crashes. Now raises RuntimeError with a clear message. Add tests to verify the fix and ensure normal parsing still works.
|
I personally prefer stopping at separators rather than whitespaces. I think zsh stops at punctuations. So I would first open a DPO thread about this before changing anything. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for the feedback @picnixz! The distinction I'm making is between two different readline commands:
The current code maps Ctrl-W to This PR keeps That said, I'm happy to open a Discourse thread if you think this needs broader discussion first. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I am a bit torn here... I would say M-backspace is... less convenient to type but at the same time if ctrl+w is meant to emulate the Unix one then I guess it may be better to ensure this. What is the behavior on the old REPL? (in 3.12?) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
ctrl-w (unix-word-rubout) uses whitespace boundaries on bash, zsh, and fish on macOS. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
ctrl-w stops on whitespace boundaries in the 3.12 REPL.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @injust for confirming the cross-shell behavior and the 3.12 regression! To summarize: this is a regression introduced in 3.13's pyrepl where This PR restores the 3.12 behavior by adding |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks but please make tests less LLM-esque.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| p -= 1 | ||
| return p + 1 | ||
|
|
||
| def bow_whitespace(self, p: int | None = None) -> int: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Maybe unix_bow() instead? or bow_ws()? since we use quite short names.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| class TestBowWhitespace(TestCase): | ||
| def test_bow_whitespace_stops_at_whitespace(self): | ||
| # GH#146044 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
# See https://github.com/cpython/issues/146044Use a link looking like that so that I can click on it in my IDE. I created the link from memory sonjust check that it is the correct URL.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| reader.pos = len(reader.buffer) | ||
|
|
||
| result = reader.bow() | ||
| self.assertEqual(result, 8) # same — "baz" is all word chars |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| self.assertEqual(result, 8) # same — "baz" is all word chars | |
| self.assertEqual(result, 8) # same: "baz" is all word chars |
Avoid LLM long dashes and use regular english please
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| reader.buffer = list("foo.bar") | ||
| reader.pos = len(reader.buffer) | ||
|
|
||
| # bow() stops at '.' → returns index of 'b' in "bar" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| # bow() stops at '.' → returns index of 'b' in "bar" | |
| # bow() stops at '.' so we return the index of 'b' in "bar" |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -0,0 +1,3 @@ | |||
| Fix ``unix-word-rubout`` (Ctrl-W) in the REPL to use whitespace-only word | |||
| boundaries, matching bash/readline behavior. Previously it used | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| boundaries, matching bash/readline behavior. Previously it used | |
| boundaries, matching behavior of the basic REPL. Previously it used |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| self.assert_screen_equal(reader, 'flag {o}={z} {s}"🏳️\\u200d🌈"{z}'.format(**colors)) | ||
|
|
||
|
|
||
| class TestBowWhitespace(TestCase): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This entire test case can have one single reference to the GH issue as a comment and we can remove them from the methods.
However I would prefer that we extend the existing test case with the bow tests and place them where existing ones are.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| p -= 1 | ||
| while p >= 0 and b[p] in (" ", "\n"): | ||
| p -= 1 | ||
| while p >= 0 and b[p] not in (" ", "\n"): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| while p >= 0 and b[p] not in (" ", "\n"): | |
| while p >= 0 and b[p] not in " \n": |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| p = self.pos | ||
| b = self.buffer | ||
| p -= 1 | ||
| while p >= 0 and b[p] in (" ", "\n"): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| while p >= 0 and b[p] in (" ", "\n"): | |
| while p >= 0 and b[p] in " \n": |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| p -= 1 | ||
| while p >= 0 and b[p] in (" ", "\n"): | ||
| p -= 1 | ||
| while p >= 0 and b[p] not in (" ", "\n"): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
OOC newlines are also counted but what about tabs? do we also convert them to 4-indents in the REPL or?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
- Rename bow_whitespace() to bow_ws() for shorter naming convention - Move tests from separate TestBowWhitespace class into TestReader - Add tab character to whitespace set (space, newline, tab) - Add test_bow_ws_with_tabs for tab handling - Fix link format to python#146044 - Remove LLM-style long dashes from comments - Update NEWS wording per review
|
Thanks @picnixz! Updated:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| p defaults to self.pos; only whitespace is considered a word | ||
| boundary, matching the behavior of unix-word-rubout in bash/readline. | ||
| See https://github.com/python/cpython/issues/146044""" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| See https://github.com/python/cpython/issues/146044""" | |
| """ |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| self.assertEqual(reader.bow_ws(), 4) | ||
|
|
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| self.assertEqual(reader.bow_ws(), 4) | |
| self.assertEqual(reader.bow_ws(), 4) | |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| reader.setpos_from_xy(8, 0) | ||
| self.assertEqual(reader.pos, 7) | ||
|
|
||
| def test_bow_ws_stops_at_whitespace(self): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Where are the existing tests for bow()? id there are some, please put those tests next to them
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| def test_bow_ws_includes_punctuation_in_word(self): | ||
| reader = prepare_reader(prepare_console([])) | ||
| reader.buffer = list("foo.bar(baz) qux") | ||
| reader.pos = 12 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Use the index() method to get the index of )
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| def test_bow_ws_with_tabs(self): | ||
| reader = prepare_reader(prepare_console([])) | ||
| reader.buffer = list("foo\tbar") |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Add tests with \n and ensure that you also properly jump lines.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
|
|
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Remove those extra blanks
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| p defaults to self.pos; only whitespace is considered a word | ||
| boundary, matching the behavior of unix-word-rubout in bash/readline. | ||
| See https://github.com/python/cpython/issues/146044 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
My suggestion was to remove the ref to the issue
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| self.assertEqual(reader.pos, 7) | ||
|
|
||
| def test_bow_ws_stops_at_whitespace(self): | ||
| # See https://github.com/python/cpython/issues/146044 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| # See https://github.com/python/cpython/issues/146044 | |
| # See https://github.com/python/cpython/issues/146044. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Per @picnixz's review: - Remove issue URL from bow_ws() docstring (keep reference in tests only) - Add period to issue reference comment in test - Add test_bow_ws_with_newlines to cover newline as whitespace boundary
|
Please stop pinging me that frequently. My backlog is nontrivial and it may take more than 1 month for a review. Those comments do not help either as they just repeat what you already did once. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| p = self.pos | ||
| b = self.buffer | ||
| p -= 1 | ||
| while p >= 0 and b[p] in " \n\t": |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We already use c.isspace() for whitespace in kill_line just above the caller in commands.py. Why hardcode " \n\t" here twice instead? b[p].isspace() would be consistent and also cover \r/\f/\v.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| reader.setpos_from_xy(8, 0) | ||
| self.assertEqual(reader.pos, 7) | ||
|
|
||
| def test_bow_ws_stops_at_whitespace(self): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
These only exercise bow_ws() directly. Do we have a test that drives the actual unix-word-rubout (ctrl-w) command end to end? That is the behavior we are fixing.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 90 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
ctrl-w deletes words with punctuation instead of whitespace boundary
There was an error while loading. Please reload this page.