New submission from Justin <justin.a.bl...@gmail.com>:

On macOs 10.14.6 laptop with a qwerty layout, when I switch my keyboard layout 
to `French - PC` and use a tkinter keyboard listener
and press the '[' button which should be the '^' button on the azerty keyboard, 
this Error is thrown:
```
2020-12-14 10:13:26.533 Python[14880:1492926] *** Terminating app due to 
uncaught exception 'NSRangeException', reason: '-[__NSCFConstantString 
characterAtIndex:]: Range or index out of bounds'
*** First throw call stack:
(
        0   CoreFoundation                      0x00007fff41ce49ad 
__exceptionPreprocess + 256
        1   libobjc.A.dylib                     0x00007fff6c3dfa17 
objc_exception_throw + 48
        2   CoreFoundation                      0x00007fff41ce47df 
+[NSException raise:format:] + 201
        3   CoreFoundation                      0x00007fff41c5a159 
-[__NSCFString characterAtIndex:] + 102
        4   Tk                                  0x00007fff4da8a806 
TkpInitKeymapInfo + 719
        5   Tk                                  0x00007fff4da905e9 
Tk_MacOSXSetupTkNotifier + 793
        6   Tcl                                 0x00007fff4d98c48e 
Tcl_DoOneEvent + 301
        7   _tkinter.cpython-38-darwin.so       0x00000001090802de 
_tkinter_tkapp_mainloop + 342
        8   Python                              0x0000000108ac1b0a 
method_vectorcall_FASTCALL + 250
        9   Python                              0x0000000108b5a299 
call_function + 346
        10  Python                              0x0000000108b51457 
_PyEval_EvalFrameDefault + 3895
        11  Python                              0x0000000108b5ae5d 
_PyEval_EvalCodeWithName + 2107
        12  Python                              0x0000000108abad39 
_PyFunction_Vectorcall + 217
        13  Python                              0x0000000108abcc7d 
method_vectorcall + 135
        14  Python                              0x0000000108b5a299 
call_function + 346
        15  Python                              0x0000000108b51477 
_PyEval_EvalFrameDefault + 3927
        16  Python                              0x0000000108b5ae5d 
_PyEval_EvalCodeWithName + 2107
        17  Python                              0x0000000108b5047d 
PyEval_EvalCode + 51
        18  Python                              0x0000000108b89025 
run_eval_code_obj + 102
        19  Python                              0x0000000108b88473 run_mod + 82
        20  Python                              0x0000000108b87345 
PyRun_FileExFlags + 160
        21  Python                              0x0000000108b86a29 
PyRun_SimpleFileExFlags + 271
        22  Python                              0x0000000108b9e449 Py_RunMain + 
1870
        23  Python                              0x0000000108b9e790 pymain_main 
+ 306
        24  Python                              0x0000000108b9e7de Py_BytesMain 
+ 42
        25  libdyld.dylib                       0x00007fff6dbae3d5 start + 1
        26  ???                                 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6
```
One can verify this by running this program on a macOs laptop with a qwerty 
keyboard, switching the layout to French - PC and pressing the '[' key.
```
import pygame
pygame.init()
pygame.display.set_mode((100, 100))
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit(); #sys.exit() if sys is imported
        if event.type == pygame.KEYDOWN:
            key_name = pygame.key.name(event.key)
            print(event, event.key.__class__, event.key, key_name)
        elif event.type == pygame.KEYUP:
            key_name = pygame.key.name(event.key)
            print(event, event.key.__class__, event.key, key_name)
```
```

----------
messages: 382998
nosy: spacether
priority: normal
severity: normal
status: open
title: tkinter throws exception when key is pressed

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42640>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to