diff options
author | marmeladema <xademax@gmail.com> | 2018-05-21 15:20:44 +0200 |
---|---|---|
committer | Eli Bendersky <eliben@users.noreply.github.com> | 2018-05-21 06:20:44 -0700 |
commit | 5549e39e717b331f4bf3b8bfd024ba881074bc5e (patch) | |
tree | 4fc5074ee89480684fecaa41f69d00848fc950f5 | |
parent | aedb4ed5a96ed2d1ac10804c257d62148915533f (diff) | |
download | pycparser-5549e39e717b331f4bf3b8bfd024ba881074bc5e.tar.gz |
Replace a call to Popen by check_output in order to check that cpp returns 0. (#260)
-rw-r--r-- | pycparser/__init__.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/pycparser/__init__.py b/pycparser/__init__.py index e089166..9abd6fc 100644 --- a/pycparser/__init__.py +++ b/pycparser/__init__.py @@ -10,7 +10,7 @@ __all__ = ['c_lexer', 'c_parser', 'c_ast'] __version__ = '2.18' -from subprocess import Popen, PIPE +from subprocess import check_output from .c_parser import CParser @@ -39,10 +39,7 @@ def preprocess_file(filename, cpp_path='cpp', cpp_args=''): # Note the use of universal_newlines to treat all newlines # as \n for Python's purpose # - pipe = Popen( path_list, - stdout=PIPE, - universal_newlines=True) - text = pipe.communicate()[0] + text = check_output(path_list, universal_newlines=True) except OSError as e: raise RuntimeError("Unable to invoke 'cpp'. " + 'Make sure its path was passed correctly\n' + |