summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyril Roelandt <cyril.roelandt@enovance.com>2014-02-07 04:31:25 +0100
committerCyril Roelandt <cyril.roelandt@enovance.com>2014-02-07 04:31:25 +0100
commit1ee161e162ff9c50e18124eac47a434ff327f500 (patch)
tree0bbdb6f8d26051713a23f161207d80aa561ba9d7
parent3d0eacddf9a920b3bf8fb19dd522433fa771d6fb (diff)
downloadpython-keystoneclient-1ee161e162ff9c50e18124eac47a434ff327f500.tar.gz
cms: Use universal_newlines=True in subprocess.Popen()
The Python documentation states that "the type of [the first argument of subprocess.communicate()] must be bytes or, if universal_newlines was True, a string"[1]. Currently, in Python 3, a text string is given to subprocess.communicate(), even though the process was created with universal_newlines=False (the default value). Rather than converting strings to bytes (and the other way around) everywhere in the code, just create the process with universal_newlines=True. The side effect is that '\n', '\r\n' and '\r' will be recognized as ending lines[2], which should not be an issue. [1] http://docs.python.org/3/library/subprocess.html?highlight=popen#subprocess.Popen.communicate [2] http://docs.python.org/3/glossary.html#term-universal-newlines Change-Id: I668b187ba8ed00ad6d55ec487af623b79b21589d
-rw-r--r--keystoneclient/common/cms.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/keystoneclient/common/cms.py b/keystoneclient/common/cms.py
index eb64e1f..6ff060b 100644
--- a/keystoneclient/common/cms.py
+++ b/keystoneclient/common/cms.py
@@ -114,7 +114,8 @@ def cms_verify(formatted, signing_cert_file_name, ca_file_name):
"-nocerts", "-noattr"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ stderr=subprocess.PIPE,
+ universal_newlines=True)
output, err, retcode = _process_communicate_handle_oserror(
process, formatted, (signing_cert_file_name, ca_file_name))
@@ -225,7 +226,8 @@ def cms_sign_text(text, signing_cert_file_name, signing_key_file_name):
"-nocerts", "-noattr"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ stderr=subprocess.PIPE,
+ universal_newlines=True)
output, err, retcode = _process_communicate_handle_oserror(
process, text, (signing_cert_file_name, signing_key_file_name))