Skip to content
Myr

Merge branch '1.0-maintenance'

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 · parents ddf58b2, 50469da · Browse files · 3 files+36 added−3 removed
This commit

State

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

Diff stats

3 files+36 added−3 removed

  • tests:+12 added−0 removed
  • other:+24 added−3 removed

3 files+36 added−3 removed

modified:click/_compat.py+16 added-3 removed
4 unmodified lines
5import codecs6import tempfile789PY2 = sys.version_info[0] == 2101112def _make_text_stream(stream, encoding, errors):13 if encoding is None:14 encoding = get_best_encoding(stream)15 if errors is None:
19 unmodified lines
353637class _NonClosingTextIOWrapper(io.TextIOWrapper):3836 def __init__(self, stream, encoding, errors):39 def __init__(self, stream, encoding, errors, **extra):40 io.TextIOWrapper.__init__(self, _FixupStream(stream),38 encoding, errors)41 encoding, errors, **extra)4243 # The io module is already a place where Python 2 got the44 # python 3 text behavior forced on, so we need to unbreak45 # it to look like python 2 stuff.46 if PY2:47 def write(self, x):48 return io.TextIOWrapper.write(self, unicode(x))4950 def writelines(self, lines):51 lines = map(unicode, lines)52 return io.TextIOWrapper.writelines(self, lines)5354 def __del__(self):55 try:56 self.detach()57 except Exception:
51 unmodified lines
109 return False110 return True11111299PY2 = sys.version_info[0] == 2113if PY2:114 text_type = unicode115 bytes = str116 raw_input = raw_input
322 unmodified lines
modified:tests/test_arguments.py+12 added
90 unmodified lines
91 with open('foo.txt', 'rb') as f:92 assert f.read() == b'Foo bar baz\n'939495def test_stdout_default(runner):96 @click.command()97 @click.argument('output', type=click.File('w'), default='-')98 def inout(output):99 output.write('Foo bar baz\n')100 output.flush()101102 result = runner.invoke(inout, [])103 assert not result.exception104 assert result.output == 'Foo bar baz\n'105106107def test_nargs_envvar(runner):108 @click.command()109 @click.option('--arg', nargs=-1)110 def cmd(arg):
39 unmodified lines
modified:CHANGES+8 added
11 unmodified lines
12 binary mode correctly.13- added support for atomic writes to files by going through14 a temporary file.1516Version 1.117-----------1819(bugfix release, release to be decided)2021- fixed a bug that caused text files on Python 2 to not accept22 native strings.2324Version 1.025-----------2627(no codename, released on May 21st 2014)
2 unmodified lines