[Python-checkins] r55501 - in sandbox/trunk/2to3: fixes/fix_callable.py tests/test_fixers.py

neal.norwitz python-checkins at python.org
Tue May 22 07:49:06 CEST 2007


Author: neal.norwitz
Date: Tue May 22 07:49:04 2007
New Revision: 55501
Modified:
 sandbox/trunk/2to3/fixes/fix_callable.py
 sandbox/trunk/2to3/tests/test_fixers.py
Log:
Fix XXXs by tightening the pattern and add a few test cases.
Modified: sandbox/trunk/2to3/fixes/fix_callable.py
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_callable.py	(original)
+++ sandbox/trunk/2to3/fixes/fix_callable.py	Tue May 22 07:49:04 2007
@@ -12,11 +12,16 @@
 
 class FixCallable(basefix.BaseFix):
 
- # XXX(nnorwitz): need to ignore: callable(*args)
- # XXX(nnorwitz): or use of keywords, it could signify doing a callback,
- # not using the builtin callable().
+ # Ignore callable(*args) or use of keywords.
+ # Either could be a hint that the builtin callable() is not being used.
 PATTERN = """
- power< 'callable' trailer< '(' func=any ')' > >
+ power< 'callable'
+ trailer< lpar='('
+ ( not(arglist | argument<any '=' any>) func=any
+ | func=arglist<(not argument<any '=' any>) any ','> )
+ rpar=')' >
+ after=any*
+ >
 """
 
 def transform(self, node):
Modified: sandbox/trunk/2to3/tests/test_fixers.py
==============================================================================
--- sandbox/trunk/2to3/tests/test_fixers.py	(original)
+++ sandbox/trunk/2to3/tests/test_fixers.py	Tue May 22 07:49:04 2007
@@ -1791,6 +1791,16 @@
 a = """hasattr(x, '__call__')"""
 self.check(b, a)
 
+ def test_callable_should_not_change(self):
+ a = """callable(*x)"""
+ self.check(a, a)
+
+ a = """callable(x, y)"""
+ self.check(a, a)
+
+ a = """callable(x, kw=y)"""
+ self.check(a, a)
+
 
 if __name__ == "__main__":
 import __main__


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /