[Python-3000-checkins] r67299 - in python/branches/py3k: Lib/test/test_super.py Objects/typeobject.c RELNOTES

barry.warsaw python-3000-checkins at python.org
Thu Nov 20 21:01:58 CET 2008


Author: barry.warsaw
Date: Thu Nov 20 21:01:57 2008
New Revision: 67299

Log:
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.


Modified:
   python/branches/py3k/Lib/test/test_super.py
   python/branches/py3k/Objects/typeobject.c
   python/branches/py3k/RELNOTES

Modified: python/branches/py3k/Lib/test/test_super.py
==============================================================================
--- python/branches/py3k/Lib/test/test_super.py	(original)
+++ python/branches/py3k/Lib/test/test_super.py	Thu Nov 20 21:01:57 2008
@@ -70,6 +70,17 @@
         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)

Modified: python/branches/py3k/Objects/typeobject.c
==============================================================================
--- python/branches/py3k/Objects/typeobject.c	(original)
+++ python/branches/py3k/Objects/typeobject.c	Thu Nov 20 21:01:57 2008
@@ -6170,8 +6170,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");

Modified: python/branches/py3k/RELNOTES
==============================================================================
--- python/branches/py3k/RELNOTES	(original)
+++ python/branches/py3k/RELNOTES	Thu Nov 20 21:01:57 2008
@@ -20,3 +20,10 @@
   If you need bsddb3 support in Python 3.0, you can find it here:
 
   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 at 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.


More information about the Python-3000-checkins mailing list