google-code-export / pyglet

Automatically exported from code.google.com/p/pyglet
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

[patch] fn keys crash pyglet #568

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
this is exactly as the issue: 
  Issue 487:    vendor specific keys on linux are crashing pyglet
Please see patch attached below. 

What steps will reproduce the problem?
1. Run any pyglet app
2. Press any Multimedia key on your multimedia keyboard, or something like "fn" 
key on your laptop.
3. crash

Paste in the traceback or error message:
 python2 brainworkshop.pyw 
Traceback (most recent call last):
  File "brainworkshop.pyw", line 4319, in <module>
    pyglet.app.run()
  File "/usr/lib/python2.7/site-packages/pyglet/app/__init__.py", line 264, in run
    EventLoop().run()
  File "/usr/lib/python2.7/site-packages/pyglet/app/xlib.py", line 82, in run
    window.dispatch_platform_event(e)
  File "/usr/lib/python2.7/site-packages/pyglet/window/xlib/__init__.py", line 1169, in dispatch_platform_event
    event_handler(e)
  File "/usr/lib/python2.7/site-packages/pyglet/window/xlib/__init__.py", line 1326, in _event_key
    text, symbol = self._event_text_symbol(ev)
  File "/usr/lib/python2.7/site-packages/pyglet/window/xlib/__init__.py", line 1262, in _event_text_symbol
    symbol = ord(unichr(symbol).lower())
ValueError: unichr() arg not in range(0x110000) (wide Python build)
AL lib: ReleaseALC: 1 device not closed

pyglet 1.1 with Python 2.5: Paste in the output of `python -m pyglet.info`
Other: Paste in the output of tools/gl_info.py (included in source distro):

Any additional info (platform/language/hardware) that may be relevant?

-----------------------------------------------------
PATCH:

diff --git a/pyglet/window/xlib/__init__.py b/pyglet/window/xlib/__init__.py
index 24b51cb..94a39d5 100644
--- a/pyglet/window/xlib/__init__.py
+++ b/pyglet/window/xlib/__init__.py
@@ -1259,7 +1259,11 @@ class XlibWindow(BaseWindow):
         # raw key code to a user key.
         if symbol and symbol not in key._key_names and ev.xkey.keycode:
             # Issue 353: Symbol is uppercase when shift key held down.
-            symbol = ord(unichr(symbol).lower())
+           # Issue 487: vendor specific keys on linux are crashing pyglet
+           try:
+                symbol = ord(unichr(symbol).lower())
+            except ValueError:
+                pass

             # If still not recognised, use the keycode
             if symbol not in key._key_names:

Original issue reported on code.google.com by markota...@gmail.com on 2 Apr 2012 at 7:55

GoogleCodeExporter commented 9 years ago
This issue seems to be fixed in the latest from mercurial.

Original comment by Adam.JT...@gmail.com on 25 Apr 2012 at 6:25