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