Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f22c26ec
Commit
f22c26ec
authored
Sep 01, 2008
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#3703 unhelpful _fileio.FileIO error message when trying to open a directory
Reviewer: Gregory P. Smith
parent
f07e5a9e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
1 deletion
+17
-1
Lib/test/test_fileio.py
Lib/test/test_fileio.py
+11
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_fileio.c
Modules/_fileio.c
+3
-1
No files found.
Lib/test/test_fileio.py
View file @
f22c26ec
...
...
@@ -101,6 +101,17 @@ class AutoFileTests(unittest.TestCase):
# should raise on closed file
self
.
assertRaises
(
ValueError
,
method
)
def
testOpendir
(
self
):
# Issue 3703: opening a directory should fill the errno
# Windows always returns "[Errno 13]: Permission denied
# Unix calls dircheck() and returns "[Errno 21]: Is a directory"
try
:
_fileio
.
_FileIO
(
'.'
,
'r'
)
except
IOError
as
e
:
self
.
assertNotEqual
(
e
.
errno
,
0
)
else
:
self
.
fail
(
"Should have raised IOError"
)
class
OtherFileTests
(
unittest
.
TestCase
):
...
...
Misc/NEWS
View file @
f22c26ec
...
...
@@ -52,6 +52,9 @@ Library
- Fixed two format strings in the _collections module.
- #3703 _fileio.FileIO gave unhelpful error message when trying to open a
directory.
Extension Modules
-----------------
...
...
Modules/_fileio.c
View file @
f22c26ec
...
...
@@ -262,7 +262,7 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
#endif
self
->
fd
=
open
(
name
,
flags
,
0666
);
Py_END_ALLOW_THREADS
if
(
self
->
fd
<
0
||
dircheck
(
self
)
<
0
)
{
if
(
self
->
fd
<
0
)
{
#ifdef MS_WINDOWS
PyErr_SetFromErrnoWithUnicodeFilename
(
PyExc_IOError
,
widename
);
#else
...
...
@@ -270,6 +270,8 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
#endif
goto
error
;
}
if
(
dircheck
(
self
)
<
0
)
goto
error
;
}
goto
done
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment