[pypy-commit] pypy py3k: hg merge default
amauryfa
noreply at buildbot.pypy.org
Wed May 2 01:04:09 CEST 2012
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r54863:67e35dd3ead5
Date: 2012-05-01 18:50 +0200
http://bitbucket.org/pypy/pypy/changeset/67e35dd3ead5/
Log: hg merge default
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
@@ -4,7 +4,7 @@
from pypy.module.cpyext.unicodeobject import (
Py_UNICODE, PyUnicodeObject, new_empty_unicode)
from pypy.module.cpyext.api import PyObjectP, PyObject
-from pypy.module.cpyext.pyobject import Py_DecRef
+from pypy.module.cpyext.pyobject import Py_DecRef, from_ref
from pypy.rpython.lltypesystem import rffi, lltype
import sys, py
@@ -180,7 +180,9 @@
w_res = api.PyUnicode_FromString(s)
assert space.unwrap(w_res) == u'sp�m'
- w_res = api.PyUnicode_FromStringAndSize(s, 4)
+ res = api.PyUnicode_FromStringAndSize(s, 4)
+ w_res = from_ref(space, res)
+ api.Py_DecRef(res)
assert space.unwrap(w_res) == u'sp�'
rffi.free_charp(s)
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
@@ -419,10 +419,10 @@
needed data. The buffer is copied into the new object. If the buffer is not
NULL, the return value might be a shared object. Therefore, modification of
the resulting Unicode object is only allowed when u is NULL."""
- if not s:
- raise NotImplementedError
- w_str = space.wrap(rffi.charpsize2str(s, size))
- return space.call_method(w_str, 'decode', space.wrap("utf-8"))
+ if s:
+ return make_ref(space, PyUnicode_DecodeUTF8(space, s, size, None))
+ else:
+ return rffi.cast(PyObject, new_empty_unicode(space, size))
@cpython_api([rffi.INT_real], PyObject)
def PyUnicode_FromOrdinal(space, ordinal):
@@ -481,6 +481,7 @@
else:
w_errors = space.w_None
return space.call_method(w_s, 'decode', space.wrap(encoding), w_errors)
+ globals()['PyUnicode_Decode%s' % suffix] = PyUnicode_DecodeXXX
@cpython_api([CONST_WSTRING, Py_ssize_t, CONST_STRING], PyObject)
@func_renamer('PyUnicode_Encode%s' % suffix)
@@ -494,6 +495,7 @@
else:
w_errors = space.w_None
return space.call_method(w_u, 'encode', space.wrap(encoding), w_errors)
+ globals()['PyUnicode_Encode%s' % suffix] = PyUnicode_EncodeXXX
make_conversion_functions('UTF8', 'utf-8')
make_conversion_functions('ASCII', 'ascii')
More information about the pypy-commit
mailing list