mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
Add an errors parameter to open() and TextIOWrapper() to specify error handling.
This commit is contained in:
parent
c6fe37bab9
commit
e7fc50f2d0
7 changed files with 77 additions and 17 deletions
|
|
@ -915,6 +915,7 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
return NULL;
|
||||
}
|
||||
cr.real = PyFloat_AsDouble(tmp);
|
||||
cr.imag = 0.0; /* Shut up compiler warning */
|
||||
Py_DECREF(tmp);
|
||||
}
|
||||
if (i == NULL) {
|
||||
|
|
|
|||
|
|
@ -27,15 +27,16 @@ extern "C" {
|
|||
|
||||
PyObject *
|
||||
PyFile_FromFd(int fd, char *name, char *mode, int buffering, char *encoding,
|
||||
char *newline, int closefd)
|
||||
char *errors, char *newline, int closefd)
|
||||
{
|
||||
PyObject *io, *stream, *nameobj = NULL;
|
||||
|
||||
io = PyImport_ImportModule("io");
|
||||
if (io == NULL)
|
||||
return NULL;
|
||||
stream = PyObject_CallMethod(io, "open", "isissi", fd, mode,
|
||||
buffering, encoding, newline, closefd);
|
||||
stream = PyObject_CallMethod(io, "open", "isisssi", fd, mode,
|
||||
buffering, encoding, errors,
|
||||
newline, closefd);
|
||||
Py_DECREF(io);
|
||||
if (stream == NULL)
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue