##// END OF EJS Templates
osutil: consider WindowsError's behaviour to support python 2.4 on Windows...
Shun-ichi GOTO -
r19465:004f9656 default
parent child Browse files
Show More
@@ -59,6 +59,7 b" if os.name != 'nt':"
59 posixfile = open
59 posixfile = open
60 else:
60 else:
61 import ctypes, msvcrt
61 import ctypes, msvcrt
62 from errno import ESRCH, ENOENT
62
63
63 _kernel32 = ctypes.windll.kernel32
64 _kernel32 = ctypes.windll.kernel32
64
65
@@ -98,7 +99,14 b' else:'
98
99
99 def _raiseioerror(name):
100 def _raiseioerror(name):
100 err = ctypes.WinError()
101 err = ctypes.WinError()
101 raise IOError(err.errno, '%s: %s' % (name, err.strerror))
102 # For python 2.4, treat ESRCH as ENOENT like WindowsError does
103 # in python 2.5 or later.
104 # py24: WindowsError(3, '').errno => 3
105 # py25 or later: WindowsError(3, '').errno => 2
106 errno = err.errno
107 if errno == ESRCH:
108 errno = ENOENT
109 raise IOError(errno, '%s: %s' % (name, err.strerror))
102
110
103 class posixfile(object):
111 class posixfile(object):
104 '''a file object aiming for POSIX-like semantics
112 '''a file object aiming for POSIX-like semantics
General Comments 0
You need to be logged in to leave comments. Login now