summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2012-06-25 14:26:43 +0200
committerJulian Andres Klode <jak@debian.org>2012-06-25 14:26:43 +0200
commitf513760769e5e0c7ba08f171e4d5399000b8ae51 (patch)
tree218bb7cfe1b83fbe5bcc9ff755af1ade2acae660
parentb50494275b8235e5c8a53e13fd56e3cea1c8d5b3 (diff)
downloadpython-apt-f513760769e5e0c7ba08f171e4d5399000b8ae51.tar.gz
Use Popen.communicate() instead of stdin, stdout
-rw-r--r--apt/auth.py22
-rw-r--r--debian/changelog1
2 files changed, 13 insertions, 10 deletions
diff --git a/apt/auth.py b/apt/auth.py
index 1a81d3b0..5d4b1cd6 100644
--- a/apt/auth.py
+++ b/apt/auth.py
@@ -70,17 +70,19 @@ def _call_apt_key_script(*args, **kwargs):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
- try:
- proc.stdin.write(kwargs["stdin"])
- except KeyError:
- pass
- finally:
- proc.stdin.close()
- return_code = proc.wait()
- output = proc.stdout.read()
- if return_code:
+
+ content = kwargs.get("stdin", None)
+ if isinstance(content, unicode):
+ content = content.encode("utf-8")
+
+ output, stderr = proc.communicate(content)
+
+ assert stderr == None
+
+ if proc.returncode:
raise SystemError("The apt-key script failed with return code %s:\n"
- "%s\n%s" % (return_code, " ".join(cmd), output))
+ "%s\n%s" % (proc.returncode, " ".join(cmd),
+ output))
return output.strip()
finally:
if conf is not None:
diff --git a/debian/changelog b/debian/changelog
index e6d6d648..627ef655 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,7 @@ python-apt (0.8.6) UNRELEASED; urgency=low
[ Julian Andres Klode ]
* apt/auth.py:
- Use tempfile.NamedTemporaryFile to create temporary file
+ - Use Popen.communicate() instead of stdin, stdout
-- Michael Vogt <mvo@debian.org> Mon, 25 Jun 2012 13:41:02 +0200