rshk / python-libxdo

Python bindings for libxdo
BSD 3-Clause "New" or "Revised" License
76 stars 19 forks source link

Failed X requests crash the interpreter #6

Closed mzizzi closed 8 years ago

mzizzi commented 8 years ago

I wonder if there is a nice way to wrap these types of errors with an exception. As written we cannot catch errors like these and the interpreter will crash. Below is an example of trying to fetch the size of a bad window id.

$ python
>>> import xdo
>>> x = xdo.Xdo()
>>> x.get_window_size(123)
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  3 (X_GetWindowAttributes)
  Resource id in failed request:  0x7b
  Serial number of failed request:  17
  Current serial number in output stream:  18
$
rshk commented 8 years ago

It was missing an error handler: http://motifdeveloper.com/tips/tip29.html

7 seems to fix the issue, although it can be nicer

mzizzi commented 8 years ago

Thanks! I hadn't had time to look into this.

rshk commented 8 years ago

Issue seems to be fixed now, feel free to reopen if this still happens.