Kaydet (Commit) 91cc8fb9 authored tarafından Barry Warsaw's avatar Barry Warsaw

Fix for bug 4360 "SystemError when method has both super() & closure". Patch

by amaury.forgeotdarc and reviewed by brett.cannon.

Also add release notes about the known problems with the email package.
üst 2d1ca2db
...@@ -70,6 +70,17 @@ class TestSuper(unittest.TestCase): ...@@ -70,6 +70,17 @@ class TestSuper(unittest.TestCase):
e = E() e = E()
self.assertEqual(e.cm(), (e, (E, (E, (E, 'A'), 'B'), 'C'), 'D')) 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(): def test_main():
support.run_unittest(TestSuper) support.run_unittest(TestSuper)
......
...@@ -6170,8 +6170,9 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds) ...@@ -6170,8 +6170,9 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
assert(PyUnicode_Check(name)); assert(PyUnicode_Check(name));
if (!PyUnicode_CompareWithASCIIString(name, if (!PyUnicode_CompareWithASCIIString(name,
"__class__")) { "__class__")) {
PyObject *cell = Py_ssize_t index = co->co_nlocals +
f->f_localsplus[co->co_nlocals + i]; PyTuple_GET_SIZE(co->co_cellvars) + i;
PyObject *cell = f->f_localsplus[index];
if (cell == NULL || !PyCell_Check(cell)) { if (cell == NULL || !PyCell_Check(cell)) {
PyErr_SetString(PyExc_SystemError, PyErr_SetString(PyExc_SystemError,
"super(): bad __class__ cell"); "super(): bad __class__ cell");
......
...@@ -20,3 +20,10 @@ Additional notes for Python 3.0 final ...@@ -20,3 +20,10 @@ Additional notes for Python 3.0 final
If you need bsddb3 support in Python 3.0, you can find it here: If you need bsddb3 support in Python 3.0, you can find it here:
http://pypi.python.org/pypi/bsddb3 http://pypi.python.org/pypi/bsddb3
* The email package needs quite a bit of work to make it consistent with
respect to bytes and strings. There have been discussions on
email-sig@python.org about where to go with the email package for 3.0, but
this was not resolved in time for 3.0 final. With enough care though, the
email package in Python 3.0 should be about as usable as it is with Python
2.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment