Patch: Update RuleDispatch for python-2.7

Toshio Kuratomi <[email protected]> Sun, 1 Aug 2010 10:01:20 -0400
Newsgroups gmane.comp.python.peak
Message-ID <[email protected]>
In Fedora we've recently upgraded from python-2.6 to python-2.7.  In doing
so we found that the unittests for RuleDispatch were failing.  The failures
seem to be legitimate bugs in ruledispatch so I've updated the code to fix
them.  I'm attaching a patch for your perusal.

Thanks,
-Toshio

_______________________________________________
PEAK mailing list
[email protected]
http://www.eby-sarna.com/mailman/listinfo/peak
ruledispatch-py27.patch (text/plain, 1.2 KB)
Index: RuleDispatch-0.5a1.dev-r2506/src/dispatch/ast_builder.py
===================================================================
--- RuleDispatch-0.5a1.dev-r2506.orig/src/dispatch/ast_builder.py
+++ RuleDispatch-0.5a1.dev-r2506/src/dispatch/ast_builder.py
@@ -55,7 +55,9 @@ def com_binary(opname, builder,nodelist)
 testlist = subscriptlist = curry(com_binary, 'Tuple')
 
 # testlist_gexp test (gen_for | (',' test)* [','])
+# In python-2.7+, testlist_comp replaces testlist_gexp
 testlist_gexp = testlist    # XXX
+testlist_comp = testlist    # XXX
 
 # test: and_test ('or' and_test)* | lambdef
 test = curry(com_binary, 'Or')
Index: RuleDispatch-0.5a1.dev-r2506/src/dispatch/strategy.py
===================================================================
--- RuleDispatch-0.5a1.dev-r2506.orig/src/dispatch/strategy.py
+++ RuleDispatch-0.5a1.dev-r2506/src/dispatch/strategy.py
@@ -548,6 +548,9 @@ class Pointer(int):
     def __eq__(self,other):
         return self is other or int(self)==other and self.ref() is not None
 
+    def __ne__(self, other):
+        return not self.__eq__(other)
+
     def __repr__(self):
         if self.ref() is None:
             return "Pointer(<invalid at 0x%s>)" % hex(self)
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)

iEYEARECAAYFAkxVfjAACgkQX6yAic2E7khzSACfVOSzuXu0SkCaDNKT5q7yO3Zv
/p0An2h7nH743V5gPr5mx2lRSFZR2Jgi
=ekJm
-----END PGP SIGNATURE-----