pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/f62ad4f2c4214fdc05cc45c27a5c068553c7942c

aa60c69660fa.css" /> gh-89653: Use int type for Unicode kind (#92704) · python/cpython@f62ad4f · GitHub
Skip to content

Commit f62ad4f

Browse files
authored
gh-89653: Use int type for Unicode kind (#92704)
Use the same type that PyUnicode_FromKindAndData() kind parameter type (public C API): int.
1 parent 22a1db3 commit f62ad4f

13 files changed

Lines changed: 49 additions & 52 deletions

File tree

Include/cpython/unicodeobject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ PyAPI_FUNC(Py_UCS4) _PyUnicode_FindMaxChar (
507507
typedef struct {
508508
PyObject *buffer;
509509
void *data;
510-
enum PyUnicode_Kind kind;
510+
int kind;
511511
Py_UCS4 maxchar;
512512
Py_ssize_t size;
513513
Py_ssize_t pos;
@@ -566,7 +566,7 @@ _PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer,
566566
macro instead. */
567567
PyAPI_FUNC(int)
568568
_PyUnicodeWriter_PrepareKindInternal(_PyUnicodeWriter *writer,
569-
enum PyUnicode_Kind kind);
569+
int kind);
570570

571571
/* Append a Unicode character.
572572
Return 0 on success, raise an exception and return -1 on error. */

Modules/_csv.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ Reader_iternext(ReaderObj *self)
868868
PyObject *fields = NULL;
869869
Py_UCS4 c;
870870
Py_ssize_t pos, linelen;
871-
unsigned int kind;
871+
int kind;
872872
const void *data;
873873
PyObject *lineobj;
874874

@@ -1066,7 +1066,7 @@ join_reset(WriterObj *self)
10661066
* record length.
10671067
*/
10681068
static Py_ssize_t
1069-
join_append_data(WriterObj *self, unsigned int field_kind, const void *field_data,
1069+
join_append_data(WriterObj *self, int field_kind, const void *field_data,
10701070
Py_ssize_t field_len, int *quoted,
10711071
int copy_phase)
10721072
{
@@ -1179,7 +1179,7 @@ join_check_rec_size(WriterObj *self, Py_ssize_t rec_len)
11791179
static int
11801180
join_append(WriterObj *self, PyObject *field, int quoted)
11811181
{
1182-
unsigned int field_kind = -1;
1182+
int field_kind = -1;
11831183
const void *field_data = NULL;
11841184
Py_ssize_t field_len = 0;
11851185
Py_ssize_t rec_len;
@@ -1211,7 +1211,7 @@ static int
12111211
join_append_lineterminator(WriterObj *self)
12121212
{
12131213
Py_ssize_t terminator_len, i;
1214-
unsigned int term_kind;
1214+
int term_kind;
12151215
const void *term_data;
12161216

12171217
terminator_len = PyUnicode_GET_LENGTH(self->dialect->lineterminator);

Modules/_datetimemodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5284,7 +5284,7 @@ _sanitize_isoformat_str(PyObject *dtstr)
52845284
//
52855285
// The result of this, if not NULL, returns a new reference
52865286
const void* const unicode_data = PyUnicode_DATA(dtstr);
5287-
const unsigned int kind = PyUnicode_KIND(dtstr);
5287+
const int kind = PyUnicode_KIND(dtstr);
52885288

52895289
// Depending on the format of the string, the separator can only ever be
52905290
// in positions 7, 8 or 10. We'll check each of these for a surrogate and

Modules/_decimal/_decimal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,7 +1918,7 @@ dec_dealloc(PyObject *dec)
19181918
/******************************************************************************/
19191919

19201920
Py_LOCAL_INLINE(int)
1921-
is_space(enum PyUnicode_Kind kind, const void *data, Py_ssize_t pos)
1921+
is_space(int kind, const void *data, Py_ssize_t pos)
19221922
{
19231923
Py_UCS4 ch = PyUnicode_READ(kind, data, pos);
19241924
return Py_UNICODE_ISSPACE(ch);
@@ -1935,7 +1935,7 @@ is_space(enum PyUnicode_Kind kind, const void *data, Py_ssize_t pos)
19351935
static char *
19361936
numeric_as_ascii(PyObject *u, int strip_ws, int ignore_underscores)
19371937
{
1938-
enum PyUnicode_Kind kind;
1938+
int kind;
19391939
const void *data;
19401940
Py_UCS4 ch;
19411941
char *res, *cp;

Modules/_elementtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ checkpath(PyObject* tag)
11211121
if (PyUnicode_Check(tag)) {
11221122
const Py_ssize_t len = PyUnicode_GET_LENGTH(tag);
11231123
const void *data = PyUnicode_DATA(tag);
1124-
unsigned int kind = PyUnicode_KIND(tag);
1124+
int kind = PyUnicode_KIND(tag);
11251125
if (len >= 3 && PyUnicode_READ(kind, data, 0) == '{' && (
11261126
PyUnicode_READ(kind, data, 1) == '}' || (
11271127
PyUnicode_READ(kind, data, 1) == '*' &&

Modules/_operator.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,9 +1230,6 @@ attrgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
12301230
/* prepare attr while checking args */
12311231
for (idx = 0; idx < nattrs; ++idx) {
12321232
PyObject *item = PyTuple_GET_ITEM(args, idx);
1233-
Py_ssize_t item_len;
1234-
const void *data;
1235-
unsigned int kind;
12361233
int dot_count;
12371234

12381235
if (!PyUnicode_Check(item)) {
@@ -1245,9 +1242,9 @@ attrgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
12451242
Py_DECREF(attr);
12461243
return NULL;
12471244
}
1248-
item_len = PyUnicode_GET_LENGTH(item);
1249-
kind = PyUnicode_KIND(item);
1250-
data = PyUnicode_DATA(item);
1245+
Py_ssize_t item_len = PyUnicode_GET_LENGTH(item);
1246+
int kind = PyUnicode_KIND(item);
1247+
const void *data = PyUnicode_DATA(item);
12511248

12521249
/* check whether the string is dotted */
12531250
dot_count = 0;

Modules/_pickle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2579,7 +2579,7 @@ raw_unicode_escape(PyObject *obj)
25792579
char *p;
25802580
Py_ssize_t i, size;
25812581
const void *data;
2582-
unsigned int kind;
2582+
int kind;
25832583
_PyBytesWriter writer;
25842584

25852585
if (PyUnicode_READY(obj))

Modules/pyexpat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ PyUnknownEncodingHandler(void *encodingHandlerData,
10881088
PyObject* u;
10891089
int i;
10901090
const void *data;
1091-
unsigned int kind;
1091+
int kind;
10921092

10931093
if (PyErr_Occurred())
10941094
return XML_STATUS_ERROR;

Objects/bytesobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2396,7 +2396,7 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray)
23962396

23972397
if (!PyUnicode_IS_ASCII(string)) {
23982398
const void *data = PyUnicode_DATA(string);
2399-
unsigned int kind = PyUnicode_KIND(string);
2399+
int kind = PyUnicode_KIND(string);
24002400
Py_ssize_t i;
24012401

24022402
/* search for the first non-ASCII character */

Objects/longobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,7 @@ long_to_decimal_string_internal(PyObject *aa,
17141714
digit *pout, *pin, rem, tenpow;
17151715
int negative;
17161716
int d;
1717-
enum PyUnicode_Kind kind;
1717+
int kind;
17181718

17191719
a = (PyLongObject *)aa;
17201720
if (a == NULL || !PyLong_Check(a)) {
@@ -1904,7 +1904,7 @@ long_format_binary(PyObject *aa, int base, int alternate,
19041904
PyObject *v = NULL;
19051905
Py_ssize_t sz;
19061906
Py_ssize_t size_a;
1907-
enum PyUnicode_Kind kind;
1907+
int kind;
19081908
int negative;
19091909
int bits;
19101910

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy