Skip to content

Commit 8f22300

Browse files
committed
[gyb] Popen explicit string instead of byte sequence
The Popen command on Python returns a byte sequence on stdout by default. However by sending the constructor the argument `universal_newlines=True` it forces the Popen to put a string on stdout. This was not a problem on Python 2 because the Python 2 regex engine seemed to work find on byte sequences where Python 3's does not. By explicitly converting everything to a string the same behavior is now seen on Python 2 and 3. See: https://docs.python.org/2/library/subprocess.html#frequently-used-arguments See: https://docs.python.org/3/library/subprocess.html#frequently-used-arguments
1 parent 360c2b2 commit 8f22300

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

utils/line-directive

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ def run():
7171
sources = sys.argv[1:dashes]
7272

7373
command = subprocess.Popen(
74-
sys.argv[dashes + 1:], stderr = subprocess.STDOUT, stdout = subprocess.PIPE
74+
sys.argv[dashes + 1:],
75+
stderr = subprocess.STDOUT,
76+
stdout = subprocess.PIPE,
77+
universal_newlines = True
7578
)
7679

7780
error_pattern = re.compile(

0 commit comments

Comments
 (0)