diff -r 218e28a935ab Lib/test/test_py3kwarn.py --- a/Lib/test/test_py3kwarn.py Sat Apr 12 09:31:28 2014 -0700 +++ b/Lib/test/test_py3kwarn.py Mon Apr 14 23:00:38 2014 -0400 @@ -78,7 +78,7 @@ safe_exec("def {0}(): pass".format(keyword)) self.assertWarning(None, w, expected) w.reset() - safe_exec("class {0}: pass".format(keyword)) + safe_exec("class {0}(object): pass".format(keyword)) self.assertWarning(None, w, expected) w.reset() safe_exec("def f({0}=43): pass".format(keyword)) @@ -307,6 +307,14 @@ w.reset() self.assertWarning(sequenceIncludes(range(3), 2), w, seq_warn) + def test_oldstyle_class(self): + expected = ('Old-style classes are removed in 3.x. All classes should ' + 'subclass object.') + def check(s): + with check_py3k_warnings((expected, DeprecationWarning)): + exec s in {} + check("class X: pass") + class TestStdlibRemovals(unittest.TestCase): diff -r 218e28a935ab Python/ceval.c --- a/Python/ceval.c Sat Apr 12 09:31:28 2014 -0700 +++ b/Python/ceval.c Mon Apr 14 23:00:38 2014 -0400 @@ -4625,6 +4625,10 @@ if (g != NULL && PyDict_Check(g)) metaclass = PyDict_GetItemString(g, "__metaclass__"); if (metaclass == NULL) + if (PyErr_WarnPy3k("Old-style classes are removed in 3.x. All " + "classes should subclass object.", 0) < 0) { + return NULL; + } metaclass = (PyObject *) &PyClass_Type; Py_INCREF(metaclass); }