diff options
-rw-r--r-- | Lib/test/test_descr.py | 10 | ||||
-rw-r--r-- | Objects/typeobject.c | 4 |
2 files changed, 13 insertions, 1 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 1ec7c19..ea987f2 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -922,6 +922,16 @@ def multi(): vereq(m.m3method(), "M3 a") vereq(m.all_method(), "M3 b") + class Classic: + pass + try: + class New(Classic): + __metaclass__ = type + except TypeError: + pass + else: + raise TestFailed, "new class with only classic bases - shouldn't be" + def diamond(): if verbose: print "Testing multiple inheritance special cases..." class A(object): diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 6243e81..ba30063 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -757,7 +757,9 @@ best_base(PyObject *bases) return NULL; } } - assert(base != NULL); + if (base == NULL) + PyErr_SetString(PyExc_TypeError, + "a new-style class can't have only classic bases"); return base; } |