-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
bpo-46006: Fix _PyUnicode_EqualToASCIIId() for interned strings #30123
Conversation
Fix string comparisons for subinterpreters: no longer make the assumption that two interned strings are not equal if they have different different memory addresses. This assumption is no longer true since interned strings have been made per interpreter in Python 3.10. Fix _PyUnicode_EqualToASCIIId() and type update_slot() functions. The change makes update_slot() a little bit less efficient: update_slot() now compares the strings contents, rather than comparing strings memory addresses.
cc @methane @serhiy-storchaka @corona10 We will be able to add again this micro-optimization once Python C extensions and third-party C extensions will no longer define and use static types and will stop sharing objects between two interpreters. Sadly, this long term goal may take a few years... |
It is meaningless to compare strings from one fully isolated interpreter with those in another. Feel free to add an assert, but please avoid this sort of pessimization for a hypothetical future which may well not happen. |
Suggestion: add the reproducer from https://bugs.python.org/issue46034 as a test? |
@markshannon: I'm not sure what you are talking about. https://bugs.python.org/issue46006 is affecting multiple Python 3.10 users right now. It's not an hypothetical bug. At least, jep and mod_wsgi projects are known to be affected by the bug:
The bug may also explain https://bugs.python.org/issue46070 which affects more projects. |
@markshannon: I added long comments as part of the change to explain the issue. Did you see my comments? It's about interned strings of static types which are shared by all interpreters. |
I'll comment on the issue. |
I agree that a fix is needed. But this is not the needed fix. |
I merged GH-20085 instead. |
Fix string comparisons for subinterpreters: no longer make the assumption
that two interned strings are not equal if they have different different
memory addresses. This assumption is no longer true since interned
strings have been made per interpreter in Python 3.10.
Fix _PyUnicode_EqualToASCIIId() and type update_slot() functions.
The change makes update_slot() a little bit less efficient:
update_slot() now compares the strings contents, rather than
comparing strings memory addresses.
https://bugs.python.org/issue46006