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)
commit16d84ac355c532a1e7d25cf75e0b577923de2856 (patch)
tree975ca5f98cf91f599673cf4a9e7477d11667b989 /Objects
parent3fb05a90cefe29bad82c87336fa32de36e6add3d (diff)
downloadcpython-16d84ac355c532a1e7d25cf75e0b577923de2856.zip
cpython-16d84ac355c532a1e7d25cf75e0b577923de2856.tar.gz
cpython-16d84ac355c532a1e7d25cf75e0b577923de2856.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 e006694..f0c787f 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -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)