mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
use a invalid name for the __class__ closure for super() (closes #12370)
This prevents the assignment of __class__ in the class body from breaking super. (Although a determined person could do locals()["@__class__"] = 4)
This commit is contained in:
parent
019d0f27a3
commit
f5ff22329b
5 changed files with 26 additions and 10 deletions
|
|
@ -6399,7 +6399,7 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
|
|||
PyObject *name = PyTuple_GET_ITEM(co->co_freevars, i);
|
||||
assert(PyUnicode_Check(name));
|
||||
if (!PyUnicode_CompareWithASCIIString(name,
|
||||
"__class__")) {
|
||||
"@__class__")) {
|
||||
Py_ssize_t index = co->co_nlocals +
|
||||
PyTuple_GET_SIZE(co->co_cellvars) + i;
|
||||
PyObject *cell = f->f_localsplus[index];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue