From 23f2bf42857b7f292d1166a525914cf06b45ad73 Mon Sep 17 00:00:00 2001 From: gesslerpd Date: Mon, 20 Jan 2020 20:31:13 -0600 Subject: [PATCH 1/3] Fix #399 --- CHANGELOG.rst | 5 +++++ src/setuptools_scm/file_finder_git.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d8807a0d..8a671e2b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,8 @@ +v3.4.3 +====== + +* fix #399: ensure the git file finder closes file descriptor after reading archive + v3.4.2 ====== diff --git a/src/setuptools_scm/file_finder_git.py b/src/setuptools_scm/file_finder_git.py index 5cda162d..191abcad 100644 --- a/src/setuptools_scm/file_finder_git.py +++ b/src/setuptools_scm/file_finder_git.py @@ -28,7 +28,7 @@ def _git_toplevel(path): def _git_interpret_archive(fd, toplevel): - with tarfile.open(fileobj=fd, mode="r|*") as tf: + with fd, tarfile.open(fileobj=fd, mode="r|*") as tf: git_files = set() git_dirs = {toplevel} for member in tf.getmembers(): @@ -49,7 +49,7 @@ def _git_ls_files_and_dirs(toplevel): try: return _git_interpret_archive(proc.stdout, toplevel) finally: - # ensure we avoid ressource warnings by cleaning up the pocess + # ensure we avoid resource warnings by cleaning up the pocess proc.wait() except Exception: if proc.wait() != 0: From aacfd451f0f635784d68cb8110b6173d2d43f8e8 Mon Sep 17 00:00:00 2001 From: gesslerpd Date: Mon, 20 Jan 2020 21:11:38 -0600 Subject: [PATCH 2/3] terminate process to cleanup --- src/setuptools_scm/file_finder_git.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/setuptools_scm/file_finder_git.py b/src/setuptools_scm/file_finder_git.py index 191abcad..651e76c7 100644 --- a/src/setuptools_scm/file_finder_git.py +++ b/src/setuptools_scm/file_finder_git.py @@ -28,7 +28,7 @@ def _git_toplevel(path): def _git_interpret_archive(fd, toplevel): - with fd, tarfile.open(fileobj=fd, mode="r|*") as tf: + with tarfile.open(fileobj=fd, mode="r|*") as tf: git_files = set() git_dirs = {toplevel} for member in tf.getmembers(): @@ -49,8 +49,8 @@ def _git_ls_files_and_dirs(toplevel): try: return _git_interpret_archive(proc.stdout, toplevel) finally: - # ensure we avoid resource warnings by cleaning up the pocess - proc.wait() + # ensure we avoid resource warnings by cleaning up the process + proc.terminate() except Exception: if proc.wait() != 0: log.exception("listing git files failed - pretending there aren't any") From 710434f2f9ef383108fa91505487377aa6b755c4 Mon Sep 17 00:00:00 2001 From: gesslerpd Date: Mon, 20 Jan 2020 21:15:22 -0600 Subject: [PATCH 3/3] update changelog --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8a671e2b..bb09487c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,7 +1,7 @@ v3.4.3 ====== -* fix #399: ensure the git file finder closes file descriptor after reading archive +* fix #399: ensure the git file finder terminates subprocess after reading archive v3.4.2 ======