8000 setupinfo.py: check the return value of subprocesses (GH-336) · lxml/lxml@55f2815 · GitHub
[go: up one dir, main page]

Skip to content

Commit 55f2815

Browse files
authored
setupinfo.py: check the return value of subprocesses (GH-336)
Use the return value altogether to check the subprocess execute successfully or not as in some case it will print some noise message though run successfully as below. # python Python 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import subprocess >>> cmd = "pkg-config --modversion libxml-2.0" >>> p = subprocess.Popen(cmd, shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE) >>> stdout_data, errors = p.communicate() >>> print(stdout_data) b'2.9.12\n' >>> print(errors) b'do_ypcall: clnt_call: RPC: Unable to send; errno = Network is unreachable\n'
1 parent 5a5c7fb commit 55f2815

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

setupinfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def run_command(cmd, *args):
365365
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
366366
stdout_data, errors = p.communicate()
367367

368-
if errors:
368+
if p.returncode != 0 and errors:
369369
return ''
370370
return decode_input(stdout_data).strip()
371371

0 commit comments

Comments
 (0)
0