I am using a scientific software including a Python script that is calling
close failed in file object destructor:
IOError: [Errno 9] Bad file descriptor
You get this error message if a Python file was closed from "the outside", i.e. not from the file object's
>>> f = open(".bashrc") >>> os.close(f.fileno()) >>> del f close failed in file object destructor: IOError: [Errno 9] Bad file descriptor
del f deletes the last reference to the file object, causing its destructor
file.__del__ to be called. The internal state of the file object indicates the file is still open since
f.close() was never called, so the destructor tries to close the file. The OS subsequently throws an error because of the attempt to close a file that's not open.
Since the implementation of
os.system() does not create any Python file objects, it does not seem likely that the
system() call is the origin of the error. Maybe you could show a bit more code?