[pypy-commit] pypy py3k: The methods str._formatter_parser and formatter_field_name_split have moved to a new _string module.
amauryfa
noreply at buildbot.pypy.org
Thu Oct 13 22:40:13 CEST 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r48021:ec3004f1eb9e
Date: 2011-10-13 22:37 +0200
http://bitbucket.org/pypy/pypy/changeset/ec3004f1eb9e/
Log: The methods str._formatter_parser and formatter_field_name_split
have moved to a new _string module.
diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -21,7 +21,7 @@
["_codecs", "gc", "_weakref", "marshal", "errno", "imp",
"math", "cmath", "_sre", "_pickle_support", "operator",
"parser", "symbol", "token", "_ast", "_io", "_random", "__pypy__",
- "_testing"]))
+ "_string", "_testing"]))
# --allworkingmodules
diff --git a/pypy/module/_string/__init__.py b/pypy/module/_string/__init__.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/_string/__init__.py
@@ -0,0 +1,17 @@
+"""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 = {}
+
diff --git a/pypy/module/_string/formatter.py b/pypy/module/_string/formatter.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/_string/formatter.py
@@ -0,0 +1,10 @@
+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()
+
diff --git a/pypy/objspace/std/stringtype.py b/pypy/objspace/std/stringtype.py
--- a/pypy/objspace/std/stringtype.py
+++ b/pypy/objspace/std/stringtype.py
@@ -272,19 +272,6 @@
' 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())
# ____________________________________________________________
diff --git a/pypy/objspace/std/unicodetype.py b/pypy/objspace/std/unicodetype.py
--- a/pypy/objspace/std/unicodetype.py
+++ b/pypy/objspace/std/unicodetype.py
@@ -151,19 +151,6 @@
' 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
More information about the pypy-commit
mailing list