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
c8511065
Commit
c8511065
authored
9 years ago
by
Martin Panter
Browse files
Options
Browse Files
Download
Plain Diff
Issue #25717: Merge fstat() fix from 3.5
parents
0d559cf7
0bb62b12
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
12 deletions
+31
-12
Misc/NEWS
Misc/NEWS
+4
-0
Modules/_io/fileio.c
Modules/_io/fileio.c
+27
-12
No files found.
Misc/NEWS
View file @
c8511065
...
...
@@ -109,6 +109,10 @@ Core and Builtins
Library
-------
- Issue #25717: Restore the previous behaviour of tolerating most fstat()
errors when opening files. This was a regression in 3.5a1, and stopped
anonymous temporary files from working in special cases.
- Issue #24903: Fix regression in number of arguments compileall accepts when
'
-
d
' is specified. The check on the number of arguments has been dropped
completely as it never worked correctly anyway.
...
...
This diff is collapsed.
Click to expand it.
Modules/_io/fileio.c
View file @
c8511065
...
...
@@ -250,6 +250,7 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
int
*
atomic_flag_works
=
NULL
;
#endif
struct
_Py_stat_struct
fdfstat
;
int
fstat_result
;
int
async_err
=
0
;
assert
(
PyFileIO_Check
(
self
));
...
...
@@ -438,22 +439,36 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
}
self
->
blksize
=
DEFAULT_BUFFER_SIZE
;
if
(
_Py_fstat
(
self
->
fd
,
&
fdfstat
)
<
0
)
goto
error
;
#if defined(S_ISDIR) && defined(EISDIR)
/* On Unix, open will succeed for directories.
In Python, there should be no file objects referring to
directories, so we need a check. */
if
(
S_ISDIR
(
fdfstat
.
st_mode
))
{
errno
=
EISDIR
;
PyErr_SetFromErrnoWithFilenameObject
(
PyExc_IOError
,
nameobj
);
goto
error
;
Py_BEGIN_ALLOW_THREADS
fstat_result
=
_Py_fstat_noraise
(
self
->
fd
,
&
fdfstat
);
Py_END_ALLOW_THREADS
if
(
fstat_result
<
0
)
{
#ifdef MS_WINDOWS
if
(
GetLastError
()
==
ERROR_INVALID_HANDLE
)
{
PyErr_SetFromWindowsErr
(
0
);
#else
if
(
errno
==
EBADF
)
{
PyErr_SetFromErrno
(
PyExc_OSError
);
#endif
goto
error
;
}
}
else
{
#if defined(S_ISDIR) && defined(EISDIR)
/* On Unix, open will succeed for directories.
In Python, there should be no file objects referring to
directories, so we need a check. */
if
(
S_ISDIR
(
fdfstat
.
st_mode
))
{
errno
=
EISDIR
;
PyErr_SetFromErrnoWithFilenameObject
(
PyExc_IOError
,
nameobj
);
goto
error
;
}
#endif
/* defined(S_ISDIR) */
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
if
(
fdfstat
.
st_blksize
>
1
)
self
->
blksize
=
fdfstat
.
st_blksize
;
if
(
fdfstat
.
st_blksize
>
1
)
self
->
blksize
=
fdfstat
.
st_blksize
;
#endif
/* HAVE_STRUCT_STAT_ST_BLKSIZE */
}
#if defined(MS_WINDOWS) || defined(__CYGWIN__)
/* don't translate newlines (\r\n <=> \n) */
...
...
This diff is collapsed.
Click to expand it.
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