Mercurial > cpython-lru_cache-weakref
diff Objects/typeobject.c @ 67550:2ea1cfdf929b 3.1
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
........
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Wed, 12 Jan 2011 15:42:34 +0000 |
| parents | b9e26b0c4617 |
| children | 6cc5277f5e7a |
line wrap: on
line diff
--- a/Objects/typeobject.c Wed Jan 12 04:51:02 2011 +0000 +++ b/Objects/typeobject.c Wed Jan 12 15:42:34 2011 +0000 @@ -340,8 +340,17 @@ 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)) {
