diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-01-22 20:18:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-22 20:18:05 (GMT) |
commit | 6d43f6f081023b680d9db4542d19b9e382149f0a (patch) | |
tree | d777411c26c08e73b757e5a903669b5a00fb5747 /Objects/fileobject.c | |
parent | 28f6cb34f602b9796987904a607dceaf2e4a9e78 (diff) | |
download | cpython-6d43f6f081023b680d9db4542d19b9e382149f0a.zip cpython-6d43f6f081023b680d9db4542d19b9e382149f0a.tar.gz cpython-6d43f6f081023b680d9db4542d19b9e382149f0a.tar.bz2 |
bpo-35713: Split _Py_InitializeCore into subfunctions (GH-11650)
* Split _Py_InitializeCore_impl() into subfunctions: add multiple pycore_init_xxx() functions
* Preliminary sys.stderr is now set earlier to get an usable
sys.stderr ealier.
* Move code into _Py_Initialize_ReconfigureCore() to be able to call
it from _Py_InitializeCore().
* Split _PyExc_Init(): create a new _PyBuiltins_AddExceptions()
function.
* Call _PyExc_Init() earlier in _Py_InitializeCore_impl()
and new_interpreter() to get working exceptions earlier.
* _Py_ReadyTypes() now returns _PyInitError rather than calling
Py_FatalError().
* Misc code cleanup
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r-- | Objects/fileobject.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 313f1d0..babaa05 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -359,6 +359,9 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args) Py_ssize_t n; int err; + /* The function can clear the current exception */ + assert(!PyErr_Occurred()); + if (self->fd < 0) { /* fd might be invalid on Windows * I can't raise an exception here. It may lead to an @@ -367,10 +370,11 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args) Py_RETURN_NONE; } - if (!PyArg_ParseTuple(args, "U", &unicode)) + if (!PyArg_ParseTuple(args, "U", &unicode)) { return NULL; + } - /* encode Unicode to UTF-8 */ + /* Encode Unicode to UTF-8/surrogateescape */ str = PyUnicode_AsUTF8AndSize(unicode, &n); if (str == NULL) { PyErr_Clear(); |