Author: Antonio Cuni <[email protected]>
Branch: py3k
Changeset: r53683:f777de064e71
Date: 2012-03-15 16:56 +0100
http://bitbucket.org/pypy/pypy/changeset/f777de064e71/
Log: remove the implicit conversion bytes-->unicode. Now calling
space.unicode_w(w_some_bytes) raises TypeError. This fixes at least
test_join in test_unicodeobject.py
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1329,10 +1329,6 @@
return self.str_w(w_obj)
def unicode_w(self, w_obj):
- if not we_are_translated():
- if self.isinstance_w(w_obj, self.w_bytes):
- import pdb; pdb.set_trace()
- assert False, "unicode_w was called with a bytes string"
return w_obj.unicode_w(self)
def unicode0_w(self, w_obj):
diff --git a/pypy/objspace/std/stringobject.py
b/pypy/objspace/std/stringobject.py
--- a/pypy/objspace/std/stringobject.py
+++ b/pypy/objspace/std/stringobject.py
@@ -55,20 +55,6 @@
def bytes_w(w_self, space):
return w_self._value
- def unicode_w(w_self, space):
- # Use the default encoding.
- from pypy.objspace.std.unicodetype import unicode_from_string, \
- decode_object
- w_defaultencoding = space.call_function(space.sys.get(
- 'getdefaultencoding'))
- from pypy.objspace.std.unicodetype import _get_encoding_and_errors, \
- unicode_from_string, decode_object
- encoding, errors = _get_encoding_and_errors(space, w_defaultencoding,
- space.w_None)
- if encoding is None and errors is None:
- return space.unicode_w(unicode_from_string(space, w_self))
- return space.unicode_w(decode_object(space, w_self, encoding, errors))
-
registerimplementation(W_StringObject)
W_StringObject.EMPTY = W_StringObject('')
diff --git a/pypy/objspace/std/test/test_unicodeobject.py
b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -30,7 +30,7 @@
check(', '.join(['a']), 'a')
raises(TypeError, ','.join, [b'a'])
exc = raises(TypeError, ''.join, ['a', 2, 3])
- assert 'sequence item 1' in str(e.value)
+ assert 'sequence item 1' in str(exc.value)
def test_contains(self):
assert '' in 'abc'
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit