display.get_input_focus().focus results in infinite 100% loop after Window.get_wm_name errors out. #54
Comments
|
Did you try with the current master? A fix was recently pushed for properties handling. |
|
@benoit-pierre Yes I am quite sure. Are you referring to the commit from 6 days ago? I pulled from master 3 days ago. |
|
When you press ctrl+C when it never returns, it traces back to: |
|
Can you provide a full stack trace? A link to the Recorder program would help too. |
|
I discovered it using pyxhook, which can be retrieved from: The function that is raising the error is: And the UnicodeDecodeError error occurs at line: In the next event, it never returns from: I am not on my linux pc right now. Therefore I cannot provide a full stack trace. Will add when I am able to. |
|
So when you say If I use the |
|
(Yes I meant RECORD extension) That is odd, because I definitely get the error at: |
|
Using the following patch: diff --git i/pyxhook.py w/pyxhook.py
index c751001..a24a670 100644
--- i/pyxhook.py
+++ w/pyxhook.py
@@ -275,12 +275,14 @@ class HookManager(threading.Thread):
return pyxhookmouseevent(storewm["handle"], storewm["name"], storewm["class"], (self.mouse_position_x, self.mouse_position_y), MessageName)
def xwindowinfo(self):
+ from traceback import print_exc
try:
windowvar = self.local_dpy.get_input_focus().focus
wmname = windowvar.get_wm_name()
wmclass = windowvar.get_wm_class()
wmhandle = str(windowvar)[20:30]
except:
+ print_exc()
## This is to keep things running smoothly. It almost never happens, but still...
return {"name":None, "class":None, "handle":None}
if (wmname == None) and (wmclass == None):
@@ -290,6 +292,7 @@ class HookManager(threading.Thread):
wmclass = windowvar.get_wm_class()
wmhandle = str(windowvar)[20:30]
except:
+ print_exc()
## This is to keep things running smoothly. It almost never happens, but still...
return {"name":None, "class":None, "handle":None}
if wmclass == None:I get this with Traceback (most recent call last):
File "/home/bpierre/progs/src/pyxhook/pyxhook.py", line 291, in xwindowinfo
wmname = windowvar.get_wm_name()
File "build/bdist.linux-x86_64/egg/Xlib/xobject/drawable.py", line 644, in get_wm_name
d = self.get_full_property(Xatom.WM_NAME, Xatom.STRING)
File "build/bdist.linux-x86_64/egg/Xlib/xobject/drawable.py", line 465, in get_full_property
prop.bytes_after // 4 + 1)
File "build/bdist.linux-x86_64/egg/Xlib/xobject/drawable.py", line 449, in get_property
long_length = length)
File "build/bdist.linux-x86_64/egg/Xlib/protocol/rq.py", line 1361, in __init__
self.reply()
File "build/bdist.linux-x86_64/egg/Xlib/protocol/rq.py", line 1373, in reply
self._display.send_and_recv(request = self._serial)
File "build/bdist.linux-x86_64/egg/Xlib/protocol/display.py", line 576, in send_and_recv
gotreq = self.parse_response(request)
File "build/bdist.linux-x86_64/egg/Xlib/protocol/display.py", line 668, in parse_response
gotreq = self.parse_request_response(request) or gotreq
File "build/bdist.linux-x86_64/egg/Xlib/protocol/display.py", line 756, in parse_request_response
req._parse_response(self.data_recv[:self.recv_packet_len])
File "build/bdist.linux-x86_64/egg/Xlib/protocol/rq.py", line 1385, in _parse_response
self._data, d = self._reply.parse_binary(data, self._display, rawdict = 1)
File "build/bdist.linux-x86_64/egg/Xlib/protocol/rq.py", line 1197, in parse_binary
formats.get(f.name),
File "build/bdist.linux-x86_64/egg/Xlib/protocol/rq.py", line 653, in parse_binary_value
ret = (8, data[:length].decode())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb7 in position 59: ordinal not in range(128)And this with the current master: Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/home/bpierre/progs/src/pyxhook/pyxhook.py", line 112, in run
self.record_dpy.record_enable_context(self.ctx, self.processevents)
File "/home/bpierre/progs/src/python-xlib/Xlib/ext/record.py", line 243, in enable_context
context = context)
File "/home/bpierre/progs/src/python-xlib/Xlib/ext/record.py", line 220, in __init__
rq.ReplyRequest.__init__(self, *args, **keys)
File "/home/bpierre/progs/src/python-xlib/Xlib/protocol/rq.py", line 1360, in __init__
self.reply()
File "/home/bpierre/progs/src/python-xlib/Xlib/protocol/rq.py", line 1372, in reply
self._display.send_and_recv(request = self._serial)
File "/home/bpierre/progs/src/python-xlib/Xlib/protocol/display.py", line 576, in send_and_recv
gotreq = self.parse_response(request)
File "/home/bpierre/progs/src/python-xlib/Xlib/protocol/display.py", line 668, in parse_response
gotreq = self.parse_request_response(request) or gotreq
File "/home/bpierre/progs/src/python-xlib/Xlib/protocol/display.py", line 756, in parse_request_response
req._parse_response(self.data_recv[:self.recv_packet_len])
File "/home/bpierre/progs/src/python-xlib/Xlib/ext/record.py", line 224, in _parse_response
self._callback(r)
File "/home/bpierre/progs/src/pyxhook/pyxhook.py", line 153, in processevents
self.KeyDown(hookevent)
File "example.py", line 14, in kbevent
print event
File "/home/bpierre/progs/src/pyxhook/pyxhook.py", line 328, in __str__
return "Window Handle: " + str(self.Window) + "\nWindow Name: " + str(self.WindowName) + "\nWindow's Process Name: " + str(self.WindowProcName) + "\nKey Pressed: " + str(self.Key) + "\nAscii Value: " + str(self.Ascii) + "\nKeyID: " + str(self.KeyID) + "\nScanCode: " + str(self.ScanCode) + "\nMessageName: " + str(self.MessageName) + "\n"
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 99: ordinal not in range(128)So are you sure you're using the right version? |
|
I feel embarassed, but it is my own mistake. benoit-pierre is right. I had a zombied installation of Xlib (0.16). After reinstalling from master and rebooting, it was fixed. I will do a pull request for pyxhook to get the code fixed. |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

I am running the latest Xlib and using RECORD extension (almost same code as
examples/recorder_demo.py).I try to access the window title name, handle and class when a keyboard event occurs.
w = self.local_dpy.get_input_focus().focuswm = w.get_wm_name()However, if the window title contains a non-ascii character, such as '·', the get_wm_name excepts with a
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb7 in position 10: ordinal not in range(128).That would not be a problem on itself. But, on the next event, when
get_input_focus()is called again, it never returns and boosts CPU usage to 100%.To reproduce this you could open any browser window and browse to github, because github uses '·' regularly in their page titles.
I am running python2.7
The text was updated successfully, but these errors were encountered: