summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2022-12-07 22:56:31 (GMT)
committerGitHub <noreply@github.com>2022-12-07 22:56:31 (GMT)
commit91a8e002c21a5388c5152c5a4871b9a2d85f0fc1 (patch)
treee6be380d88efc246ca7b4f864a67fc541a62b861 /Modules/_io
parentd47ffeb9e35dbc7264ffa12fddaa6e0d3ba767a4 (diff)
downloadcpython-91a8e002c21a5388c5152c5a4871b9a2d85f0fc1.zip
cpython-91a8e002c21a5388c5152c5a4871b9a2d85f0fc1.tar.gz
cpython-91a8e002c21a5388c5152c5a4871b9a2d85f0fc1.tar.bz2
gh-81057: Move More Globals to _PyRuntimeState (gh-100092)
https://github.com/python/cpython/issues/81057
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/bufferedio.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index 6df55b5..ba8969f 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -746,26 +746,26 @@ _buffered_init(buffered *self)
int
_PyIO_trap_eintr(void)
{
- static PyObject *eintr_int = NULL;
PyObject *typ, *val, *tb;
PyOSErrorObject *env_err;
-
- if (eintr_int == NULL) {
- eintr_int = PyLong_FromLong(EINTR);
- assert(eintr_int != NULL);
- }
if (!PyErr_ExceptionMatches(PyExc_OSError))
return 0;
PyErr_Fetch(&typ, &val, &tb);
PyErr_NormalizeException(&typ, &val, &tb);
env_err = (PyOSErrorObject *) val;
assert(env_err != NULL);
- if (env_err->myerrno != NULL &&
- PyObject_RichCompareBool(env_err->myerrno, eintr_int, Py_EQ) > 0) {
- Py_DECREF(typ);
- Py_DECREF(val);
- Py_XDECREF(tb);
- return 1;
+ if (env_err->myerrno != NULL) {
+ assert(EINTR > 0 && EINTR < INT_MAX);
+ assert(PyLong_CheckExact(env_err->myerrno));
+ int overflow;
+ int myerrno = PyLong_AsLongAndOverflow(env_err->myerrno, &overflow);
+ PyErr_Clear();
+ if (myerrno == EINTR) {
+ Py_DECREF(typ);
+ Py_DECREF(val);
+ Py_XDECREF(tb);
+ return 1;
+ }
}
/* This silences any error set by PyObject_RichCompareBool() */
PyErr_Restore(typ, val, tb);