Author: Brian Kearns <[email protected]>
Branch: py3k
Changeset: r71249:86e1c15b52c6
Date: 2014-05-03 18:55 -0400
http://bitbucket.org/pypy/pypy/changeset/86e1c15b52c6/
Log: kill bufferstr_or_u_w
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1392,7 +1392,7 @@
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:
@@ -1448,17 +1448,6 @@
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
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -129,9 +129,6 @@
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)
@@ -251,9 +248,6 @@
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(),))
@@ -397,9 +391,6 @@
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(),))
diff --git a/pypy/module/_codecs/interp_codecs.py
b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -769,9 +769,9 @@
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)
@@ -789,9 +789,9 @@
# ____________________________________________________________
# 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)
@@ -828,14 +828,16 @@
# 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))])
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit