}
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 (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 *prev = NULL;
_channelref *ref = _channelref_find(channels->head, id, &prev);
if (ref == NULL) {
- PyErr_Format(ChannelNotFoundError, "channel %d not found", id);
+ PyErr_Format(ChannelNotFoundError, "channel %lld not found", id);
goto done;
}
_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;
// Past this point we are responsible for releasing the mutex.
if (chan->closing != NULL) {
- PyErr_Format(ChannelClosedError, "channel %d closed", id);
+ PyErr_Format(ChannelClosedError, "channel %lld closed", id);
PyThread_release_lock(mutex);
return -1;
}
PyThread_release_lock(mutex);
if (data == NULL) {
if (!PyErr_Occurred()) {
- PyErr_Format(ChannelEmptyError, "channel %d is empty", id);
+ PyErr_Format(ChannelEmptyError, "channel %lld is empty", id);
}
return NULL;
}
channelid *cid = (channelid *)self;
const char *fmt;
if (cid->end == CHANNEL_SEND) {
- fmt = "%s(%d, send=True)";
+ fmt = "%s(%lld, send=True)";
}
else if (cid->end == CHANNEL_RECV) {
- fmt = "%s(%d, recv=True)";
+ fmt = "%s(%lld, recv=True)";
}
else {
- fmt = "%s(%d)";
+ fmt = "%s(%lld)";
}
return PyUnicode_FromFormat(fmt, name, cid->id);
}
channelid_str(PyObject *self)
{
channelid *cid = (channelid *)self;
- return PyUnicode_FromFormat("%d", cid->id);
+ return PyUnicode_FromFormat("%lld", cid->id);
}
PyObject *
PyTypeObject *type = Py_TYPE(self);
const char *name = _PyType_Name(type);
interpid *id = (interpid *)self;
- return PyUnicode_FromFormat("%s(%d)", name, id->id);
+ return PyUnicode_FromFormat("%s(%lld)", name, id->id);
}
static PyObject *
interpid_str(PyObject *self)
{
interpid *id = (interpid *)self;
- return PyUnicode_FromFormat("%d", id->id);
+ return PyUnicode_FromFormat("%lld", id->id);
}
PyObject *