Skip to content
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

Fix PyUnicode functions for Python 3.13 #17504

Merged
merged 3 commits into from
Jul 7, 2024

Conversation

cdce8p
Copy link
Collaborator

@cdce8p cdce8p commented Jul 7, 2024

Replace _PyUnicode_EqualToASCIIString with PyUnicode_EqualToUTF8.

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

Fixes

  /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)

@cdce8p cdce8p added the topic-mypyc mypyc bugs label Jul 7, 2024
Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: want to change the comment on L83 of str_ops.c?

I guess we could still use _PyUnicode_FastCopyCharacters, but is maybe not the biggest deal

@cdce8p
Copy link
Collaborator Author

cdce8p commented Jul 7, 2024

nit: want to change the comment on L83 of str_ops.c?

Done!

I guess we could still use _PyUnicode_FastCopyCharacters, but is maybe not the biggest deal

Yeah, technically _PyUnicode_FastCopyCharacters was only moved to internal/pycore_unicodeobject.h which we still include for _PyUnicode_EQ (see #17506). However, moving to the public PyUnicode_CopyCharacters might be the better call here (even if slightly slower if at all).
https://github.com/python/cpython/blob/v3.13.0b3/Include/internal/pycore_unicodeobject.h#L56

@cdce8p
Copy link
Collaborator Author

cdce8p commented Jul 7, 2024

I guess we could still use _PyUnicode_FastCopyCharacters, but is maybe not the biggest deal

Yeah, technically _PyUnicode_FastCopyCharacters was only moved to internal/pycore_unicodeobject.h which we still include for _PyUnicode_EQ (see #17506). However, moving to the public PyUnicode_CopyCharacters might be the better call here (even if slightly slower if at all). https://github.com/python/cpython/blob/v3.13.0b3/Include/internal/pycore_unicodeobject.h#L56

Scratch that. Let's just continue using _PyUnicode_FastCopyCharacters here. It's also used in _PyUnicode_JoinArray which this functions is adapted from.

@hauntsaninja hauntsaninja merged commit 966d6d3 into python:master Jul 7, 2024
14 checks passed
@cdce8p cdce8p deleted the fix-3.13-unicode branch July 7, 2024 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-mypyc mypyc bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants