Skip to content

Commit 4ec41ed

Browse files
committed
re-add 201 fix
1 parent 3f2c1d2 commit 4ec41ed

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

yappi/_yappi.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,15 +613,21 @@ _ccode2pit(void *cco, uintptr_t current_tag)
613613
name = PyStr_FromString(cfn->m_ml->ml_name);
614614
if (name != NULL) {
615615
obj_type = PyObject_Type(cfn->m_self);
616+
if (obj_type == NULL) {
617+
PyErr_Clear();
618+
Py_DECREF(name);
619+
goto fallback_name;
620+
}
616621

617622
// use method descriptor instead of instance methods for builtin
618-
// objects. Othwerwise, there might be some errors since we INCREF
623+
// objects. Otherwise, there might be some errors since we INCREF
619624
// on the bound method. See: https://github.com/sumerc/yappi/issues/60
620625
method_descriptor = PyObject_GetAttr(obj_type, name);
621626
if (method_descriptor) {
622627
pit->fn_descriptor = method_descriptor;
623628
Py_INCREF(method_descriptor);
624629
}
630+
PyErr_Clear();
625631

626632
// get name from type+name
627633
mo = _PyType_Lookup((PyTypeObject *)obj_type, name);
@@ -637,6 +643,7 @@ _ccode2pit(void *cco, uintptr_t current_tag)
637643
PyErr_Clear();
638644
}
639645

646+
fallback_name:
640647
if (pit->fn_descriptor == NULL) {
641648
pit->fn_descriptor = (PyObject *)cfn;
642649
Py_INCREF(cfn);

0 commit comments

Comments
 (0)