8000 Rename to PyUnicodeWriter_FromFormat() · python/cpython@8de16a1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8de16a1

Browse files
committed
Rename to PyUnicodeWriter_FromFormat()
1 parent e751859 commit 8de16a1

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

Include/cpython/unicodeobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ PyAPI_FUNC(int) PyUnicodeWriter_WriteSubstring(
470470
PyObject *str,
471471
Py_ssize_t start,
472472
Py_ssize_t stop);
473-
PyAPI_FUNC(int) PyUnicodeWriter_Format(
473+
PyAPI_FUNC(int) PyUnicodeWriter_FromFormat(
474474
PyUnicodeWriter *writer,
475475
const char *format,
476476
...);

Modules/_testcapi/unicode.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,21 +249,26 @@ test_unicodewriter(PyObject *self, PyObject *Py_UNUSED(args))
249249
}
250250

251251
// test PyUnicodeWriter_WriteSubstring()
252-
str = PyUnicode_FromString("[value]");
252+
str = PyUnicode_FromString("[long]");
253253
if (str == NULL) {
254254
goto error;
255255
}
256-
ret = PyUnicodeWriter_WriteSubstring(writer, str, 1, 6);
256+
ret = PyUnicodeWriter_WriteSubstring(writer, str, 1, 5);
257257
Py_CLEAR(str);
258258
if (ret < 0) {
259259
goto error;
260260
}
261261

262< 10000 /td>+
// test PyUnicodeWriter_WriteASCIIString()
263+
if (PyUnicodeWriter_WriteASCIIString(writer, " value", 6) < 0) {
264+
goto error;
265+
}
266+
262267
PyObject *result = PyUnicodeWriter_Finish(writer);
263268
if (result == NULL) {
264269
return NULL;
265270
}
266-
assert(PyUnicode_EqualToUTF8(result, "var=value"));
271+
assert(PyUnicode_EqualToUTF8(result, "var=long value"));
267272
Py_DECREF(result);
268273

269274
Py_RETURN_NONE;
@@ -282,8 +287,8 @@ test_unicodewriter_format(PyObject *self, PyObject *Py_UNUSED(args))
282287
return NULL;
283288
}
284289

285-
// test PyUnicodeWriter_Format()
286-
if (PyUnicodeWriter_Format(writer, "%s %i", "Hello", 123) < 0) {
290+
// test PyUnicodeWriter_FromFormat()
291+
if (PyUnicodeWriter_FromFormat(writer, "%s %i", "Hello", 123) < 0) {
287292
goto error;
288293
}
289294

Objects/unicodeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2938,7 +2938,7 @@ PyUnicode_FromFormat(const char *format, ...)
29382938
}
29392939

29402940
int
2941-
PyUnicodeWriter_Format(PyUnicodeWriter *writer, const char *format, ...)
2941+
PyUnicodeWriter_FromFormat(PyUnicodeWriter *writer, const char *format, ...)
29422942
{
29432943
_PyUnicodeWriter *_writer = (_PyUnicodeWriter*)writer;
29442944

0 commit comments

Comments
 (0)
0