[Checkins] SVN: zope.interface/trunk/ Avoid exceptions due to tne new ``__qualname__`` attribute added in Python 3.3

Tres Seaver tseaver at palladion.com
Thu Feb 16 21:50:26 UTC 2012


Log message for revision 124423:
  Avoid exceptions due to tne new ``__qualname__`` attribute added in Python 3.3 
  
  See PEP 3155 for rationale.  Thanks to Antoine Pitrou for the patch.
  
  Fixes LP #900906.
  

Changed:
  U   zope.interface/trunk/CHANGES.txt
  U   zope.interface/trunk/src/zope/interface/interface.py

-=-
Modified: zope.interface/trunk/CHANGES.txt
===================================================================
--- zope.interface/trunk/CHANGES.txt	2012-02-16 18:17:11 UTC (rev 124422)
+++ zope.interface/trunk/CHANGES.txt	2012-02-16 21:50:25 UTC (rev 124423)
@@ -4,7 +4,9 @@
 3.8.1 (unreleased)
 ------------------
 
-- No changes yet.
+- LP #900906:  Avoid exceptions due to tne new ``__qualname__`` attribute
+  added in Python 3.3 (see PEP 3155 for rationale).  Thanks to Antoine
+  Pitrou for the patch.
 
 3.8.0 (2011-09-22)
 ------------------

Modified: zope.interface/trunk/src/zope/interface/interface.py
===================================================================
--- zope.interface/trunk/src/zope/interface/interface.py	2012-02-16 18:17:11 UTC (rev 124422)
+++ zope.interface/trunk/src/zope/interface/interface.py	2012-02-16 21:50:25 UTC (rev 124423)
@@ -480,9 +480,11 @@
 
         # Make sure that all recorded attributes (and methods) are of type
         # `Attribute` and `Method`
-        for name, attr in attrs.items():
-            if name == '__locals__':
-                # This happens under Python 3 sometimes, not sure why. /regebro
+        for name, attr in list(attrs.items()):
+            if name in ('__locals__', '__qualname__'):
+                # __locals__: Python 3 sometimes adds this.
+                # __qualname__: PEP 3155 (Python 3.3+)
+                del attrs[name]
                 continue
             if isinstance(attr, Attribute):
                 attr.interface = self



More information about the checkins mailing list