Skip to content

Commit

Permalink
Fix PyUnicode functions for Python 3.13 (#17504)
Browse files Browse the repository at this point in the history
Replace `_PyUnicode_EqualToASCIIString` with `PyUnicode_EqualToUTF8`.

https://docs.python.org/dev/c-api/unicode.html#c.PyUnicode_EqualToUTF8
python/cpython#110289

Fixes
```cpp
  /home/runner/work/mypy/mypy/mypyc/lib-rt/getargs.c: In function ‘vgetargskeywords’: (diff)
  /home/runner/work/mypy/mypy/mypyc/lib-rt/pythonsupport.h:310:45: error: implicit declaration of function ‘_PyUnicode_EqualToASCIIString’; did you mean ‘CPyUnicode_EqualToASCIIString’? [-Werror=implicit-function-declaration] (diff)
    310 | #define CPyUnicode_EqualToASCIIString(x, y) _PyUnicode_EqualToASCIIString(x, y) (diff)
        |                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (diff)
  /home/runner/work/mypy/mypy/mypyc/lib-rt/getargs.c:398:21: note: in expansion of macro ‘CPyUnicode_EqualToASCIIString’ (diff)
    398 |                 if (CPyUnicode_EqualToASCIIString(key, kwlist[i])) { (diff)
        |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (diff)
```
  • Loading branch information
cdce8p committed Jul 7, 2024
1 parent 7f67090 commit 966d6d3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 1 addition & 1 deletion mypyc/lib-rt/getargs.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
goto latefail;
}
for (i = pos; i < len; i++) {
if (CPyUnicode_EqualToASCIIString(key, kwlist[i])) {
if (PyUnicode_EqualToUTF8(key, kwlist[i])) {
match = 1;
break;
}
Expand Down
2 changes: 0 additions & 2 deletions mypyc/lib-rt/pythonsupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,6 @@ list_count(PyListObject *self, PyObject *value)
return CPyTagged_ShortFromSsize_t(count);
}

#define CPyUnicode_EqualToASCIIString(x, y) _PyUnicode_EqualToASCIIString(x, y)

// Adapted from genobject.c in Python 3.7.2
// Copied because it wasn't in 3.5.2 and it is undocumented anyways.
/*
Expand Down

0 comments on commit 966d6d3

Please sign in to comment.