Skip to content
Myr

Only return unicode params from get_os_args if unchanged.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent ed978a6 · Browse files · 2 files+28 added−20 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+28 added−20 removed

  • other:+28 added−20 removed

2 files+28 added−20 removed

modified:click/_winconsole.py+23 added-18 removed
8 unmodified lines
9# echo and prmopt.1011import io12import sys13import zlib14import ctypes15from click._compat import _NonClosingTextIOWrapper, text_type, PY216from ctypes import byref, POINTER, pythonapi, c_int, c_char, c_char_p, \17 c_void_p, py_object, c_ssize_t, c_ulong, windll, WINFUNCTYPE18from ctypes.wintypes import LPWSTR, LPCWSTR192020PY2 = sys.version_info[0] == 22121c_ssize_p = POINTER(c_ssize_t)2223PyObject_GetBuffer = pythonapi.PyObject_GetBuffer24PyBuffer_Release = pythonapi.PyBuffer_Release
185 unmodified lines
210 'utf-16-le', 'strict', line_buffering=True)211 return ConsoleStream(text_stream, buffer_stream)212213215def _get_windows_argv():216 argc = c_int(0)217 argv_unicode = CommandLineToArgvW(GetCommandLineW(), byref(argc))218 argv = [argv_unicode[i] for i in range(0, argc.value)]214if PY2:215 def _hash_py_argv():216 return zlib.crc32('\x00'.join(sys.argv[1:]))217220 if not hasattr(sys, 'frozen'):221 argv = argv[1:]222 while len(argv) > 0:223 arg = argv[0]224 if not arg.startswith('-') or arg == '-':225 break218 _initial_argv_hash = _hash_py_argv()219220 def _get_windows_argv():221 argc = c_int(0)222 argv_unicode = CommandLineToArgvW(GetCommandLineW(), byref(argc))223 argv = [argv_unicode[i] for i in range(0, argc.value)]224225 if not hasattr(sys, 'frozen'):226 argv = argv[1:]227 while len(argv) > 0:228 arg = argv[0]229 if not arg.startswith('-') or arg == '-':230 break231 argv = argv[1:]227 if arg == '-m':228 break229 if arg == '-c':230 argv[0] = u'-c'231 break232 if arg == '-m':233 break234 if arg == '-c':235 argv[0] = u'-c'236 break237233 return argv238 return argv239240241_stream_factories = {242 0: _get_text_stdin,
16 unmodified lines
modified:click/utils.py+5 added-2 removed
10 unmodified lines
1112if not PY2:13 from ._compat import _find_binary_writer14elif WIN:15 from ._winconsole import _get_windows_argv15 from ._winconsole import _get_windows_argv, \16 _hash_py_argv, _initial_argv_hash171819echo_native_types = string_types + (bytes, bytearray)20
383 unmodified lines
404 carry all possible values that sys.argv can have.405406 .. versionadded:: 6.0407 """407 if PY2 and WIN:408 # We can only extract the unicode argv if sys.argv has not been409 # changed since the startup of the application.410 if PY2 and WIN and _initial_argv_hash == _hash_py_argv():411 return _get_windows_argv()412 return sys.argv[1:]413414
66 unmodified lines