Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

AttributeError calling subprocess.check_output(input=None) with encoding or errors args #97825

Copy link
Copy link
Closed
@akulakov

Description

@akulakov
Issue body actions

Bug report

subprocess.check_output(input=None) raises an AttributeError when called with encoding or errors args.

Example:

>>> check_output(['ls'], input=None, encoding='utf-8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ak/opensource/cpython4/Lib/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ak/opensource/cpython4/Lib/subprocess.py", line 549, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ak/opensource/cpython4/Lib/subprocess.py", line 1206, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ak/opensource/cpython4/Lib/subprocess.py", line 2035, in _communicate
    self._save_input(input)
  File "/Users/ak/opensource/cpython4/Lib/subprocess.py", line 2115, in _save_input
    self._input = self._input.encode(self.stdin.encoding,
                  ^^^^^^^^^^^^^^^^^^
AttributeError: 'bytes' object has no attribute 'encode'. Did you mean: 'decode'?

Your environment

  • CPython versions tested on: 3.12 (the issue is also present in 3.10 and 3.11)
  • Operating system and architecture: MacOS M1, 11.5

I will create a PR a bit later today.

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10only security fixesonly security fixes3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibPython modules in the Lib dirPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.