Package: python-xlib
Severity: important
Tags: patch
X-Debbugs-Cc: andre...@debian.org


Hi,
CC:-ing Andrew Shadura, as he has been the last uploader in debian/changelog of python-xlibs.

recently, in Debian stretch, I started seeing errors like below with my X2Go client implementation pyhoca-gui / pyhoca-cli.

I started porting pyhoca and python-x2go (the underlying module) to Python 3 over the last weekend and realized that in Python 3 the issues did not occur anymore.

However, in Python 2 they persist:

```
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/gevent/greenlet.py", line 534, in run
    result = self._run(*self.args, **self.kwargs)
File "/home/mike/MyDocuments/4projects/x2go-upstream/pyhoca-gui/x2go/backends/terminal/plain.py", line 1092, in _find_session_window
    window = utils.find_session_window(self.session_info.name)
File "/home/mike/MyDocuments/4projects/x2go-upstream/pyhoca-gui/x2go/utils.py", line 639, in find_session_window
    name = window.get_wm_name()
File "/usr/lib/python2.7/dist-packages/Xlib/xobject/drawable.py", line 636, in get_wm_name
    d = self.get_full_property(Xatom.WM_NAME, Xatom.STRING)
File "/usr/lib/python2.7/dist-packages/Xlib/xobject/drawable.py", line 458, in get_full_property
    val = val + prop.value
UnicodeDecodeError: 'ascii' codec can't decode byte 0xdf in position 29: ordinal not in range(128) <Greenlet at 0x7fa0fb3315f0: <bound method X2GoTerminalSession._find_session_window of <x2go.backends.terminal.plain.X2GoTerminalSession object at 0x7fa0f9490410>>(timeout=60)> failed with UnicodeDecodeError
```

The underlying cause for this issue is in Xlib/protocol/rq.py. The patch below fixes the issue:

The patch gets applied in String8.parse_binary_value().

```
--- rq.py       2015-08-25 17:58:11.000000000 +0200
+++ rq.py.fixed 2017-09-25 12:18:58.172941197 +0200
@@ -415,8 +415,14 @@
             s = s.decode('UTF-8')
         except UnicodeDecodeError:
             pass  # return as bytes
-        return s, data[slen:]

+        d = data[slen:]
+        try:
+            d = d.decode('UTF-8')
+        except UnicodeDecodeError:
+            pass
+
+        return s, d

```

Without the above patch, sometimes <str> types get returned, sometime <unicode> types. With the above patch, everything is returned as <unicode>.

Ideally, this fix should also go into Debian stretch. Thanks!

As no real persons seems to be maintaining the python-xlib package (no Uploaders: field), nor has it been orphaned, I'll consider fixing the above issue myself as an NMU or team upload (unless someone replies to my report).

I'd be really happy about a second pair of eyes to look at this issue, before I upload this.

Thanks!

Mike

--

DAS-NETZWERKTEAM
mike gabriel, herweg 7, 24357 fleckeby
mobile: +49 (1520) 1976 148
landline: +49 (4354) 8390 139

GnuPG Fingerprint: 9BFB AEE8 6C0A A5FF BF22  0782 9AF4 6B30 2577 1B31
mail: mike.gabr...@das-netzwerkteam.de, http://das-netzwerkteam.de

Attachment: pgpmmJtL0j3Cu.pgp
Description: Digitale PGP-Signatur

Reply via email to