Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r45125:e2764bf4c162 Date: 2011-06-25 19:19 +0200 http://bitbucket.org/pypy/pypy/changeset/e2764bf4c162/
Log: merge heads 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 @@ -367,3 +367,14 @@ data, len(u), lltype.nullptr(rffi.CCHARP.TO)) rffi.free_wcharp(data) + def test_format(self, space, api): + w_format = space.wrap(u'hi %s') + w_args = space.wrap((u'test',)) + w_formated = api.PyUnicode_Format(w_format, w_args) + assert space.unwrap(w_formated) == space.unwrap(space.mod(w_format, w_args)) + + def test_join(self, space, api): + w_sep = space.wrap(u'<sep>') + w_seq = space.wrap([u'a', u'b']) + w_joined = api.PyUnicode_Join(w_sep, w_seq) + assert space.unwrap(w_joined) == u'a<sep>b' diff --git a/pypy/module/cpyext/unicodeobject.py b/pypy/module/cpyext/unicodeobject.py --- a/pypy/module/cpyext/unicodeobject.py +++ b/pypy/module/cpyext/unicodeobject.py @@ -523,3 +523,11 @@ copies sizeof(Py_UNICODE) * length bytes from source to target""" for i in range(0, length): target[i] = source[i] + +@cpython_api([PyObject, PyObject], PyObject) +def PyUnicode_Format(space, w_format, w_args): + return space.mod(w_format, w_args) + +@cpython_api([PyObject, PyObject], PyObject) +def PyUnicode_Join(space, w_sep, w_seq): + return space.call_method(w_sep, 'join', w_seq) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit