Skip to content

Problems with some characters: [ ] { } ... #1606

Description

@giorgio-denunzio

Dear all,
I am getting mad how to figure this out.
Windows 11, Winpython64-3.13.3.0dot.7z.

I run "WinPython Command Prompt.exe".
At the prompt, with my Italian keyboard, I get:
"[" with "Alt Gr" + "è"
"]" with "Alt Gr" + "+"
"{" with "Alt Gr" + "Shift" + "è"
etc
I also get these characters and others with the usual sequences "Alt"+number keyboard, such as "Alt"+1,2,5 for "}", etc

I now enter python's shell by calling "python".
None of these sequences or key combination works anymore:
"Alt Gr" + "è" gives nothing but if I repeat it I get "["
"Alt Gr" + "+" gives nothing
If I want "]" I can do "Alt Gr" + "è" followed by "Alt Gr" + "+"
If I want "{" I can do "Alt Gr" + "è" followed by "Shift" + "Alt Gr" + "è"
If I want "}" I can do "Alt Gr" + "è" followed by "Shift" + "Alt Gr" + "+"

This happens only within python.
What is also strange is that I tried another portable python for Windows, with the same absurd result.
Edit: it also happens with an installable version.
Any hint?
Thanks
Giorgio
giorgio.denunzio@unisalento.it

Activity

  1. stonebig commented on May 15, 2025

    @stonebig
    Contributor

    It's a python-3.13.3 issue... when launched from a dos console

  2. stonebig commented on May 15, 2025

    @stonebig
    Contributor

    The issue was raised on cpython, already resolved I think on 3.14.0b1.
    So either you launch python repl from the powershell console, either you wait python 3.13.4

  3. stonebig commented on May 15, 2025

    @stonebig
    Contributor

    Maybe it was OK on python-3.13.2 , also

  4. stonebig commented on May 15, 2025

    @stonebig
    Contributor

    fix for upcoming python-3.13.4: python/cpython#133460

    issue was raised April 13th 2025 (only): python/cpython#132439

  5. giorgio-denunzio commented on May 16, 2025

    @giorgio-denunzio
    Author

    Dear stonebig,
    Thank you very much for your reply! So I had the “luck” of choosing version 3.13 😄
    After reading your answer:

    • I tried launching WinPython Powershell Prompt.exe and then calling Python, but the problem is still there.
    • I also tried using the installed version by opening PowerShell and calling C:\Users\giorg\AppData\Local\Programs\Python\Python313\python.exe directly from the command line, but the issue persists.

    Anyway, it’s not a big problem for now: I’ll simply download an older version and wait for 3.14.
    Thanks again!
    Best regards,
    Giorgio

  6. stonebig commented on May 18, 2025

    @stonebig
    Contributor

    You are right, impossible to get it working... shame... so let see, just 7 lines to adjust... in your \python\Lib_pyrepl.py:

    I'll do that for b2, but you may two... check lines with # GH-132439 pull 133460

    Image

        def get_event(self, block: bool = True) -> Event | None:
            """Return an Event instance.  Returns None if |block| is false
            and there is no event pending, otherwise waits for the
            completion of an event."""
            if self.event_queue:
                return self.event_queue.pop()
    
            while True:
                rec = self._read_input(block)
                if rec is None:
                    return None
    
                if rec.EventType == WINDOW_BUFFER_SIZE_EVENT:
                    return Event("resize", "")
    
                if rec.EventType != KEY_EVENT or not rec.Event.KeyEvent.bKeyDown:
                    # Only process keys and keydown events
                    if block:
                        continue
                    return None
    
                key_event = rec.Event.KeyEvent
                raw_key = key = key_event.uChar.UnicodeChar
    
                if key == "\r":
                    # Make enter unix-like
                    return Event(evt="key", data="\n")  # GH-132439 pull 133460
                elif key_event.wVirtualKeyCode == 8:
                    # Turn backspace directly into the command
                    key = "backspace"
                elif key == "\x00":
                    # Handle special keys like arrow keys and translate them into the appropriate command
                    key = VK_MAP.get(key_event.wVirtualKeyCode)
                    if key:
                        if key_event.dwControlKeyState & CTRL_ACTIVE:
                            key = f"ctrl {key}"
                        elif key_event.dwControlKeyState & ALT_ACTIVE:
                            # queue the key, return the meta command
                            self.event_queue.insert(0, Event(evt="key", data=key))  # GH-132439 pull 133460
                            return Event(evt="key", data="\033")  # keymap.py uses this for meta
                        return Event(evt="key", data=key)  # GH-132439 pull 133460
                    if block:
                        continue
    
                    return None
    
                if key_event.dwControlKeyState & ALT_ACTIVE:
                    # queue the key, return the meta command
                    if not key_event.dwControlKeyState & CTRL_ACTIVE:  # GH-132439 pull 133460 
                        self.event_queue.insert(0, Event(evt="key", data=key))  # GH-132439 pull 133460 
                        return Event(evt="key", data="\033")  # GH-132439 pull 133460
    
                return Event(evt="key", data=key)  # GH-132439 pull 133460 
    
        def push_char(self, char: int | bytes) -> None:````
    
  7. stonebig commented on May 18, 2025

    @stonebig
    Contributor

    waiting 15 days bugs me

  8. giorgio-denunzio commented on May 18, 2025

    @giorgio-denunzio
    Author

    Congratulations :-)
    Thanks for sharing!
    Best,
    Giorgio

  9. stonebig commented on May 18, 2025

    @stonebig
    Contributor
  10. stonebig commented on May 21, 2025

    @stonebig
    Contributor

    well a=[ 1, 2] works, but not copy/paste of code

  11. stonebig commented on May 21, 2025

    @stonebig
    Contributor

    So the "hammer" way WAS, is, to just copy from cpython-3.13 branch the inside lib\_pyrepl object that have changes since less than 2 month.

    Trying to be smart was stupid

    you can download at the same _pyrepl place all the 7 filesmodified since less than 2 month from https://github.com/python/cpython/tree/3.13/Lib/_pyrepl

    Image

    It works, did check on the copy/past of sudoku code in the console proofing

  12. giorgio-denunzio commented on May 21, 2025

    @giorgio-denunzio
    Author

    Wow! When I opened the issue, I didn’t think I’d end up keeping you up at night! :-D
    Congratulations!
    Giorgio

  13. stonebig commented on May 21, 2025

    @stonebig
    Contributor

    nevertheless, copy.paste is wayyyy faster in 3.14 console... so it fixes but it's slow:

    • 8 seconds to paste 250 lines on 3.13 patched REPL
    • 0.5 second or less on 3.14 REPL
  14. stonebig commented on May 21, 2025

    @stonebig
    Contributor

    this is were you see there is way more WORKFORCE than before in cpython

  15. stonebig commented on May 21, 2025

    @stonebig
    Contributor

    in 3.13.1 , the copy paste WAS also that slow... and NOT WORKING.

    so:

    • my patch was maybe correct
    • but 3.13.1 to 3.13.3 was not "copy/paste" friendly
    • it's really python-3.14.0 improvements

    ... feeling less stupid, but it was still not smart

  16. stonebig commented on May 24, 2025

    @stonebig
    Contributor

    also, current REPL in 3.14 b1:

    • on par with ptpython for copy/paste
    • still feels less stable and complete than ptpyhon.... but they stiil backport things, so issues raising may help after b2
  17. stonebig commented on May 26, 2025

    @stonebig
    Contributor

    the slowness of REPL on copy/past was raised in february... python/cpython#130328
    a fix reached 3.14 yesterday python/cpython#134653
    not sure the fix will reach 3.13 ... in theory it's more a bug than a feature.

  18. stonebig commented on May 26, 2025

    @stonebig
    Contributor

    as I was already faster when I took the 3.14, I suppose it comes from this that already speed-up things python/cpython#133247

  19. stonebig commented on May 26, 2025

    @stonebig
    Contributor

    no backport for the slowness problem .... so 3.13 will remain with ptpython when available.
    for 3.14, we need to see what 3.14b2 brings in completion.

    ptpython (and jedi) was a giant leap forward, I hope more of it will integrate the standard over time

    wppm -p ptpython
              ptpython==3.0.29 ,
                   appdirs==1.4.4
                   jedi==0.19.2 >=0.16.0,
                        parso==0.8.4 (<0.9.0,>=0.8.4)
                   prompt-toolkit==3.0.50 <3.1.0,>=3.0.43,
                        wcwidth==0.2.13
                   pygments==2.19.1
    
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions