summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-01-12 15:49:47 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-01-12 15:49:47 (GMT)
commit9b911ca14d4897e517276cb9729ecc6ad6c178db (patch)
treef7809013eaadfe8169474e5bc112e65df1ea0159 /Objects
parent0551144b3567de99eb8668284b37050e33df8eab (diff)
downloadcpython-9b911ca14d4897e517276cb9729ecc6ad6c178db.zip
cpython-9b911ca14d4897e517276cb9729ecc6ad6c178db.tar.gz
cpython-9b911ca14d4897e517276cb9729ecc6ad6c178db.tar.bz2
Merged revisions 87952-87954 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r87952 | benjamin.peterson | 2011-01-12 09:24:27 -0600 (Wed, 12 Jan 2011) | 1 line move this test to test_descr; it's not abc specific ........ r87953 | benjamin.peterson | 2011-01-12 09:25:02 -0600 (Wed, 12 Jan 2011) | 1 line oops, wrong class ........ r87954 | benjamin.peterson | 2011-01-12 09:34:01 -0600 (Wed, 12 Jan 2011) | 1 line don't segfault on deleting __abstractmethods__ #10892 ........
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 7a11796..84a755a 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -327,8 +327,17 @@ type_set_abstractmethods(PyTypeObject *type, PyObject *value, void *context)
abc.ABCMeta.__new__, so this function doesn't do anything
special to update subclasses.
*/
- int res = PyDict_SetItemString(type->tp_dict,
- "__abstractmethods__", value);
+ int res;
+ if (value != NULL) {
+ res = PyDict_SetItemString(type->tp_dict, "__abstractmethods__", value);
+ }
+ else {
+ res = PyDict_DelItemString(type->tp_dict, "__abstractmethods__");
+ if (res && PyErr_ExceptionMatches(PyExc_KeyError)) {
+ PyErr_Format(PyExc_AttributeError, "__abstractmethods__", value);
+ return -1;
+ }
+ }
if (res == 0) {
PyType_Modified(type);
if (value && PyObject_IsTrue(value)) {