Skip to content

Commit

Permalink
Update subprocess.Popen args for Python 3.9+ (#1679)
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
  • Loading branch information
2 people authored and DanielNoord committed Jul 9, 2022
1 parent 8609566 commit 5567716
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Release date: TBA

Closes PyCQA/pylint#6017

* Updated the stdlib brain for ``subprocess.Popen`` to accommodate Python 3.9+.

Closes PyCQA/pylint#7092


What's New in astroid 2.11.6?
=============================
Expand Down
20 changes: 13 additions & 7 deletions astroid/brain/brain_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,26 @@

from astroid.brain.helpers import register_module_extender
from astroid.builder import parse
from astroid.const import PY37_PLUS, PY39_PLUS
from astroid.const import PY37_PLUS, PY39_PLUS, PY310_PLUS, PY311_PLUS
from astroid.manager import AstroidManager


def _subprocess_transform():
communicate = (bytes("string", "ascii"), bytes("string", "ascii"))
communicate_signature = "def communicate(self, input=None, timeout=None)"
args = """\
self, args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None,
preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None,
universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True,
start_new_session=False, pass_fds=(), *, encoding=None, errors=None"""
if PY37_PLUS:
args += ", text=None"
self, args, bufsize=-1, executable=None, stdin=None, stdout=None, stderr=None,
preexec_fn=None, close_fds=True, shell=False, cwd=None, env=None,
universal_newlines=None, startupinfo=None, creationflags=0, restore_signals=True,
start_new_session=False, pass_fds=(), *, encoding=None, errors=None, text=None"""

if PY39_PLUS:
args += ", user=None, group=None, extra_groups=None, umask=-1"
if PY310_PLUS:
args += ", pipesize=-1"
if PY311_PLUS:
args += ", process_group=None"

init = f"""
def __init__({args}):
pass"""
Expand Down
1 change: 1 addition & 0 deletions astroid/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
PY38_PLUS = sys.version_info >= (3, 8)
PY39_PLUS = sys.version_info >= (3, 9)
PY310_PLUS = sys.version_info >= (3, 10)
PY311_PLUS = sys.version_info >= (3, 11)
BUILTINS = "builtins" # TODO Remove in 2.8

WIN32 = sys.platform == "win32"
Expand Down

0 comments on commit 5567716

Please sign in to comment.