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
8acde7dc
Commit
8acde7dc
authored
Mar 07, 2015
by
Steve Dower
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #23524: Change back to using Windows errors for _Py_fstat instead of the errno shim.
parent
35a97c0b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
5 deletions
+13
-5
Modules/_io/fileio.c
Modules/_io/fileio.c
+7
-1
Modules/signalmodule.c
Modules/signalmodule.c
+1
-1
Python/fileutils.c
Python/fileutils.c
+5
-3
No files found.
Modules/_io/fileio.c
View file @
8acde7dc
...
...
@@ -182,7 +182,13 @@ check_fd(int fd)
{
#if defined(HAVE_FSTAT) || defined(MS_WINDOWS)
struct
_Py_stat_struct
buf
;
if
(
_Py_fstat
(
fd
,
&
buf
)
<
0
&&
errno
==
EBADF
)
{
if
(
_Py_fstat
(
fd
,
&
buf
)
<
0
&&
#ifdef MS_WINDOWS
GetLastError
()
==
ERROR_INVALID_HANDLE
#else
errno
==
EBADF
#endif
)
{
PyObject
*
exc
;
char
*
msg
=
strerror
(
EBADF
);
exc
=
PyObject_CallFunction
(
PyExc_OSError
,
"(is)"
,
...
...
Modules/signalmodule.c
View file @
8acde7dc
...
...
@@ -560,7 +560,7 @@ signal_set_wakeup_fd(PyObject *self, PyObject *args)
}
if
(
_Py_fstat
(
fd
,
&
st
)
!=
0
)
{
PyErr_Set
FromErrno
(
PyExc_OSError
);
PyErr_Set
ExcFromWindowsErr
(
PyExc_OSError
,
GetLastError
()
);
return
NULL
;
}
...
...
Python/fileutils.c
View file @
8acde7dc
...
...
@@ -637,10 +637,14 @@ _Py_fstat(int fd, struct _Py_stat_struct *result)
else
h
=
(
HANDLE
)
_get_osfhandle
(
fd
);
/* Protocol violation: we explicitly clear errno, instead of
setting it to a POSIX error. Callers should use GetLastError. */
errno
=
0
;
if
(
h
==
INVALID_HANDLE_VALUE
)
{
errno
=
EBADF
;
/* This is really a C library error (invalid file handle).
We set the Win32 error to the closes one matching. */
SetLastError
(
ERROR_INVALID_HANDLE
);
return
-
1
;
}
memset
(
result
,
0
,
sizeof
(
*
result
));
...
...
@@ -649,7 +653,6 @@ _Py_fstat(int fd, struct _Py_stat_struct *result)
if
(
type
==
FILE_TYPE_UNKNOWN
)
{
DWORD
error
=
GetLastError
();
if
(
error
!=
0
)
{
errno
=
EINVAL
;
return
-
1
;
}
/* else: valid but unknown file */
...
...
@@ -664,7 +667,6 @@ _Py_fstat(int fd, struct _Py_stat_struct *result)
}
if
(
!
GetFileInformationByHandle
(
h
,
&
info
))
{
errno
=
EINVAL
;
return
-
1
;
}
...
...
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