summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-03-16 14:32:59 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-03-16 14:32:59 (GMT)
commit6e7832b04caf33196a56c153821631d33bbb3bff (patch)
tree3f75dbefc12a38a02432b9ecfc4b5e1029eb3acd /Objects
parent51a65c91611aa7deb222f24ad2c94021910b7a54 (diff)
downloadcpython-6e7832b04caf33196a56c153821631d33bbb3bff.zip
cpython-6e7832b04caf33196a56c153821631d33bbb3bff.tar.gz
cpython-6e7832b04caf33196a56c153821631d33bbb3bff.tar.bz2
check to make sure the attribute is a string (#14334)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index ce1d42b..877bcb7 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2530,6 +2530,13 @@ type_getattro(PyTypeObject *type, PyObject *name)
PyObject *meta_attribute, *attribute;
descrgetfunc meta_get;
+ if (!PyString_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)