Skip to content

Commit 7931d9a

Browse files
author
Victor Stinner
committed
Replace PyUnicodeObject type by PyObject
* _PyUnicode_CheckConsistency() now takes a PyObject* instead of void* * Remove now useless casts to PyObject*
1 parent 76a31a6 commit 7931d9a

3 files changed

Lines changed: 133 additions & 148 deletions

File tree

Include/unicodeobject.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,9 +2000,8 @@ PyAPI_FUNC(Py_UNICODE*) PyUnicode_AsUnicodeCopy(
20002000
#endif /* Py_LIMITED_API */
20012001

20022002
#if defined(Py_DEBUG) && !defined(Py_LIMITED_API)
2003-
/* FIXME: use PyObject* type for op */
20042003
PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
2005-
void *op,
2004+
PyObject *op,
20062005
int check_content);
20072006
#endif
20082007

Objects/stringlib/unicode_format.h

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ render_field(PyObject *fieldobj, SubString *format_spec, _PyAccu *acc)
528528
PyObject *result = NULL;
529529
PyObject *format_spec_object = NULL;
530530
PyObject *(*formatter)(PyObject *, PyObject *, Py_ssize_t, Py_ssize_t) = NULL;
531-
531+
532532
/* If we know the type exactly, skip the lookup of __format__ and just
533533
call the formatter directly. */
534534
if (PyUnicode_CheckExact(fieldobj))
@@ -654,7 +654,7 @@ typedef struct {
654654
} MarkupIterator;
655655

656656
static int
657-
MarkupIterator_init(MarkupIterator *self, PyObject *str,
657+
MarkupIterator_init(MarkupIterator *self, PyObject *str,
658658
Py_ssize_t start, Py_ssize_t end)
659659
{
660660
SubString_init(&self->str, str, start, end);
@@ -713,8 +713,8 @@ MarkupIterator_next(MarkupIterator *self, SubString *literal,
713713
at_end = self->str.start >= self->str.end;
714714
len = self->str.start - start;
715715

716-
if ((c == '}') && (at_end ||
717-
(c != PyUnicode_READ_CHAR(self->str.str,
716+
if ((c == '}') && (at_end ||
717+
(c != PyUnicode_READ_CHAR(self->str.str,
718718
self->str.start)))) {
719719
PyErr_SetString(PyExc_ValueError, "Single '}' encountered "
720720
"in format string");
@@ -992,9 +992,7 @@ do_string_format_map(PyObject *self, PyObject *obj)
992992

993993
typedef struct {
994994
PyObject_HEAD
995-
996-
PyUnicodeObject *str;
997-
995+
PyObject *str;
998996
MarkupIterator it_markup;
999997
} formatteriterobject;
1000998

@@ -1121,7 +1119,7 @@ static PyTypeObject PyFormatterIter_Type = {
11211119
describing the parsed elements. It's a wrapper around
11221120
stringlib/string_format.h's MarkupIterator */
11231121
static PyObject *
1124-
formatter_parser(PyObject *ignored, PyUnicodeObject *self)
1122+
formatter_parser(PyObject *ignored, PyObject *self)
11251123
{
11261124
formatteriterobject *it;
11271125

@@ -1158,9 +1156,7 @@ formatter_parser(PyObject *ignored, PyUnicodeObject *self)
11581156

11591157
typedef struct {
11601158
PyObject_HEAD
1161-
1162-
PyUnicodeObject *str;
1163-
1159+
PyObject *str;
11641160
FieldNameIterator it_field;
11651161
} fieldnameiterobject;
11661162

@@ -1261,7 +1257,7 @@ static PyTypeObject PyFieldNameIter_Type = {
12611257
field_name_split. The iterator it returns is a
12621258
FieldNameIterator */
12631259
static PyObject *
1264-
formatter_field_name_split(PyObject *ignored, PyUnicodeObject *self)
1260+
formatter_field_name_split(PyObject *ignored, PyObject *self)
12651261
{
12661262
SubString first;
12671263
Py_ssize_t first_idx;

0 commit comments

Comments
 (0)