GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — AttributeError calling subprocess.check_output(input=None) with encoding or errors args · Issue #97825 · python/cpython

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

New issue
Copy link
New issue
Copy link
Closed
Closed
AttributeError calling subprocess.check_output(input=None) with encoding or errors args#97825
Copy link
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@akulakov
akulakov
opened on Oct 4, 2022
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.

Activity

  1. akulakov
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Oct 4, 2022
  2. eryksun
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    3.11only security fixesonly security fixes
    3.10 (EOL)end of lifeend of life
    3.12only security fixesonly security fixes
    on Oct 4, 2022
  3. brettcannon
    added a commit that references this issue on Oct 5, 2022

    pythongh-97825: fix AttributeError when calling subprocess.check_outp…

    db64fb9
  4. miss-islington
    added 2 commits that reference this issue on Oct 5, 2022

    pythongh-97825: fix AttributeError when calling subprocess.check_outp…

    537a90f

    pythongh-97825: fix AttributeError when calling subprocess.check_outp…

    b771e84
  5. gpshead commented on Oct 5, 2022

    @gpshead
    gpshead
    on Oct 5, 2022
    Member
    More actions

    thanks! That this bug has probably been present for so long I guess means people don't use this combination of args very often?

  6. gpshead
    closed this as completedon Oct 5, 2022
  7. akulakov commented on Oct 5, 2022

    @akulakov
    akulakov
    on Oct 5, 2022
    ContributorAuthor
    More actions

    I think input=None maybe isn't used much, and the workaround of input='' is not too hard to find.

    Thanks for reviewing @gpshead @JelleZijlstra !

  8. miss-islington
    added 2 commits that reference this issue on Oct 5, 2022

    gh-97825: fix AttributeError when calling subprocess.check_output(inp…

    9133aab

    gh-97825: fix AttributeError when calling subprocess.check_output(inp…

    ece5f7e
  9. carljm
    added a commit that references this issue on Oct 6, 2022

    Merge branch 'main' into dictwatch

    4bb5d9d
  10. mpage
    added a commit that references this issue on Oct 11, 2022

    pythongh-97825: fix AttributeError when calling subprocess.check_outp…

    2efca9c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-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

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.