Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r63620:c78ecde0e05e
Date: 2013-04-25 18:27 -0700
http://bitbucket.org/pypy/pypy/changeset/c78ecde0e05e/
Log: cpython issue12802: win's ERROR_DIRECTORY -> ENOTDIR
diff --git a/pypy/module/exceptions/test/test_exc.py
b/pypy/module/exceptions/test/test_exc.py
--- a/pypy/module/exceptions/test/test_exc.py
+++ b/pypy/module/exceptions/test/test_exc.py
@@ -4,6 +4,9 @@
class AppTestExc(object):
spaceconfig = dict(usemodules=('exceptions',))
+ def setup_class(cls):
+ cls.w_file = cls.space.wrap(__file__)
+
def test_baseexc(self):
assert str(BaseException()) == ''
assert repr(BaseException()) == 'BaseException()'
@@ -250,3 +253,15 @@
def test_set_traceback(self):
e = Exception()
raises(TypeError, "e.__traceback__ = 42")
+
+ def test_errno_ENOTDIR(self):
+ # CPython issue #12802: "not a directory" errors are ENOTDIR
+ # even on Windows
+ import os
+ import errno
+ try:
+ os.listdir(self.file)
+ except OSError as e:
+ assert e.errno == errno.ENOTDIR
+ else:
+ assert False, "Expected OSError"
diff --git a/rpython/rlib/rwin32.py b/rpython/rlib/rwin32.py
--- a/rpython/rlib/rwin32.py
+++ b/rpython/rlib/rwin32.py
@@ -178,8 +178,13 @@
int i;
for(i=1; i < 65000; i++) {
_dosmaperr(i);
- if (errno == EINVAL)
- continue;
+ if (errno == EINVAL) {
+ /* CPython issue #12802 */
+ if (i == ERROR_DIRECTORY)
+ errno = ENOTDIR;
+ else
+ continue;
+ }
printf("%d\t%d\n", i, errno);
}
return 0;
@@ -201,7 +206,7 @@
132: 13, 145: 41, 158: 13, 161: 2, 164: 11, 167: 13, 183: 17,
188: 8, 189: 8, 190: 8, 191: 8, 192: 8, 193: 8, 194: 8,
195: 8, 196: 8, 197: 8, 198: 8, 199: 8, 200: 8, 201: 8,
- 202: 8, 206: 2, 215: 11, 1816: 12,
+ 202: 8, 206: 2, 215: 11, 267: 20, 1816: 12,
}
else:
output = os.popen(str(exename))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit