Add an errors parameter to open() and TextIOWrapper() to specify error handling.

This commit is contained in:
Guido van Rossum 2007-12-03 22:54:21 +00:00
parent c6fe37bab9
commit e7fc50f2d0
7 changed files with 77 additions and 17 deletions

View file

@ -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) {

View file

@ -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;