Skip to content

Commit

Permalink
Make sure we convert our subprocess input to bytes.
Browse files Browse the repository at this point in the history
Summary:
Python3 cares that the input is bytes rather than strings.  This is
probably right: even for python2 the filenames could conceivably be
unicode and we should encode them before passing to the subshell.

Test Plan:
Fingers crossed, I don't have a good python3 setup.  But I ran:
    python -c 'print "\n".join(["foo"]).encode("utf-8")'
    python3 -c 'print("\n".join(["foo"]).encode("utf-8"))'
and they returned `'foo'` and `b'foo'` respectively, which seems right
to me.

Reviewers: amos, benkraft

Reviewed By: amos

Subscribers: kevinb

Differential Revision: https://phabricator.khanacademy.org/D63670
  • Loading branch information
csilvers committed Jun 3, 2020
1 parent e03e3ee commit e750413
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hook_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def lint_files(files_to_lint):
# --stdin means we don't need to worry about how many files there are.
p = subprocess.Popen(['ka-lint', '--stdin', '--blacklist=yes'],
stdin=subprocess.PIPE)
p.communicate(input='\n'.join(files_to_lint))
p.communicate(input='\n'.join(files_to_lint).encode('utf-8'))
return p.wait()


Expand Down

0 comments on commit e750413

Please sign in to comment.