@@ -1185,12 +1185,15 @@ channelid_richcompare(PyObject *self, PyObject *other, int op)
1185
1185
Py_RETURN_NOTIMPLEMENTED ;
1186
1186
}
1187
1187
1188
- int64_t cid = (( channelid * )self ) -> id ;
1189
- int64_t othercid ;
1188
+ channelid * cid = (channelid * )self ;
1189
+ int equal ;
1190
1190
if (PyObject_TypeCheck (other , & ChannelIDtype )) {
1191
- othercid = ((channelid * )other )-> id ;
1192
- if (((channelid * )other )-> end != ((channelid * )self )-> end ) {
1193
- Py_RETURN_FALSE ;
1191
+ channelid * othercid = (channelid * )other ;
1192
+ if (cid -> end != othercid -> end ) {
1193
+ equal = 0 ;
1194
+ }
1195
+ else {
1196
+ equal = (cid -> id == othercid -> id );
1194
1197
}
1195
1198
}
1196
1199
else {
@@ -1199,15 +1202,23 @@ channelid_richcompare(PyObject *self, PyObject *other, int op)
1199
1202
PyErr_Clear ();
1200
1203
Py_RETURN_NOTIMPLEMENTED ;
1201
1204
}
1202
- othercid = PyLong_AsLongLong (other );
1205
+ int64_t othercid = PyLong_AsLongLong (other );
1206
+ // XXX decref other here?
1203
1207
if (othercid == -1 && PyErr_Occurred () != NULL ) {
1204
1208
return NULL ;
1205
1209
}
1206
1210
if (othercid < 0 || othercid > INT64_MAX ) {
1207
- Py_RETURN_FALSE ;
1211
+ equal = 0 ;
1212
+ }
1213
+ else {
1214
+ equal = (cid -> id == othercid );
1208
1215
}
1209
1216
}
1210
- Py_RETURN_RICHCOMPARE (othercid != cid , 0 , op );
1217
+
1218
+ if ((op == Py_EQ && equal ) || (op == Py_NE && !equal )) {
1219
+ Py_RETURN_TRUE ;
1220
+ }
1221
+ Py_RETURN_FALSE ;
1211
1222
}
1212
1223
1213
1224
struct _channelid_xid {
@@ -1477,7 +1488,7 @@ _run_script_in_interpreter(PyInterpreterState *interp, const char *codestr,
1477
1488
hold PyObject values. */
1478
1489
static struct globals {
1479
1490
_channels channels ;
1480
- } _globals = {0 };
1491
+ } _globals = {{ 0 } };
1481
1492
1482
1493
static int
1483
1494
_init_globals (void )
0 commit comments