-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
GH-132439: Fix REPL swallowing characters entered with AltGr on cmd.exe #132440
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
59d71b0
cca6155
1e61540
c60a727
ed035e5
69e8779
8ee232c
e67452b
396f48e
40b339a
1fbe240
2d59563
adb89ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -459,22 +459,26 @@ def get_event(self, block: bool = True) -> Event | None: | |||||||||||
key = f"ctrl {key}" | ||||||||||||
elif key_event.dwControlKeyState & ALT_ACTIVE: | ||||||||||||
# queue the key, return the meta command | ||||||||||||
self.event_queue.insert(Event(evt="key", data=key, raw=key)) | ||||||||||||
self.event_queue.insert(Event(evt="key", data=key, raw=raw_key)) | ||||||||||||
return Event(evt="key", data="\033") # keymap.py uses this for meta | ||||||||||||
return Event(evt="key", data=key, raw=key) | ||||||||||||
return Event(evt="key", data=key, raw=raw_key) | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the diff , previously return Event(
evt="key", data=code, raw=rec.Event.KeyEvent.uChar.UnicodeChar
) was used, which in the new code should have been There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I was wondering why this change did not break anything, but AFAICT the cpython/Lib/_pyrepl/unix_console.py Line 513 in 5d8e432
where the two getpending implementations dutifully respect e.raw += e.raw :)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When searching in the code base for cpython/Lib/_pyrepl/windows_console.py Lines 518 to 521 in 5d8e432
which clearly seems to be a bug to me? Because even though I've addressed this in https://github.com/python/cpython/pull/132889/files#r2059235071. |
||||||||||||
if block: | ||||||||||||
continue | ||||||||||||
|
||||||||||||
return None | ||||||||||||
elif self.__vt_support: | ||||||||||||
# If virtual terminal is enabled, scanning VT sequences | ||||||||||||
self.event_queue.push(rec.Event.KeyEvent.uChar.UnicodeChar) | ||||||||||||
self.event_queue.push(raw_key) | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A missed opportunity when main was merged during development of #124119. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which @sergey-miryanov takes care of here as part of #131901. So maybe I should remove this one, but I'd really like to keep the other two There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO you should merge my branch here :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can undo the change - then you won't have conflicts. I don't think we should (partially) merge between our two PRs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think you are right - we shouldn't merge our PRs. You can keep your changes - I'm OK if here will be conflict. |
||||||||||||
continue | ||||||||||||
|
||||||||||||
if key_event.dwControlKeyState & ALT_ACTIVE: | ||||||||||||
# queue the key, return the meta command | ||||||||||||
self.event_queue.insert(Event(evt="key", data=key, raw=raw_key)) | ||||||||||||
return Event(evt="key", data="\033") # keymap.py uses this for meta | ||||||||||||
# Do not swallow characters that have been entered via AltGr: | ||||||||||||
# Windows internally converts AltGr to CTRL+ALT, see | ||||||||||||
# https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-vkkeyscanw | ||||||||||||
if not key_event.dwControlKeyState & CTRL_ACTIVE: | ||||||||||||
ambv marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
# queue the key, return the meta command | ||||||||||||
self.event_queue.insert(Event(evt="key", data=key, raw=raw_key)) | ||||||||||||
return Event(evt="key", data="\033") # keymap.py uses this for meta | ||||||||||||
|
||||||||||||
return Event(evt="key", data=key, raw=raw_key) | ||||||||||||
return self.event_queue.get() | ||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Fix ``PyREPL`` on Windows: characters entered via AltGr are swallowed. Fix | ||
by Chris Eibl. | ||
chris-eibl marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.