Skip to content
Myr

Merge branch '4.x-maintenance'

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

authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parents f4961a8, be2c42b · Browse files · 4 files+15 added−9 removed
This commit

State

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

Diff stats

4 files+15 added−9 removed

  • other:+15 added−9 removed

4 files+15 added−9 removed

modified:click/_compat.py+6 added-2 removed
12 unmodified lines
1314_ansi_re = re.compile('\033\[((?:\d|;)*)([a-zA-Z])')151617def get_filesystem_encoding():18 return sys.getfilesystemencoding() or sys.getdefaultencoding()192021def _make_text_stream(stream, encoding, errors):22 if encoding is None:23 encoding = get_best_encoding(stream)24 if errors is None:
167 unmodified lines
192 return _make_text_stream(sys.stderr, encoding, errors)193194 def filename_to_ui(value):195 if isinstance(value, bytes):192 value = value.decode(sys.getfilesystemencoding(), 'replace')196 value = value.decode(get_filesystem_encoding(), 'replace')197 return value198else:199 import io200 text_type = str
166 unmodified lines
367 return _force_correct_text_writer(sys.stderr, encoding, errors)368369 def filename_to_ui(value):370 if isinstance(value, bytes):367 value = value.decode(sys.getfilesystemencoding(), 'replace')371 value = value.decode(get_filesystem_encoding(), 'replace')372 else:373 value = value.encode('utf-8', 'surrogateescape') \374 .decode('utf-8', 'replace')375 return value
214 unmodified lines
modified:click/types.py+3 added-2 removed
1import os2import sys3import stat45from ._compat import open_stream, text_type, filename_to_ui, get_streerror5from ._compat import open_stream, text_type, filename_to_ui, \6 get_filesystem_encoding, get_streerror7from .exceptions import BadParameter8from .utils import safecall, LazyFile910
103 unmodified lines
114 if enc is not None:115 value = value.decode(enc)116 except UnicodeError:117 try:117 value = value.decode(sys.getfilesystemencoding())118 value = value.decode(get_filesystem_encoding())119 except UnicodeError:120 value = value.decode('utf-8', 'replace')121 return value122 return value
393 unmodified lines
modified:click/utils.py+5 added-5 removed
1import os2import sys3from collections import deque45from ._compat import text_type, open_stream, get_streerror, string_types, \6 PY2, binary_streams, text_streams, filename_to_ui, \7 auto_wrap_for_ansi, strip_ansi, should_strip_ansi, \8 _default_text_stdout, _default_text_stderr, is_bytes, WIN5from ._compat import text_type, open_stream, get_filesystem_encoding, \6 get_streerror, string_types, PY2, binary_streams, text_streams, \7 filename_to_ui, auto_wrap_for_ansi, strip_ansi, should_strip_ansi, \8 _default_text_stdout, _default_text_stderr, is_bytes, WIN910if not PY2:11 from ._compat import _find_binary_writer12
76 unmodified lines
89def make_str(value):90 """Converts a value into a valid string."""91 if isinstance(value, bytes):92 try:93 return value.decode(sys.getfilesystemencoding())93 return value.decode(get_filesystem_encoding())94 except UnicodeError:95 return value.decode('utf-8', 'replace')96 return text_type(value)97
340 unmodified lines
modified:CHANGES+1 added
19 unmodified lines
20- Fix a bug where Click would crash on docstrings with trailing newlines.21- Support streams with encoding set to `None` on Python 3 by barfing with22 a better error.23- Handle ^C in less-pager properly.24- Handle return value of `None` from `sys.getfilesystemencoding`2526Version 4.027-----------28
207 unmodified lines