gh-103712: Increase the length of the type name in AttributeError messages (#103713)

This commit is contained in:
Alex Gaynor 2023-04-24 08:23:08 -06:00 committed by GitHub
parent 59c522f965
commit 543009347e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View File

@ -337,7 +337,7 @@ Here is an example::
} }
PyErr_Format(PyExc_AttributeError, PyErr_Format(PyExc_AttributeError,
"'%.50s' object has no attribute '%.400s'", "'%.100s' object has no attribute '%.400s'",
tp->tp_name, name); tp->tp_name, name);
return NULL; return NULL;
} }

View File

@ -946,7 +946,7 @@ local_setattro(localobject *self, PyObject *name, PyObject *v)
} }
if (r == 1) { if (r == 1) {
PyErr_Format(PyExc_AttributeError, PyErr_Format(PyExc_AttributeError,
"'%.50s' object attribute '%U' is read-only", "'%.100s' object attribute '%U' is read-only",
Py_TYPE(self)->tp_name, name); Py_TYPE(self)->tp_name, name);
return -1; return -1;
} }

View File

@ -1033,7 +1033,7 @@ PyObject_GetAttr(PyObject *v, PyObject *name)
} }
else { else {
PyErr_Format(PyExc_AttributeError, PyErr_Format(PyExc_AttributeError,
"'%.50s' object has no attribute '%U'", "'%.100s' object has no attribute '%U'",
tp->tp_name, name); tp->tp_name, name);
} }
@ -1353,7 +1353,7 @@ _PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method)
} }
PyErr_Format(PyExc_AttributeError, PyErr_Format(PyExc_AttributeError,
"'%.50s' object has no attribute '%U'", "'%.100s' object has no attribute '%U'",
tp->tp_name, name); tp->tp_name, name);
set_attribute_error_context(obj, name); set_attribute_error_context(obj, name);
@ -1474,7 +1474,7 @@ _PyObject_GenericGetAttrWithDict(PyObject *obj, PyObject *name,
if (!suppress) { if (!suppress) {
PyErr_Format(PyExc_AttributeError, PyErr_Format(PyExc_AttributeError,
"'%.50s' object has no attribute '%U'", "'%.100s' object has no attribute '%U'",
tp->tp_name, name); tp->tp_name, name);
set_attribute_error_context(obj, name); set_attribute_error_context(obj, name);
@ -1545,7 +1545,7 @@ _PyObject_GenericSetAttrWithDict(PyObject *obj, PyObject *name,
} }
else { else {
PyErr_Format(PyExc_AttributeError, PyErr_Format(PyExc_AttributeError,
"'%.50s' object attribute '%U' is read-only", "'%.100s' object attribute '%U' is read-only",
tp->tp_name, name); tp->tp_name, name);
} }
goto done; goto done;

View File

@ -4328,7 +4328,7 @@ _Py_type_getattro_impl(PyTypeObject *type, PyObject *name, int * suppress_missin
/* Give up */ /* Give up */
if (suppress_missing_attribute == NULL) { if (suppress_missing_attribute == NULL) {
PyErr_Format(PyExc_AttributeError, PyErr_Format(PyExc_AttributeError,
"type object '%.50s' has no attribute '%U'", "type object '%.100s' has no attribute '%U'",
type->tp_name, name); type->tp_name, name);
} else { } else {
// signal the caller we have not set an PyExc_AttributeError and gave up // signal the caller we have not set an PyExc_AttributeError and gave up