Author: Armin Rigo <ar...@tunes.org>
Branch: fix-strbuf
Changeset: r78671:cf9f0f7412c0
Date: 2015-07-26 17:22 +0200
http://bitbucket.org/pypy/pypy/changeset/cf9f0f7412c0/

Log:    A large mostly-no-op commit extracting W_AbstractUnicodeObject

diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -49,69 +49,89 @@
 
     def descr_add(self, space, w_other):
         """x.__add__(y) <==> x+y"""
+        raise NotImplementedError
 
     def descr_contains(self, space, w_sub):
         """x.__contains__(y) <==> y in x"""
+        raise NotImplementedError
 
     def descr_eq(self, space, w_other):
         """x.__eq__(y) <==> x==y"""
+        raise NotImplementedError
 
     def descr__format__(self, space, w_format_spec):
         """S.__format__(format_spec) -> string
 
         Return a formatted version of S as described by format_spec.
         """
+        raise NotImplementedError
 
     def descr_ge(self, space, w_other):
         """x.__ge__(y) <==> x>=y"""
+        raise NotImplementedError
 
     def descr_getitem(self, space, w_index):
         """x.__getitem__(y) <==> x[y]"""
+        raise NotImplementedError
 
     def descr_getnewargs(self, space):
         ""
+        raise NotImplementedError
 
     def descr_getslice(self, space, w_start, w_stop):
         """x.__getslice__(i, j) <==> x[i:j]
 
         Use of negative indices is not supported.
         """
+        raise NotImplementedError
 
     def descr_gt(self, space, w_other):
         """x.__gt__(y) <==> x>y"""
+        raise NotImplementedError
 
     def descr_hash(self, space):
         """x.__hash__() <==> hash(x)"""
+        raise NotImplementedError
 
     def descr_le(self, space, w_other):
         """x.__le__(y) <==> x<=y"""
+        raise NotImplementedError
 
     def descr_len(self, space):
         """x.__len__() <==> len(x)"""
+        raise NotImplementedError
 
     def descr_lt(self, space, w_other):
         """x.__lt__(y) <==> x<y"""
+        raise NotImplementedError
 
     def descr_mod(self, space, w_values):
         """x.__mod__(y) <==> x%y"""
+        raise NotImplementedError
 
     def descr_mul(self, space, w_times):
         """x.__mul__(n) <==> x*n"""
+        raise NotImplementedError
 
     def descr_ne(self, space, w_other):
         """x.__ne__(y) <==> x!=y"""
+        raise NotImplementedError
 
     def descr_repr(self, space):
         """x.__repr__() <==> repr(x)"""
+        raise NotImplementedError
 
     def descr_rmod(self, space, w_values):
         """x.__rmod__(y) <==> y%x"""
+        raise NotImplementedError
 
     def descr_rmul(self, space, w_times):
         """x.__rmul__(n) <==> n*x"""
+        raise NotImplementedError
 
     def descr_str(self, space):
         """x.__str__() <==> str(x)"""
+        raise NotImplementedError
 
     def descr_capitalize(self, space):
         """S.capitalize() -> string
@@ -119,6 +139,7 @@
         Return a capitalized version of S, i.e. make the first character
         have upper case and the rest lower case.
         """
+        raise NotImplementedError
 
     @unwrap_spec(width=int, w_fillchar=WrappedDefault(' '))
     def descr_center(self, space, width, w_fillchar):
@@ -127,6 +148,7 @@
         Return S centered in a string of length width. Padding is
         done using the specified fill character (default is a space).
         """
+        raise NotImplementedError
 
     def descr_count(self, space, w_sub, w_start=None, w_end=None):
         """S.count(sub[, start[, end]]) -> int
@@ -135,6 +157,7 @@
         string S[start:end].  Optional arguments start and end are interpreted
         as in slice notation.
         """
+        raise NotImplementedError
 
     def descr_decode(self, space, w_encoding=None, w_errors=None):
         """S.decode(encoding=None, errors='strict') -> object
@@ -146,6 +169,7 @@
         as well as any other name registered with codecs.register_error that is
         able to handle UnicodeDecodeErrors.
         """
+        raise NotImplementedError
 
     def descr_encode(self, space, w_encoding=None, w_errors=None):
         """S.encode(encoding=None, errors='strict') -> object
@@ -157,6 +181,7 @@
         'xmlcharrefreplace' as well as any other name registered with
         codecs.register_error that is able to handle UnicodeEncodeErrors.
         """
+        raise NotImplementedError
 
     def descr_endswith(self, space, w_suffix, w_start=None, w_end=None):
         """S.endswith(suffix[, start[, end]]) -> bool
@@ -166,6 +191,7 @@
         With optional end, stop comparing S at that position.
         suffix can also be a tuple of strings to try.
         """
+        raise NotImplementedError
 
     @unwrap_spec(tabsize=int)
     def descr_expandtabs(self, space, tabsize=8):
@@ -174,6 +200,7 @@
         Return a copy of S where all tab characters are expanded using spaces.
         If tabsize is not given, a tab size of 8 characters is assumed.
         """
+        raise NotImplementedError
 
     def descr_find(self, space, w_sub, w_start=None, w_end=None):
         """S.find(sub[, start[, end]]) -> int
@@ -184,6 +211,7 @@
 
         Return -1 on failure.
         """
+        raise NotImplementedError
 
     def descr_format(self, space, __args__):
         """S.format(*args, **kwargs) -> string
@@ -191,12 +219,14 @@
         Return a formatted version of S, using substitutions from args and
         kwargs.  The substitutions are identified by braces ('{' and '}').
         """
+        raise NotImplementedError
 
     def descr_index(self, space, w_sub, w_start=None, w_end=None):
         """S.index(sub[, start[, end]]) -> int
 
         Like S.find() but raise ValueError when the substring is not found.
         """
+        raise NotImplementedError
 
     def descr_isalnum(self, space):
         """S.isalnum() -> bool
@@ -204,6 +234,7 @@
         Return True if all characters in S are alphanumeric
         and there is at least one character in S, False otherwise.
         """
+        raise NotImplementedError
 
     def descr_isalpha(self, space):
         """S.isalpha() -> bool
@@ -211,6 +242,7 @@
         Return True if all characters in S are alphabetic
         and there is at least one character in S, False otherwise.
         """
+        raise NotImplementedError
 
     def descr_isdigit(self, space):
         """S.isdigit() -> bool
@@ -218,6 +250,7 @@
         Return True if all characters in S are digits
         and there is at least one character in S, False otherwise.
         """
+        raise NotImplementedError
 
     def descr_islower(self, space):
         """S.islower() -> bool
@@ -225,6 +258,7 @@
         Return True if all cased characters in S are lowercase and there is
         at least one cased character in S, False otherwise.
         """
+        raise NotImplementedError
 
     def descr_isspace(self, space):
         """S.isspace() -> bool
@@ -232,6 +266,7 @@
         Return True if all characters in S are whitespace
         and there is at least one character in S, False otherwise.
         """
+        raise NotImplementedError
 
     def descr_istitle(self, space):
         """S.istitle() -> bool
@@ -241,6 +276,7 @@
         characters and lowercase characters only cased ones. Return False
         otherwise.
         """
+        raise NotImplementedError
 
     def descr_isupper(self, space):
         """S.isupper() -> bool
@@ -248,6 +284,7 @@
         Return True if all cased characters in S are uppercase and there is
         at least one cased character in S, False otherwise.
         """
+        raise NotImplementedError
 
     def descr_join(self, space, w_list):
         """S.join(iterable) -> string
@@ -255,6 +292,7 @@
         Return a string which is the concatenation of the strings in the
         iterable.  The separator between elements is S.
         """
+        raise NotImplementedError
 
     @unwrap_spec(width=int, w_fillchar=WrappedDefault(' '))
     def descr_ljust(self, space, width, w_fillchar):
@@ -263,12 +301,14 @@
         Return S left-justified in a string of length width. Padding is
         done using the specified fill character (default is a space).
         """
+        raise NotImplementedError
 
     def descr_lower(self, space):
         """S.lower() -> string
 
         Return a copy of the string S converted to lowercase.
         """
+        raise NotImplementedError
 
     def descr_lstrip(self, space, w_chars=None):
         """S.lstrip([chars]) -> string or unicode
@@ -277,6 +317,7 @@
         If chars is given and not None, remove characters in chars instead.
         If chars is unicode, S will be converted to unicode before stripping
         """
+        raise NotImplementedError
 
     def descr_partition(self, space, w_sub):
         """S.partition(sep) -> (head, sep, tail)
@@ -285,6 +326,7 @@
         the separator itself, and the part after it.  If the separator is not
         found, return S and two empty strings.
         """
+        raise NotImplementedError
 
     @unwrap_spec(count=int)
     def descr_replace(self, space, w_old, w_new, count=-1):
@@ -294,6 +336,7 @@
         old replaced by new.  If the optional argument count is
         given, only the first count occurrences are replaced.
         """
+        raise NotImplementedError
 
     def descr_rfind(self, space, w_sub, w_start=None, w_end=None):
         """S.rfind(sub[, start[, end]]) -> int
@@ -304,12 +347,14 @@
 
         Return -1 on failure.
         """
+        raise NotImplementedError
 
     def descr_rindex(self, space, w_sub, w_start=None, w_end=None):
         """S.rindex(sub[, start[, end]]) -> int
 
         Like S.rfind() but raise ValueError when the substring is not found.
         """
+        raise NotImplementedError
 
     @unwrap_spec(width=int, w_fillchar=WrappedDefault(' '))
     def descr_rjust(self, space, width, w_fillchar):
@@ -318,6 +363,7 @@
         Return S right-justified in a string of length width. Padding is
         done using the specified fill character (default is a space).
         """
+        raise NotImplementedError
 
     def descr_rpartition(self, space, w_sub):
         """S.rpartition(sep) -> (head, sep, tail)
@@ -326,6 +372,7 @@
         the part before it, the separator itself, and the part after it.  If
         the separator is not found, return two empty strings and S.
         """
+        raise NotImplementedError
 
     @unwrap_spec(maxsplit=int)
     def descr_rsplit(self, space, w_sep=None, maxsplit=-1):
@@ -337,6 +384,7 @@
         done. If sep is not specified or is None, any whitespace string
         is a separator.
         """
+        raise NotImplementedError
 
     def descr_rstrip(self, space, w_chars=None):
         """S.rstrip([chars]) -> string or unicode
@@ -345,6 +393,7 @@
         If chars is given and not None, remove characters in chars instead.
         If chars is unicode, S will be converted to unicode before stripping
         """
+        raise NotImplementedError
 
     @unwrap_spec(maxsplit=int)
     def descr_split(self, space, w_sep=None, maxsplit=-1):
@@ -356,6 +405,7 @@
         whitespace string is a separator and empty strings are removed
         from the result.
         """
+        raise NotImplementedError
 
     @unwrap_spec(keepends=bool)
     def descr_splitlines(self, space, keepends=False):
@@ -365,6 +415,7 @@
         Line breaks are not included in the resulting list unless keepends
         is given and true.
         """
+        raise NotImplementedError
 
     def descr_startswith(self, space, w_prefix, w_start=None, w_end=None):
         """S.startswith(prefix[, start[, end]]) -> bool
@@ -374,6 +425,7 @@
         With optional end, stop comparing S at that position.
         prefix can also be a tuple of strings to try.
         """
+        raise NotImplementedError
 
     def descr_strip(self, space, w_chars=None):
         """S.strip([chars]) -> string or unicode
@@ -383,6 +435,7 @@
         If chars is given and not None, remove characters in chars instead.
         If chars is unicode, S will be converted to unicode before stripping
         """
+        raise NotImplementedError
 
     def descr_swapcase(self, space):
         """S.swapcase() -> string
@@ -390,6 +443,7 @@
         Return a copy of the string S with uppercase characters
         converted to lowercase and vice versa.
         """
+        raise NotImplementedError
 
     def descr_title(self, space):
         """S.title() -> string
@@ -397,6 +451,7 @@
         Return a titlecased version of S, i.e. words start with uppercase
         characters, all remaining cased characters have lowercase.
         """
+        raise NotImplementedError
 
     @unwrap_spec(w_deletechars=WrappedDefault(''))
     def descr_translate(self, space, w_table, w_deletechars):
@@ -409,12 +464,14 @@
         If the table argument is None, no translation is applied and
         the operation simply removes the characters in deletechars.
         """
+        raise NotImplementedError
 
     def descr_upper(self, space):
         """S.upper() -> string
 
         Return a copy of the string S converted to uppercase.
         """
+        raise NotImplementedError
 
     @unwrap_spec(width=int)
     def descr_zfill(self, space, width):
@@ -423,6 +480,7 @@
         Pad a numeric string S with zeros on the left, to fill a field
         of the specified width. The string S is never truncated.
         """
+        raise NotImplementedError
 
     def writebuf_w(self, space):
         raise OperationError(space.w_TypeError, space.wrap(
@@ -439,6 +497,16 @@
                         "found", len(value))
         return space.wrap(ord(value[0]))
 
+    def descr_formatter_parser(self, space):
+        from pypy.objspace.std.newformat import str_template_formatter
+        tformat = str_template_formatter(space, space.str_w(self))
+        return tformat.formatter_parser()
+
+    def descr_formatter_field_name_split(self, space):
+        from pypy.objspace.std.newformat import str_template_formatter
+        tformat = str_template_formatter(space, space.str_w(self))
+        return tformat.formatter_field_name_split()
+
 
 class W_BytesObject(W_AbstractBytesObject):
     import_from_mixin(StringMethods)
@@ -832,16 +900,6 @@
     def descr_upper(self, space):
         return W_BytesObject(self._value.upper())
 
-    def descr_formatter_parser(self, space):
-        from pypy.objspace.std.newformat import str_template_formatter
-        tformat = str_template_formatter(space, space.str_w(self))
-        return tformat.formatter_parser()
-
-    def descr_formatter_field_name_split(self, space):
-        from pypy.objspace.std.newformat import str_template_formatter
-        tformat = str_template_formatter(space, space.str_w(self))
-        return tformat.formatter_field_name_split()
-
 
 def _create_list_from_bytes(value):
     # need this helper function to allow the jit to look inside and inline
@@ -950,9 +1008,10 @@
     __mod__ = interpindirect2app(W_AbstractBytesObject.descr_mod),
     __getnewargs__ = interpindirect2app(
         W_AbstractBytesObject.descr_getnewargs),
-    _formatter_parser = interp2app(W_BytesObject.descr_formatter_parser),
+    _formatter_parser =
+        interp2app(W_AbstractBytesObject.descr_formatter_parser),
     _formatter_field_name_split =
-        interp2app(W_BytesObject.descr_formatter_field_name_split),
+        interp2app(W_AbstractBytesObject.descr_formatter_field_name_split),
 )
 W_BytesObject.typedef.flag_sequence_bug_compat = True
 
diff --git a/pypy/objspace/std/test/test_strbufobject.py 
b/pypy/objspace/std/test/test_strbufobject.py
--- a/pypy/objspace/std/test/test_strbufobject.py
+++ b/pypy/objspace/std/test/test_strbufobject.py
@@ -94,3 +94,8 @@
         a = 'abc'
         a += 'bc'
         print a
+
+    def test_formatter_parser(self):
+        a = 'abc'
+        a += 'bc'
+        assert list(a._formatter_parser()) == [('abcbc', None, None, None)]
diff --git a/pypy/objspace/std/unicodeobject.py 
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -11,7 +11,8 @@
 from pypy.interpreter import unicodehelper
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.error import OperationError, oefmt
-from pypy.interpreter.gateway import WrappedDefault, interp2app, unwrap_spec
+from pypy.interpreter.gateway import (
+    WrappedDefault, interp2app, interpindirect2app, unwrap_spec)
 from pypy.interpreter.typedef import TypeDef
 from pypy.module.unicodedata import unicodedb
 from pypy.objspace.std import newformat
@@ -24,7 +25,488 @@
            'unicode_from_string', 'unicode_to_decimal_w']
 
 
-class W_UnicodeObject(W_Root):
+class W_AbstractUnicodeObject(W_Root):
+    __slots__ = ()
+
+    def is_w(self, space, w_other):
+        if not isinstance(w_other, W_AbstractUnicodeObject):
+            return False
+        if self is w_other:
+            return True
+        if self.user_overridden_class or w_other.user_overridden_class:
+            return False
+        return space.unicode_w(self) is space.unicode_w(w_other)
+
+    def immutable_unique_id(self, space):
+        if self.user_overridden_class:
+            return None
+        return space.wrap(compute_unique_id(space.unicode_w(self)))
+
+    def str_w(self, space):
+        return space.str_w(space.str(self))
+
+    charbuf_w = str_w
+
+    def descr_add(self, space, w_other):
+        """x.__add__(y) <==> x+y"""
+        raise NotImplementedError
+
+    def descr_contains(self, space, w_sub):
+        """x.__contains__(y) <==> y in x"""
+        raise NotImplementedError
+
+    def descr_eq(self, space, w_other):
+        """x.__eq__(y) <==> x==y"""
+        raise NotImplementedError
+
+    def descr__format__(self, space, w_format_spec):
+        """S.__format__(format_spec) -> string
+
+        Return a formatted version of S as described by format_spec.
+        """
+        raise NotImplementedError
+
+    def descr_ge(self, space, w_other):
+        """x.__ge__(y) <==> x>=y"""
+        raise NotImplementedError
+
+    def descr_getitem(self, space, w_index):
+        """x.__getitem__(y) <==> x[y]"""
+        raise NotImplementedError
+
+    def descr_getnewargs(self, space):
+        ""
+        raise NotImplementedError
+
+    def descr_getslice(self, space, w_start, w_stop):
+        """x.__getslice__(i, j) <==> x[i:j]
+
+        Use of negative indices is not supported.
+        """
+        raise NotImplementedError
+
+    def descr_gt(self, space, w_other):
+        """x.__gt__(y) <==> x>y"""
+        raise NotImplementedError
+
+    def descr_hash(self, space):
+        """x.__hash__() <==> hash(x)"""
+        raise NotImplementedError
+
+    def descr_le(self, space, w_other):
+        """x.__le__(y) <==> x<=y"""
+        raise NotImplementedError
+
+    def descr_len(self, space):
+        """x.__len__() <==> len(x)"""
+        raise NotImplementedError
+
+    def descr_lt(self, space, w_other):
+        """x.__lt__(y) <==> x<y"""
+        raise NotImplementedError
+
+    def descr_mod(self, space, w_values):
+        """x.__mod__(y) <==> x%y"""
+        raise NotImplementedError
+
+    def descr_mul(self, space, w_times):
+        """x.__mul__(n) <==> x*n"""
+        raise NotImplementedError
+
+    def descr_ne(self, space, w_other):
+        """x.__ne__(y) <==> x!=y"""
+        raise NotImplementedError
+
+    def descr_repr(self, space):
+        """x.__repr__() <==> repr(x)"""
+        raise NotImplementedError
+
+    def descr_rmod(self, space, w_values):
+        """x.__rmod__(y) <==> y%x"""
+        raise NotImplementedError
+
+    def descr_rmul(self, space, w_times):
+        """x.__rmul__(n) <==> n*x"""
+        raise NotImplementedError
+
+    def descr_str(self, space):
+        """x.__str__() <==> str(x)"""
+        raise NotImplementedError
+
+    def descr_capitalize(self, space):
+        """S.capitalize() -> unicode
+
+        Return a capitalized version of S, i.e. make the first character
+        have upper case and the rest lower case.
+        """
+        raise NotImplementedError
+
+    @unwrap_spec(width=int, w_fillchar=WrappedDefault(' '))
+    def descr_center(self, space, width, w_fillchar):
+        """S.center(width[, fillchar]) -> unicode
+
+        Return S centered in a Unicode string of length width. Padding is
+        done using the specified fill character (default is a space).
+        """
+        raise NotImplementedError
+
+    def descr_count(self, space, w_sub, w_start=None, w_end=None):
+        """S.count(sub[, start[, end]]) -> int
+
+        Return the number of non-overlapping occurrences of substring sub in
+        Unicode string S[start:end].  Optional arguments start and end are
+        interpreted as in slice notation.
+        """
+        raise NotImplementedError
+
+    def descr_decode(self, space, w_encoding=None, w_errors=None):
+        """S.decode(encoding=None, errors='strict') -> string or unicode
+
+        Decode S using the codec registered for encoding. encoding defaults
+        to the default encoding. errors may be given to set a different error
+        handling scheme. Default is 'strict' meaning that encoding errors raise
+        a UnicodeDecodeError. Other possible values are 'ignore' and 'replace'
+        as well as any other name registered with codecs.register_error that is
+        able to handle UnicodeDecodeErrors.
+        """
+        raise NotImplementedError
+
+    def descr_encode(self, space, w_encoding=None, w_errors=None):
+        """S.encode(encoding=None, errors='strict') -> string or unicode
+
+        Encode S using the codec registered for encoding. encoding defaults
+        to the default encoding. errors may be given to set a different error
+        handling scheme. Default is 'strict' meaning that encoding errors raise
+        a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and
+        'xmlcharrefreplace' as well as any other name registered with
+        codecs.register_error that can handle UnicodeEncodeErrors.
+        """
+        raise NotImplementedError
+
+    def descr_endswith(self, space, w_suffix, w_start=None, w_end=None):
+        """S.endswith(suffix[, start[, end]]) -> bool
+
+        Return True if S ends with the specified suffix, False otherwise.
+        With optional start, test S beginning at that position.
+        With optional end, stop comparing S at that position.
+        suffix can also be a tuple of strings to try.
+        """
+        raise NotImplementedError
+
+    @unwrap_spec(tabsize=int)
+    def descr_expandtabs(self, space, tabsize=8):
+        """S.expandtabs([tabsize]) -> unicode
+
+        Return a copy of S where all tab characters are expanded using spaces.
+        If tabsize is not given, a tab size of 8 characters is assumed.
+        """
+        raise NotImplementedError
+
+    def descr_find(self, space, w_sub, w_start=None, w_end=None):
+        """S.find(sub[, start[, end]]) -> int
+
+        Return the lowest index in S where substring sub is found,
+        such that sub is contained within S[start:end].  Optional
+        arguments start and end are interpreted as in slice notation.
+
+        Return -1 on failure.
+        """
+        raise NotImplementedError
+
+    def descr_format(self, space, __args__):
+        """S.format(*args, **kwargs) -> unicode
+
+        Return a formatted version of S, using substitutions from args and
+        kwargs.  The substitutions are identified by braces ('{' and '}').
+        """
+        raise NotImplementedError
+
+    def descr_index(self, space, w_sub, w_start=None, w_end=None):
+        """S.index(sub[, start[, end]]) -> int
+
+        Like S.find() but raise ValueError when the substring is not found.
+        """
+        raise NotImplementedError
+
+    def descr_isalnum(self, space):
+        """S.isalnum() -> bool
+
+        Return True if all characters in S are alphanumeric
+        and there is at least one character in S, False otherwise.
+        """
+        raise NotImplementedError
+
+    def descr_isalpha(self, space):
+        """S.isalpha() -> bool
+
+        Return True if all characters in S are alphabetic
+        and there is at least one character in S, False otherwise.
+        """
+        raise NotImplementedError
+
+    def descr_isdecimal(self, space):
+        """S.isdecimal() -> bool
+
+        Return True if there are only decimal characters in S,
+        False otherwise.
+        """
+        raise NotImplementedError
+
+    def descr_isdigit(self, space):
+        """S.isdigit() -> bool
+
+        Return True if all characters in S are digits
+        and there is at least one character in S, False otherwise.
+        """
+        raise NotImplementedError
+
+    def descr_islower(self, space):
+        """S.islower() -> bool
+
+        Return True if all cased characters in S are lowercase and there is
+        at least one cased character in S, False otherwise.
+        """
+        raise NotImplementedError
+
+    def descr_isnumeric(self, space):
+        """S.isnumeric() -> bool
+
+        Return True if there are only numeric characters in S,
+        False otherwise.
+        """
+        raise NotImplementedError
+
+    def descr_isspace(self, space):
+        """S.isspace() -> bool
+
+        Return True if all characters in S are whitespace
+        and there is at least one character in S, False otherwise.
+        """
+        raise NotImplementedError
+
+    def descr_istitle(self, space):
+        """S.istitle() -> bool
+
+        Return True if S is a titlecased string and there is at least one
+        character in S, i.e. upper- and titlecase characters may only
+        follow uncased characters and lowercase characters only cased ones.
+        Return False otherwise.
+        """
+        raise NotImplementedError
+
+    def descr_isupper(self, space):
+        """S.isupper() -> bool
+
+        Return True if all cased characters in S are uppercase and there is
+        at least one cased character in S, False otherwise.
+        """
+        raise NotImplementedError
+
+    def descr_join(self, space, w_list):
+        """S.join(iterable) -> unicode
+
+        Return a string which is the concatenation of the strings in the
+        iterable.  The separator between elements is S.
+        """
+        raise NotImplementedError
+
+    @unwrap_spec(width=int, w_fillchar=WrappedDefault(' '))
+    def descr_ljust(self, space, width, w_fillchar):
+        """S.ljust(width[, fillchar]) -> int
+
+        Return S left-justified in a Unicode string of length width. Padding is
+        done using the specified fill character (default is a space).
+        """
+        raise NotImplementedError
+
+    def descr_lower(self, space):
+        """S.lower() -> unicode
+
+        Return a copy of the string S converted to lowercase.
+        """
+        raise NotImplementedError
+
+    def descr_lstrip(self, space, w_chars=None):
+        """S.lstrip([chars]) -> unicode
+
+        Return a copy of the string S with leading whitespace removed.
+        If chars is given and not None, remove characters in chars instead.
+        If chars is a str, it will be converted to unicode before stripping
+        """
+        raise NotImplementedError
+
+    def descr_partition(self, space, w_sub):
+        """S.partition(sep) -> (head, sep, tail)
+
+        Search for the separator sep in S, and return the part before it,
+        the separator itself, and the part after it.  If the separator is not
+        found, return S and two empty strings.
+        """
+        raise NotImplementedError
+
+    @unwrap_spec(count=int)
+    def descr_replace(self, space, w_old, w_new, count=-1):
+        """S.replace(old, new[, count]) -> unicode
+
+        Return a copy of S with all occurrences of substring
+        old replaced by new.  If the optional argument count is
+        given, only the first count occurrences are replaced.
+        """
+        raise NotImplementedError
+
+    def descr_rfind(self, space, w_sub, w_start=None, w_end=None):
+        """S.rfind(sub[, start[, end]]) -> int
+
+        Return the highest index in S where substring sub is found,
+        such that sub is contained within S[start:end].  Optional
+        arguments start and end are interpreted as in slice notation.
+
+        Return -1 on failure.
+        """
+        raise NotImplementedError
+
+    def descr_rindex(self, space, w_sub, w_start=None, w_end=None):
+        """S.rindex(sub[, start[, end]]) -> int
+
+        Like S.rfind() but raise ValueError when the substring is not found.
+        """
+        raise NotImplementedError
+
+    @unwrap_spec(width=int, w_fillchar=WrappedDefault(' '))
+    def descr_rjust(self, space, width, w_fillchar):
+        """S.rjust(width[, fillchar]) -> unicode
+
+        Return S right-justified in a Unicode string of length width. Padding
+        is done using the specified fill character (default is a space).
+        """
+        raise NotImplementedError
+
+    def descr_rpartition(self, space, w_sub):
+        """S.rpartition(sep) -> (head, sep, tail)
+
+        Search for the separator sep in S, starting at the end of S, and return
+        the part before it, the separator itself, and the part after it.  If
+        the separator is not found, return two empty strings and S.
+        """
+        raise NotImplementedError
+
+    @unwrap_spec(maxsplit=int)
+    def descr_rsplit(self, space, w_sep=None, maxsplit=-1):
+        """S.rsplit(sep=None, maxsplit=-1) -> list of strings
+
+        Return a list of the words in S, using sep as the
+        delimiter string, starting at the end of the string and
+        working to the front.  If maxsplit is given, at most maxsplit
+        splits are done. If sep is not specified, any whitespace string
+        is a separator.
+        """
+        raise NotImplementedError
+
+    def descr_rstrip(self, space, w_chars=None):
+        """S.rstrip([chars]) -> unicode
+
+        Return a copy of the string S with trailing whitespace removed.
+        If chars is given and not None, remove characters in chars instead.
+        If chars is a str, it will be converted to unicode before stripping
+        """
+        raise NotImplementedError
+
+    @unwrap_spec(maxsplit=int)
+    def descr_split(self, space, w_sep=None, maxsplit=-1):
+        """S.split(sep=None, maxsplit=-1) -> list of strings
+
+        Return a list of the words in S, using sep as the
+        delimiter string.  If maxsplit is given, at most maxsplit
+        splits are done. If sep is not specified or is None, any
+        whitespace string is a separator and empty strings are
+        removed from the result.
+        """
+        raise NotImplementedError
+
+    @unwrap_spec(keepends=bool)
+    def descr_splitlines(self, space, keepends=False):
+        """S.splitlines(keepends=False) -> list of strings
+
+        Return a list of the lines in S, breaking at line boundaries.
+        Line breaks are not included in the resulting list unless keepends
+        is given and true.
+        """
+        raise NotImplementedError
+
+    def descr_startswith(self, space, w_prefix, w_start=None, w_end=None):
+        """S.startswith(prefix[, start[, end]]) -> bool
+
+        Return True if S starts with the specified prefix, False otherwise.
+        With optional start, test S beginning at that position.
+        With optional end, stop comparing S at that position.
+        prefix can also be a tuple of strings to try.
+        """
+        raise NotImplementedError
+
+    def descr_strip(self, space, w_chars=None):
+        """S.strip([chars]) -> unicode
+
+        Return a copy of the string S with leading and trailing
+        whitespace removed.
+        If chars is given and not None, remove characters in chars instead.
+        If chars is a str, it will be converted to unicode before stripping
+        """
+        raise NotImplementedError
+
+    def descr_swapcase(self, space):
+        """S.swapcase() -> unicode
+
+        Return a copy of S with uppercase characters converted to lowercase
+        and vice versa.
+        """
+        raise NotImplementedError
+
+    def descr_title(self, space):
+        """S.title() -> unicode
+
+        Return a titlecased version of S, i.e. words start with title case
+        characters, all remaining cased characters have lower case.
+        """
+        raise NotImplementedError
+
+    def descr_translate(self, space, w_table):
+        """S.translate(table) -> unicode
+
+        Return a copy of the string S, where all characters have been mapped
+        through the given translation table, which must be a mapping of
+        Unicode ordinals to Unicode ordinals, Unicode strings or None.
+        Unmapped characters are left untouched. Characters mapped to None
+        are deleted.
+        """
+        raise NotImplementedError
+
+    def descr_upper(self, space):
+        """S.upper() -> unicode
+
+        Return a copy of S converted to uppercase.
+        """
+        raise NotImplementedError
+
+    @unwrap_spec(width=int)
+    def descr_zfill(self, space, width):
+        """S.zfill(width) -> unicode
+
+        Pad a numeric string S with zeros on the left, to fill a field
+        of the specified width. The string S is never truncated.
+        """
+
+    def descr_formatter_parser(self, space):
+        from pypy.objspace.std.newformat import unicode_template_formatter
+        tformat = unicode_template_formatter(space, space.unicode_w(self))
+        return tformat.formatter_parser()
+
+    def descr_formatter_field_name_split(self, space):
+        from pypy.objspace.std.newformat import unicode_template_formatter
+        tformat = unicode_template_formatter(space, space.unicode_w(self))
+        return tformat.formatter_field_name_split()
+
+
+class W_UnicodeObject(W_AbstractUnicodeObject):
     import_from_mixin(StringMethods)
     _immutable_fields_ = ['_value']
 
@@ -45,23 +527,6 @@
             return w_self
         return W_UnicodeObject(w_self._value)
 
-    def is_w(self, space, w_other):
-        if not isinstance(w_other, W_UnicodeObject):
-            return False
-        if self is w_other:
-            return True
-        if self.user_overridden_class or w_other.user_overridden_class:
-            return False
-        return space.unicode_w(self) is space.unicode_w(w_other)
-
-    def immutable_unique_id(self, space):
-        if self.user_overridden_class:
-            return None
-        return space.wrap(compute_unique_id(space.unicode_w(self)))
-
-    def str_w(self, space):
-        return space.str_w(space.str(self))
-
     def unicode_w(self, space):
         return self._value
 
@@ -76,8 +541,6 @@
         raise OperationError(space.w_TypeError, space.wrap(
             "cannot use unicode as modifiable buffer"))
 
-    charbuf_w = str_w
-
     def listview_unicode(w_self):
         return _create_list_from_unicode(w_self._value)
 
@@ -357,16 +820,6 @@
             return 0
         return 1
 
-    def descr_formatter_parser(self, space):
-        from pypy.objspace.std.newformat import unicode_template_formatter
-        tformat = unicode_template_formatter(space, space.unicode_w(self))
-        return tformat.formatter_parser()
-
-    def descr_formatter_field_name_split(self, space):
-        from pypy.objspace.std.newformat import unicode_template_formatter
-        tformat = unicode_template_formatter(space, space.unicode_w(self))
-        return tformat.formatter_field_name_split()
-
     def descr_isdecimal(self, space):
         return self._is_generic(space, '_isdecimal')
 
@@ -555,535 +1008,86 @@
         return unicode_from_encoded_object(space, w_str, "ascii", "strict")
 
 
-class UnicodeDocstrings:
-    """unicode(object='') -> unicode object
+W_UnicodeObject.typedef = TypeDef(
+    "unicode", basestring_typedef,
+    __new__ = interp2app(W_UnicodeObject.descr_new),
+    __doc__ = """unicode(object='') -> unicode object
     unicode(string[, encoding[, errors]]) -> unicode object
 
     Create a new Unicode object from the given encoded string.
     encoding defaults to the current default string encoding.
     errors can be 'strict', 'replace' or 'ignore' and defaults to 'strict'.
+    """,
 
-    """
+    __repr__ = interpindirect2app(W_AbstractUnicodeObject.descr_repr),
+    __str__ = interpindirect2app(W_AbstractUnicodeObject.descr_str),
+    __hash__ = interpindirect2app(W_AbstractUnicodeObject.descr_hash),
 
-    def __add__():
-        """x.__add__(y) <==> x+y"""
+    __eq__ = interpindirect2app(W_AbstractUnicodeObject.descr_eq),
+    __ne__ = interpindirect2app(W_AbstractUnicodeObject.descr_ne),
+    __lt__ = interpindirect2app(W_AbstractUnicodeObject.descr_lt),
+    __le__ = interpindirect2app(W_AbstractUnicodeObject.descr_le),
+    __gt__ = interpindirect2app(W_AbstractUnicodeObject.descr_gt),
+    __ge__ = interpindirect2app(W_AbstractUnicodeObject.descr_ge),
 
-    def __contains__():
-        """x.__contains__(y) <==> y in x"""
+    __len__ = interpindirect2app(W_AbstractUnicodeObject.descr_len),
+    __contains__ = interpindirect2app(W_AbstractUnicodeObject.descr_contains),
 
-    def __eq__():
-        """x.__eq__(y) <==> x==y"""
+    __add__ = interpindirect2app(W_AbstractUnicodeObject.descr_add),
+    __mul__ = interpindirect2app(W_AbstractUnicodeObject.descr_mul),
+    __rmul__ = interpindirect2app(W_AbstractUnicodeObject.descr_mul),
 
-    def __format__():
-        """S.__format__(format_spec) -> unicode
+    __getitem__ = interpindirect2app(W_AbstractUnicodeObject.descr_getitem),
+    __getslice__ = interpindirect2app(W_AbstractUnicodeObject.descr_getslice),
 
-        Return a formatted version of S as described by format_spec.
-        """
+    capitalize = interpindirect2app(W_AbstractUnicodeObject.descr_capitalize),
+    center = interpindirect2app(W_AbstractUnicodeObject.descr_center),
+    count = interpindirect2app(W_AbstractUnicodeObject.descr_count),
+    decode = interpindirect2app(W_AbstractUnicodeObject.descr_decode),
+    encode = interpindirect2app(W_AbstractUnicodeObject.descr_encode),
+    expandtabs = interpindirect2app(W_AbstractUnicodeObject.descr_expandtabs),
+    find = interpindirect2app(W_AbstractUnicodeObject.descr_find),
+    rfind = interpindirect2app(W_AbstractUnicodeObject.descr_rfind),
+    index = interpindirect2app(W_AbstractUnicodeObject.descr_index),
+    rindex = interpindirect2app(W_AbstractUnicodeObject.descr_rindex),
+    isalnum = interpindirect2app(W_AbstractUnicodeObject.descr_isalnum),
+    isalpha = interpindirect2app(W_AbstractUnicodeObject.descr_isalpha),
+    isdecimal = interpindirect2app(W_AbstractUnicodeObject.descr_isdecimal),
+    isdigit = interpindirect2app(W_AbstractUnicodeObject.descr_isdigit),
+    islower = interpindirect2app(W_AbstractUnicodeObject.descr_islower),
+    isnumeric = interpindirect2app(W_AbstractUnicodeObject.descr_isnumeric),
+    isspace = interpindirect2app(W_AbstractUnicodeObject.descr_isspace),
+    istitle = interpindirect2app(W_AbstractUnicodeObject.descr_istitle),
+    isupper = interpindirect2app(W_AbstractUnicodeObject.descr_isupper),
+    join = interpindirect2app(W_AbstractUnicodeObject.descr_join),
+    ljust = interpindirect2app(W_AbstractUnicodeObject.descr_ljust),
+    rjust = interpindirect2app(W_AbstractUnicodeObject.descr_rjust),
+    lower = interpindirect2app(W_AbstractUnicodeObject.descr_lower),
+    partition = interpindirect2app(W_AbstractUnicodeObject.descr_partition),
+    rpartition = interpindirect2app(W_AbstractUnicodeObject.descr_rpartition),
+    replace = interpindirect2app(W_AbstractUnicodeObject.descr_replace),
+    split = interpindirect2app(W_AbstractUnicodeObject.descr_split),
+    rsplit = interpindirect2app(W_AbstractUnicodeObject.descr_rsplit),
+    splitlines = interpindirect2app(W_AbstractUnicodeObject.descr_splitlines),
+    startswith = interpindirect2app(W_AbstractUnicodeObject.descr_startswith),
+    endswith = interpindirect2app(W_AbstractUnicodeObject.descr_endswith),
+    strip = interpindirect2app(W_AbstractUnicodeObject.descr_strip),
+    lstrip = interpindirect2app(W_AbstractUnicodeObject.descr_lstrip),
+    rstrip = interpindirect2app(W_AbstractUnicodeObject.descr_rstrip),
+    swapcase = interpindirect2app(W_AbstractUnicodeObject.descr_swapcase),
+    title = interpindirect2app(W_AbstractUnicodeObject.descr_title),
+    translate = interpindirect2app(W_AbstractUnicodeObject.descr_translate),
+    upper = interpindirect2app(W_AbstractUnicodeObject.descr_upper),
+    zfill = interpindirect2app(W_AbstractUnicodeObject.descr_zfill),
 
-    def __ge__():
-        """x.__ge__(y) <==> x>=y"""
-
-    def __getattribute__():
-        """x.__getattribute__('name') <==> x.name"""
-
-    def __getitem__():
-        """x.__getitem__(y) <==> x[y]"""
-
-    def __getnewargs__():
-        ""
-
-    def __getslice__():
-        """x.__getslice__(i, j) <==> x[i:j]
-
-        Use of negative indices is not supported.
-        """
-
-    def __gt__():
-        """x.__gt__(y) <==> x>y"""
-
-    def __hash__():
-        """x.__hash__() <==> hash(x)"""
-
-    def __le__():
-        """x.__le__(y) <==> x<=y"""
-
-    def __len__():
-        """x.__len__() <==> len(x)"""
-
-    def __lt__():
-        """x.__lt__(y) <==> x<y"""
-
-    def __mod__():
-        """x.__mod__(y) <==> x%y"""
-
-    def __mul__():
-        """x.__mul__(n) <==> x*n"""
-
-    def __ne__():
-        """x.__ne__(y) <==> x!=y"""
-
-    def __repr__():
-        """x.__repr__() <==> repr(x)"""
-
-    def __rmod__():
-        """x.__rmod__(y) <==> y%x"""
-
-    def __rmul__():
-        """x.__rmul__(n) <==> n*x"""
-
-    def __sizeof__():
-        """S.__sizeof__() -> size of S in memory, in bytes"""
-
-    def __str__():
-        """x.__str__() <==> str(x)"""
-
-    def capitalize():
-        """S.capitalize() -> unicode
-
-        Return a capitalized version of S, i.e. make the first character
-        have upper case and the rest lower case.
-        """
-
-    def center():
-        """S.center(width[, fillchar]) -> unicode
-
-        Return S centered in a Unicode string of length width. Padding is
-        done using the specified fill character (default is a space).
-        """
-
-    def count():
-        """S.count(sub[, start[, end]]) -> int
-
-        Return the number of non-overlapping occurrences of substring sub in
-        Unicode string S[start:end].  Optional arguments start and end are
-        interpreted as in slice notation.
-        """
-
-    def decode():
-        """S.decode(encoding=None, errors='strict') -> string or unicode
-
-        Decode S using the codec registered for encoding. encoding defaults
-        to the default encoding. errors may be given to set a different error
-        handling scheme. Default is 'strict' meaning that encoding errors raise
-        a UnicodeDecodeError. Other possible values are 'ignore' and 'replace'
-        as well as any other name registered with codecs.register_error that is
-        able to handle UnicodeDecodeErrors.
-        """
-
-    def encode():
-        """S.encode(encoding=None, errors='strict') -> string or unicode
-
-        Encode S using the codec registered for encoding. encoding defaults
-        to the default encoding. errors may be given to set a different error
-        handling scheme. Default is 'strict' meaning that encoding errors raise
-        a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and
-        'xmlcharrefreplace' as well as any other name registered with
-        codecs.register_error that can handle UnicodeEncodeErrors.
-        """
-
-    def endswith():
-        """S.endswith(suffix[, start[, end]]) -> bool
-
-        Return True if S ends with the specified suffix, False otherwise.
-        With optional start, test S beginning at that position.
-        With optional end, stop comparing S at that position.
-        suffix can also be a tuple of strings to try.
-        """
-
-    def expandtabs():
-        """S.expandtabs([tabsize]) -> unicode
-
-        Return a copy of S where all tab characters are expanded using spaces.
-        If tabsize is not given, a tab size of 8 characters is assumed.
-        """
-
-    def find():
-        """S.find(sub[, start[, end]]) -> int
-
-        Return the lowest index in S where substring sub is found,
-        such that sub is contained within S[start:end].  Optional
-        arguments start and end are interpreted as in slice notation.
-
-        Return -1 on failure.
-        """
-
-    def format():
-        """S.format(*args, **kwargs) -> unicode
-
-        Return a formatted version of S, using substitutions from args and
-        kwargs.  The substitutions are identified by braces ('{' and '}').
-        """
-
-    def index():
-        """S.index(sub[, start[, end]]) -> int
-
-        Like S.find() but raise ValueError when the substring is not found.
-        """
-
-    def isalnum():
-        """S.isalnum() -> bool
-
-        Return True if all characters in S are alphanumeric
-        and there is at least one character in S, False otherwise.
-        """
-
-    def isalpha():
-        """S.isalpha() -> bool
-
-        Return True if all characters in S are alphabetic
-        and there is at least one character in S, False otherwise.
-        """
-
-    def isdecimal():
-        """S.isdecimal() -> bool
-
-        Return True if there are only decimal characters in S,
-        False otherwise.
-        """
-
-    def isdigit():
-        """S.isdigit() -> bool
-
-        Return True if all characters in S are digits
-        and there is at least one character in S, False otherwise.
-        """
-
-    def islower():
-        """S.islower() -> bool
-
-        Return True if all cased characters in S are lowercase and there is
-        at least one cased character in S, False otherwise.
-        """
-
-    def isnumeric():
-        """S.isnumeric() -> bool
-
-        Return True if there are only numeric characters in S,
-        False otherwise.
-        """
-
-    def isspace():
-        """S.isspace() -> bool
-
-        Return True if all characters in S are whitespace
-        and there is at least one character in S, False otherwise.
-        """
-
-    def istitle():
-        """S.istitle() -> bool
-
-        Return True if S is a titlecased string and there is at least one
-        character in S, i.e. upper- and titlecase characters may only
-        follow uncased characters and lowercase characters only cased ones.
-        Return False otherwise.
-        """
-
-    def isupper():
-        """S.isupper() -> bool
-
-        Return True if all cased characters in S are uppercase and there is
-        at least one cased character in S, False otherwise.
-        """
-
-    def join():
-        """S.join(iterable) -> unicode
-
-        Return a string which is the concatenation of the strings in the
-        iterable.  The separator between elements is S.
-        """
-
-    def ljust():
-        """S.ljust(width[, fillchar]) -> int
-
-        Return S left-justified in a Unicode string of length width. Padding is
-        done using the specified fill character (default is a space).
-        """
-
-    def lower():
-        """S.lower() -> unicode
-
-        Return a copy of the string S converted to lowercase.
-        """
-
-    def lstrip():
-        """S.lstrip([chars]) -> unicode
-
-        Return a copy of the string S with leading whitespace removed.
-        If chars is given and not None, remove characters in chars instead.
-        If chars is a str, it will be converted to unicode before stripping
-        """
-
-    def partition():
-        """S.partition(sep) -> (head, sep, tail)
-
-        Search for the separator sep in S, and return the part before it,
-        the separator itself, and the part after it.  If the separator is not
-        found, return S and two empty strings.
-        """
-
-    def replace():
-        """S.replace(old, new[, count]) -> unicode
-
-        Return a copy of S with all occurrences of substring
-        old replaced by new.  If the optional argument count is
-        given, only the first count occurrences are replaced.
-        """
-
-    def rfind():
-        """S.rfind(sub[, start[, end]]) -> int
-
-        Return the highest index in S where substring sub is found,
-        such that sub is contained within S[start:end].  Optional
-        arguments start and end are interpreted as in slice notation.
-
-        Return -1 on failure.
-        """
-
-    def rindex():
-        """S.rindex(sub[, start[, end]]) -> int
-
-        Like S.rfind() but raise ValueError when the substring is not found.
-        """
-
-    def rjust():
-        """S.rjust(width[, fillchar]) -> unicode
-
-        Return S right-justified in a Unicode string of length width. Padding
-        is done using the specified fill character (default is a space).
-        """
-
-    def rpartition():
-        """S.rpartition(sep) -> (head, sep, tail)
-
-        Search for the separator sep in S, starting at the end of S, and return
-        the part before it, the separator itself, and the part after it.  If
-        the separator is not found, return two empty strings and S.
-        """
-
-    def rsplit():
-        """S.rsplit(sep=None, maxsplit=-1) -> list of strings
-
-        Return a list of the words in S, using sep as the
-        delimiter string, starting at the end of the string and
-        working to the front.  If maxsplit is given, at most maxsplit
-        splits are done. If sep is not specified, any whitespace string
-        is a separator.
-        """
-
-    def rstrip():
-        """S.rstrip([chars]) -> unicode
-
-        Return a copy of the string S with trailing whitespace removed.
-        If chars is given and not None, remove characters in chars instead.
-        If chars is a str, it will be converted to unicode before stripping
-        """
-
-    def split():
-        """S.split(sep=None, maxsplit=-1) -> list of strings
-
-        Return a list of the words in S, using sep as the
-        delimiter string.  If maxsplit is given, at most maxsplit
-        splits are done. If sep is not specified or is None, any
-        whitespace string is a separator and empty strings are
-        removed from the result.
-        """
-
-    def splitlines():
-        """S.splitlines(keepends=False) -> list of strings
-
-        Return a list of the lines in S, breaking at line boundaries.
-        Line breaks are not included in the resulting list unless keepends
-        is given and true.
-        """
-
-    def startswith():
-        """S.startswith(prefix[, start[, end]]) -> bool
-
-        Return True if S starts with the specified prefix, False otherwise.
-        With optional start, test S beginning at that position.
-        With optional end, stop comparing S at that position.
-        prefix can also be a tuple of strings to try.
-        """
-
-    def strip():
-        """S.strip([chars]) -> unicode
-
-        Return a copy of the string S with leading and trailing
-        whitespace removed.
-        If chars is given and not None, remove characters in chars instead.
-        If chars is a str, it will be converted to unicode before stripping
-        """
-
-    def swapcase():
-        """S.swapcase() -> unicode
-
-        Return a copy of S with uppercase characters converted to lowercase
-        and vice versa.
-        """
-
-    def title():
-        """S.title() -> unicode
-
-        Return a titlecased version of S, i.e. words start with title case
-        characters, all remaining cased characters have lower case.
-        """
-
-    def translate():
-        """S.translate(table) -> unicode
-
-        Return a copy of the string S, where all characters have been mapped
-        through the given translation table, which must be a mapping of
-        Unicode ordinals to Unicode ordinals, Unicode strings or None.
-        Unmapped characters are left untouched. Characters mapped to None
-        are deleted.
-        """
-
-    def upper():
-        """S.upper() -> unicode
-
-        Return a copy of S converted to uppercase.
-        """
-
-    def zfill():
-        """S.zfill(width) -> unicode
-
-        Pad a numeric string S with zeros on the left, to fill a field
-        of the specified width. The string S is never truncated.
-        """
-
-
-W_UnicodeObject.typedef = TypeDef(
-    "unicode", basestring_typedef,
-    __new__ = interp2app(W_UnicodeObject.descr_new),
-    __doc__ = UnicodeDocstrings.__doc__,
-
-    __repr__ = interp2app(W_UnicodeObject.descr_repr,
-                          doc=UnicodeDocstrings.__repr__.__doc__),
-    __str__ = interp2app(W_UnicodeObject.descr_str,
-                         doc=UnicodeDocstrings.__str__.__doc__),
-    __hash__ = interp2app(W_UnicodeObject.descr_hash,
-                          doc=UnicodeDocstrings.__hash__.__doc__),
-
-    __eq__ = interp2app(W_UnicodeObject.descr_eq,
-                        doc=UnicodeDocstrings.__eq__.__doc__),
-    __ne__ = interp2app(W_UnicodeObject.descr_ne,
-                        doc=UnicodeDocstrings.__ne__.__doc__),
-    __lt__ = interp2app(W_UnicodeObject.descr_lt,
-                        doc=UnicodeDocstrings.__lt__.__doc__),
-    __le__ = interp2app(W_UnicodeObject.descr_le,
-                        doc=UnicodeDocstrings.__le__.__doc__),
-    __gt__ = interp2app(W_UnicodeObject.descr_gt,
-                        doc=UnicodeDocstrings.__gt__.__doc__),
-    __ge__ = interp2app(W_UnicodeObject.descr_ge,
-                        doc=UnicodeDocstrings.__ge__.__doc__),
-
-    __len__ = interp2app(W_UnicodeObject.descr_len,
-                         doc=UnicodeDocstrings.__len__.__doc__),
-    __contains__ = interp2app(W_UnicodeObject.descr_contains,
-                              doc=UnicodeDocstrings.__contains__.__doc__),
-
-    __add__ = interp2app(W_UnicodeObject.descr_add,
-                         doc=UnicodeDocstrings.__add__.__doc__),
-    __mul__ = interp2app(W_UnicodeObject.descr_mul,
-                         doc=UnicodeDocstrings.__mul__.__doc__),
-    __rmul__ = interp2app(W_UnicodeObject.descr_mul,
-                          doc=UnicodeDocstrings.__rmul__.__doc__),
-
-    __getitem__ = interp2app(W_UnicodeObject.descr_getitem,
-                             doc=UnicodeDocstrings.__getitem__.__doc__),
-    __getslice__ = interp2app(W_UnicodeObject.descr_getslice,
-                              doc=UnicodeDocstrings.__getslice__.__doc__),
-
-    capitalize = interp2app(W_UnicodeObject.descr_capitalize,
-                            doc=UnicodeDocstrings.capitalize.__doc__),
-    center = interp2app(W_UnicodeObject.descr_center,
-                        doc=UnicodeDocstrings.center.__doc__),
-    count = interp2app(W_UnicodeObject.descr_count,
-                       doc=UnicodeDocstrings.count.__doc__),
-    decode = interp2app(W_UnicodeObject.descr_decode,
-                        doc=UnicodeDocstrings.decode.__doc__),
-    encode = interp2app(W_UnicodeObject.descr_encode,
-                        doc=UnicodeDocstrings.encode.__doc__),
-    expandtabs = interp2app(W_UnicodeObject.descr_expandtabs,
-                            doc=UnicodeDocstrings.expandtabs.__doc__),
-    find = interp2app(W_UnicodeObject.descr_find,
-                      doc=UnicodeDocstrings.find.__doc__),
-    rfind = interp2app(W_UnicodeObject.descr_rfind,
-                       doc=UnicodeDocstrings.rfind.__doc__),
-    index = interp2app(W_UnicodeObject.descr_index,
-                       doc=UnicodeDocstrings.index.__doc__),
-    rindex = interp2app(W_UnicodeObject.descr_rindex,
-                        doc=UnicodeDocstrings.rindex.__doc__),
-    isalnum = interp2app(W_UnicodeObject.descr_isalnum,
-                         doc=UnicodeDocstrings.isalnum.__doc__),
-    isalpha = interp2app(W_UnicodeObject.descr_isalpha,
-                         doc=UnicodeDocstrings.isalpha.__doc__),
-    isdecimal = interp2app(W_UnicodeObject.descr_isdecimal,
-                           doc=UnicodeDocstrings.isdecimal.__doc__),
-    isdigit = interp2app(W_UnicodeObject.descr_isdigit,
-                         doc=UnicodeDocstrings.isdigit.__doc__),
-    islower = interp2app(W_UnicodeObject.descr_islower,
-                         doc=UnicodeDocstrings.islower.__doc__),
-    isnumeric = interp2app(W_UnicodeObject.descr_isnumeric,
-                           doc=UnicodeDocstrings.isnumeric.__doc__),
-    isspace = interp2app(W_UnicodeObject.descr_isspace,
-                         doc=UnicodeDocstrings.isspace.__doc__),
-    istitle = interp2app(W_UnicodeObject.descr_istitle,
-                         doc=UnicodeDocstrings.istitle.__doc__),
-    isupper = interp2app(W_UnicodeObject.descr_isupper,
-                         doc=UnicodeDocstrings.isupper.__doc__),
-    join = interp2app(W_UnicodeObject.descr_join,
-                      doc=UnicodeDocstrings.join.__doc__),
-    ljust = interp2app(W_UnicodeObject.descr_ljust,
-                       doc=UnicodeDocstrings.ljust.__doc__),
-    rjust = interp2app(W_UnicodeObject.descr_rjust,
-                       doc=UnicodeDocstrings.rjust.__doc__),
-    lower = interp2app(W_UnicodeObject.descr_lower,
-                       doc=UnicodeDocstrings.lower.__doc__),
-    partition = interp2app(W_UnicodeObject.descr_partition,
-                           doc=UnicodeDocstrings.partition.__doc__),
-    rpartition = interp2app(W_UnicodeObject.descr_rpartition,
-                            doc=UnicodeDocstrings.rpartition.__doc__),
-    replace = interp2app(W_UnicodeObject.descr_replace,
-                         doc=UnicodeDocstrings.replace.__doc__),
-    split = interp2app(W_UnicodeObject.descr_split,
-                       doc=UnicodeDocstrings.split.__doc__),
-    rsplit = interp2app(W_UnicodeObject.descr_rsplit,
-                        doc=UnicodeDocstrings.rsplit.__doc__),
-    splitlines = interp2app(W_UnicodeObject.descr_splitlines,
-                            doc=UnicodeDocstrings.splitlines.__doc__),
-    startswith = interp2app(W_UnicodeObject.descr_startswith,
-                            doc=UnicodeDocstrings.startswith.__doc__),
-    endswith = interp2app(W_UnicodeObject.descr_endswith,
-                          doc=UnicodeDocstrings.endswith.__doc__),
-    strip = interp2app(W_UnicodeObject.descr_strip,
-                       doc=UnicodeDocstrings.strip.__doc__),
-    lstrip = interp2app(W_UnicodeObject.descr_lstrip,
-                        doc=UnicodeDocstrings.lstrip.__doc__),
-    rstrip = interp2app(W_UnicodeObject.descr_rstrip,
-                        doc=UnicodeDocstrings.rstrip.__doc__),
-    swapcase = interp2app(W_UnicodeObject.descr_swapcase,
-                          doc=UnicodeDocstrings.swapcase.__doc__),
-    title = interp2app(W_UnicodeObject.descr_title,
-                       doc=UnicodeDocstrings.title.__doc__),
-    translate = interp2app(W_UnicodeObject.descr_translate,
-                           doc=UnicodeDocstrings.translate.__doc__),
-    upper = interp2app(W_UnicodeObject.descr_upper,
-                       doc=UnicodeDocstrings.upper.__doc__),
-    zfill = interp2app(W_UnicodeObject.descr_zfill,
-                       doc=UnicodeDocstrings.zfill.__doc__),
-
-    format = interp2app(W_UnicodeObject.descr_format,
-                        doc=UnicodeDocstrings.format.__doc__),
-    __format__ = interp2app(W_UnicodeObject.descr__format__,
-                            doc=UnicodeDocstrings.__format__.__doc__),
-    __mod__ = interp2app(W_UnicodeObject.descr_mod,
-                         doc=UnicodeDocstrings.__mod__.__doc__),
-    __getnewargs__ = interp2app(W_UnicodeObject.descr_getnewargs,
-                                doc=UnicodeDocstrings.__getnewargs__.__doc__),
-    _formatter_parser = interp2app(W_UnicodeObject.descr_formatter_parser),
+    format = interpindirect2app(W_AbstractUnicodeObject.descr_format),
+    __format__ = interpindirect2app(W_AbstractUnicodeObject.descr__format__),
+    __mod__ = interpindirect2app(W_AbstractUnicodeObject.descr_mod),
+    __getnewargs__ = 
interpindirect2app(W_AbstractUnicodeObject.descr_getnewargs),
+    _formatter_parser =
+        interp2app(W_AbstractUnicodeObject.descr_formatter_parser),
     _formatter_field_name_split =
-        interp2app(W_UnicodeObject.descr_formatter_field_name_split),
+        interp2app(W_AbstractUnicodeObject.descr_formatter_field_name_split),
 )
 W_UnicodeObject.typedef.flag_sequence_bug_compat = True
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to