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

lnotify 0.34 + Python 3.7: malformed ps call #334

Open
randrej opened this issue May 3, 2019 · 1 comment
Open

lnotify 0.34 + Python 3.7: malformed ps call #334

randrej opened this issue May 3, 2019 · 1 comment
Labels
bug Unexpected problem or unintended behavior

Comments

@randrej
Copy link
Contributor

randrej commented May 3, 2019

subprocess.check_output() returns bytes.
The result of the call on line 103 (bytes) is then used to form the command passed to another call of subprocess.check_output() on the following line.

This fails on Python 3.

When lnotify is run on Python 2, the shell command on line 104 is obtained by using % string formatting (a Python 2 default), with a bytes object used as the value of the singular %s. This provides a clean output in Python 2 (say, since it's a PID, 1102) and a mangled one in Python 3 : b'1102', since there is no implicit bytes -> str conversion (apart from bytes' __str__).

window_pid, the bytes instance, must be converted to str (unicode string) in Python 3, before using it as an argument to %.

I'll submit a PR fixing this using from __future__ import unicode_literals.

@larsks
Copy link

larsks commented May 22, 2019

I was just looking at another issue related to this chunk of code. I'm curious if you have an opinion on my comments in #339.

larsks added a commit to larsks/scripts that referenced this issue May 31, 2019
The python "lnotify" plugin had some problematic code that would
suppress notifications if the active window was named "tilda",
"xterm", or "gnome-terminal". This list was not user-configurable, and
the code implementing this feature was broken due to weechat#339
(incompatible with common versions of ps) and weechat#334 (python3
bytes-vs-string incompatibility).

This commit removes the problematic code.

Closes: weechat#334
Closes: weechat#339
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants