diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-02-27 17:56:22 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-02-27 17:56:22 (GMT) |
commit | 1ca73ede26e05b656787122fea3ce9bd01a5f7f7 (patch) | |
tree | c11a10410920180770bdf012794f9bf9d81b4725 /Python/bltinmodule.c | |
parent | b7f27ff9ac4f594c7ec3fe2cca44725cb36ffb2d (diff) | |
download | cpython-1ca73ede26e05b656787122fea3ce9bd01a5f7f7.zip cpython-1ca73ede26e05b656787122fea3ce9bd01a5f7f7.tar.gz cpython-1ca73ede26e05b656787122fea3ce9bd01a5f7f7.tar.bz2 |
Merged revisions 78505-78506 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r78505 | benjamin.peterson | 2010-02-27 11:40:01 -0600 (Sat, 27 Feb 2010) | 1 line
only accept AttributeError as indicating no __prepare__ attribute on a metaclass, allowing lookup errors to propogate
........
r78506 | benjamin.peterson | 2010-02-27 11:41:13 -0600 (Sat, 27 Feb 2010) | 1 line
check PyDict_New() for error
........
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index e03b49f..069d790 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -108,8 +108,16 @@ builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds) } prep = PyObject_GetAttrString(meta, "__prepare__"); if (prep == NULL) { - PyErr_Clear(); - ns = PyDict_New(); + if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + ns = PyDict_New(); + } + else { + Py_DECREF(meta); + Py_XDECREF(mkw); + Py_DECREF(bases); + return NULL; + } } else { PyObject *pargs = PyTuple_Pack(2, name, bases); @@ -123,12 +131,12 @@ builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds) ns = PyEval_CallObjectWithKeywords(prep, pargs, mkw); Py_DECREF(pargs); Py_DECREF(prep); - if (ns == NULL) { - Py_DECREF(meta); - Py_XDECREF(mkw); - Py_DECREF(bases); - return NULL; - } + } + if (ns == NULL) { + Py_DECREF(meta); + Py_XDECREF(mkw); + Py_DECREF(bases); + return NULL; } cell = PyObject_CallFunctionObjArgs(func, ns, NULL); if (cell != NULL) { |