Skip to content

gh-89653: Use int type for Unicode kind #92704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Include/cpython/unicodeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ PyAPI_FUNC(Py_UCS4) _PyUnicode_FindMaxChar (
typedef struct {
PyObject *buffer;
void *data;
enum PyUnicode_Kind kind;
int kind;
Py_UCS4 maxchar;
Py_ssize_t size;
Py_ssize_t pos;
Expand Down Expand Up @@ -566,7 +566,7 @@ _PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer,
macro instead. */
PyAPI_FUNC(int)
_PyUnicodeWriter_PrepareKindInternal(_PyUnicodeWriter *writer,
enum PyUnicode_Kind kind);
int kind);

/* Append a Unicode character.
Return 0 on success, raise an exception and return -1 on error. */
Expand Down
8 changes: 4 additions & 4 deletions Modules/_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ Reader_iternext(ReaderObj *self)
PyObject *fields = NULL;
Py_UCS4 c;
Py_ssize_t pos, linelen;
unsigned int kind;
int kind;
const void *data;
PyObject *lineobj;

Expand Down Expand Up @@ -1066,7 +1066,7 @@ join_reset(WriterObj *self)
* record length.
*/
static Py_ssize_t
join_append_data(WriterObj *self, unsigned int field_kind, const void *field_data,
join_append_data(WriterObj *self, int field_kind, const void *field_data,
Py_ssize_t field_len, int *quoted,
int copy_phase)
{
Expand Down Expand Up @@ -1179,7 +1179,7 @@ join_check_rec_size(WriterObj *self, Py_ssize_t rec_len)
static int
join_append(WriterObj *self, PyObject *field, int quoted)
{
unsigned int field_kind = -1;
int field_kind = -1;
const void *field_data = NULL;
Py_ssize_t field_len = 0;
Py_ssize_t rec_len;
Expand Down Expand Up @@ -1211,7 +1211,7 @@ static int
join_append_lineterminator(WriterObj *self)
{
Py_ssize_t terminator_len, i;
unsigned int term_kind;
int term_kind;
const void *term_data;

terminator_len = PyUnicode_GET_LENGTH(self->dialect->lineterminator);
Expand Down
2 changes: 1 addition & 1 deletion Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5284,7 +5284,7 @@ _sanitize_isoformat_str(PyObject *dtstr)
//
// The result of this, if not NULL, returns a new reference
const void* const unicode_data = PyUnicode_DATA(dtstr);
const unsigned int kind = PyUnicode_KIND(dtstr);
const int kind = PyUnicode_KIND(dtstr);

// Depending on the format of the string, the separator can only ever be
// in positions 7, 8 or 10. We'll check each of these for a surrogate and
Expand Down
4 changes: 2 additions & 2 deletions Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1918,7 +1918,7 @@ dec_dealloc(PyObject *dec)
/******************************************************************************/

Py_LOCAL_INLINE(int)
is_space(enum PyUnicode_Kind kind, const void *data, Py_ssize_t pos)
is_space(int kind, const void *data, Py_ssize_t pos)
{
Py_UCS4 ch = PyUnicode_READ(kind, data, pos);
return Py_UNICODE_ISSPACE(ch);
Expand All @@ -1935,7 +1935,7 @@ is_space(enum PyUnicode_Kind kind, const void *data, Py_ssize_t pos)
static char *
numeric_as_ascii(PyObject *u, int strip_ws, int ignore_underscores)
{
enum PyUnicode_Kind kind;
int kind;
const void *data;
Py_UCS4 ch;
char *res, *cp;
Expand Down
2 changes: 1 addition & 1 deletion Modules/_elementtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ checkpath(PyObject* tag)
if (PyUnicode_Check(tag)) {
const Py_ssize_t len = PyUnicode_GET_LENGTH(tag);
const void *data = PyUnicode_DATA(tag);
unsigned int kind = PyUnicode_KIND(tag);
int kind = PyUnicode_KIND(tag);
if (len >= 3 && PyUnicode_READ(kind, data, 0) == '{' && (
PyUnicode_READ(kind, data, 1) == '}' || (
PyUnicode_READ(kind, data, 1) == '*' &&
Expand Down
9 changes: 3 additions & 6 deletions Modules/_operator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,9 +1230,6 @@ attrgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
/* prepare attr while checking args */
for (idx = 0; idx < nattrs; ++idx) {
PyObject *item = PyTuple_GET_ITEM(args, idx);
Py_ssize_t item_len;
const void *data;
unsigned int kind;
int dot_count;

if (!PyUnicode_Check(item)) {
Expand All @@ -1245,9 +1242,9 @@ attrgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_DECREF(attr);
return NULL;
}
item_len = PyUnicode_GET_LENGTH(item);
kind = PyUnicode_KIND(item);
data = PyUnicode_DATA(item);
Py_ssize_t item_len = PyUnicode_GET_LENGTH(item);
int kind = PyUnicode_KIND(item);
const void *data = PyUnicode_DATA(item);

/* check whether the string is dotted */
dot_count = 0;
Expand Down
2 changes: 1 addition & 1 deletion Modules/_pickle.c
Original file line number Diff line number Diff line change
Expand Up @@ -2579,7 +2579,7 @@ raw_unicode_escape(PyObject *obj)
char *p;
Py_ssize_t i, size;
const void *data;
unsigned int kind;
int kind;
_PyBytesWriter writer;

if (PyUnicode_READY(obj))
Expand Down
2 changes: 1 addition & 1 deletion Modules/pyexpat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ PyUnknownEncodingHandler(void *encodingHandlerData,
PyObject* u;
int i;
const void *data;
unsigned int kind;
int kind;

if (PyErr_Occurred())
return XML_STATUS_ERROR;
Expand Down
2 changes: 1 addition & 1 deletion Objects/bytesobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2396,7 +2396,7 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray)

if (!PyUnicode_IS_ASCII(string)) {
const void *data = PyUnicode_DATA(string);
unsigned int kind = PyUnicode_KIND(string);
int kind = PyUnicode_KIND(string);
Py_ssize_t i;

/* search for the first non-ASCII character */
Expand Down
4 changes: 2 additions & 2 deletions Objects/longobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1714,7 +1714,7 @@ long_to_decimal_string_internal(PyObject *aa,
digit *pout, *pin, rem, tenpow;
int negative;
int d;
enum PyUnicode_Kind kind;
int kind;

a = (PyLongObject *)aa;
if (a == NULL || !PyLong_Check(a)) {
Expand Down Expand Up @@ -1904,7 +1904,7 @@ long_format_binary(PyObject *aa, int base, int alternate,
PyObject *v = NULL;
Py_ssize_t sz;
Py_ssize_t size_a;
enum PyUnicode_Kind kind;
int kind;
int negative;
int bits;

Expand Down
2 changes: 1 addition & 1 deletion Objects/stringlib/localeutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ InsertThousandsGrouping_fill(_PyUnicodeWriter *writer, Py_ssize_t *buffer_pos,

if (n_zeros) {
*buffer_pos -= n_zeros;
enum PyUnicode_Kind kind = PyUnicode_KIND(writer->buffer);
int kind = PyUnicode_KIND(writer->buffer);
void *data = PyUnicode_DATA(writer->buffer);
unicode_fill(kind, data, '0', *buffer_pos, n_zeros);
}
Expand Down
Loading