[pypy-svn] r64410 - pypy/trunk/pypy/rlib
iko at codespeak.net
iko at codespeak.net
Sun Apr 19 19:39:47 CEST 2009
Author: iko
Date: Sun Apr 19 19:39:45 2009
New Revision: 64410
Modified:
pypy/trunk/pypy/rlib/streamio.py
Log:
truncate() needs to raise IOError on failure
Modified: pypy/trunk/pypy/rlib/streamio.py
==============================================================================
--- pypy/trunk/pypy/rlib/streamio.py (original)
+++ pypy/trunk/pypy/rlib/streamio.py Sun Apr 19 19:39:45 2009
@@ -161,6 +161,7 @@
from pypy.rlib import rwin32
from pypy.translator.tool.cbuild import ExternalCompilationInfo
from pypy.rpython.lltypesystem import rffi
+ import errno
_eci = ExternalCompilationInfo()
_get_osfhandle = rffi.llexternal('_get_osfhandle', [rffi.INT], rffi.LONG,
@@ -175,9 +176,10 @@
# Truncate. Note that this may grow the file!
handle = _get_osfhandle(fd)
if handle == -1:
- raise StreamError("Invalid file handle")
+ raise IOError(errno.EBADF, "Invalid file handle")
if not SetEndOfFile(handle):
- raise StreamError("Could not truncate file")
+ raise WindowsError(rwin32.GetLastError(),
+ "Could not truncate file")
finally:
os.lseek(fd, curpos, 0)
More information about the Pypy-commit
mailing list