summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-11-06 17:59:18 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-11-06 17:59:18 (GMT)
commit3688aa9a0417b5fbe94510da4a078c3ac3c481e0 (patch)
tree581e358fa392433b02a3cad1ae1b6570ed887e60 /Objects
parent5fd2e5ae8ae3dfaaf96d9771eb6f3fcacc4d3b31 (diff)
downloadcpython-3688aa9a0417b5fbe94510da4a078c3ac3c481e0.zip
cpython-3688aa9a0417b5fbe94510da4a078c3ac3c481e0.tar.gz
cpython-3688aa9a0417b5fbe94510da4a078c3ac3c481e0.tar.bz2
Issue #19512: type_abstractmethods() and type_set_abstractmethods() now use an
identifier for the "__abstractmethods__" string
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 309afa4..02ad0b7 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -48,6 +48,7 @@ _Py_IDENTIFIER(__hash__);
_Py_IDENTIFIER(__module__);
_Py_IDENTIFIER(__name__);
_Py_IDENTIFIER(__new__);
+_Py_IDENTIFIER(__abstractmethods__);
static PyObject *
slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
@@ -383,9 +384,11 @@ type_abstractmethods(PyTypeObject *type, void *context)
/* type itself has an __abstractmethods__ descriptor (this). Don't return
that. */
if (type != &PyType_Type)
- mod = PyDict_GetItemString(type->tp_dict, "__abstractmethods__");
+ mod = _PyDict_GetItemId(type->tp_dict, &PyId___abstractmethods__);
if (!mod) {
- PyErr_SetString(PyExc_AttributeError, "__abstractmethods__");
+ PyObject *message = _PyUnicode_FromId(&PyId___abstractmethods__);
+ if (message)
+ PyErr_SetObject(PyExc_AttributeError, message);
return NULL;
}
Py_XINCREF(mod);
@@ -404,13 +407,15 @@ type_set_abstractmethods(PyTypeObject *type, PyObject *value, void *context)
abstract = PyObject_IsTrue(value);
if (abstract < 0)
return -1;
- res = PyDict_SetItemString(type->tp_dict, "__abstractmethods__", value);
+ res = _PyDict_SetItemId(type->tp_dict, &PyId___abstractmethods__, value);
}
else {
abstract = 0;
- res = PyDict_DelItemString(type->tp_dict, "__abstractmethods__");
+ res = _PyDict_DelItemId(type->tp_dict, &PyId___abstractmethods__);
if (res && PyErr_ExceptionMatches(PyExc_KeyError)) {
- PyErr_SetString(PyExc_AttributeError, "__abstractmethods__");
+ PyObject *message = _PyUnicode_FromId(&PyId___abstractmethods__);
+ if (message)
+ PyErr_SetObject(PyExc_AttributeError, message);
return -1;
}
}