Skip to content

Commit

Permalink
Close subprocess stdout stream once value has been read
Browse files Browse the repository at this point in the history
Fixes the following warnings with python3:
Exception ignored in: <_io.FileIO name=4 mode='rb' closefd=True>
ResourceWarning: unclosed file <_io.BufferedReader name=4>
  • Loading branch information
iMichka committed Apr 25, 2016
1 parent 5024b82 commit f03e719
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Version 1.7.4 (not yet released)
1. Since this release, pyggcxml's version numbers do not contain the ``v``
prefix anymore. This was breaking distribution on PyPI (pypi.python.org).

2. Close subprocess stdout stream once value has been read.
Fixes some warnings under python3.

Version 1.7.3
-------------

Expand Down
1 change: 1 addition & 0 deletions pygccxml/parser/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ def create_compiler_path(xml_generator, compiler_path):
p = subprocess.Popen(
['which', 'clang++'], stdout=subprocess.PIPE)
compiler_path = p.stdout.read().decode("utf-8").rstrip()
p.stdout.close()
# No clang found; use gcc
if compiler_path == '':
compiler_path = '/usr/bin/c++'
Expand Down
3 changes: 3 additions & 0 deletions pygccxml/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ def find_xml_generator(name=None):
name = "gccxml"
p = subprocess.Popen([command, name], stdout=subprocess.PIPE)
path = p.stdout.read().decode("utf-8")
p.stdout.close()
if path == "":
name = "castxml"
p = subprocess.Popen([command, name], stdout=subprocess.PIPE)
path = p.stdout.read().decode("utf-8")
p.stdout.close()
else:
p = subprocess.Popen([command, name], stdout=subprocess.PIPE)
path = p.stdout.read().decode("utf-8")
p.stdout.close()
if path == "":
raise(Exception(
"No c++ parser found. Please install castxml or gccxml."))
Expand Down
1 change: 1 addition & 0 deletions unittests/file_cache_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def test_reopen_cache(self):
[sys.executable, "unittests/reopen_cache_tester.py"],
stdout=subprocess.PIPE)
print(p.stdout.read())
p.stdout.close()


def create_suite():
Expand Down

0 comments on commit f03e719

Please sign in to comment.