Issue #12802: the Windows error ERROR_DIRECTORY (numbered 267) is now
mapped to POSIX errno ENOTDIR (previously EINVAL).
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index d3c0062..0a7ddd4 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -5,6 +5,7 @@
import unittest
import pickle
import weakref
+import errno
from test.support import (TESTFN, unlink, run_unittest, captured_output,
gc_collect, cpython_only)
@@ -849,6 +850,13 @@
self.fail("RuntimeError not raised")
self.assertEqual(wr(), None)
+ def test_errno_ENOTDIR(self):
+ # Issue #12802: "not a directory" errors are ENOTDIR even on Windows
+ with self.assertRaises(OSError) as cm:
+ os.listdir(__file__)
+ self.assertEqual(cm.exception.errno, errno.ENOTDIR, cm.exception)
+
+
def test_main():
run_unittest(ExceptionTests)