bpo-33724: Use the right format code for int64_t in subinterpreters code. by ericsnowcurrently · Pull Request #7330 · python/cpython
static int64_t _coerce_id(PyObject *id) _coerce_id(PyObject *orig) { id = PyNumber_Long(id); if (id == NULL) { PyObject *pyid = PyNumber_Long(orig); if (pyid == NULL) { if (PyErr_ExceptionMatches(PyExc_TypeError)) { PyErr_SetString(PyExc_TypeError, "'id' must be a non-negative int"); PyErr_Format(PyExc_TypeError, "'id' must be a non-negative int, got %R", orig); } else { PyErr_SetString(PyExc_ValueError, "'id' must be a non-negative int"); PyErr_Format(PyExc_ValueError, "'id' must be a non-negative int, got %R", orig); } return -1; } int64_t cid = PyLong_AsLongLong(id); Py_DECREF(id); if (cid == -1 && PyErr_Occurred() != NULL) { int64_t id = PyLong_AsLongLong(pyid); Py_DECREF(pyid); if (id == -1 && PyErr_Occurred() != NULL) { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) { PyErr_SetString(PyExc_ValueError, "'id' must be a non-negative int"); PyErr_Format(PyExc_ValueError, "'id' must be a non-negative int, got %R", orig); } return -1; } if (cid < 0) { PyErr_SetString(PyExc_ValueError, "'id' must be a non-negative int"); if (id < 0) { PyErr_Format(PyExc_ValueError, "'id' must be a non-negative int, got %R", orig); return -1; } return cid; return id; }
_channelref *ref = _channelref_find(channels->head, id, NULL); if (ref == NULL) { PyErr_Format(ChannelNotFoundError, "channel %d not found", id); PyErr_Format(ChannelNotFoundError, "channel %lld not found", id); goto done; } if (ref->chan == NULL || !ref->chan->open) { PyErr_Format(ChannelClosedError, "channel %d closed", id); PyErr_Format(ChannelClosedError, "channel %lld closed", id); goto done; }
_channelref *ref = _channelref_find(channels->head, cid, NULL); if (ref == NULL) { PyErr_Format(ChannelNotFoundError, "channel %d not found", cid); PyErr_Format(ChannelNotFoundError, "channel %lld not found", cid); goto done; }
if (ref->chan == NULL) { PyErr_Format(ChannelClosedError, "channel %d closed", cid); PyErr_Format(ChannelClosedError, "channel %lld closed", cid); goto done; } else if (!force && end == CHANNEL_SEND && ref->chan->closing != NULL) { PyErr_Format(ChannelClosedError, "channel %d closed", cid); PyErr_Format(ChannelClosedError, "channel %lld closed", cid); goto done; } else { if (_channel_close_all(ref->chan, end, force) != 0) { if (end == CHANNEL_SEND && PyErr_ExceptionMatches(ChannelNotEmptyError)) { if (ref->chan->closing != NULL) { PyErr_Format(ChannelClosedError, "channel %d closed", cid); PyErr_Format(ChannelClosedError, "channel %lld closed", cid); goto done; } // Mark the channel as closing and return. The channel
_channelref *ref = _channelref_find(channels->head, id, NULL); if (ref == NULL) { PyErr_Format(ChannelNotFoundError, "channel %d not found", id); PyErr_Format(ChannelNotFoundError, "channel %lld not found", id); goto done; } ref->objcount += 1;
if (chan->closing != NULL) { PyErr_Format(ChannelClosedError, "channel %d closed", id); PyErr_Format(ChannelClosedError, "channel %lld closed", id); PyThread_release_lock(mutex); return -1; }
PyObject *
static PyObject * interpid_str(PyObject *self) { interpid *id = (interpid *)self; return PyUnicode_FromFormat("%d", id->id); return PyUnicode_FromFormat("%lld", id->id); }
PyObject *