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
This commit is contained in:
parent
3d0eacddf9
commit
1ee161e162
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user