summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-05-13 10:41:05 (GMT)
committerGitHub <noreply@github.com>2022-05-13 10:41:05 (GMT)
commitf62ad4f2c4214fdc05cc45c27a5c068553c7942c (patch)
tree5c8cf46c3ae7c874ac601f3e18357a1862474fba /Modules
parent22a1db378c5c381272362c5b2f68ac78a368e136 (diff)
downloadcpython-f62ad4f2c4214fdc05cc45c27a5c068553c7942c.zip
cpython-f62ad4f2c4214fdc05cc45c27a5c068553c7942c.tar.gz
cpython-f62ad4f2c4214fdc05cc45c27a5c068553c7942c.tar.bz2
gh-89653: Use int type for Unicode kind (#92704)
Use the same type that PyUnicode_FromKindAndData() kind parameter type (public C API): int.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_csv.c8
-rw-r--r--Modules/_datetimemodule.c2
-rw-r--r--Modules/_decimal/_decimal.c4
-rw-r--r--Modules/_elementtree.c2
-rw-r--r--Modules/_operator.c9
-rw-r--r--Modules/_pickle.c2
-rw-r--r--Modules/pyexpat.c2
7 files changed, 13 insertions, 16 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c
index cbf4c5d..d34d0a1 100644
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -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;
@@ -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)
{
@@ -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;
@@ -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);
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index e0bb4ee..06dff8f 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -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
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c
index 5cbddac..548bd60 100644
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -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);
@@ -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;
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 89f877f..453e57a 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -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) == '*' &&
diff --git a/Modules/_operator.c b/Modules/_operator.c
index 739ae5b..1af4a4f 100644
--- a/Modules/_operator.c
+++ b/Modules/_operator.c
@@ -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)) {
@@ -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;
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 851fead..0adfa41 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -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))
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index ad8148a..b8535df 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -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;