Commits

Brian Kearns  committed 86e1c15

kill bufferstr_or_u_w

  • Participants
  • Parent commits 3360556
  • Branches py3k

Comments (0)

Files changed (3)

File pypy/interpreter/baseobjspace.py

             code = 's*'
         if code == 's*':
             if self.isinstance_w(w_obj, self.w_str):
-                return StringBuffer(w_obj.bytes_w)
+                return StringBuffer(w_obj.bytes_w(self))
             if self.isinstance_w(w_obj, self.w_unicode):
                 return StringBuffer(w_obj.identifier_w(self))
             try:
         else:
             return buf.as_str()
 
-    def bufferstr_or_u_w(self, w_obj):
-        """Returns an interp-level str, directly if possible.
-
-        Accepts unicode or any type supporting the buffer
-        interface. Unicode objects will be encoded to the default
-        encoding (UTF-8)
-        """
-        if self.isinstance_w(w_obj, self.w_unicode):
-            return w_obj.identifier_w(self)
-        return self.bufferstr_w(w_obj)
-
     def str_or_None_w(self, w_obj):
         if self.is_w(w_obj, self.w_None):
             return None

File pypy/interpreter/gateway.py

     def visit_bufferstr(self, el, app_sig):
         self.checked_space_method(el, app_sig)
 
-    def visit_bufferstr_or_u(self, el, app_sig):
-        self.checked_space_method(el, app_sig)
-
     def visit_str_or_None(self, el, app_sig):
         self.checked_space_method(el, app_sig)
 
     def visit_bufferstr(self, typ):
         self.run_args.append("space.bufferstr_w(%s)" % (self.scopenext(),))
 
-    def visit_bufferstr_or_u(self, typ):
-        self.run_args.append("space.bufferstr_or_u_w(%s)" % (self.scopenext(),))
-
     def visit_str_or_None(self, typ):
         self.run_args.append("space.str_or_None_w(%s)" % (self.scopenext(),))
 
     def visit_bufferstr(self, typ):
         self.unwrap.append("space.bufferstr_w(%s)" % (self.nextarg(),))
 
-    def visit_bufferstr_or_u(self, typ):
-        self.unwrap.append("space.bufferstr_or_u_w(%s)" % (self.nextarg(),))
-
     def visit_str_or_None(self, typ):
         self.unwrap.append("space.str_or_None_w(%s)" % (self.nextarg(),))
 

File pypy/module/_codecs/interp_codecs.py

             return -1
         return space.int_w(w_code)
 
-@unwrap_spec(string='bufferstr_or_u', errors='str_or_None',
-             w_final=WrappedDefault(False))
-def unicode_escape_decode(space, string, errors="strict", w_final=None):
+@unwrap_spec(errors='str_or_None', w_final=WrappedDefault(False))
+def unicode_escape_decode(space, w_string, errors="strict", w_final=None):
+    string = space.getarg_w('s*', w_string).as_str()
     if errors is None:
         errors = 'strict'
     final = space.is_true(w_final)
 # ____________________________________________________________
 # Raw Unicode escape (accepts bytes or str)
 
-@unwrap_spec(string='bufferstr_or_u', errors='str_or_None',
-             w_final=WrappedDefault(False))
-def raw_unicode_escape_decode(space, string, errors="strict", w_final=None):
+@unwrap_spec(errors='str_or_None', w_final=WrappedDefault(False))
+def raw_unicode_escape_decode(space, w_string, errors="strict", w_final=None):
+    string = space.getarg_w('s*', w_string).as_str()
     if errors is None:
         errors = 'strict'
     final = space.is_true(w_final)
 # support for the "string escape" translation
 # This is a bytes-to bytes transformation
 
-@unwrap_spec(data="bufferstr", errors='str_or_None')
-def escape_encode(space, data, errors='strict'):
+@unwrap_spec(errors='str_or_None')
+def escape_encode(space, w_data, errors='strict'):
+    data = space.bytes_w(w_data)
     from pypy.objspace.std.bytesobject import string_escape_encode
     result = string_escape_encode(data, False)
     return space.newtuple([space.wrapbytes(result), space.wrap(len(data))])
 
-@unwrap_spec(data='bufferstr_or_u', errors='str_or_None')
-def escape_decode(space, data, errors='strict'):
+@unwrap_spec(errors='str_or_None')
+def escape_decode(space, w_data, errors='strict'):
+    data = space.getarg_w('s#', w_data)
     from pypy.interpreter.pyparser.parsestring import PyString_DecodeEscape
     result = PyString_DecodeEscape(space, data, errors, None)
     return space.newtuple([space.wrapbytes(result), space.wrap(len(data))])