Skip to content

Commit f03e719

Browse files
committed
Close subprocess stdout stream once value has been read
Fixes the following warnings with python3: Exception ignored in: <_io.FileIO name=4 mode='rb' closefd=True> ResourceWarning: unclosed file <_io.BufferedReader name=4>
1 parent 5024b82 commit f03e719

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

docs/history.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Version 1.7.4 (not yet released)
1717
1. Since this release, pyggcxml's version numbers do not contain the ``v``
1818
prefix anymore. This was breaking distribution on PyPI (pypi.python.org).
1919

20+
2. Close subprocess stdout stream once value has been read.
21+
Fixes some warnings under python3.
22+
2023
Version 1.7.3
2124
-------------
2225

pygccxml/parser/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ def create_compiler_path(xml_generator, compiler_path):
452452
p = subprocess.Popen(
453453
['which', 'clang++'], stdout=subprocess.PIPE)
454454
compiler_path = p.stdout.read().decode("utf-8").rstrip()
455+
p.stdout.close()
455456
# No clang found; use gcc
456457
if compiler_path == '':
457458
compiler_path = '/usr/bin/c++'

pygccxml/utils/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,16 @@ def find_xml_generator(name=None):
5050
name = "gccxml"
5151
p = subprocess.Popen([command, name], stdout=subprocess.PIPE)
5252
path = p.stdout.read().decode("utf-8")
53+
p.stdout.close()
5354
if path == "":
5455
name = "castxml"
5556
p = subprocess.Popen([command, name], stdout=subprocess.PIPE)
5657
path = p.stdout.read().decode("utf-8")
58+
p.stdout.close()
5759
else:
5860
p = subprocess.Popen([command, name], stdout=subprocess.PIPE)
5961
path = p.stdout.read().decode("utf-8")
62+
p.stdout.close()
6063
if path == "":
6164
raise(Exception(
6265
"No c++ parser found. Please install castxml or gccxml."))

unittests/file_cache_tester.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def test_reopen_cache(self):
8989
[sys.executable, "unittests/reopen_cache_tester.py"],
9090
stdout=subprocess.PIPE)
9191
print(p.stdout.read())
92+
p.stdout.close()
9293

9394

9495
def create_suite():

0 commit comments

Comments
 (0)