| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -456,7 +456,8 @@ def check_output(*popenargs, timeout=None, **kwargs): | |||
| 456 | 456 | if 'input' in kwargs and kwargs['input'] is None: | |
| 457 | 457 | # Explicitly passing input=None was previously equivalent to passing an | |
| 458 | 458 | # empty string. That is maintained here for backwards compatibility. | |
| 459 | - if kwargs.get('universal_newlines') or kwargs.get('text'): | ||
| 459 | + if kwargs.get('universal_newlines') or kwargs.get('text') or kwargs.get('encoding') \ | ||
| 460 | + or kwargs.get('errors'): | ||
| 460 | 461 | empty = '' | |
| 461 | 462 | else: | |
| 462 | 463 | empty = b'' | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -238,6 +238,12 @@ def test_check_output_input_none_universal_newlines(self): | |||
| 238 | 238 | input=None, universal_newlines=True) | |
| 239 | 239 | self.assertNotIn('XX', output) | |
| 240 | 240 | ||
| 241 | + def test_check_output_input_none_encoding_errors(self): | ||
| 242 | + output = subprocess.check_output( | ||
| 243 | + [sys.executable, "-c", "print('foo')"], | ||
| 244 | + input=None, encoding='utf-8', errors='ignore') | ||
| 245 | + self.assertIn('foo', output) | ||
| 246 | + | ||
| 241 | 247 | def test_check_output_stdout_arg(self): | |
| 242 | 248 | # check_output() refuses to accept 'stdout' argument | |
| 243 | 249 | with self.assertRaises(ValueError) as c: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + Fixes :exc:`AttributeError` when :meth:`subprocess.check_output` is used with argument ``input=None`` and either of the arguments *encoding* or *errors* are used. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments