[Reproducible-commits] [diffoscope] 08/09: Set feeder fds as inheritable before running diff
Jérémy Bobbio
lunar at moszumanska.debian.org
Fri Sep 18 10:54:40 UTC 2015
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch master
in repository diffoscope.
commit 68395e24c130ff2e6823e4e26b24c64d4a420c59
Author: Jérémy Bobbio <lunar at debian.org>
Date: Fri Sep 18 12:26:27 2015 +0200
Set feeder fds as inheritable before running diff
Newly created file descriptors are now non-inheritable by default in Python 3.4:
https://docs.python.org/3.5/whatsnew/3.4.html#pep-446-newly-created-file-descriptors-are-non-inheritable
So we need to manually set them as inheritable and tell subprocess.Popen to
keep them open.
---
diffoscope/difference.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/diffoscope/difference.py b/diffoscope/difference.py
index 828f83e..70d5b27 100644
--- a/diffoscope/difference.py
+++ b/diffoscope/difference.py
@@ -136,11 +136,15 @@ def run_diff(fd1, fd2, end_nl_q1, end_nl_q2):
os.close(fd)
except OSError:
pass
+ if hasattr(os, 'set_inheritable'): # new in Python 3.4
+ os.set_inheritable(fd1, True)
+ os.set_inheritable(fd2, True)
p = subprocess.Popen(cmd, shell=False, bufsize=1,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
- preexec_fn=close_fds)
+ preexec_fn=close_fds,
+ close_fds=False)
p.stdin.close()
os.close(fd1)
os.close(fd2)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the Reproducible-commits
mailing list