mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Don't UnicodeDecodeError on non-ascii not-found hooks. Resolves #207.
This commit is contained in:
parent
20c546a7da
commit
7905594215
5 changed files with 35 additions and 12 deletions
|
|
@ -77,12 +77,8 @@ def get_hook_message(
|
|||
)
|
||||
|
||||
|
||||
def sys_stdout_write_wrapper(s, stream=sys.stdout):
|
||||
"""Python 2.6 chokes on unicode being passed to sys.stdout.write.
|
||||
stdout_byte_stream = getattr(sys.stdout, 'buffer', sys.stdout)
|
||||
|
||||
This is an adapter because PY2 is ok with bytes and PY3 requires text.
|
||||
"""
|
||||
assert type(s) is five.text
|
||||
if five.PY2: # pragma: no cover (PY2)
|
||||
s = s.encode('UTF-8')
|
||||
stream.write(s)
|
||||
|
||||
def sys_stdout_write_wrapper(s, stream=stdout_byte_stream):
|
||||
stream.write(five.to_bytes(s))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue