[pypy-commit] pypy py3.5: Rename _PyUnicode_AsString to PyUnicode_AsUTF8 (changed in 3.3)
rlamy
pypy.commits at gmail.com
Fri Jan 27 14:44:39 EST 2017
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.5
Changeset: r89805:2e61542390d8
Date: 2017-01-27 19:43 +0000
http://bitbucket.org/pypy/pypy/changeset/2e61542390d8/
Log: Rename _PyUnicode_AsString to PyUnicode_AsUTF8 (changed in 3.3)
diff --git a/pypy/module/cpyext/include/unicodeobject.h b/pypy/module/cpyext/include/unicodeobject.h
--- a/pypy/module/cpyext/include/unicodeobject.h
+++ b/pypy/module/cpyext/include/unicodeobject.h
@@ -10,6 +10,8 @@
PyAPI_FUNC(PyObject *) PyUnicode_FromFormatV(const char *format, va_list vargs);
PyAPI_FUNC(PyObject *) PyUnicode_FromFormat(const char *format, ...);
+#define _PyUnicode_AsString PyUnicode_AsUTF8
+
PyAPI_FUNC(wchar_t*) PyUnicode_AsWideCharString(PyObject *unicode, Py_ssize_t *size);
Py_LOCAL_INLINE(size_t) Py_UNICODE_strlen(const Py_UNICODE *u)
diff --git a/pypy/module/cpyext/modsupport.py b/pypy/module/cpyext/modsupport.py
--- a/pypy/module/cpyext/modsupport.py
+++ b/pypy/module/cpyext/modsupport.py
@@ -28,7 +28,7 @@
"""Create a new module object, given the definition in module, assuming the
API version module_api_version. If that version does not match the version
of the running interpreter, a RuntimeWarning is emitted.
-
+
Most uses of this function should be using PyModule_Create()
instead; only use this if you are sure you need it."""
@@ -123,5 +123,5 @@
# and returns a "char *" inside this PyStringObject.
if not isinstance(w_mod, Module):
raise oefmt(space.w_SystemError, "PyModule_GetName(): not a module")
- from pypy.module.cpyext.unicodeobject import _PyUnicode_AsString
- return _PyUnicode_AsString(space, as_pyobj(space, w_mod.w_name))
+ from pypy.module.cpyext.unicodeobject import PyUnicode_AsUTF8
+ return PyUnicode_AsUTF8(space, as_pyobj(space, w_mod.w_name))
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -645,9 +645,9 @@
w_typename = space.getattr(w_type, space.wrap('__name__'))
heaptype = cts.cast('PyHeapTypeObject*', pto)
heaptype.c_ht_name = make_ref(space, w_typename)
- from pypy.module.cpyext.unicodeobject import _PyUnicode_AsString
+ from pypy.module.cpyext.unicodeobject import PyUnicode_AsUTF8
pto.c_tp_name = cts.cast('const char *',
- _PyUnicode_AsString(space, heaptype.c_ht_name))
+ PyUnicode_AsUTF8(space, heaptype.c_ht_name))
else:
pto.c_tp_name = cts.cast('const char*', rffi.str2charp(w_type.name))
# uninitialized fields:
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
@@ -2,7 +2,7 @@
from rpython.rtyper.lltypesystem import rffi, lltype
from pypy.module.unicodedata import unicodedb
from pypy.module.cpyext.api import (
- CANNOT_FAIL, Py_ssize_t, build_type_checkers, cpython_api,
+ CANNOT_FAIL, Py_ssize_t, build_type_checkers, cpython_api, api_decl,
bootstrap_function, CONST_STRING,
CONST_WSTRING, Py_CLEANUP_SUPPORTED, slot_function, cts, parse_dir)
from pypy.module.cpyext.pyerrors import PyErr_BadArgument
@@ -234,8 +234,8 @@
raise oefmt(space.w_TypeError, "expected unicode object")
return PyUnicode_AS_UNICODE(space, rffi.cast(rffi.VOIDP, ref))
- at cpython_api([PyObject], rffi.CCHARP)
-def _PyUnicode_AsString(space, ref):
+ at api_decl("char * PyUnicode_AsUTF8(PyObject *unicode)", cts)
+def PyUnicode_AsUTF8(space, ref):
ref_unicode = rffi.cast(PyUnicodeObject, ref)
if not ref_unicode.c_utf8buffer:
# Copy unicode buffer
More information about the pypy-commit
mailing list