| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ | |||
| 5 | 5 | import unittest | |
| 6 | 6 | import pickle | |
| 7 | 7 | import weakref | |
| 8 | + import errno | ||
| 8 | 9 | ||
| 9 | 10 | from test.support import (TESTFN, unlink, run_unittest, captured_output, | |
| 10 | 11 | gc_collect, cpython_only) | |
@@ -849,6 +850,13 @@ def inner(): | |||
| 849 | 850 | self.fail("RuntimeError not raised") | |
| 850 | 851 | self.assertEqual(wr(), None) | |
| 851 | 852 | ||
| 853 | + def test_errno_ENOTDIR(self): | ||
| 854 | + # Issue #12802: "not a directory" errors are ENOTDIR even on Windows | ||
| 855 | + with self.assertRaises(OSError) as cm: | ||
| 856 | + os.listdir(__file__) | ||
| 857 | + self.assertEqual(cm.exception.errno, errno.ENOTDIR, cm.exception) | ||
| 858 | + | ||
| 859 | + | ||
| 852 | 860 | def test_main(): | |
| 853 | 861 | run_unittest(ExceptionTests) | |
| 854 | 862 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,9 @@ What's New in Python 3.2.3? | |||
| 10 | 10 | Core and Builtins | |
| 11 | 11 | ----------------- | |
| 12 | 12 | ||
| 13 | + - Issue #12802: the Windows error ERROR_DIRECTORY (numbered 267) is now | ||
| 14 | + mapped to POSIX errno ENOTDIR (previously EINVAL). | ||
| 15 | + | ||
| 13 | 16 | - Accept bytes for the AST string type. This is temporary until a proper fix in | |
| 14 | 17 | 3.3. | |
| 15 | 18 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -72,6 +72,7 @@ int winerror_to_errno(int winerror) | |||
| 72 | 72 | case 202: return 8; | |
| 73 | 73 | case 206: return 2; | |
| 74 | 74 | case 215: return 11; | |
| 75 | + case 267: return 20; | ||
| 75 | 76 | case 1816: return 12; | |
| 76 | 77 | default: return EINVAL; | |
| 77 | 78 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,6 @@ | |||
| 1 | + #include <windows.h> | ||
| 2 | + #include <fcntl.h> | ||
| 3 | + #include <io.h> | ||
| 1 | 4 | #include <stdio.h> | |
| 2 | 5 | #include <errno.h> | |
| 3 | 6 | ||
@@ -6,15 +9,21 @@ | |||
| 6 | 9 | int main() | |
| 7 | 10 | { | |
| 8 | 11 | int i; | |
| 12 | + _setmode(fileno(stdout), O_BINARY); | ||
| 9 | 13 | printf("/* Generated file. Do not edit. */\n"); | |
| 10 | 14 | printf("int winerror_to_errno(int winerror)\n"); | |
| 11 | - printf("{\n\tswitch(winerror) {\n"); | ||
| 15 | + printf("{\n switch(winerror) {\n"); | ||
| 12 | 16 | for(i=1; i < 65000; i++) { | |
| 13 | 17 | _dosmaperr(i); | |
| 14 | - if (errno == EINVAL) | ||
| 15 | - continue; | ||
| 16 | - printf("\t\tcase %d: return %d;\n", i, errno); | ||
| 18 | + if (errno == EINVAL) { | ||
| 19 | + /* Issue #12802 */ | ||
| 20 | + if (i == ERROR_DIRECTORY) | ||
| 21 | + errno = ENOTDIR; | ||
| 22 | + else | ||
| 23 | + continue; | ||
| 24 | + } | ||
| 25 | + printf(" case %d: return %d;\n", i, errno); | ||
| 17 | 26 | } | |
| 18 | - printf("\t\tdefault: return EINVAL;\n"); | ||
| 19 | - printf("\t}\n}\n"); | ||
| 27 | + printf(" default: return EINVAL;\n"); | ||
| 28 | + printf(" }\n}\n"); | ||
| 20 | 29 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments