Commits

Amaury Forgeot d'Arc committed ec3004f

The methods str._formatter_parser and formatter_field_name_split have moved to a new _string module.

Comments (0)

Files changed (5)

pypy/config/pypyoption.py

     ["_codecs", "gc", "_weakref", "marshal", "errno", "imp",
      "math", "cmath", "_sre", "_pickle_support", "operator",
      "parser", "symbol", "token", "_ast",  "_io", "_random", "__pypy__",
-     "_testing"]))
+     "_string", "_testing"]))
 
 
 # --allworkingmodules

pypy/module/_string/__init__.py

+"""A _string module, to export formatter_parser and
+   formatter_field_name_split to the string.Formatter class
+   implemented in Python."""
+
+
+from pypy.interpreter.mixedmodule import MixedModule
+
+class Module(MixedModule):
+    "string helper module"
+
+    interpleveldefs = {
+        'formatter_field_name_split': 'formatter.formatter_field_name_split',
+        'formatter_parser': 'formatter.formatter_parser',
+    }
+
+    appleveldefs = {}
+

pypy/module/_string/formatter.py

+def formatter_parser(space, w_unicode):
+    from pypy.objspace.std.newformat import unicode_template_formatter
+    tformat = unicode_template_formatter(space, space.unicode_w(w_unicode))
+    return tformat.formatter_parser()
+
+def formatter_field_name_split(space, w_unicode):
+    from pypy.objspace.std.newformat import unicode_template_formatter
+    tformat = unicode_template_formatter(space, space.unicode_w(w_unicode))
+    return tformat.formatter_field_name_split()
+

pypy/objspace/std/stringtype.py

                          ' with\ncodecs.register_error that is able to handle'
                          ' UnicodeEncodeErrors.')
 
-str_formatter_parser           = SMM('_formatter_parser', 1)
-str_formatter_field_name_split = SMM('_formatter_field_name_split', 1)
-
-def str_formatter_parser__ANY(space, w_str):
-    from pypy.objspace.std.newformat import str_template_formatter
-    tformat = str_template_formatter(space, space.str_w(w_str))
-    return tformat.formatter_parser()
-
-def str_formatter_field_name_split__ANY(space, w_str):
-    from pypy.objspace.std.newformat import str_template_formatter
-    tformat = str_template_formatter(space, space.str_w(w_str))
-    return tformat.formatter_field_name_split()
-
 register_all(vars(), globals())
 
 # ____________________________________________________________

pypy/objspace/std/unicodetype.py

                              ' field\nof the specified width. The string x is'
                              ' never truncated.')
 
-unicode_formatter_parser           = SMM('_formatter_parser', 1)
-unicode_formatter_field_name_split = SMM('_formatter_field_name_split', 1)
-
-def unicode_formatter_parser__ANY(space, w_unicode):
-    from pypy.objspace.std.newformat import unicode_template_formatter
-    tformat = unicode_template_formatter(space, space.unicode_w(w_unicode))
-    return tformat.formatter_parser()
-
-def unicode_formatter_field_name_split__ANY(space, w_unicode):
-    from pypy.objspace.std.newformat import unicode_template_formatter
-    tformat = unicode_template_formatter(space, space.unicode_w(w_unicode))
-    return tformat.formatter_field_name_split()
-
 # stuff imported from stringtype for interoperability
 
 from pypy.objspace.std.stringtype import str_endswith as unicode_endswith