mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Fix xargs.partition: use sys.getfilesystemencoding
The previous `sys.getdefaultencoding` almost always fallsback to `ascii` while `sys.getfilesystemencoding` is utf-8 once in utf-8 mode.
This commit is contained in:
parent
df5d171cd7
commit
2ad69e12ce
2 changed files with 3 additions and 3 deletions
|
|
@ -22,7 +22,7 @@ def _get_command_length(command, arg):
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
return len(full_cmd)
|
return len(full_cmd)
|
||||||
|
|
||||||
return len(full_cmd.encode(sys.getdefaultencoding()))
|
return len(full_cmd.encode(sys.getfilesystemencoding()))
|
||||||
|
|
||||||
|
|
||||||
class ArgumentTooLongError(RuntimeError):
|
class ArgumentTooLongError(RuntimeError):
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ from pre_commit import xargs
|
||||||
def sys_win32_mock(mocker):
|
def sys_win32_mock(mocker):
|
||||||
return mocker.Mock(
|
return mocker.Mock(
|
||||||
platform='win32',
|
platform='win32',
|
||||||
getdefaultencoding=mocker.Mock(return_value='utf-8'),
|
getfilesystemencoding=mocker.Mock(return_value='utf-8'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ def sys_win32_mock(mocker):
|
||||||
def sys_linux_mock(mocker):
|
def sys_linux_mock(mocker):
|
||||||
return mocker.Mock(
|
return mocker.Mock(
|
||||||
platform='linux',
|
platform='linux',
|
||||||
getdefaultencoding=mocker.Mock(return_value='utf-8'),
|
getfilesystemencoding=mocker.Mock(return_value='utf-8'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue