Skip to content

gh-131430: Fix crashes on an empty DELETE_WORD_BACKWARDS (^W) followed by CLEAR_TO_START (^K) - #131452

Open
deepwzh wants to merge 4 commits into
python:mainfrom
deepwzh:fix-issue-131430
Open

deepwzh wants to merge 4 commits into
python:mainfrom
deepwzh:fix-issue-131430

Conversation

@deepwzh

@deepwzh deepwzh commented Mar 19, 2025 •

Copy link
Copy Markdown
Contributor

Add the handling of kill_range null detection, which is a left closed and right open interval. When end start<=1, it means that no operation has been done and should be skipped; The original writing only handled the case of end==start.

@bedevere-app

bedevere-app Bot commented Mar 19, 2025

Copy link
Copy Markdown

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 skip news label instead.

@bedevere-app

bedevere-app Bot commented Mar 19, 2025

Copy link
Copy Markdown

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 skip news label instead.

@tomasr8 tomasr8 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @deepwzh! This will need a news entry and ideally a test to make sure we don't regress. Feel free to have a look at our devguide or just ask me if you need help!

Comment thread Lib/_pyrepl/commands.py Outdated
class KillCommand(Command):
def kill_range(self, start: int, end: int) -> None:
if start == end:
if end - start <= 1:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct, consider for example this input:

>>> 12

where the cursor is over 2. If you press ^w, this no longer removes the 1 .

Perhaps checking that kill_ring is not an empty list would be a good alternative?

- if is_kill(r.last_command):
+ if is_kill(r.last_command) and r.kill_ring:

@deepwzh

deepwzh commented Apr 30, 2025

Copy link
Copy Markdown
Contributor Author

Thanks for the PR @deepwzh! This will need a news entry and ideally a test to make sure we don't regress. Feel free to have a look at our devguide or just ask me if you need help!

Thank you for your guidance. I will try to submit a revised version again~~

I have something to ask first. I noticed that after submitting my PR for a considerable period of time, the automatically assigned reviewers do not seem to have enough time to review. In this situation, do I usually need to be patient and wait, or can I look for other reviewers?

@tomasr8

tomasr8 commented Apr 30, 2025

Copy link
Copy Markdown
Member

We are nearing the beta freeze for Python 3.14 so everybody is even busier than usual and there can be larger delays in getting reviews.. That said, I'm happy to help you review the PR, feel free to ping me once you have addressed my comment 🙂

@deepwzh
deepwzh force-pushed the fix-issue-131430 branch 2 times, most recently from 413c3f9 to ac7bbfc Compare May 11, 2025 06:57
@deepwzh

deepwzh commented May 11, 2025

Copy link
Copy Markdown
Contributor Author

We are nearing the beta freeze for Python 3.14 so everybody is even busier than usual and there can be larger delays in getting reviews.. That said, I'm happy to help you review the PR, feel free to ping me once you have addressed my comment 🙂

Got it! Thanks for your contributions to Python!

@tomasr8 Today I completed the revisions as per your instructions and added some additional tests. Could you please review them when you have time?

@deepwzh
deepwzh requested a review from tomasr8 May 11, 2025 09:51
Comment thread Lib/test/test_pyrepl/test_reader.py Resolved
Comment thread Lib/test/test_pyrepl/test_reader.py Resolved
Comment thread Lib/test/test_pyrepl/test_reader.py Resolved
Comment thread Lib/test/test_pyrepl/test_reader.py Resolved
@deepwzh
deepwzh force-pushed the fix-issue-131430 branch from efbeeab to f95e9c3 Compare May 12, 2025 06:13
@deepwzh
deepwzh requested a review from tomasr8 May 12, 2025 07:06
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 22, 2026
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Nov 26, 2026
Comment thread Lib/_pyrepl/commands.py
text = b[start:end]
del b[start:end]
if is_kill(r.last_command):
if is_kill(r.last_command) and r.kill_ring:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prevents the crash, but Ctrl-W followed by Ctrl-K on an empty prompt now adds an empty entry to the kill ring. Can we return early when the buffer slice is empty?

@bedevere-app

bedevere-app Bot commented Nov 26, 2026

Copy link
Copy Markdown

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants