Index: Objects/typeobject.c =================================================================== --- Objects/typeobject.c (revision 67045) +++ Objects/typeobject.c (working copy) @@ -6137,8 +6137,9 @@ assert(PyUnicode_Check(name)); if (!PyUnicode_CompareWithASCIIString(name, "__class__")) { - PyObject *cell = - f->f_localsplus[co->co_nlocals + i]; + Py_ssize_t index = co->co_nlocals + + PyTuple_GET_SIZE(co->co_cellvars) + i; + PyObject *cell = f->f_localsplus[index]; if (cell == NULL || !PyCell_Check(cell)) { PyErr_SetString(PyExc_SystemError, "super(): bad __class__ cell"); Index: Lib/test/test_super.py =================================================================== --- Lib/test/test_super.py (revision 67045) +++ Lib/test/test_super.py (working copy) @@ -70,7 +70,18 @@ e = E() self.assertEqual(e.cm(), (e, (E, (E, (E, 'A'), 'B'), 'C'), 'D')) + def testSuperWithClosure(self): + # Issue4360: super() did not work in a function that + # contains a closure + class E(A): + def f(self): + def nested(): + self + return super().f() + 'E' + self.assertEqual(E().f(), 'AE') + + def test_main(): support.run_unittest(TestSuper)