Patch #517521: Consider byte strings before Unicode strings
in PyObject_Get/SetAttr.
This commit is contained in:
parent
e5363b7de5
commit
0c160a08f2
|
@ -1085,6 +1085,7 @@ PyObject_GetAttr(PyObject *v, PyObject *name)
|
|||
{
|
||||
PyTypeObject *tp = v->ob_type;
|
||||
|
||||
if (!PyString_Check(name)) {
|
||||
#ifdef Py_USING_UNICODE
|
||||
/* The Unicode to string conversion is done here because the
|
||||
existing tp_getattro slots expect a string object as name
|
||||
|
@ -1096,11 +1097,12 @@ PyObject_GetAttr(PyObject *v, PyObject *name)
|
|||
}
|
||||
else
|
||||
#endif
|
||||
if (!PyString_Check(name)) {
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"attribute name must be string");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (tp->tp_getattro != NULL)
|
||||
return (*tp->tp_getattro)(v, name);
|
||||
if (tp->tp_getattr != NULL)
|
||||
|
@ -1129,6 +1131,7 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
|
|||
PyTypeObject *tp = v->ob_type;
|
||||
int err;
|
||||
|
||||
if (!PyString_Check(name)){
|
||||
#ifdef Py_USING_UNICODE
|
||||
/* The Unicode to string conversion is done here because the
|
||||
existing tp_setattro slots expect a string object as name
|
||||
|
@ -1140,11 +1143,12 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
|
|||
}
|
||||
else
|
||||
#endif
|
||||
if (!PyString_Check(name)){
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"attribute name must be string");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
Py_INCREF(name);
|
||||
|
||||
|
@ -1217,6 +1221,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
|
|||
descrgetfunc f;
|
||||
PyObject **dictptr;
|
||||
|
||||
if (!PyString_Check(name)){
|
||||
#ifdef Py_USING_UNICODE
|
||||
/* The Unicode to string conversion is done here because the
|
||||
existing tp_setattro slots expect a string object as name
|
||||
|
@ -1228,11 +1233,12 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
|
|||
}
|
||||
else
|
||||
#endif
|
||||
if (!PyString_Check(name)){
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"attribute name must be string");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
Py_INCREF(name);
|
||||
|
||||
|
@ -1291,6 +1297,7 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
|
|||
PyObject **dictptr;
|
||||
int res = -1;
|
||||
|
||||
if (!PyString_Check(name)){
|
||||
#ifdef Py_USING_UNICODE
|
||||
/* The Unicode to string conversion is done here because the
|
||||
existing tp_setattro slots expect a string object as name
|
||||
|
@ -1302,11 +1309,12 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
|
|||
}
|
||||
else
|
||||
#endif
|
||||
if (!PyString_Check(name)){
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"attribute name must be string");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
Py_INCREF(name);
|
||||
|
||||
|
|
Loading…
Reference in New Issue