Commit a20593e8 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Special refcounting exemption for buggy extensions

google's protobuf library gives away one too many refs to one of its types.

This workaround feels excessively specific, but this is a common mistake to
make, and it works just fine in CPython, so let people get away with it
as well in Pyston.
parent 3e10ff4d
......@@ -4847,7 +4847,15 @@ extern "C" void Py_Finalize() noexcept {
b->getHCAttrsPtr()->_clearRaw();
Py_CLEAR(b->tp_mro);
}
Py_DECREF(b);
// Try to support extensions that get away with having one-too-few refs to their class
// (such as google protobufs)
if (b->ob_refcnt == 0) {
RELEASE_ASSERT(!b->is_pyston_class, "%s", b->tp_name);
RELEASE_ASSERT((b->tp_flags & Py_TPFLAGS_HEAPTYPE) == 0, "%s", b->tp_name);
} else {
Py_DECREF(b);
}
}
clearAllICs();
......
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