Commit b679d358 authored by Kevin Modzelewski's avatar Kevin Modzelewski

That old check was silly and broken anyway; just use a blacklist now

parent 3b67736b
...@@ -1140,26 +1140,26 @@ extern "C" int PyType_Ready(PyTypeObject* cls) { ...@@ -1140,26 +1140,26 @@ extern "C" int PyType_Ready(PyTypeObject* cls) {
RELEASE_ASSERT(cls->tp_setattr == NULL, ""); RELEASE_ASSERT(cls->tp_setattr == NULL, "");
RELEASE_ASSERT(cls->tp_compare == NULL, ""); RELEASE_ASSERT(cls->tp_compare == NULL, "");
// Hacky way to assert that only tp_as_number slots we support are getting set:
// zero out the ones we know about, then assert that the entire struct
// is zero, then restore the ones we know about.
if (cls->tp_as_number) { if (cls->tp_as_number) {
#define SAVE(N) \ auto num = cls->tp_as_number;
auto N = cls->tp_as_number->N; \ // Members not added yet:
cls->tp_as_number->N = NULL; assert(num->nb_coerce == NULL);
#define RESTORE(N) cls->tp_as_number->N = N; assert(num->nb_inplace_add == NULL);
assert(num->nb_inplace_subtract == NULL);
SAVE(nb_nonzero); assert(num->nb_inplace_multiply == NULL);
SAVE(nb_add); assert(num->nb_inplace_divide == NULL);
assert(num->nb_inplace_remainder == NULL);
for (void** p = (void**)cls->tp_as_number; p < (void**)(cls->tp_as_number + 1); p++) { assert(num->nb_inplace_power == NULL);
// RELEASE_ASSERT(*p == NULL, ""); assert(num->nb_inplace_lshift == NULL);
} assert(num->nb_inplace_rshift == NULL);
assert(num->nb_inplace_and == NULL);
RESTORE(nb_nonzero); assert(num->nb_inplace_xor == NULL);
RESTORE(nb_add) assert(num->nb_inplace_or == NULL);
#undef SAVE assert(num->nb_floor_divide == NULL);
#undef RESTORE assert(num->nb_true_divide == NULL);
assert(num->nb_inplace_floor_divide == NULL);
assert(num->nb_inplace_true_divide == NULL);
assert(num->nb_index == NULL);
} }
RELEASE_ASSERT(cls->tp_getattro == NULL || cls->tp_getattro == PyObject_GenericGetAttr, ""); RELEASE_ASSERT(cls->tp_getattro == NULL || cls->tp_getattro == PyObject_GenericGetAttr, "");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment