[pypy-svn] r76123 - pypy/branch/fast-forward/pypy/objspace/std

benjamin at codespeak.net benjamin at codespeak.net
Mon Jul 12 05:05:31 CEST 2010


Author: benjamin
Date: Mon Jul 12 05:05:29 2010
New Revision: 76123

Modified:
   pypy/branch/fast-forward/pypy/objspace/std/floatobject.py
   pypy/branch/fast-forward/pypy/objspace/std/intobject.py
   pypy/branch/fast-forward/pypy/objspace/std/longobject.py
   pypy/branch/fast-forward/pypy/objspace/std/newformat.py
Log:
finally hack this method lookup into submission

Modified: pypy/branch/fast-forward/pypy/objspace/std/floatobject.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/floatobject.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/floatobject.py	Mon Jul 12 05:05:29 2010
@@ -158,7 +158,7 @@
     return float2string(space, w_float, "%.12g")
 
 def format__Float_ANY(space, w_float, w_spec):
-    return newformat.get_formatter(space, w_spec).format_float(w_float)
+    return newformat.run_formatter(space, w_spec, "format_float", w_float)
 
 # ____________________________________________________________
 # A mess to handle all cases of float comparison without relying

Modified: pypy/branch/fast-forward/pypy/objspace/std/intobject.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/intobject.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/intobject.py	Mon Jul 12 05:05:29 2010
@@ -62,8 +62,8 @@
 str__Int = repr__Int
 
 def format__Int_ANY(space, w_int, w_format_spec):
-    form = newformat.get_formatter(space, w_format_spec)
-    return form.format_int_or_long(w_int, newformat.INT_KIND)
+    return newformat.run_formatter(space, w_format_spec, "format_int_or_long",
+                                   w_int, newformat.INT_KIND)
 
 def declare_new_int_comparison(opname):
     import operator

Modified: pypy/branch/fast-forward/pypy/objspace/std/longobject.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/longobject.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/longobject.py	Mon Jul 12 05:05:29 2010
@@ -126,8 +126,8 @@
     return space.wrap(w_long.num.str())
 
 def format__Long_ANY(space, w_long, w_format_spec):
-    formatter = newformat.get_formatter(space, w_format_spec)
-    return formatter.format_int_or_long(w_long, newformat.LONG_KIND)
+    return newformat.run_formatter(space, w_format_spec, "format_int_or_long",
+                                   w_long, newformat.LONG_KIND)
 
 
 def lt__Long_Long(space, w_long1, w_long2):

Modified: pypy/branch/fast-forward/pypy/objspace/std/newformat.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/newformat.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/newformat.py	Mon Jul 12 05:05:29 2010
@@ -843,8 +843,11 @@
     return Formatter(space, False, spec)
 
 
-def get_formatter(space, w_format_spec):
+ at specialize.arg(2)
+def run_formatter(space, w_format_spec, meth, *args):
     if space.isinstance_w(w_format_spec, space.w_unicode):
-        return unicode_formatter(space, space.unicode_w(w_format_spec))
+        formatter = unicode_formatter(space, space.unicode_w(w_format_spec))
+        return getattr(formatter, meth)(*args)
     else:
-        return str_formatter(space, space.str_w(w_format_spec))
+        formatter = str_formatter(space, space.str_w(w_format_spec))
+        return getattr(formatter, meth)(*args)



More information about the Pypy-commit mailing list