[Python-bugs-list] [Bug #110616] source file stays open after parsing is done (PR#209)
Wed, 23 Aug 2000 07:53:19 -0700
Bug #110616, was updated on 2000-Jul-31 21:06
Here is a current snapshot of the bug.
Bug Group: None
Summary: source file stays open after parsing is done (PR#209)
Details: Jitterbug-Id: 209
Submitted-By: Guido van Rossum <firstname.lastname@example.org>
Date: Tue, 22 Feb 2000 10:42:17 -0500
The post below is evidence that there is a real need to close the
source file sooner than when the program execution is over.
Unfortunately, as Martin points out, this requires changing function
signatures (in the sense that the behaviors change).
The close-on-exec solution is not good enough; apart from the
portability issue it also doesn't solve other problems caused by
keeping the file open too long.
--Guido van Rossum (home page: http://www.python.org/~guido/)
------- Forwarded Message
Date: Mon, 21 Feb 2000 19:00:32 +0100
From: Martin von Loewis <email@example.com>
cc: firstname.lastname@example.org, guido@CNRI.Reston.VA.US
Subject: Re: [Python-Help] execve
> I tried to submit the below report via the web interface, but kept getting
> the folowing message:
> The system encountered a fatal error
> After command:
> The last error code was: Connection refused
> So, the bug report is below. Thanks.
Thanks for your report. It looks like Python is not closing the file
descriptor of the script being executed. Please have a look at
Py_Main, where fp is the file descriptor of the script being executed
(potentially stdin). That is passed to PyRun_AnyFile, which eventually
calls the parser to read the file. When PyRun_AnyFile returns, the
file is closed if it is not stdin (or, rather, does not have a name).
Unfortunately, if the script performs exec, that file descriptor is
I see two solutions:
a) close the file after it has been parsed, before execution starts.
That appears to be the Right Way (TM), but requires changes to the
signatures of a number of functions.
b) set the close-on-exec flag for the script. That will automagically
close it when necessary, but doing so is not very portable. It will
probably work on both Linux and LynxOS, so you may consider fixing
it that way yourself.
P.S. CC'ed to Guido for inspection.
------- End of Forwarded Message
Wed Feb 23 21:30:38 2000 guido moved from incoming to open
For detailed info, follow this link: