Merge lp:~3v1n0/unity/unity-script-fix-byte-regex into lp:unity

Proposed by Marco Trevisan (Treviño) on 2015-12-15
Status: Merged
Approved by: Marco Trevisan (Treviño) on 2015-12-16
Approved revision: 4055
Merged at revision: 4058
Proposed branch: lp:~3v1n0/unity/unity-script-fix-byte-regex
Merge into: lp:unity
Diff against target: 15 lines (+2/-2)
1 file modified
tools/unity.cmake (+2/-2)
To merge this branch: bzr merge lp:~3v1n0/unity/unity-script-fix-byte-regex
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-12-15
Barry Warsaw (community) Approve on 2015-12-15
Sebastien Bacher 2015-12-15 Approve on 2015-12-15
Review via email: mp+280624@code.launchpad.net

Commit Message

Unity: compile a byte regex in order to get proper matching with byte cmdline

To post a comment you must log in.
4055. By Marco Trevisan (Treviño) on 2015-12-15

Unity: compile a byte regex in order to get proper matching with byte cmdline

Sebastien Bacher (seb128) wrote :

looks fine to me but you might want another review from somebody who can make sense of python encoding issues ;-)

review: Approve
Barry Warsaw (barry) wrote :

Since you're reading the command line in 'rb' mode, cmdline is indeed a bytes object, so this patch is good.

Aside, you're letting garbage collection close the open file descriptor, which generally isn't a good idea. You might also consider changing the preceding line to:

     with open(os.path.join(pid_path, "cmdline"), "rb") as fp:
         cmdline = fp.read()

That will ensure the fd gets closed in all cases.

review: Approve
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
4056. By Marco Trevisan (Treviño) on 2015-12-17

unity.cmake: correctly compare strings with strings

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tools/unity.cmake'
2--- tools/unity.cmake 2015-11-19 10:36:04 +0000
3+++ tools/unity.cmake 2015-12-17 23:30:38 +0000
4@@ -107,9 +107,9 @@
5 try:
6 pid_path = os.path.join("/proc", pid)
7 cmdline = open(os.path.join(pid_path, "cmdline"), "rb").read()
8- if re.match(r"^compiz\b", cmdline):
9+ if re.match(rb"^compiz\b", cmdline):
10 compiz_env = open(os.path.join(pid_path, "environ"), "rb").read()
11- if display in compiz_env:
12+ if display in compiz_env.decode(sys.getdefaultencoding()):
13 subprocess.call (["kill", "-9", pid])
14 except IOError:
15 continue