Xpra: Ticket #2494: bug in platform/xposix/keyboard.py

Launching « xpra start » on Fedora, I get this error :

xpra main error:
Traceback (most recent call last):
  File "/usr/lib64/python3.7/site-packages/xpra/scripts/main.py", line 110, in main
    return run_mode(script_file, err, options, args, mode, defaults)
  File "/usr/lib64/python3.7/site-packages/xpra/scripts/main.py", line 333, in run_mode
    return run_remote_server(error_cb, options, args, mode, defaults)
  File "/usr/lib64/python3.7/site-packages/xpra/scripts/main.py", line 1905, in run_remote_server
    app.init_ui(opts)
  File "/usr/lib64/python3.7/site-packages/xpra/client/ui_client_base.py", line 189, in init_ui
    opts.keyboard_raw, *overrides)
  File "/usr/lib64/python3.7/site-packages/xpra/client/gtk_base/gtk_keyboard_helper.py", line 30, in __init__
    self.update()
  File "/usr/lib64/python3.7/site-packages/xpra/client/gtk_base/gtk_keyboard_helper.py", line 63, in update
    self.query_xkbmap()
  File "/usr/lib64/python3.7/site-packages/xpra/client/keyboard_helper.py", line 352, in query_xkbmap
    ) = self.get_layout_spec()
  File "/usr/lib64/python3.7/site-packages/xpra/client/keyboard_helper.py", line 305, in get_layout_spec
    layout, layouts, variant, variants, options = self.keyboard.get_layout_spec()
  File "/usr/lib64/python3.7/site-packages/xpra/platform/xposix/keyboard.py", line 142, in get_layout_spec
    locale = self.get_locale_status()
  File "/usr/lib64/python3.7/site-packages/xpra/platform/xposix/keyboard.py", line 89, in get_locale_status
    parts = line.lstrip(" ").split(": ")
TypeError: a bytes-like object is required, not 'str'

proposed bugfix : replace line 89 in /usr/lib64/python3.7/site-packages/xpra/platform/xposix/keyboard.py by :

    parts = line.lstrip(b" ").split(b": ")


Tue, 26 Nov 2019 15:44:04 GMT - Antoine Martin: status, description changed; resolution set

Thanks!

The fix is correct and has been applied in r24499. Not sure why I didn't hit it before you did as I use Fedora for development and testing.


Thu, 28 Nov 2019 09:14:28 GMT - Antoine Martin: status changed; resolution deleted

019-11-28 16:12:14,368 failed to start client
Traceback (most recent call last):
  File "/usr/lib64/python3.7/site-packages/xpra/client/gtk_base/client_launcher.py", line 820, in start_XpraClient
    self.do_start_XpraClient(conn, display_desc)
  File "/usr/lib64/python3.7/site-packages/xpra/client/gtk_base/client_launcher.py", line 829, in do_start_XpraClient
    self.client.init_ui(self.config)
  File "/usr/lib64/python3.7/site-packages/xpra/client/ui_client_base.py", line 187, in init_ui
    opts.keyboard_raw, *overrides)
  File "/usr/lib64/python3.7/site-packages/xpra/client/gtk_base/gtk_keyboard_helper.py", line 27, in __init__
    self.update()
  File "/usr/lib64/python3.7/site-packages/xpra/client/gtk_base/gtk_keyboard_helper.py", line 60, in update
    self.query_xkbmap()
  File "/usr/lib64/python3.7/site-packages/xpra/client/keyboard_helper.py", line 352, in query_xkbmap
    ) = self.get_layout_spec()
  File "/usr/lib64/python3.7/site-packages/xpra/client/keyboard_helper.py", line 305, in get_layout_spec
    layout, layouts, variant, variants, options = self.keyboard.get_layout_spec()
  File "/usr/lib64/python3.7/site-packages/xpra/platform/xposix/keyboard.py", line 138, in get_layout_spec
    locale = self.get_locale_status()
  File "/usr/lib64/python3.7/site-packages/xpra/platform/xposix/keyboard.py", line 85, in get_locale_status
    parts = line.lstrip(b" ").split(b": ")
TypeError: lstrip arg must be None or str

This "fix" breaks things for me.


Thu, 28 Nov 2019 09:20:28 GMT - Antoine Martin: owner, status changed

The python documentation for subprocess.getoutput clearly states: Like getstatusoutput(), except the exit code is ignored and the return value is a string containing the command’s output.

So I am reverting r24499 in r24507.

Please try:

$ python3 -c 'from subprocess import getoutput;print(type(getoutput("localectl status")))'
<class 'str'>

It should be a string, and if it isn't then there's something fishy with your system's python3.


Sun, 01 Dec 2019 04:13:21 GMT - Antoine Martin: status changed; resolution set

r24542 is a better / safer fix.

Not heard back so closing.

I still believe that there's something wrong with your system python3, but without further information, it's impossible to tell what.


Sat, 23 Jan 2021 05:52:49 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/2494