[Checkins] SVN: zope.interface/branches/regebro-python3/src/zope/interface/ More Python 3 changes. The unicode representation no longer use steh unicode literal u'', and

Lennart Regebro regebro at gmail.com
Wed Apr 8 08:11:40 EDT 2009


Log message for revision 99006:
  More Python 3 changes. The unicode representation no longer use steh unicode literal u'', and 
  unbound methods are now just straight functions.
  

Changed:
  U   zope.interface/branches/regebro-python3/src/zope/interface/adapter.ru.txt
  U   zope.interface/branches/regebro-python3/src/zope/interface/adapter.txt
  U   zope.interface/branches/regebro-python3/src/zope/interface/verify.py

-=-
Modified: zope.interface/branches/regebro-python3/src/zope/interface/adapter.ru.txt
===================================================================
--- zope.interface/branches/regebro-python3/src/zope/interface/adapter.ru.txt	2009-04-08 11:08:44 UTC (rev 99005)
+++ zope.interface/branches/regebro-python3/src/zope/interface/adapter.ru.txt	2009-04-08 12:11:40 UTC (rev 99006)
@@ -384,24 +384,21 @@
 
   >>> adapters = list(registry.lookupAll([IR1], IP1))
   >>> adapters.sort()
-  >>> adapters
-  [(u'', 11), (u'bob', "Bob's 12")]
+  >>> assert adapters == [(u'', 11), (u'bob', "Bob's 12")]
 
 Это работает также и для мульти-адаптеров::
 
   >>> registry.register([IR1, IQ2], IP2, 'bob', '1q2 for bob')
   >>> adapters = list(registry.lookupAll([IR2, IQ2], IP1))
   >>> adapters.sort()
-  >>> adapters
-  [(u'', '1q22'), (u'bob', '1q2 for bob')]
+  >>> assert adapters == [(u'', '1q22'), (u'bob', '1q2 for bob')]
 
 И даже для нулевых адаптеров::
 
   >>> registry.register([], IP2, 'bob', 3)
   >>> adapters = list(registry.lookupAll([], IP1))
   >>> adapters.sort()
-  >>> adapters
-  [(u'', 2), (u'bob', 3)]
+  >>> assert adapters == [(u'', 2), (u'bob', 3)]
 
 Подписки
 ========

Modified: zope.interface/branches/regebro-python3/src/zope/interface/adapter.txt
===================================================================
--- zope.interface/branches/regebro-python3/src/zope/interface/adapter.txt	2009-04-08 11:08:44 UTC (rev 99005)
+++ zope.interface/branches/regebro-python3/src/zope/interface/adapter.txt	2009-04-08 12:11:40 UTC (rev 99006)
@@ -386,24 +386,21 @@
 
   >>> adapters = list(registry.lookupAll([IR1], IP1))
   >>> adapters.sort()
-  >>> adapters
-  [(u'', 11), (u'bob', "Bob's 12")]
+  >>> assert adapters == [(u'', 11), (u'bob', "Bob's 12")]
 
 This works for multi-adapters too::
 
   >>> registry.register([IR1, IQ2], IP2, 'bob', '1q2 for bob')
   >>> adapters = list(registry.lookupAll([IR2, IQ2], IP1))
   >>> adapters.sort()
-  >>> adapters
-  [(u'', '1q22'), (u'bob', '1q2 for bob')]
+  >>> assert adapters == [(u'', '1q22'), (u'bob', '1q2 for bob')]
 
 And even null adapters::
 
   >>> registry.register([], IP2, 'bob', 3)
   >>> adapters = list(registry.lookupAll([], IP1))
   >>> adapters.sort()
-  >>> adapters
-  [(u'', 2), (u'bob', 3)]
+  >>> assert adapters == [(u'', 2), (u'bob', 3)]
 
 Subscriptions
 =============

Modified: zope.interface/branches/regebro-python3/src/zope/interface/verify.py
===================================================================
--- zope.interface/branches/regebro-python3/src/zope/interface/verify.py	2009-04-08 11:08:44 UTC (rev 99005)
+++ zope.interface/branches/regebro-python3/src/zope/interface/verify.py	2009-04-08 12:11:40 UTC (rev 99006)
@@ -19,6 +19,7 @@
 from zope.interface.exceptions import BrokenMethodImplementation
 from types import FunctionType, MethodType
 from zope.interface.interface import fromMethod, fromFunction, Method
+import sys
 
 # This will be monkey-patched when running under Zope 2, so leave this
 # here:
@@ -67,8 +68,12 @@
             continue
 
         if isinstance(attr, FunctionType):
-            # should never get here, since classes should not provide functions
-            meth = fromFunction(attr, iface, name=name)
+            if sys.version[0] == '3' and isinstance(candidate, type):
+                # This is an "unbound method" in Python 3.
+                meth = fromFunction(attr, iface, name=name, imlevel=1)
+            else:
+                # Nope, just a normal function
+                meth = fromFunction(attr, iface, name=name)
         elif (isinstance(attr, MethodTypes)
               and type(attr.im_func) is FunctionType):
             meth = fromMethod(attr, iface, name)



More information about the Checkins mailing list