mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Allow arbitrary bytes in output. Resolves #245
This commit is contained in:
parent
826aa4cebd
commit
66b1d39c6e
11 changed files with 104 additions and 50 deletions
6
testing/resources/arbitrary_bytes_repo/hooks.yaml
Normal file
6
testing/resources/arbitrary_bytes_repo/hooks.yaml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
- id: python3-hook
|
||||
name: Python 3 Hook
|
||||
entry: python3-hook
|
||||
language: python
|
||||
language_version: python3.3
|
||||
files: \.py$
|
||||
13
testing/resources/arbitrary_bytes_repo/python3_hook/main.py
Normal file
13
testing/resources/arbitrary_bytes_repo/python3_hook/main.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def func():
|
||||
# Intentionally write mixed encoding to the output. This should not crash
|
||||
# pre-commit and should write bytes to the output.
|
||||
sys.stdout.buffer.write('☃'.encode('UTF-8') + '²'.encode('latin1') + b'\n')
|
||||
# Return 1 to trigger printing
|
||||
return 1
|
||||
11
testing/resources/arbitrary_bytes_repo/setup.py
Normal file
11
testing/resources/arbitrary_bytes_repo/setup.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
from setuptools import find_packages
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='python3_hook',
|
||||
version='0.0.0',
|
||||
packages=find_packages('.'),
|
||||
entry_points={
|
||||
'console_scripts': ['python3-hook = python3_hook.main:func'],
|
||||
},
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue