Skip to content

Commit ac44f1c

Browse files
mbr0wndkogan
authored andcommitted
Fix setting inheritance on None-fd
When gnuplotlib is called from an environment that changes sys.stdout, then self.fdDupSTDOUT is None. However, we still try to make the fd inheritable, which fails. This fix only makes the duplicated fd inheritable if it in fact was able to be duplicated.
1 parent 5c04873 commit ac44f1c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

gnuplotlib.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,10 +1502,11 @@ def _startgnuplot(self):
15021502
# would happen by default, but in python3 I need to do this extra thing
15031503
# for some reason. And it's a new thing that didn't exist in python2, so
15041504
# I need to explicitly allow this to fail in python2
1505-
try:
1506-
os.set_inheritable(self.fdDupSTDOUT, True)
1507-
except AttributeError:
1508-
pass
1505+
if self.fdDupSTDOUT:
1506+
try:
1507+
os.set_inheritable(self.fdDupSTDOUT, True)
1508+
except AttributeError:
1509+
pass
15091510

15101511
self.gnuplotProcess = \
15111512
subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,

0 commit comments

Comments
 (0)