mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
check to make sure the attribute is a string (#14334)
This commit is contained in:
parent
3fb05a90ce
commit
16d84ac355
3 changed files with 13 additions and 0 deletions
|
|
@ -2462,6 +2462,13 @@ type_getattro(PyTypeObject *type, PyObject *name)
|
|||
PyObject *meta_attribute, *attribute;
|
||||
descrgetfunc meta_get;
|
||||
|
||||
if (!PyUnicode_Check(name)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"attribute name must be string, not '%.200s'",
|
||||
name->ob_type->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Initialize this type (we'll assume the metatype is initialized) */
|
||||
if (type->tp_dict == NULL) {
|
||||
if (PyType_Ready(type) < 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue