From 798a36c2d808ef23e0405a7f656e6168c4ad89a1 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Tue, 13 Jun 2017 10:13:25 +0100 Subject: [PATCH] subprocess: Use getfullargspec on python3 --- ubuntutools/subprocess.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ubuntutools/subprocess.py b/ubuntutools/subprocess.py index 0569f8f..1d9e90a 100644 --- a/ubuntutools/subprocess.py +++ b/ubuntutools/subprocess.py @@ -15,6 +15,7 @@ from __future__ import absolute_import import inspect import signal import subprocess +import sys from subprocess import PIPE, STDOUT, CalledProcessError @@ -25,8 +26,12 @@ __all__ = ['Popen', 'call', 'check_call', 'check_output', 'CalledProcessError', class Popen(subprocess.Popen): def __init__(self, *args, **kwargs): kwargs.setdefault('close_fds', True) + if sys.version_info[0] >= 3: + getargs = inspect.getfullargspec + else: + getargs = inspect.getargspec - if 'restore_signals' not in inspect.getargspec(subprocess.Popen.__init__)[0]: + if 'restore_signals' not in getargs(subprocess.Popen.__init__)[0]: given_preexec_fn = kwargs.pop('preexec_fn', None) restore_signals = kwargs.pop('restore_signals', True)