Skip to content

Commit 19f5f29

Browse files
Eliminate eintr_int.
1 parent e3bd40e commit 19f5f29

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

Modules/_io/bufferedio.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -746,26 +746,26 @@ _buffered_init(buffered *self)
746746
int
747747
_PyIO_trap_eintr(void)
748748
{
749-
static PyObject *eintr_int = NULL;
750749
PyObject *typ, *val, *tb;
751750
PyOSErrorObject *env_err;
752-
753-
if (eintr_int == NULL) {
754-
eintr_int = PyLong_FromLong(EINTR);
755-
assert(eintr_int != NULL);
756-
}
757751
if (!PyErr_ExceptionMatches(PyExc_OSError))
758752
return 0;
759753
PyErr_Fetch(&typ, &val, &tb);
760754
PyErr_NormalizeException(&typ, &val, &tb);
761755
env_err = (PyOSErrorObject *) val;
762756
assert(env_err != NULL);
763-
if (env_err->myerrno != NULL &&
764-
PyObject_RichCompareBool(env_err->myerrno, eintr_int, Py_EQ) > 0) {
765-
Py_DECREF(typ);
766-
Py_DECREF(val);
767-
Py_XDECREF(tb);
768-
return 1;
757+
if (env_err->myerrno != NULL) {
758+
assert(EINTR > 0 && EINTR < INT_MAX);
759+
assert(PyLong_CheckExact(env_err->myerrno));
760+
int overflow;
761+
int myerrno = PyLong_AsLongAndOverflow(env_err->myerrno, &overflow);
762+
PyErr_Clear();
763+
if (myerrno == EINTR) {
764+
Py_DECREF(typ);
765+
Py_DECREF(val);
766+
Py_XDECREF(tb);
767+
return 1;
768+
}
769769
}
770770
/* This silences any error set by PyObject_RichCompareBool() */
771771
PyErr_Restore(typ, val, tb);

Tools/c-analyzer/cpython/globals-to-fix.tsv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@ Modules/faulthandler.c - old_stack -
393393
##-----------------------
394394
## initialized once
395395

396-
Modules/_io/bufferedio.c _PyIO_trap_eintr eintr_int -
397396
Modules/posixmodule.c os_dup2_impl dup3_works -
398397
Modules/posixmodule.c - structseq_new -
399398
Modules/posixmodule.c - ticks_per_second -

0 commit comments

Comments
 (0)