homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mth
Recipients mth
Date 2012年07月18日.14:17:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1342621050.08.0.170764357594.issue15388@psf.upfronthosting.co.za>
In-reply-to
Content
The following example uses make_parser / parse to read a trivial XML document by filename and then attempts to delete the file. On Win32 I can't unlink the file because the parse does not seem to close the file handle.
import os
import tempfile
from xml.sax import make_parser, ContentHandler
(handle, path) = tempfile.mkstemp()
os.write(handle, b"<foo/>")
os.close(handle)
parser = make_parser()
parser.parse(path)
# This unlink fails on win32. It succeeds if I comment out the call to parse.
os.unlink(path)
As I provide a filename rather than a file object, I would expect the parse call to both open and close it. I can't see a way to do the clean-up myself.
This issue exists in Python 2.7.3 but I could not reproduce it in 3.2.3.
Windows cmd transcript:
c:\Users\mth>Python2.7.3\python.exe fileleak.py
Traceback (most recent call last):
 File "fileleak.py", line 14, in <module>
 os.unlink(path)
WindowsError: [Error 32] The process cannot access the file because it is being used by another process: 'c:\\d\\tmpvyqg2c'
c:\Users\mth>Python3.2.3\python.exe fileleak.py
c:\Users\mth>
History
Date User Action Args
2012年07月18日 14:17:30mthsetrecipients: + mth
2012年07月18日 14:17:30mthsetmessageid: <1342621050.08.0.170764357594.issue15388@psf.upfronthosting.co.za>
2012年07月18日 14:17:29mthlinkissue15388 messages
2012年07月18日 14:17:28mthcreate

AltStyle によって変換されたページ (->オリジナル) /