Author: Ronan Lamy <[email protected]>
Branch:
Changeset: r93261:9344c533d95d
Date: 2017-12-03 20:41 +0000
http://bitbucket.org/pypy/pypy/changeset/9344c533d95d/
Log: space.unwrap() -> space.unicode_w()
diff --git a/pypy/module/cpyext/test/test_codecs.py
b/pypy/module/cpyext/test/test_codecs.py
--- a/pypy/module/cpyext/test/test_codecs.py
+++ b/pypy/module/cpyext/test/test_codecs.py
@@ -11,5 +11,5 @@
w_encoded = space.call_method(w_encoder, 'encode',
space.wrap(u'späm'))
w_decoder = PyCodec_IncrementalDecoder(space, utf8, None)
w_decoded = space.call_method(w_decoder, 'decode', w_encoded)
- assert space.unwrap(w_decoded) == u'späm'
+ assert space.unicode_w(w_decoded) == u'späm'
rffi.free_charp(utf8)
diff --git a/pypy/module/cpyext/test/test_eval.py
b/pypy/module/cpyext/test/test_eval.py
--- a/pypy/module/cpyext/test/test_eval.py
+++ b/pypy/module/cpyext/test/test_eval.py
@@ -131,7 +131,7 @@
finally:
rffi.free_charp(buf)
w_a = space.getitem(w_globals, space.wrap("a"))
- assert space.unwrap(w_a) == u'caf\xe9'
+ assert space.unicode_w(w_a) == u'caf\xe9'
lltype.free(flags, flavor='raw')
def test_run_file(self, space):
diff --git a/pypy/module/cpyext/test/test_object.py
b/pypy/module/cpyext/test/test_object.py
--- a/pypy/module/cpyext/test/test_object.py
+++ b/pypy/module/cpyext/test/test_object.py
@@ -8,7 +8,7 @@
from pypy.module.cpyext.object import (
PyObject_IsTrue, PyObject_Not, PyObject_GetAttrString,
PyObject_DelAttrString, PyObject_GetAttr, PyObject_DelAttr,
- PyObject_GetItem,
+ PyObject_GetItem,
PyObject_IsInstance, PyObject_IsSubclass, PyObject_AsFileDescriptor,
PyObject_Hash, PyObject_Cmp, PyObject_Unicode
)
@@ -209,9 +209,9 @@
PyObject_Cmp(space, w(u"\xe9"), w("\xe9"), ptr)
def test_unicode(self, space, api):
- assert space.unwrap(api.PyObject_Unicode(None)) == u"<NULL>"
- assert space.unwrap(api.PyObject_Unicode(space.wrap([]))) == u"[]"
- assert space.unwrap(api.PyObject_Unicode(space.wrap("e"))) == u"e"
+ assert space.unicode_w(api.PyObject_Unicode(None)) == u"<NULL>"
+ assert space.unicode_w(api.PyObject_Unicode(space.wrap([]))) == u"[]"
+ assert space.unicode_w(api.PyObject_Unicode(space.wrap("e"))) == u"e"
with raises_w(space, UnicodeDecodeError):
PyObject_Unicode(space, space.wrap("\xe9"))
@@ -562,7 +562,7 @@
PyObject *a = PyTuple_GetItem(args, 0);
PyObject *b = PyTuple_GetItem(args, 1);
int res = PyObject_RichCompareBool(a, b, Py_EQ);
- return PyLong_FromLong(res);
+ return PyLong_FromLong(res);
"""),])
a = float('nan')
b = float('nan')
diff --git a/pypy/module/cpyext/test/test_unicodeobject.py
b/pypy/module/cpyext/test/test_unicodeobject.py
--- a/pypy/module/cpyext/test/test_unicodeobject.py
+++ b/pypy/module/cpyext/test/test_unicodeobject.py
@@ -178,7 +178,7 @@
array = rffi.cast(rffi.CWCHARP, PyUnicode_AS_DATA(space, word))
array2 = PyUnicode_AS_UNICODE(space, word)
array3 = PyUnicode_AsUnicode(space, word)
- for (i, char) in enumerate(space.unwrap(word)):
+ for (i, char) in enumerate(space.unicode_w(word)):
assert array[i] == char
assert array2[i] == char
assert array3[i] == char
@@ -216,12 +216,12 @@
def test_fromstring(self, space):
s = rffi.str2charp(u'sp\x09m'.encode("utf-8"))
w_res = PyUnicode_FromString(space, s)
- assert space.unwrap(w_res) == u'sp\x09m'
+ assert space.unicode_w(w_res) == u'sp\x09m'
res = PyUnicode_FromStringAndSize(space, s, 4)
w_res = from_ref(space, res)
Py_DecRef(space, res)
- assert space.unwrap(w_res) == u'sp\x09m'
+ assert space.unicode_w(w_res) == u'sp\x09m'
rffi.free_charp(s)
def test_unicode_resize(self, space):
@@ -256,17 +256,17 @@
u = rffi.str2charp(u'sp\x134m'.encode("utf-8"))
w_u = PyUnicode_DecodeUTF8(space, u, 5, None)
assert space.type(w_u) is space.w_unicode
- assert space.unwrap(w_u) == u'sp\x134m'
+ assert space.unicode_w(w_u) == u'sp\x134m'
w_u = PyUnicode_DecodeUTF8(space, u, 2, None)
assert space.type(w_u) is space.w_unicode
- assert space.unwrap(w_u) == 'sp'
+ assert space.unicode_w(w_u) == 'sp'
rffi.free_charp(u)
def test_encode_utf8(self, space):
u = rffi.unicode2wcharp(u'sp\x09m')
w_s = PyUnicode_EncodeUTF8(space, u, 4, None)
- assert space.unwrap(w_s) == u'sp\x09m'.encode('utf-8')
+ assert space.unicode_w(w_s) == u'sp\x09m'.encode('utf-8')
rffi.free_wcharp(u)
def test_encode_decimal(self, space):
@@ -364,18 +364,18 @@
def test_fromobject(self, space):
w_u = space.wrap(u'a')
assert PyUnicode_FromObject(space, w_u) is w_u
- assert space.unwrap(
+ assert space.unicode_w(
PyUnicode_FromObject(space, space.wrap('test'))) == 'test'
def test_decode(self, space):
b_text = rffi.str2charp('caf\x82xx')
b_encoding = rffi.str2charp('cp437')
- assert space.unwrap(
+ assert space.unicode_w(
PyUnicode_Decode(space, b_text, 4, b_encoding, None)) == u'caf\xe9'
w_text = PyUnicode_FromEncodedObject(space, space.wrap("test"),
b_encoding, None)
assert space.isinstance_w(w_text, space.w_unicode)
- assert space.unwrap(w_text) == "test"
+ assert space.unicode_w(w_text) == "test"
with raises_w(space, TypeError):
PyUnicode_FromEncodedObject(space, space.wrap(u"test"),
@@ -391,7 +391,8 @@
u_text = u'abcdefg'
s_text = space.str_w(PyUnicode_AsEncodedString(space,
space.wrap(u_text), null_charp, null_charp))
b_text = rffi.str2charp(s_text)
- assert space.unwrap(PyUnicode_Decode(space, b_text, len(s_text),
null_charp, null_charp)) == u_text
+ assert space.unicode_w(PyUnicode_Decode(
+ space, b_text, len(s_text), null_charp, null_charp)) == u_text
with raises_w(space, TypeError):
PyUnicode_FromEncodedObject(
space, space.wrap(u_text), null_charp, None)
@@ -508,7 +509,7 @@
def test_concat(self, space):
w_res = PyUnicode_Concat(space, space.wrap(u'a'), space.wrap(u'b'))
- assert space.unwrap(w_res) == u'ab'
+ assert space.unicode_w(w_res) == u'ab'
def test_copy(self, space):
w_x = space.wrap(u"abcd\u0660")
@@ -579,29 +580,30 @@
w_format = space.wrap(u'hi %s')
w_args = space.wrap((u'test',))
w_formated = PyUnicode_Format(space, w_format, w_args)
- assert space.unwrap(w_formated) == space.unwrap(space.mod(w_format,
w_args))
+ assert (space.unicode_w(w_formated) ==
+ space.unicode_w(space.mod(w_format, w_args)))
def test_join(self, space):
w_sep = space.wrap(u'<sep>')
w_seq = space.wrap([u'a', u'b'])
w_joined = PyUnicode_Join(space, w_sep, w_seq)
- assert space.unwrap(w_joined) == u'a<sep>b'
+ assert space.unicode_w(w_joined) == u'a<sep>b'
def test_fromordinal(self, space):
w_char = PyUnicode_FromOrdinal(space, 65)
- assert space.unwrap(w_char) == u'A'
+ assert space.unicode_w(w_char) == u'A'
w_char = PyUnicode_FromOrdinal(space, 0)
- assert space.unwrap(w_char) == u'\0'
+ assert space.unicode_w(w_char) == u'\0'
w_char = PyUnicode_FromOrdinal(space, 0xFFFF)
- assert space.unwrap(w_char) == u'\uFFFF'
+ assert space.unicode_w(w_char) == u'\uFFFF'
def test_replace(self, space):
w_str = space.wrap(u"abababab")
w_substr = space.wrap(u"a")
w_replstr = space.wrap(u"z")
- assert u"zbzbabab" == space.unwrap(
+ assert u"zbzbabab" == space.unicode_w(
PyUnicode_Replace(space, w_str, w_substr, w_replstr, 2))
- assert u"zbzbzbzb" == space.unwrap(
+ assert u"zbzbzbzb" == space.unicode_w(
PyUnicode_Replace(space, w_str, w_substr, w_replstr, -1))
def test_tailmatch(self, space):
diff --git a/pypy/module/unicodedata/test/test_hyp.py
b/pypy/module/unicodedata/test/test_hyp.py
--- a/pypy/module/unicodedata/test/test_hyp.py
+++ b/pypy/module/unicodedata/test/test_hyp.py
@@ -10,7 +10,7 @@
def normalize(s):
w_s = space.newunicode(s)
w_res = ucd.normalize(space, NF_code, w_s)
- return space.unwrap(w_res)
+ return space.unicode_w(w_res)
return normalize
all_forms = ['NFC', 'NFD', 'NFKC', 'NFKD']
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit