aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-05-20 08:48:12 +0300
committerGitHub <noreply@github.com>2018-05-20 08:48:12 +0300
commitf5e7b1999f46e592d42dfab51563ea5411946fb7 (patch)
tree3001498a55273fc45ac4d2c7b393190d4d2dbd42 /Python/bltinmodule.c
parentbpo-23722: Fix docs for future __classcell__ changes. (GH-6999) (diff)
downloadcpython-f5e7b1999f46e592d42dfab51563ea5411946fb7.tar.gz
cpython-f5e7b1999f46e592d42dfab51563ea5411946fb7.tar.bz2
cpython-f5e7b1999f46e592d42dfab51563ea5411946fb7.zip
bpo-23722: Raise a RuntimeError for absent __classcell__. (GH-6931)
A DeprecationWarning was emitted in Python 3.6-3.7.
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r--Python/bltinmodule.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 839258b8749..88a4bf991d8 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -254,30 +254,19 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs,
if (cls != NULL && PyType_Check(cls) && PyCell_Check(cell)) {
PyObject *cell_cls = PyCell_GET(cell);
if (cell_cls != cls) {
- /* TODO: In 3.7, DeprecationWarning will become RuntimeError.
- * At that point, cell_error won't be needed.
- */
- int cell_error;
if (cell_cls == NULL) {
const char *msg =
"__class__ not set defining %.200R as %.200R. "
"Was __classcell__ propagated to type.__new__?";
- cell_error = PyErr_WarnFormat(
- PyExc_DeprecationWarning, 1, msg, name, cls);
+ PyErr_Format(PyExc_RuntimeError, msg, name, cls);
} else {
const char *msg =
"__class__ set to %.200R defining %.200R as %.200R";
PyErr_Format(PyExc_TypeError, msg, cell_cls, name, cls);
- cell_error = 1;
- }
- if (cell_error) {
- Py_DECREF(cls);
- cls = NULL;
- goto error;
- } else {
- /* Fill in the cell, since type.__new__ didn't do it */
- PyCell_Set(cell, cls);
}
+ Py_DECREF(cls);
+ cls = NULL;
+ goto error;
}
}
}