Skip to content
Myr

Support missing stream encodings on Python 3. This fixes #344

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 7ec17e4 · Browse files · 2 files+7 added−1 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+7 added−1 removed

  • other:+7 added−1 removed

2 files+7 added−1 removed

modified:click/_compat.py+5 added-1 removed
253 unmodified lines
254 return buf255256 def _stream_is_misconfigured(stream):257 """A stream is misconfigured if its encoding is ASCII."""258 # If the stream does not have an encoding set, we assume it's set259 # to ASCII. This appears to happen in certain unittest260 # environments. It's not quite clear what the correct behavior is261 # but this at least will force Click to recover somehow.258 return is_ascii_encoding(getattr(stream, 'encoding', None))262 return is_ascii_encoding(getattr(stream, 'encoding', None) or 'ascii')263264 def _is_compatible_text_stream(stream, encoding, errors):265 stream_encoding = getattr(stream, 'encoding', None)266 stream_errors = getattr(stream, 'errors', None)
306 unmodified lines
modified:CHANGES+2 added
8 unmodified lines
9(bugfix release, release date yet to be decided)1011- Fix a bug where error messages would include a trailing `None` string.12- Fix a bug where Click would crash on docstrings with trailing newlines.13- Support streams with encoding set to `None` on Python 3 by barfing with14 a better error.1516Version 4.017-----------18
207 unmodified lines