◐ Shell
reader mode source ↗
Skip to content

gh-128388: pyrepl on Windows: add meta and ctrl+arrow keybindings#128389

Merged
encukou merged 10 commits into
python:mainfrom
paulie4:fix-issue-128388
Jan 10, 2025
Merged

gh-128388: pyrepl on Windows: add meta and ctrl+arrow keybindings#128389
encukou merged 10 commits into
python:mainfrom
paulie4:fix-issue-128388

Conversation

@paulie4

@paulie4 paulie4 commented Jan 1, 2025

Copy link
Copy Markdown
Contributor

Fix Lib/_pyrepl/windows_console.py to support more keybindings, like the Ctrl+ and Ctrl+ word-skipping keybindings and those with meta (i.e. Alt), e.g. to kill-word or backward-kill-word.

Specifics: if Ctrl is pressed, emit "ctrl left" and "ctrl right" instead of just "left" or "right," and if Meta/Alt is pressed, emit the special key code for meta before emitting the other key that was pressed.

NOTE: this is my first PR for https://github.com/python/cpython, so please tell me if I need to do something else, e.g. does this need an entry added somewhere under Misc/NEWS.d?

@ghost

ghost commented Jan 1, 2025

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app

bedevere-app Bot commented Jan 1, 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 Jan 1, 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.

@hugovk hugovk added OS-windows topic-repl Related to the interactive shell labels Jan 1, 2025
@hugovk

hugovk commented Jan 1, 2025

Copy link
Copy Markdown
Member

NOTE: this is my first PR for https://github.com/python/cpython, so please tell me if I need to do something else, e.g. does this need an entry added somewhere under Misc/NEWS.d?

Yes please, and also sign the CLA.

@paulie4

paulie4 commented Jan 1, 2025

Copy link
Copy Markdown
Contributor Author

@hugovk, Misc/NEWS.d is a directory, so I don't know which file(s) in there to edit, especially since it looks like the versions in there have all been released. Do I need to create a new file (or files if it's going to both 3.13.2 and to a 3.14.0a)?

UPDATE: it looks like these are the instructions for which file I should create: https://devguide.python.org/core-developers/committing/#how-to-add-a-news-entry. I think _pyrepr is part of the standard library, right?

I tried signing the CLA, but the SIGN IN WITH GITHUB TO AGREE button doesn't work with the @users.noreply.github.com email address I use for my commits. I submitted a manual CLA, so hopefully that will work. FYI, this is the error I get when I try to use https://cpython-clabot.herokuapp.com/contributor-license-agreement?state=...:

Thank you for authorizing our application, but the CLA must be signed by the users who contributed to the PR. Authors emails are: 203125+paulie4@users.noreply.github.com.

@hugovk

hugovk commented Jan 1, 2025

Copy link
Copy Markdown
Member

UPDATE: it looks like these are the instructions for which file I should create: https://devguide.python.org/core-developers/committing/#how-to-add-a-news-entry. I think _pyrepr is part of the standard library, right?

Yes, that's right, the Lib dir is the stdlib.

…8.8UdMz_.rst`

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
@paulie4

paulie4 commented Jan 2, 2025

Copy link
Copy Markdown
Contributor Author

@hugovk, thank you for that suggested doc change, which I approved. Is there anything else I need to do, or do we now just need to wait for someone else (e.g. @pablogsal, @lysnikolaou, or @ambv) to review the code changes?

@hugovk

hugovk commented Jan 3, 2025

Copy link
Copy Markdown
Member

Thanks for the updates. Yes, someone with Windows will need to review, hopefully it shouldn't be too long :)

@eendebakpt eendebakpt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hide comment

I left some comments for improvement of the code, but the PR is good: I tested with Windows 11 and the meta keybindings work now

paulie4 and others added 4 commits January 3, 2025 20:39
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>

@vstinner vstinner 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.

Hide comment

LGTM. It works as expected: CTRL+Left skips a whole word and ALT+Backspace deletes a word.

18 hidden items Load more…
@encukou encukou merged commit 688f3a0 into python:main Jan 10, 2025
@paulie4 paulie4 deleted the fix-issue-128388 branch January 13, 2025 01:57
@hugovk hugovk added the needs backport to 3.13 bugs and security fixes label Feb 24, 2025
@miss-islington-app

Copy link
Copy Markdown

Thanks @paulie4 for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 24, 2025
…gs (pythonGH-128389)

Fix `Lib/_pyrepl/windows_console.py` to support more keybindings, like the
`Ctrl`+`←` and `Ctrl`+`→` word-skipping keybindings and those with meta (i.e. Alt),
e.g. to `kill-word` or `backward-kill-word`.

Specifics: if Ctrl is pressed, emit "ctrl left" and "ctrl right" instead of just "left" or
"right," and if Meta/Alt is pressed, emit the special key code for meta before
emitting the other key that was pressed.
(cherry picked from commit 688f3a0)

Co-authored-by: Paulie Peña <203125+paulie4@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
@bedevere-app

bedevere-app Bot commented Feb 24, 2025

Copy link
Copy Markdown

GH-130500 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Feb 24, 2025
encukou pushed a commit that referenced this pull request Mar 3, 2025
…ngs (GH-128389) (GH-130500)

gh-128388: pyrepl on Windows: add meta and ctrl+arrow keybindings (GH-128389)

Fix `Lib/_pyrepl/windows_console.py` to support more keybindings, like the
`Ctrl`+`←` and `Ctrl`+`→` word-skipping keybindings and those with meta (i.e. Alt),
e.g. to `kill-word` or `backward-kill-word`.

Specifics: if Ctrl is pressed, emit "ctrl left" and "ctrl right" instead of just "left" or
"right," and if Meta/Alt is pressed, emit the special key code for meta before
emitting the other key that was pressed.
(cherry picked from commit 688f3a0)

Co-authored-by: Paulie Peña <203125+paulie4@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 FreeBSD14 3.13 (tier-3) has failed when building commit 4c6318e.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1481/builds/1020) and take a look at the build logs.
  4. Check if the failure is related to this commit (4c6318e) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1481/builds/1020

Failed tests:

  • test_interpreters

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.13.opsec-fbsd14/build/Lib/threading.py", line 1041, in _bootstrap_inner
    self.run()
    ~~~~~~~~^^
  File "/home/buildbot/buildarea/3.13.opsec-fbsd14/build/Lib/threading.py", line 992, in run
    self._target(*self._args, **self._kwargs)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/buildbot/buildarea/3.13.opsec-fbsd14/build/Lib/test/test_interpreters/test_stress.py", line 30, in task
    interp = interpreters.create()
  File "/home/buildbot/buildarea/3.13.opsec-fbsd14/build/Lib/test/support/interpreters/__init__.py", line 76, in create
    id = _interpreters.create(reqrefs=True)
interpreters.InterpreterError: interpreter creation failed
k


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.13.opsec-fbsd14/build/Lib/threading.py", line 1041, in _bootstrap_inner
    self.run()
    ~~~~~~~~^^
  File "/home/buildbot/buildarea/3.13.opsec-fbsd14/build/Lib/threading.py", line 992, in run
    self._target(*self._args, **self._kwargs)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/buildbot/buildarea/3.13.opsec-fbsd14/build/Lib/test/test_interpreters/test_stress.py", line 47, in run
    interp = interpreters.create()
  File "/home/buildbot/buildarea/3.13.opsec-fbsd14/build/Lib/test/support/interpreters/__init__.py", line 76, in create
    id = _interpreters.create(reqrefs=True)
interpreters.InterpreterError: interpreter creation failed
k

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

Labels

OS-windows topic-repl Related to the interactive shell

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants