File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -17,9 +17,9 @@ def _command_length(*cmd):
1717 full_cmd = ' ' .join (cmd )
1818
1919 # win32 uses the amount of characters, more details at:
20- # https://blogs.msdn.microsoft. com/oldnewthing/20031210-00/?p=41553/
20+ # https://github. com/pre-commit/pre-commit/pull/839
2121 if sys .platform == 'win32' :
22- return len (full_cmd )
22+ return len (full_cmd . encode ( 'utf-16le' )) // 2
2323
2424 return len (full_cmd .encode (sys .getfilesystemencoding ()))
2525
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ def test_partition_limits():
5555
5656def test_partition_limit_win32 (sys_win32_mock ):
5757 cmd = ('ninechars' ,)
58- varargs = (u '😑' * 10 ,)
58+ varargs = ('😑' * 10 ,)
5959 with mock .patch ('pre_commit.xargs.sys' , sys_win32_mock ):
6060 ret = xargs .partition (cmd , varargs , _max_length = 20 )
6161
@@ -64,7 +64,7 @@ def test_partition_limit_win32(sys_win32_mock):
6464
6565def test_partition_limit_linux (sys_linux_mock ):
6666 cmd = ('ninechars' ,)
67- varargs = (u '😑' * 5 ,)
67+ varargs = ('😑' * 5 ,)
6868 with mock .patch ('pre_commit.xargs.sys' , sys_linux_mock ):
6969 ret = xargs .partition (cmd , varargs , _max_length = 30 )
7070
@@ -73,7 +73,7 @@ def test_partition_limit_linux(sys_linux_mock):
7373
7474def test_argument_too_long_with_large_unicode (sys_linux_mock ):
7575 cmd = ('ninechars' ,)
76- varargs = (u '😑' * 10 ,) # 4 bytes * 10
76+ varargs = ('😑' * 10 ,) # 4 bytes * 10
7777 with mock .patch ('pre_commit.xargs.sys' , sys_linux_mock ):
7878 with pytest .raises (xargs .ArgumentTooLongError ):
7979 xargs .partition (cmd , varargs , _max_length = 20 )
You can’t perform that action at this time.
0 commit comments