Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 unicode/bytes issue with KDE terminal #6

Closed
Pidgeot opened this issue Apr 4, 2020 · 0 comments
Closed

Python 3 unicode/bytes issue with KDE terminal #6

Pidgeot opened this issue Apr 4, 2020 · 0 comments
Assignees
Labels

Comments

@Pidgeot
Copy link
Owner

Pidgeot commented Apr 4, 2020

I tried to launch pylnp from source-- that is, using launch.py rather than the compiled binary-- with Python 3 on Fedora. It worked until I actually tried to launch DF, at which point I got this traceback:

Traceback (most recent call last):
  File "/home/bjr/.pylnp/pylnp/tkgui/tkgui.py", line 542, in run_df
    launcher.run_df()
  File "/home/bjr/.pylnp/pylnp/core/launcher.py", line 52, in run_df
    result = run_program(executable, force, True, spawn_terminal)
  File "/home/bjr/.pylnp/pylnp/core/launcher.py", line 91, in run_program
    run_args = terminal.get_terminal_command([path,])
  File "/home/bjr/.pylnp/pylnp/core/terminal.py", line 25, in get_terminal_command
    term = get_configured_terminal().get_command_line()
  File "/home/bjr/.pylnp/pylnp/core/terminal.py", line 125, in get_command_line
    '\n', '')
TypeError: a bytes-like object is required, not 'str'

The KDETerminal implementation of get_command_line looks like this:

    @staticmethod
    def get_command_line():
        s = subprocess.check_output(
            ['kreadconfig', '--file', 'kdeglobals', '--group', 'General',
             '--key', 'TerminalApplication', '--default', 'konsole']).replace(
                 '\n', '')
        return ['nohup', s, '-e']

I was able to fix this by just changing the arguments to .replace() to be binary strings (e.g. “b'\n' and b''). Not sure if there’s a more elegant thing to do here. And looking at some of the other code in this module, they seem to have similar looking code, which suggests to me other places might have this problem too.

[Issue created by TC01: 2019-09-15]
[Last updated on bitbucket: 2020-04-04]

[Comment created by Pidgeot: 2019-09-15]
I’ll have to verify it doesn’t break other Python versions, but otherwise it seems like a reasonable enough change.

Just for reference, can you check exactly which version of Python you’re running?

[Comment created by TC01: 2019-09-15]
Sure! I’m using Python 3.7.4 here.

[Comment created by McArcady: 2020-04-04]
This problem may be fixed by the github PR#3 #3, that fixes some terminal handling issues with python3 on Linux.

I’ve not tested it with the KDE Terminal though.

[Comment created by Pidgeot: 2020-04-04]
I’ve merged the pull request over on Github, it’ll appear on Bitbucket shortly.

I'm in the process of migrating over the Bitbucket issues now, so please open a new issue over on Github if this happens again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant