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
55fe1ae9
Commit
55fe1ae9
authored
Apr 16, 2017
by
Serhiy Storchaka
Committed by
GitHub
Apr 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051)
parent
fdbd0115
Changes
36
Hide whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
1530 additions
and
1530 deletions
+1530
-1530
Include/ceval.h
Include/ceval.h
+2
-2
Lib/idlelib/run.py
Lib/idlelib/run.py
+1
-1
Lib/importlib/_bootstrap_external.py
Lib/importlib/_bootstrap_external.py
+4
-4
Lib/importlib/abc.py
Lib/importlib/abc.py
+3
-3
Lib/mimetypes.py
Lib/mimetypes.py
+3
-3
Lib/pstats.py
Lib/pstats.py
+1
-1
Lib/site.py
Lib/site.py
+1
-1
Lib/test/support/__init__.py
Lib/test/support/__init__.py
+1
-1
Lib/unittest/test/test_assertions.py
Lib/unittest/test/test_assertions.py
+2
-2
Lib/urllib/error.py
Lib/urllib/error.py
+1
-1
Modules/_bz2module.c
Modules/_bz2module.c
+3
-3
Modules/_dbmmodule.c
Modules/_dbmmodule.c
+1
-1
Modules/_gdbmmodule.c
Modules/_gdbmmodule.c
+1
-1
Modules/_io/_iomodule.c
Modules/_io/_iomodule.c
+4
-4
Modules/_io/_iomodule.h
Modules/_io/_iomodule.h
+1
-1
Modules/_io/bufferedio.c
Modules/_io/bufferedio.c
+9
-9
Modules/_io/clinic/_iomodule.c.h
Modules/_io/clinic/_iomodule.c.h
+2
-2
Modules/_io/fileio.c
Modules/_io/fileio.c
+4
-4
Modules/_io/iobase.c
Modules/_io/iobase.c
+2
-2
Modules/_io/stringio.c
Modules/_io/stringio.c
+2
-2
Modules/_io/textio.c
Modules/_io/textio.c
+5
-5
Modules/_multiprocessing/multiprocessing.c
Modules/_multiprocessing/multiprocessing.c
+3
-3
Modules/_multiprocessing/semaphore.c
Modules/_multiprocessing/semaphore.c
+1
-1
Modules/_ssl.c
Modules/_ssl.c
+3
-3
Modules/_winapi.c
Modules/_winapi.c
+10
-10
Modules/fcntlmodule.c
Modules/fcntlmodule.c
+7
-7
Modules/main.c
Modules/main.c
+1
-1
Modules/ossaudiodev.c
Modules/ossaudiodev.c
+20
-20
Modules/readline.c
Modules/readline.c
+4
-4
Modules/selectmodule.c
Modules/selectmodule.c
+2
-2
Modules/signalmodule.c
Modules/signalmodule.c
+1
-1
Modules/zipimport.c
Modules/zipimport.c
+3
-3
Objects/object.c
Objects/object.c
+1
-1
PC/clinic/msvcrtmodule.c.h
PC/clinic/msvcrtmodule.c.h
+3
-3
PC/msvcrtmodule.c
PC/msvcrtmodule.c
+12
-12
Python/importlib_external.h
Python/importlib_external.h
+1406
-1406
No files found.
Include/ceval.h
View file @
55fe1ae9
...
...
@@ -153,7 +153,7 @@ PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(struct _frame *f, int exc);
if (...premature_exit...) {
Py_BLOCK_THREADS
PyErr_SetFromErrno(PyExc_
IO
Error);
PyErr_SetFromErrno(PyExc_
OS
Error);
return NULL;
}
...
...
@@ -161,7 +161,7 @@ PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(struct _frame *f, int exc);
Py_BLOCK_THREADS
if (...premature_exit...) {
PyErr_SetFromErrno(PyExc_
IO
Error);
PyErr_SetFromErrno(PyExc_
OS
Error);
return NULL;
}
Py_UNBLOCK_THREADS
...
...
Lib/idlelib/run.py
View file @
55fe1ae9
...
...
@@ -52,7 +52,7 @@ def idle_showwarning_subproc(
try
:
file
.
write
(
idle_formatwarning
(
message
,
category
,
filename
,
lineno
,
line
))
except
IO
Error
:
except
OS
Error
:
pass
# the file (probably stderr) is invalid - this warning gets lost.
_warnings_showwarning
=
None
...
...
Lib/importlib/_bootstrap_external.py
View file @
55fe1ae9
...
...
@@ -689,9 +689,9 @@ class SourceLoader(_LoaderBasics):
"""Optional method that returns the modification time (an int) for the
specified path, where path is a str.
Raises
IO
Error when the path cannot be handled.
Raises
OS
Error when the path cannot be handled.
"""
raise
IO
Error
raise
OS
Error
def
path_stats
(
self
,
path
):
"""Optional method returning a metadata dict for the specified path
...
...
@@ -702,7 +702,7 @@ class SourceLoader(_LoaderBasics):
- 'size' (optional) is the size in bytes of the source code.
Implementing this method allows the loader to read bytecode files.
Raises
IO
Error when the path cannot be handled.
Raises
OS
Error when the path cannot be handled.
"""
return
{
'mtime'
:
self
.
path_mtime
(
path
)}
...
...
@@ -757,7 +757,7 @@ class SourceLoader(_LoaderBasics):
else
:
try
:
st
=
self
.
path_stats
(
source_path
)
except
IO
Error
:
except
OS
Error
:
pass
else
:
source_mtime
=
int
(
st
[
'mtime'
])
...
...
Lib/importlib/abc.py
View file @
55fe1ae9
...
...
@@ -193,7 +193,7 @@ class ResourceLoader(Loader):
def
get_data
(
self
,
path
):
"""Abstract method which when implemented should return the bytes for
the specified path. The path must be a str."""
raise
IO
Error
raise
OS
Error
class
InspectLoader
(
Loader
):
...
...
@@ -315,7 +315,7 @@ class SourceLoader(_bootstrap_external.SourceLoader, ResourceLoader, ExecutionLo
def
path_mtime
(
self
,
path
):
"""Return the (int) modification time for the path (str)."""
if
self
.
path_stats
.
__func__
is
SourceLoader
.
path_stats
:
raise
IO
Error
raise
OS
Error
return
int
(
self
.
path_stats
(
path
)[
'mtime'
])
def
path_stats
(
self
,
path
):
...
...
@@ -326,7 +326,7 @@ class SourceLoader(_bootstrap_external.SourceLoader, ResourceLoader, ExecutionLo
- 'size' (optional) is the size in bytes of the source code.
"""
if
self
.
path_mtime
.
__func__
is
SourceLoader
.
path_mtime
:
raise
IO
Error
raise
OS
Error
return
{
'mtime'
:
self
.
path_mtime
(
path
)}
def
set_data
(
self
,
path
,
data
):
...
...
Lib/mimetypes.py
View file @
55fe1ae9
...
...
@@ -245,7 +245,7 @@ class MimeTypes:
while
True
:
try
:
ctype
=
_winreg
.
EnumKey
(
mimedb
,
i
)
except
Environment
Error
:
except
OS
Error
:
break
else
:
if
'
\
0
'
not
in
ctype
:
...
...
@@ -259,13 +259,13 @@ class MimeTypes:
# Only check file extensions
if
not
subkeyname
.
startswith
(
"."
):
continue
# raises
Environment
Error if no 'Content Type' value
# raises
OS
Error if no 'Content Type' value
mimetype
,
datatype
=
_winreg
.
QueryValueEx
(
subkey
,
'Content Type'
)
if
datatype
!=
_winreg
.
REG_SZ
:
continue
self
.
add_type
(
mimetype
,
subkeyname
,
strict
)
except
Environment
Error
:
except
OS
Error
:
continue
def
guess_type
(
url
,
strict
=
True
):
...
...
Lib/pstats.py
View file @
55fe1ae9
...
...
@@ -579,7 +579,7 @@ if __name__ == '__main__':
if
self
.
stats
:
try
:
self
.
stats
.
add
(
line
)
except
IO
Error
as
e
:
except
OS
Error
as
e
:
print
(
"Failed to load statistics for %s: %s"
%
(
line
,
e
),
file
=
self
.
stream
)
else
:
print
(
"No statistics object is loaded."
,
file
=
self
.
stream
)
...
...
Lib/site.py
View file @
55fe1ae9
...
...
@@ -416,7 +416,7 @@ def enablerlcompleter():
'.python_history'
)
try
:
readline
.
read_history_file
(
history
)
except
IO
Error
:
except
OS
Error
:
pass
atexit
.
register
(
readline
.
write_history_file
,
history
)
...
...
Lib/test/support/__init__.py
View file @
55fe1ae9
...
...
@@ -741,7 +741,7 @@ def system_must_validate_cert(f):
def
dec
(
*
args
,
**
kwargs
):
try
:
f
(
*
args
,
**
kwargs
)
except
IO
Error
as
e
:
except
OS
Error
as
e
:
if
"CERTIFICATE_VERIFY_FAILED"
in
str
(
e
):
raise
unittest
.
SkipTest
(
"system does not contain "
"necessary certificates"
)
...
...
Lib/unittest/test/test_assertions.py
View file @
55fe1ae9
...
...
@@ -112,8 +112,8 @@ class Test_Assertions(unittest.TestCase):
a
=
A
()
wr
=
weakref
.
ref
(
a
)
try
:
raise
IO
Error
except
IO
Error
:
raise
OS
Error
except
OS
Error
:
raise
ValueError
def
test_functional
(
self
):
...
...
Lib/urllib/error.py
View file @
55fe1ae9
...
...
@@ -19,7 +19,7 @@ __all__ = ['URLError', 'HTTPError', 'ContentTooShortError']
class
URLError
(
OSError
):
# URLError is a sub-type of OSError, but it doesn't share any of
# the implementation. need to override __init__ and __str__.
# It sets self.args for compatibility with other
Environment
Error
# It sets self.args for compatibility with other
OS
Error
# subclasses, but args doesn't have the typical format with errno in
# slot 0 and strerror in slot 1. This may be better than nothing.
def
__init__
(
self
,
reason
,
filename
=
None
):
...
...
Modules/_bz2module.c
View file @
55fe1ae9
...
...
@@ -96,10 +96,10 @@ catch_bz2_error(int bzerror)
return
1
;
case
BZ_DATA_ERROR
:
case
BZ_DATA_ERROR_MAGIC
:
PyErr_SetString
(
PyExc_
IO
Error
,
"Invalid data stream"
);
PyErr_SetString
(
PyExc_
OS
Error
,
"Invalid data stream"
);
return
1
;
case
BZ_IO_ERROR
:
PyErr_SetString
(
PyExc_
IO
Error
,
"Unknown I/O error"
);
PyErr_SetString
(
PyExc_
OS
Error
,
"Unknown I/O error"
);
return
1
;
case
BZ_UNEXPECTED_EOF
:
PyErr_SetString
(
PyExc_EOFError
,
...
...
@@ -112,7 +112,7 @@ catch_bz2_error(int bzerror)
"Invalid sequence of commands sent to libbzip2"
);
return
1
;
default:
PyErr_Format
(
PyExc_
IO
Error
,
PyErr_Format
(
PyExc_
OS
Error
,
"Unrecognized error from libbzip2: %d"
,
bzerror
);
return
1
;
}
...
...
Modules/_dbmmodule.c
View file @
55fe1ae9
...
...
@@ -483,7 +483,7 @@ PyInit__dbm(void) {
d
=
PyModule_GetDict
(
m
);
if
(
DbmError
==
NULL
)
DbmError
=
PyErr_NewException
(
"_dbm.error"
,
PyExc_
IO
Error
,
NULL
);
PyExc_
OS
Error
,
NULL
);
s
=
PyUnicode_FromString
(
which_dbm
);
if
(
s
!=
NULL
)
{
PyDict_SetItemString
(
d
,
"library"
,
s
);
...
...
Modules/_gdbmmodule.c
View file @
55fe1ae9
...
...
@@ -649,7 +649,7 @@ PyInit__gdbm(void) {
if
(
m
==
NULL
)
return
NULL
;
d
=
PyModule_GetDict
(
m
);
DbmError
=
PyErr_NewException
(
"_gdbm.error"
,
PyExc_
IO
Error
,
NULL
);
DbmError
=
PyErr_NewException
(
"_gdbm.error"
,
PyExc_
OS
Error
,
NULL
);
if
(
DbmError
!=
NULL
)
{
PyDict_SetItemString
(
d
,
"error"
,
DbmError
);
s
=
PyUnicode_FromString
(
dbmmodule_open_flags
);
...
...
Modules/_io/_iomodule.c
View file @
55fe1ae9
...
...
@@ -61,7 +61,7 @@ PyDoc_STRVAR(module_doc,
"At the top of the I/O hierarchy is the abstract base class IOBase. It
\n
"
"defines the basic interface to a stream. Note, however, that there is no
\n
"
"separation between reading and writing to streams; implementations are
\n
"
"allowed to raise an
IO
Error if they do not support a given operation.
\n
"
"allowed to raise an
OS
Error if they do not support a given operation.
\n
"
"
\n
"
"Extending IOBase is RawIOBase which deals simply with the reading and
\n
"
"writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide
\n
"
...
...
@@ -107,7 +107,7 @@ _io.open
closefd: bool(accept={int}) = True
opener: object = None
Open file and return a stream. Raise
IO
Error upon failure.
Open file and return a stream. Raise
OS
Error upon failure.
file is either a text or byte string giving the name (and the path
if the file isn't in the current working directory) of the file to
...
...
@@ -231,7 +231,7 @@ static PyObject *
_io_open_impl
(
PyObject
*
module
,
PyObject
*
file
,
const
char
*
mode
,
int
buffering
,
const
char
*
encoding
,
const
char
*
errors
,
const
char
*
newline
,
int
closefd
,
PyObject
*
opener
)
/*[clinic end generated code: output=aefafc4ce2b46dc0 input=
7f81b2a1d3b02344
]*/
/*[clinic end generated code: output=aefafc4ce2b46dc0 input=
03da2940c8a65871
]*/
{
unsigned
i
;
...
...
@@ -656,7 +656,7 @@ PyInit__io(void)
if
(
PyModule_AddIntMacro
(
m
,
DEFAULT_BUFFER_SIZE
)
<
0
)
goto
fail
;
/* UnsupportedOperation inherits from ValueError and
IO
Error */
/* UnsupportedOperation inherits from ValueError and
OS
Error */
state
->
unsupported_operation
=
PyObject_CallFunction
(
(
PyObject
*
)
&
PyType_Type
,
"s(OO){}"
,
"UnsupportedOperation"
,
PyExc_OSError
,
PyExc_ValueError
);
...
...
Modules/_io/_iomodule.h
View file @
55fe1ae9
...
...
@@ -67,7 +67,7 @@ extern Py_ssize_t _PyIO_find_line_ending(
int
translated
,
int
universal
,
PyObject
*
readnl
,
int
kind
,
const
char
*
start
,
const
char
*
end
,
Py_ssize_t
*
consumed
);
/* Return 1 if an
Environment
Error with errno == EINTR is set (and then
/* Return 1 if an
OS
Error with errno == EINTR is set (and then
clears the error indicator), 0 otherwise.
Should only be called when PyErr_Occurred() is true.
*/
...
...
Modules/_io/bufferedio.c
View file @
55fe1ae9
...
...
@@ -695,7 +695,7 @@ _buffered_raw_tell(buffered *self)
Py_DECREF
(
res
);
if
(
n
<
0
)
{
if
(
!
PyErr_Occurred
())
PyErr_Format
(
PyExc_
IO
Error
,
PyErr_Format
(
PyExc_
OS
Error
,
"Raw stream returned invalid position %"
PY_PRIdOFF
,
(
PY_OFF_T_COMPAT
)
n
);
return
-
1
;
...
...
@@ -728,7 +728,7 @@ _buffered_raw_seek(buffered *self, Py_off_t target, int whence)
Py_DECREF
(
res
);
if
(
n
<
0
)
{
if
(
!
PyErr_Occurred
())
PyErr_Format
(
PyExc_
IO
Error
,
PyErr_Format
(
PyExc_
OS
Error
,
"Raw stream returned invalid position %"
PY_PRIdOFF
,
(
PY_OFF_T_COMPAT
)
n
);
return
-
1
;
...
...
@@ -776,7 +776,7 @@ _buffered_init(buffered *self)
return
0
;
}
/* Return 1 if an
Environment
Error with errno == EINTR is set (and then
/* Return 1 if an
OS
Error with errno == EINTR is set (and then
clears the error indicator), 0 otherwise.
Should only be called when PyErr_Occurred() is true.
*/
...
...
@@ -785,17 +785,17 @@ _PyIO_trap_eintr(void)
{
static
PyObject
*
eintr_int
=
NULL
;
PyObject
*
typ
,
*
val
,
*
tb
;
Py
Environment
ErrorObject
*
env_err
;
Py
OS
ErrorObject
*
env_err
;
if
(
eintr_int
==
NULL
)
{
eintr_int
=
PyLong_FromLong
(
EINTR
);
assert
(
eintr_int
!=
NULL
);
}
if
(
!
PyErr_ExceptionMatches
(
PyExc_
Environment
Error
))
if
(
!
PyErr_ExceptionMatches
(
PyExc_
OS
Error
))
return
0
;
PyErr_Fetch
(
&
typ
,
&
val
,
&
tb
);
PyErr_NormalizeException
(
&
typ
,
&
val
,
&
tb
);
env_err
=
(
Py
Environment
ErrorObject
*
)
val
;
env_err
=
(
Py
OS
ErrorObject
*
)
val
;
assert
(
env_err
!=
NULL
);
if
(
env_err
->
myerrno
!=
NULL
&&
PyObject_RichCompareBool
(
env_err
->
myerrno
,
eintr_int
,
Py_EQ
)
>
0
)
{
...
...
@@ -1374,7 +1374,7 @@ buffered_iternext(buffered *self)
line
=
PyObject_CallMethodObjArgs
((
PyObject
*
)
self
,
_PyIO_str_readline
,
NULL
);
if
(
line
&&
!
PyBytes_Check
(
line
))
{
PyErr_Format
(
PyExc_
IO
Error
,
PyErr_Format
(
PyExc_
OS
Error
,
"readline() should have returned a bytes object, "
"not '%.200s'"
,
Py_TYPE
(
line
)
->
tp_name
);
Py_DECREF
(
line
);
...
...
@@ -1501,7 +1501,7 @@ _bufferedreader_raw_read(buffered *self, char *start, Py_ssize_t len)
n
=
PyNumber_AsSsize_t
(
res
,
PyExc_ValueError
);
Py_DECREF
(
res
);
if
(
n
<
0
||
n
>
len
)
{
PyErr_Format
(
PyExc_
IO
Error
,
PyErr_Format
(
PyExc_
OS
Error
,
"raw readinto() returned invalid length %zd "
"(should have been between 0 and %zd)"
,
n
,
len
);
return
-
1
;
...
...
@@ -1858,7 +1858,7 @@ _bufferedwriter_raw_write(buffered *self, char *start, Py_ssize_t len)
n
=
PyNumber_AsSsize_t
(
res
,
PyExc_ValueError
);
Py_DECREF
(
res
);
if
(
n
<
0
||
n
>
len
)
{
PyErr_Format
(
PyExc_
IO
Error
,
PyErr_Format
(
PyExc_
OS
Error
,
"raw write() returned invalid length %zd "
"(should have been between 0 and %zd)"
,
n
,
len
);
return
-
1
;
...
...
Modules/_io/clinic/_iomodule.c.h
View file @
55fe1ae9
...
...
@@ -7,7 +7,7 @@ PyDoc_STRVAR(_io_open__doc__,
" errors=None, newline=None, closefd=True, opener=None)
\n
"
"--
\n
"
"
\n
"
"Open file and return a stream. Raise
IO
Error upon failure.
\n
"
"Open file and return a stream. Raise
OS
Error upon failure.
\n
"
"
\n
"
"file is either a text or byte string giving the name (and the path
\n
"
"if the file isn
\'
t in the current working directory) of the file to
\n
"
...
...
@@ -158,4 +158,4 @@ _io_open(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
exit:
return
return_value
;
}
/*[clinic end generated code: output=
79fd04d9c9d8f28f
input=a9049054013a1b77]*/
/*[clinic end generated code: output=
e6011c784fe6589b
input=a9049054013a1b77]*/
Modules/_io/fileio.c
View file @
55fe1ae9
...
...
@@ -123,7 +123,7 @@ internal_close(fileio *self)
}
if
(
err
<
0
)
{
errno
=
save_errno
;
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
-
1
;
}
return
0
;
...
...
@@ -456,7 +456,7 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
directories, so we need a check. */
if
(
S_ISDIR
(
fdfstat
.
st_mode
))
{
errno
=
EISDIR
;
PyErr_SetFromErrnoWithFilenameObject
(
PyExc_
IO
Error
,
nameobj
);
PyErr_SetFromErrnoWithFilenameObject
(
PyExc_
OS
Error
,
nameobj
);
goto
error
;
}
#endif
/* defined(S_ISDIR) */
...
...
@@ -910,7 +910,7 @@ portable_lseek(int fd, PyObject *posobj, int whence)
_Py_END_SUPPRESS_IPH
Py_END_ALLOW_THREADS
if
(
res
<
0
)
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
#if defined(HAVE_LARGEFILE_SUPPORT)
return
PyLong_FromLongLong
(
res
);
...
...
@@ -1023,7 +1023,7 @@ _io_FileIO_truncate_impl(fileio *self, PyObject *posobj)
if
(
ret
!=
0
)
{
Py_DECREF
(
posobj
);
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
NULL
;
}
...
...
Modules/_io/iobase.c
View file @
55fe1ae9
...
...
@@ -526,7 +526,7 @@ _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit)
goto
fail
;
}
if
(
!
PyBytes_Check
(
readahead
))
{
PyErr_Format
(
PyExc_
IO
Error
,
PyErr_Format
(
PyExc_
OS
Error
,
"peek() should have returned a bytes object, "
"not '%.200s'"
,
Py_TYPE
(
readahead
)
->
tp_name
);
Py_DECREF
(
readahead
);
...
...
@@ -566,7 +566,7 @@ _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit)
goto
fail
;
}
if
(
!
PyBytes_Check
(
b
))
{
PyErr_Format
(
PyExc_
IO
Error
,
PyErr_Format
(
PyExc_
OS
Error
,
"read() should have returned a bytes object, "
"not '%.200s'"
,
Py_TYPE
(
b
)
->
tp_name
);
Py_DECREF
(
b
);
...
...
Modules/_io/stringio.c
View file @
55fe1ae9
...
...
@@ -410,7 +410,7 @@ stringio_iternext(stringio *self)
line
=
PyObject_CallMethodObjArgs
((
PyObject
*
)
self
,
_PyIO_str_readline
,
NULL
);
if
(
line
&&
!
PyUnicode_Check
(
line
))
{
PyErr_Format
(
PyExc_
IO
Error
,
PyErr_Format
(
PyExc_
OS
Error
,
"readline() should have returned a str object, "
"not '%.200s'"
,
Py_TYPE
(
line
)
->
tp_name
);
Py_DECREF
(
line
);
...
...
@@ -498,7 +498,7 @@ _io_StringIO_seek_impl(stringio *self, Py_ssize_t pos, int whence)
return
NULL
;
}
else
if
(
whence
!=
0
&&
pos
!=
0
)
{
PyErr_SetString
(
PyExc_
IO
Error
,
PyErr_SetString
(
PyExc_
OS
Error
,
"Can't do nonzero cur-relative seeks"
);
return
NULL
;
}
...
...
Modules/_io/textio.c
View file @
55fe1ae9
...
...
@@ -924,7 +924,7 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
goto
error
;
}
else
{
PyErr_SetString
(
PyExc_
IO
Error
,
PyErr_SetString
(
PyExc_
OS
Error
,
"could not determine default encoding"
);
}
...
...
@@ -2205,7 +2205,7 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence)
/* Skip chars_to_skip of the decoded characters. */
if
(
PyUnicode_GetLength
(
self
->
decoded_chars
)
<
cookie
.
chars_to_skip
)
{
PyErr_SetString
(
PyExc_
IO
Error
,
"can't restore logical file position"
);
PyErr_SetString
(
PyExc_
OS
Error
,
"can't restore logical file position"
);
goto
fail
;
}
self
->
decoded_chars_used
=
cookie
.
chars_to_skip
;
...
...
@@ -2255,7 +2255,7 @@ _io_TextIOWrapper_tell_impl(textio *self)
goto
fail
;
}
if
(
!
self
->
telling
)
{
PyErr_SetString
(
PyExc_
IO
Error
,
PyErr_SetString
(
PyExc_
OS
Error
,
"telling position disabled by next() call"
);
goto
fail
;
}
...
...
@@ -2421,7 +2421,7 @@ _io_TextIOWrapper_tell_impl(textio *self)
cookie
.
need_eof
=
1
;
if
(
chars_decoded
<
chars_to_skip
)
{
PyErr_SetString
(
PyExc_
IO
Error
,
PyErr_SetString
(
PyExc_
OS
Error
,
"can't reconstruct logical file position"
);
goto
fail
;
}
...
...
@@ -2693,7 +2693,7 @@ textiowrapper_iternext(textio *self)
line
=
PyObject_CallMethodObjArgs
((
PyObject
*
)
self
,
_PyIO_str_readline
,
NULL
);
if
(
line
&&
!
PyUnicode_Check
(
line
))
{
PyErr_Format
(
PyExc_
IO
Error
,
PyErr_Format
(
PyExc_
OS
Error
,
"readline() should have returned a str object, "
"not '%.200s'"
,
Py_TYPE
(
line
)
->
tp_name
);
Py_DECREF
(
line
);
...
...
Modules/_multiprocessing/multiprocessing.c
View file @
55fe1ae9
...
...
@@ -64,7 +64,7 @@ multiprocessing_closesocket(PyObject *self, PyObject *args)
Py_END_ALLOW_THREADS
if
(
ret
)
return
PyErr_SetExcFromWindowsErr
(
PyExc_
IO
Error
,
WSAGetLastError
());
return
PyErr_SetExcFromWindowsErr
(
PyExc_
OS
Error
,
WSAGetLastError
());
Py_RETURN_NONE
;
}
...
...
@@ -88,7 +88,7 @@ multiprocessing_recv(PyObject *self, PyObject *args)
if
(
nread
<
0
)
{
Py_DECREF
(
buf
);
return
PyErr_SetExcFromWindowsErr
(
PyExc_
IO
Error
,
WSAGetLastError
());
return
PyErr_SetExcFromWindowsErr
(
PyExc_
OS
Error
,
WSAGetLastError
());
}
_PyBytes_Resize
(
&
buf
,
nread
);
return
buf
;
...
...
@@ -112,7 +112,7 @@ multiprocessing_send(PyObject *self, PyObject *args)
PyBuffer_Release
(
&
buf
);
if
(
ret
<
0
)
return
PyErr_SetExcFromWindowsErr
(
PyExc_
IO
Error
,
WSAGetLastError
());
return
PyErr_SetExcFromWindowsErr
(
PyExc_
OS
Error
,
WSAGetLastError
());
return
PyLong_FromLong
(
ret
);
}
...
...
Modules/_multiprocessing/semaphore.c
View file @
55fe1ae9
...
...
@@ -135,7 +135,7 @@ semlock_acquire(SemLockObject *self, PyObject *args, PyObject *kwds)
Py_RETURN_TRUE
;
case
WAIT_OBJECT_0
+
1
:
errno
=
EINTR
;
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
case
WAIT_FAILED
:
return
PyErr_SetFromWindowsErr
(
0
);
default:
...
...
Modules/_ssl.c
View file @
55fe1ae9
...
...
@@ -3275,7 +3275,7 @@ _ssl__SSLContext_load_cert_chain_impl(PySSLContext *self, PyObject *certfile,
}
else
if
(
errno
!=
0
)
{
ERR_clear_error
();
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
}
else
{
_setSSLError
(
NULL
,
0
,
__FILE__
,
__LINE__
);
...
...
@@ -3296,7 +3296,7 @@ _ssl__SSLContext_load_cert_chain_impl(PySSLContext *self, PyObject *certfile,
}
else
if
(
errno
!=
0
)
{
ERR_clear_error
();
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
}
else
{
_setSSLError
(
NULL
,
0
,
__FILE__
,
__LINE__
);
...
...
@@ -3504,7 +3504,7 @@ _ssl__SSLContext_load_verify_locations_impl(PySSLContext *self,
ok
=
0
;
if
(
errno
!=
0
)
{
ERR_clear_error
();
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
}
else
{
_setSSLError
(
NULL
,
0
,
__FILE__
,
__LINE__
);
...
...
Modules/_winapi.c
View file @
55fe1ae9
...
...
@@ -224,7 +224,7 @@ _winapi_Overlapped_GetOverlappedResult_impl(OverlappedObject *self, int wait)
break
;
default:
self
->
pending
=
0
;
return
PyErr_SetExcFromWindowsErr
(
PyExc_
IO
Error
,
err
);
return
PyErr_SetExcFromWindowsErr
(
PyExc_
OS
Error
,
err
);
}
if
(
self
->
completed
&&
self
->
read_buffer
!=
NULL
)
{
assert
(
PyBytes_CheckExact
(
self
->
read_buffer
));
...
...
@@ -276,7 +276,7 @@ _winapi_Overlapped_cancel_impl(OverlappedObject *self)
/* CancelIoEx returns ERROR_NOT_FOUND if the I/O completed in-between */
if
(
!
res
&&
GetLastError
()
!=
ERROR_NOT_FOUND
)
return
PyErr_SetExcFromWindowsErr
(
PyExc_
IO
Error
,
0
);
return
PyErr_SetExcFromWindowsErr
(
PyExc_
OS
Error
,
0
);
self
->
pending
=
0
;
Py_RETURN_NONE
;
}
...
...
@@ -1139,7 +1139,7 @@ _winapi_PeekNamedPipe_impl(PyObject *module, HANDLE handle, int size)
Py_END_ALLOW_THREADS
if
(
!
ret
)
{
Py_DECREF
(
buf
);
return
PyErr_SetExcFromWindowsErr
(
PyExc_
IO
Error
,
0
);
return
PyErr_SetExcFromWindowsErr
(
PyExc_
OS
Error
,
0
);
}
if
(
_PyBytes_Resize
(
&
buf
,
nread
))
return
NULL
;
...
...
@@ -1150,7 +1150,7 @@ _winapi_PeekNamedPipe_impl(PyObject *module, HANDLE handle, int size)
ret
=
PeekNamedPipe
(
handle
,
NULL
,
0
,
NULL
,
&
navail
,
&
nleft
);
Py_END_ALLOW_THREADS
if
(
!
ret
)
{
return
PyErr_SetExcFromWindowsErr
(
PyExc_
IO
Error
,
0
);
return
PyErr_SetExcFromWindowsErr
(
PyExc_
OS
Error
,
0
);
}
return
Py_BuildValue
(
"ii"
,
navail
,
nleft
);
}
...
...
@@ -1201,7 +1201,7 @@ _winapi_ReadFile_impl(PyObject *module, HANDLE handle, int size,
overlapped
->
pending
=
1
;
else
if
(
err
!=
ERROR_MORE_DATA
)
{
Py_DECREF
(
overlapped
);
return
PyErr_SetExcFromWindowsErr
(
PyExc_
IO
Error
,
0
);
return
PyErr_SetExcFromWindowsErr
(
PyExc_
OS
Error
,
0
);
}
}
return
Py_BuildValue
(
"NI"
,
(
PyObject
*
)
overlapped
,
err
);
...
...
@@ -1209,7 +1209,7 @@ _winapi_ReadFile_impl(PyObject *module, HANDLE handle, int size,
if
(
!
ret
&&
err
!=
ERROR_MORE_DATA
)
{
Py_DECREF
(
buf
);
return
PyErr_SetExcFromWindowsErr
(
PyExc_
IO
Error
,
0
);
return
PyErr_SetExcFromWindowsErr
(
PyExc_
OS
Error
,
0
);
}
if
(
_PyBytes_Resize
(
&
buf
,
nread
))
return
NULL
;
...
...
@@ -1366,10 +1366,10 @@ _winapi_WaitForMultipleObjects_impl(PyObject *module, PyObject *handle_seq,
Py_END_ALLOW_THREADS
if
(
result
==
WAIT_FAILED
)
return
PyErr_SetExcFromWindowsErr
(
PyExc_
IO
Error
,
0
);
return
PyErr_SetExcFromWindowsErr
(
PyExc_
OS
Error
,
0
);
else
if
(
sigint_event
!=
NULL
&&
result
==
WAIT_OBJECT_0
+
nhandles
-
1
)
{
errno
=
EINTR
;
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
}
return
PyLong_FromLong
((
int
)
result
);
...
...
@@ -1455,7 +1455,7 @@ _winapi_WriteFile_impl(PyObject *module, HANDLE handle, PyObject *buffer,
overlapped
->
pending
=
1
;
else
{
Py_DECREF
(
overlapped
);
return
PyErr_SetExcFromWindowsErr
(
PyExc_
IO
Error
,
0
);
return
PyErr_SetExcFromWindowsErr
(
PyExc_
OS
Error
,
0
);
}
}
return
Py_BuildValue
(
"NI"
,
(
PyObject
*
)
overlapped
,
err
);
...
...
@@ -1463,7 +1463,7 @@ _winapi_WriteFile_impl(PyObject *module, HANDLE handle, PyObject *buffer,
PyBuffer_Release
(
buf
);
if
(
!
ret
)
return
PyErr_SetExcFromWindowsErr
(
PyExc_
IO
Error
,
0
);
return
PyErr_SetExcFromWindowsErr
(
PyExc_
OS
Error
,
0
);
return
Py_BuildValue
(
"II"
,
written
,
err
);
}
...
...
Modules/fcntlmodule.c
View file @
55fe1ae9
...
...
@@ -79,7 +79,7 @@ fcntl_fcntl_impl(PyObject *module, int fd, int code, PyObject *arg)
ret
=
fcntl
(
fd
,
code
,
buf
);
Py_END_ALLOW_THREADS
if
(
ret
<
0
)
{
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
NULL
;
}
return
PyBytes_FromStringAndSize
(
buf
,
len
);
...
...
@@ -99,7 +99,7 @@ fcntl_fcntl_impl(PyObject *module, int fd, int code, PyObject *arg)
ret
=
fcntl
(
fd
,
code
,
(
int
)
int_arg
);
Py_END_ALLOW_THREADS
if
(
ret
<
0
)
{
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
NULL
;
}
return
PyLong_FromLong
((
long
)
ret
);
...
...
@@ -210,7 +210,7 @@ fcntl_ioctl_impl(PyObject *module, int fd, unsigned int code,
}
PyBuffer_Release
(
&
pstr
);
/* No further access to str below this point */
if
(
ret
<
0
)
{
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
NULL
;
}
if
(
mutate_arg
)
{
...
...
@@ -238,7 +238,7 @@ fcntl_ioctl_impl(PyObject *module, int fd, unsigned int code,
Py_END_ALLOW_THREADS
if
(
ret
<
0
)
{
PyBuffer_Release
(
&
pstr
);
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
NULL
;
}
PyBuffer_Release
(
&
pstr
);
...
...
@@ -258,7 +258,7 @@ fcntl_ioctl_impl(PyObject *module, int fd, unsigned int code,
ret
=
ioctl
(
fd
,
code
,
arg
);
Py_END_ALLOW_THREADS
if
(
ret
<
0
)
{
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
NULL
;
}
return
PyLong_FromLong
((
long
)
ret
);
...
...
@@ -316,7 +316,7 @@ fcntl_flock_impl(PyObject *module, int fd, int code)
}
#endif
/* HAVE_FLOCK */
if
(
ret
<
0
)
{
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
NULL
;
}
Py_RETURN_NONE
;
...
...
@@ -412,7 +412,7 @@ fcntl_lockf_impl(PyObject *module, int fd, int code, PyObject *lenobj,
Py_END_ALLOW_THREADS
}
if
(
ret
<
0
)
{
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
NULL
;
}
Py_RETURN_NONE
;
...
...
Modules/main.c
View file @
55fe1ae9
...
...
@@ -141,7 +141,7 @@ static void RunStartupFile(PyCompilerFlags *cf)
save_errno
=
errno
;
PySys_WriteStderr
(
"Could not open PYTHONSTARTUP
\n
"
);
errno
=
save_errno
;
PyErr_SetFromErrnoWithFilename
(
PyExc_
IO
Error
,
PyErr_SetFromErrnoWithFilename
(
PyExc_
OS
Error
,
startup
);
PyErr_Print
();
PyErr_Clear
();
...
...
Modules/ossaudiodev.c
View file @
55fe1ae9
...
...
@@ -128,13 +128,13 @@ newossobject(PyObject *arg)
expected write() semantics. */
if
(
fcntl
(
fd
,
F_SETFL
,
0
)
==
-
1
)
{
close
(
fd
);
PyErr_SetFromErrnoWithFilename
(
PyExc_
IO
Error
,
devicename
);
PyErr_SetFromErrnoWithFilename
(
PyExc_
OS
Error
,
devicename
);
return
NULL
;
}
if
(
ioctl
(
fd
,
SNDCTL_DSP_GETFMTS
,
&
afmts
)
==
-
1
)
{
close
(
fd
);
PyErr_SetFromErrnoWithFilename
(
PyExc_
IO
Error
,
devicename
);
PyErr_SetFromErrnoWithFilename
(
PyExc_
OS
Error
,
devicename
);
return
NULL
;
}
/* Create and initialize the object */
...
...
@@ -253,7 +253,7 @@ _do_ioctl_1(int fd, PyObject *args, char *fname, int cmd)
return
NULL
;
if
(
ioctl
(
fd
,
cmd
,
&
arg
)
==
-
1
)
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
PyLong_FromLong
(
arg
);
}
...
...
@@ -278,7 +278,7 @@ _do_ioctl_1_internal(int fd, PyObject *args, char *fname, int cmd)
return
NULL
;
if
(
ioctl
(
fd
,
cmd
,
&
arg
)
==
-
1
)
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
PyLong_FromLong
(
arg
);
}
...
...
@@ -306,7 +306,7 @@ _do_ioctl_0(int fd, PyObject *args, char *fname, int cmd)
Py_END_ALLOW_THREADS
if
(
rv
==
-
1
)
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
Py_RETURN_NONE
;
}
...
...
@@ -324,7 +324,7 @@ oss_nonblock(oss_audio_t *self, PyObject *unused)
/* Hmmm: it doesn't appear to be possible to return to blocking
mode once we're in non-blocking mode! */
if
(
ioctl
(
self
->
fd
,
SNDCTL_DSP_NONBLOCK
,
NULL
)
==
-
1
)
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
Py_RETURN_NONE
;
}
...
...
@@ -346,7 +346,7 @@ oss_getfmts(oss_audio_t *self, PyObject *unused)
return
NULL
;
if
(
ioctl
(
self
->
fd
,
SNDCTL_DSP_GETFMTS
,
&
mask
)
==
-
1
)
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
PyLong_FromLong
(
mask
);
}
...
...
@@ -491,7 +491,7 @@ oss_writeall(oss_audio_t *self, PyObject *args)
assert
(
select_rv
!=
0
);
/* no timeout, can't expire */
if
(
select_rv
==
-
1
)
{
PyBuffer_Release
(
&
data
);
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
}
rv
=
_Py_write
(
self
->
fd
,
cp
,
Py_MIN
(
size
,
INT_MAX
));
...
...
@@ -575,7 +575,7 @@ oss_setparameters(oss_audio_t *self, PyObject *args)
fmt
=
wanted_fmt
;
if
(
ioctl
(
self
->
fd
,
SNDCTL_DSP_SETFMT
,
&
fmt
)
==
-
1
)
{
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
}
if
(
strict
&&
fmt
!=
wanted_fmt
)
{
return
PyErr_Format
...
...
@@ -586,7 +586,7 @@ oss_setparameters(oss_audio_t *self, PyObject *args)
channels
=
wanted_channels
;
if
(
ioctl
(
self
->
fd
,
SNDCTL_DSP_CHANNELS
,
&
channels
)
==
-
1
)
{
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
}
if
(
strict
&&
channels
!=
wanted_channels
)
{
return
PyErr_Format
...
...
@@ -597,7 +597,7 @@ oss_setparameters(oss_audio_t *self, PyObject *args)
rate
=
wanted_rate
;
if
(
ioctl
(
self
->
fd
,
SNDCTL_DSP_SPEED
,
&
rate
)
==
-
1
)
{
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
}
if
(
strict
&&
rate
!=
wanted_rate
)
{
return
PyErr_Format
...
...
@@ -656,11 +656,11 @@ oss_bufsize(oss_audio_t *self, PyObject *unused)
return
NULL
;
if
(
_ssize
(
self
,
&
nchannels
,
&
ssize
)
<
0
||
!
nchannels
||
!
ssize
)
{
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
NULL
;
}
if
(
ioctl
(
self
->
fd
,
SNDCTL_DSP_GETOSPACE
,
&
ai
)
<
0
)
{
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
NULL
;
}
return
PyLong_FromLong
((
ai
.
fragstotal
*
ai
.
fragsize
)
/
(
nchannels
*
ssize
));
...
...
@@ -678,11 +678,11 @@ oss_obufcount(oss_audio_t *self, PyObject *unused)
return
NULL
;
if
(
_ssize
(
self
,
&
nchannels
,
&
ssize
)
<
0
||
!
nchannels
||
!
ssize
)
{
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
NULL
;
}
if
(
ioctl
(
self
->
fd
,
SNDCTL_DSP_GETOSPACE
,
&
ai
)
<
0
)
{
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
NULL
;
}
return
PyLong_FromLong
((
ai
.
fragstotal
*
ai
.
fragsize
-
ai
.
bytes
)
/
...
...
@@ -701,11 +701,11 @@ oss_obuffree(oss_audio_t *self, PyObject *unused)
return
NULL
;
if
(
_ssize
(
self
,
&
nchannels
,
&
ssize
)
<
0
||
!
nchannels
||
!
ssize
)
{
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
NULL
;
}
if
(
ioctl
(
self
->
fd
,
SNDCTL_DSP_GETOSPACE
,
&
ai
)
<
0
)
{
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
NULL
;
}
return
PyLong_FromLong
(
ai
.
bytes
/
(
ssize
*
nchannels
));
...
...
@@ -725,7 +725,7 @@ oss_getptr(oss_audio_t *self, PyObject *unused)
else
req
=
SNDCTL_DSP_GETOPTR
;
if
(
ioctl
(
self
->
fd
,
req
,
&
info
)
==
-
1
)
{
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
NULL
;
}
return
Py_BuildValue
(
"iii"
,
info
.
bytes
,
info
.
blocks
,
info
.
ptr
);
...
...
@@ -805,7 +805,7 @@ oss_mixer_get(oss_mixer_t *self, PyObject *args)
}
if
(
ioctl
(
self
->
fd
,
MIXER_READ
(
channel
),
&
volume
)
==
-
1
)
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
Py_BuildValue
(
"(ii)"
,
volume
&
0xff
,
(
volume
&
0xff00
)
>>
8
);
}
...
...
@@ -835,7 +835,7 @@ oss_mixer_set(oss_mixer_t *self, PyObject *args)
volume
=
(
rightVol
<<
8
)
|
leftVol
;
if
(
ioctl
(
self
->
fd
,
MIXER_WRITE
(
channel
),
&
volume
)
==
-
1
)
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
Py_BuildValue
(
"(ii)"
,
volume
&
0xff
,
(
volume
&
0xff00
)
>>
8
);
}
...
...
Modules/readline.c
View file @
55fe1ae9
...
...
@@ -188,7 +188,7 @@ read_init_file(PyObject *self, PyObject *args)
}
else
errno
=
rl_read_init_file
(
NULL
);
if
(
errno
)
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
Py_RETURN_NONE
;
}
...
...
@@ -214,7 +214,7 @@ read_history_file(PyObject *self, PyObject *args)
}
else
errno
=
read_history
(
NULL
);
if
(
errno
)
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
Py_RETURN_NONE
;
}
...
...
@@ -249,7 +249,7 @@ write_history_file(PyObject *self, PyObject *args)
Py_XDECREF
(
filename_bytes
);
errno
=
err
;
if
(
errno
)
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
Py_RETURN_NONE
;
}
...
...
@@ -285,7 +285,7 @@ append_history_file(PyObject *self, PyObject *args)
Py_XDECREF
(
filename_bytes
);
errno
=
err
;
if
(
errno
)
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
Py_RETURN_NONE
;
}
...
...
Modules/selectmodule.c
View file @
55fe1ae9
...
...
@@ -768,7 +768,7 @@ static int devpoll_flush(devpollObject *self)
** the wild.
** See http://bugs.python.org/issue6397.
*/
PyErr_Format
(
PyExc_
IO
Error
,
"failed to write all pollfds. "
PyErr_Format
(
PyExc_
OS
Error
,
"failed to write all pollfds. "
"Please, report at http://bugs.python.org/. "
"Data to report: Size tried: %d, actual size written: %d."
,
size
,
n
);
...
...
@@ -948,7 +948,7 @@ devpoll_poll(devpollObject *self, PyObject *args)
}
while
(
1
);
if
(
poll_result
<
0
)
{
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
NULL
;
}
...
...
Modules/signalmodule.c
View file @
55fe1ae9
...
...
@@ -1438,7 +1438,7 @@ PyInit__signal(void)
#if defined (HAVE_SETITIMER) || defined (HAVE_GETITIMER)
ItimerError
=
PyErr_NewException
(
"signal.ItimerError"
,
PyExc_
IO
Error
,
NULL
);
PyExc_
OS
Error
,
NULL
);
if
(
ItimerError
!=
NULL
)
PyDict_SetItemString
(
d
,
"ItimerError"
,
ItimerError
);
#endif
...
...
Modules/zipimport.c
View file @
55fe1ae9
...
...
@@ -603,7 +603,7 @@ zipimporter_get_data(PyObject *obj, PyObject *args)
goto
error
;
toc_entry
=
PyDict_GetItem
(
self
->
files
,
key
);
if
(
toc_entry
==
NULL
)
{
PyErr_SetFromErrnoWithFilenameObject
(
PyExc_
IO
Error
,
key
);
PyErr_SetFromErrnoWithFilenameObject
(
PyExc_
OS
Error
,
key
);
Py_DECREF
(
key
);
goto
error
;
}
...
...
@@ -709,7 +709,7 @@ module, or raises ZipImportError if it wasn't found.");
PyDoc_STRVAR
(
doc_get_data
,
"get_data(pathname) -> string with file data.
\n
\
\n
\
Return the data associated with 'pathname'. Raise
IO
Error if
\n
\
Return the data associated with 'pathname'. Raise
OS
Error if
\n
\
the file wasn't found."
);
PyDoc_STRVAR
(
doc_is_package
,
...
...
@@ -1193,7 +1193,7 @@ get_data(PyObject *archive, PyObject *toc_entry)
goto
file_error
;
}
if
(
fread
(
buf
,
1
,
data_size
,
fp
)
!=
(
size_t
)
data_size
)
{
PyErr_SetString
(
PyExc_
IO
Error
,
PyErr_SetString
(
PyExc_
OS
Error
,
"zipimport: can't read data"
);
goto
error
;
}
...
...
Objects/object.c
View file @
55fe1ae9
...
...
@@ -406,7 +406,7 @@ PyObject_Print(PyObject *op, FILE *fp, int flags)
}
if
(
ret
==
0
)
{
if
(
ferror
(
fp
))
{
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
clearerr
(
fp
);
ret
=
-
1
;
}
...
...
PC/clinic/msvcrtmodule.c.h
View file @
55fe1ae9
...
...
@@ -29,7 +29,7 @@ PyDoc_STRVAR(msvcrt_locking__doc__,
"
\n
"
"Lock part of a file based on file descriptor fd from the C runtime.
\n
"
"
\n
"
"Raises
IO
Error on failure. The locked region of the file extends from
\n
"
"Raises
OS
Error on failure. The locked region of the file extends from
\n
"
"the current file position for nbytes bytes, and may continue beyond
\n
"
"the end of the file. mode must be one of the LK_* constants listed
\n
"
"below. Multiple regions in a file may be locked at the same time, but
\n
"
...
...
@@ -155,7 +155,7 @@ PyDoc_STRVAR(msvcrt_get_osfhandle__doc__,
"
\n
"
"Return the file handle for the file descriptor fd.
\n
"
"
\n
"
"Raises
IO
Error if fd is not recognized."
);
"Raises
OS
Error if fd is not recognized."
);
#define MSVCRT_GET_OSFHANDLE_METHODDEF \
{"get_osfhandle", (PyCFunction)msvcrt_get_osfhandle, METH_O, msvcrt_get_osfhandle__doc__},
...
...
@@ -589,4 +589,4 @@ exit:
#ifndef MSVCRT_SET_ERROR_MODE_METHODDEF
#define MSVCRT_SET_ERROR_MODE_METHODDEF
#endif
/* !defined(MSVCRT_SET_ERROR_MODE_METHODDEF) */
/*[clinic end generated code: output=
36f1e78ca8bd3944
input=a9049054013a1b77]*/
/*[clinic end generated code: output=
be516d0e78532ba3
input=a9049054013a1b77]*/
PC/msvcrtmodule.c
View file @
55fe1ae9
...
...
@@ -82,7 +82,7 @@ msvcrt_heapmin_impl(PyObject *module)
/*[clinic end generated code: output=1ba00f344782dc19 input=82e1771d21bde2d8]*/
{
if
(
_heapmin
()
!=
0
)
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
Py_RETURN_NONE
;
}
...
...
@@ -96,7 +96,7 @@ msvcrt.locking
Lock part of a file based on file descriptor fd from the C runtime.
Raises
IO
Error on failure. The locked region of the file extends from
Raises
OS
Error on failure. The locked region of the file extends from
the current file position for nbytes bytes, and may continue beyond
the end of the file. mode must be one of the LK_* constants listed
below. Multiple regions in a file may be locked at the same time, but
...
...
@@ -106,7 +106,7 @@ individually.
static
PyObject
*
msvcrt_locking_impl
(
PyObject
*
module
,
int
fd
,
int
mode
,
long
nbytes
)
/*[clinic end generated code: output=a4a90deca9785a03 input=
d9f13f0f6a713ba7
]*/
/*[clinic end generated code: output=a4a90deca9785a03 input=
e97bd15fc4a04fef
]*/
{
int
err
;
...
...
@@ -116,7 +116,7 @@ msvcrt_locking_impl(PyObject *module, int fd, int mode, long nbytes)
_Py_END_SUPPRESS_IPH
Py_END_ALLOW_THREADS
if
(
err
!=
0
)
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
Py_RETURN_NONE
;
}
...
...
@@ -144,7 +144,7 @@ msvcrt_setmode_impl(PyObject *module, int fd, int flags)
flags
=
_setmode
(
fd
,
flags
);
_Py_END_SUPPRESS_IPH
if
(
flags
==
-
1
)
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
flags
;
}
...
...
@@ -173,7 +173,7 @@ msvcrt_open_osfhandle_impl(PyObject *module, intptr_t handle, int flags)
fd
=
_open_osfhandle
(
handle
,
flags
);
_Py_END_SUPPRESS_IPH
if
(
fd
==
-
1
)
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
fd
;
}
...
...
@@ -186,12 +186,12 @@ msvcrt.get_osfhandle -> handle
Return the file handle for the file descriptor fd.
Raises
IO
Error if fd is not recognized.
Raises
OS
Error if fd is not recognized.
[clinic start generated code]*/
static
intptr_t
msvcrt_get_osfhandle_impl
(
PyObject
*
module
,
int
fd
)
/*[clinic end generated code: output=7ce761dd0de2b503 input=
c7d18d02c8017ec1
]*/
/*[clinic end generated code: output=7ce761dd0de2b503 input=
305900f4bfab76c7
]*/
{
intptr_t
handle
=
-
1
;
...
...
@@ -199,7 +199,7 @@ msvcrt_get_osfhandle_impl(PyObject *module, int fd)
handle
=
_get_osfhandle
(
fd
);
_Py_END_SUPPRESS_IPH
if
(
handle
==
-
1
)
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
handle
;
}
...
...
@@ -359,7 +359,7 @@ msvcrt_ungetch_impl(PyObject *module, char char_value)
_Py_END_SUPPRESS_IPH
if
(
res
==
EOF
)
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
Py_RETURN_NONE
;
}
...
...
@@ -383,7 +383,7 @@ msvcrt_ungetwch_impl(PyObject *module, int unicode_char)
_Py_END_SUPPRESS_IPH
if
(
res
==
WEOF
)
return
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
return
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
Py_RETURN_NONE
;
}
...
...
@@ -435,7 +435,7 @@ msvcrt_CrtSetReportMode_impl(PyObject *module, int type, int mode)
res
=
_CrtSetReportMode
(
type
,
mode
);
_Py_END_SUPPRESS_IPH
if
(
res
==
-
1
)
PyErr_SetFromErrno
(
PyExc_
IO
Error
);
PyErr_SetFromErrno
(
PyExc_
OS
Error
);
return
res
;
}
...
...
Python/importlib_external.h
View file @
55fe1ae9
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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