FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[mypyc] Replace deprecated _PY_IDENTIFIER uses by cdce8p · Pull Request #20460 · python/mypy · GitHub

Repository navigation

[mypyc] Replace deprecated _PY_IDENTIFIER uses - #20460

Merged
JukkaL merged 5 commits into
python:masterfrom
cdce8p:mypyc-replace-py_identifier
Jan 5, 2026
Merged

JukkaL merged 5 commits into
python:masterfrom
cdce8p:mypyc-replace-py_identifier

Conversation

cdce8p commented Dec 22, 2025

Copy link
Copy Markdown
Collaborator

Uses of _PY_IDENTIFIER will trigger a deprecation warning for Python 3.15. Replace these with statically allocated PyObject unicode objects which are being prevented from garbage collection via PyUnicode_InternFromString.

The implementation is adopted from a similar one in numpy.
https://github.com/numpy/numpy/blob/v2.4.0/numpy/_core/src/multiarray/npy_static_data.h
https://github.com/numpy/numpy/blob/v2.4.0/numpy/_core/src/multiarray/npy_static_data.c

https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_InternFromString

Replaces #19870

cdce8p added the topic-mypyc mypyc bugs label Dec 22, 2025

cdce8p commented Dec 22, 2025

Copy link
Copy Markdown
Collaborator Author

/CC @BobTheBuidler

continue;
}
if (PyObject_GetOptionalAttrString(base, PyId___mro_entries__.string, &meth) < 0) {
if (PyObject_GetOptionalAttrString(base, "__mro_entries__", &meth) < 0) {

cdce8p Dec 22, 2025 •
edited
Loading

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We can't use mypyc_interned_str.__mro_entries__ here since it isn't initialized yet when the header file is loaded. Similarly for __init_subclass__ below.

I believe the best solution might be to just move these functions to pythonsupport.c but that can be done at a later point.

}
#endif

#if PY_VERSION_HEX >= 0x030A0000 // 3.10

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Mypy recently dropped support for Python 3.9, so the version guard is no longer necessary.

cdce8p force-pushed the mypyc-replace-py_identifier branch from 6c4687a to 796672f Compare December 23, 2025 02:38

hauntsaninja left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Great, thanks!

JukkaL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nice!

JukkaL merged commit c41dbd0 into python:master Jan 5, 2026
16 checks passed
cdce8p deleted the mypyc-replace-py_identifier branch January 5, 2026 19:42
ilevkivskyi pushed a commit that referenced this pull request Jan 10, 2026
hauntsaninja pushed a commit that referenced this pull request Jan 29, 2026
Followup to
#20460 (comment)

It's not possible to use `mypyc_interned_str.<name>` in header files.
Move some functions from `pythonsupport.h` to `pythonsupport.c`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL