Skip to content

Commit bf6e560

Browse files
author
Victor Stinner
committed
Make PyUnicode_Copy() private => _PyUnicode_Copy()
Undocument the function. Make also decode_utf8_errors() as private (static).
1 parent 7a9105a commit bf6e560

5 files changed

Lines changed: 12 additions & 17 deletions

File tree

‎Doc/c-api/unicode.rst‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,6 @@ APIs:
386386
.. versionadded:: 3.3
387387
388388
389-
.. c:function:: PyObject* PyUnicode_Copy(PyObject *unicode)
390-
391-
Get a new copy of a Unicode object.
392-
393-
.. versionadded:: 3.3
394-
395-
396389
.. c:function:: PyObject* PyUnicode_FromKindAndData(int kind, const void *buffer, \
397390
Py_ssize_t size)
398391

‎Doc/whatsnew/3.3.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,8 @@ Unicode functions and methods using :c:type:`Py_UNICODE` and
769769
* :c:macro:`PyUnicode_GET_DATA_SIZE`: use
770770
``PyUnicode_GET_LENGTH(str) * PyUnicode_KIND(str)`` (only work on ready
771771
strings)
772-
* :c:func:`PyUnicode_AsUnicodeCopy`: use :c:func:`PyUnicode_AsUCS4Copy`,
773-
:c:func:`PyUnicode_AsWideCharString` or :c:func:`PyUnicode_Copy`
772+
* :c:func:`PyUnicode_AsUnicodeCopy`: use :c:func:`PyUnicode_AsUCS4Copy` or
773+
:c:func:`PyUnicode_AsWideCharString`
774774

775775
Functions and macros manipulating Py_UNICODE* strings:
776776

‎Include/unicodeobject.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,11 @@ PyAPI_FUNC(int) _PyUnicode_Ready(
616616
#endif
617617

618618
/* Get a copy of a Unicode string. */
619-
PyAPI_FUNC(PyObject*) PyUnicode_Copy(
619+
#ifndef Py_LIMITED_API
620+
PyAPI_FUNC(PyObject*) _PyUnicode_Copy(
620621
PyObject *unicode
621622
);
623+
#endif
622624

623625
/* Copy character from one unicode object into another, this function performs
624626
character conversion when necessary and falls back to memcpy if possible.

‎Objects/codeobject.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ validate_and_copy_tuple(PyObject *tup)
249249
return NULL;
250250
}
251251
else {
252-
item = PyUnicode_Copy(item);
252+
item = _PyUnicode_Copy(item);
253253
if (item == NULL) {
254254
Py_DECREF(newtuple);
255255
return NULL;

‎Objects/unicodeobject.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ unicode_result_unchanged(PyObject *unicode)
497497
}
498498
else
499499
/* Subtype -- return genuine unicode string with the same value. */
500-
return PyUnicode_Copy(unicode);
500+
return _PyUnicode_Copy(unicode);
501501
}
502502

503503
#ifdef HAVE_MBCS
@@ -1961,7 +1961,7 @@ unicode_adjust_maxchar(PyObject **p_unicode)
19611961
}
19621962

19631963
PyObject*
1964-
PyUnicode_Copy(PyObject *unicode)
1964+
_PyUnicode_Copy(PyObject *unicode)
19651965
{
19661966
Py_ssize_t length;
19671967
PyObject *copy;
@@ -2832,7 +2832,7 @@ PyUnicode_FromObject(register PyObject *obj)
28322832
if (PyUnicode_Check(obj)) {
28332833
/* For a Unicode subtype that's not a Unicode object,
28342834
return a true Unicode object with the same data. */
2835-
return PyUnicode_Copy(obj);
2835+
return _PyUnicode_Copy(obj);
28362836
}
28372837
PyErr_Format(PyExc_TypeError,
28382838
"Can't convert '%.100s' object to str implicitly",
@@ -4333,7 +4333,7 @@ utf8_scanner(const unsigned char *p, Py_ssize_t string_size, Py_ssize_t *unicode
43334333
goto onError; \
43344334
} while (0)
43354335

4336-
PyObject *
4336+
static PyObject *
43374337
decode_utf8_errors(const char *starts,
43384338
Py_ssize_t size,
43394339
const char *errors,
@@ -9231,7 +9231,7 @@ fixup(PyObject *self,
92319231
Py_UCS4 maxchar_old, maxchar_new = 0;
92329232
PyObject *v;
92339233

9234-
u = PyUnicode_Copy(self);
9234+
u = _PyUnicode_Copy(self);
92359235
if (u == NULL)
92369236
return NULL;
92379237
maxchar_old = PyUnicode_MAX_CHAR_VALUE(u);
@@ -12753,7 +12753,7 @@ PyDoc_STRVAR(sizeof__doc__,
1275312753
static PyObject *
1275412754
unicode_getnewargs(PyObject *v)
1275512755
{
12756-
PyObject *copy = PyUnicode_Copy(v);
12756+
PyObject *copy = _PyUnicode_Copy(v);
1275712757
if (!copy)
1275812758
return NULL;
1275912759
return Py_BuildValue("(N)", copy);

0 commit comments

Comments
 (0)