Skip to content

Commit f28f1d5

Browse files
committed
Clearer goto name + extra assert
1 parent 404359d commit f28f1d5

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Objects/exceptions.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2731,6 +2731,7 @@ AttributeError_str(PyObject *op)
27312731
Py_END_CRITICAL_SECTION();
27322732

27332733
if (!obj) {
2734+
assert(!name);
27342735
return BaseException_str(op); /* re-acquires lock */
27352736
}
27362737

@@ -2739,7 +2740,7 @@ AttributeError_str(PyObject *op)
27392740
PyModuleObject *mod = _PyModule_CAST(obj);
27402741
PyObject *modname;
27412742
if (PyDict_GetItemRef(mod->md_dict, &_Py_ID(__name__), &modname) < 0) {
2742-
goto error;
2743+
goto done;
27432744
}
27442745
if (modname && PyUnicode_Check(modname)) {
27452746
result = PyUnicode_FromFormat("module '%U' has no attribute '%U'",
@@ -2756,7 +2757,7 @@ AttributeError_str(PyObject *op)
27562757
result = PyUnicode_FromFormat("'%T' object has no attribute '%U'",
27572758
obj, name);
27582759
}
2759-
error:
2760+
done:
27602761
Py_DECREF(obj);
27612762
Py_DECREF(name);
27622763
return result;

0 commit comments

Comments
 (0)