Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.3k
gh-113993: Allow interned strings to be mortal, and fix related issues#120520
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
79 commits Select commitHold shift + click to select a range
2b74021
Declare explicit interning routines
encukou0aedb83
Use _PyUnicode_InternStatic for the statically allocated stuff
encukouaad79b2
Add _PyUnicode_InternStatic and extra checks
encukou5413223
Check against immortalizing un-interned strings
encukou23845fb
Add _PyUnicode_InternImmortal & make `marshal` use it
encukou9ece220
Remove special case that makes previously-immortal strings STATIC
encukou7c62641
Split _PyUnicode_InternMortal and _PyUnicode_InternImmortal
encukou62a35a1
Do the refcnt dance in _PyUnicode_InternMortal & _PyUnicode_ClearInte…
encukouac55a05
Deallocate mortal interned strings
encukou2466ae9
Use _PyUnicode_InternMortal in codecs
encukou032ac17
Start a notes document
encukou198d9c6
Handle attempts to "overwrite" interned heap types by static ones
encukou86ccb08
Intern statically allocated non-identifier strings at init
encukoue34b8da
Parenthesize the LATIN1 macro argument
encukou66338fe
Don't create the per-interp interned_dict until after InitStaticStrings
encukou9f16cb0
Move hashmap destroy to _PyUnicode_ClearInterned (symmetry with creat…
encukoue27abfc
Special-case short string singletons
encukou89f24df
Verify we don't add process-global entries after a per-interp dict ex…
encukoub965acf
More editing of the InternalDocs write-up
encukou4b69712
Only readjust refleak tests for *immortal* interned strings
encukoub2c9865
Be pedantic with the ref total
encukoucf7cb72
Split InternInPlace in sysmodule
encukou85f9fe0
Split InternInPlace in import
encukoua288389
Split InternInPlace in getargs
encukou6036cb1
Use mortal strings in type_setattro
encukou01f2dbf
Use mortal string in type_module
encukou73f7fb3
Use mortal strings for object attributes
encukou13be4e7
Use mortal strings for code object names
encukou1930919
Use mortal strings for code constants
encukoud45f20b
Use mortals in pickle
encukou348d95c
Use mortals for PyDict_SetItemString keys
encukou04f080e
Use mortals in operator: methodcaller_new
encukouafe5400
Use mortals in operator: attrgetter_new
encukoufe0b8c5
Simplify logic in _PyUnicode_InternImmortal
encukou1116191
Immortalize ill interned strings in the free-threaded build
encukouf10e521
Rewrite the write-up
encukou0787f8f
Restore immortalization for PyDict_SetItemString.
encukou0d56eba
Intern single-byte (latin1) strings at startup in free-threaded build
encukou8b32762
Make the three sets of singletons disjoint
encukou24bf76a
One more single-char string in _Py_STR
encukou2fb04fd
Use a less unwieldy name
encukou26fa26e
Adjust comments & writeup
encukou9b14dbb
Don't call _Py_SetImmortal on strings.
encukouac6dfae
Beef up the tests
encukoua9e91b1
Fix comment
encukouee0f068
A bit more thought-through error handling for failed PyDict_Pop
encukou61bf404
Switch parser to PyUnicode_InternImmortal
encukou80ce95b
Touch up comments
encukou70aa294
Switch public PyUnicode API to _PyUnicode_InternImmortal
encukoude2ff7f
Add an assert to _PyUnicode_EqualToASCIIId
encukou0e6744e
Remove #ifdef Py_DEBUG from the body of _PyUnicode_ClearInterned.
encukouc50e151
Consolidate the interning logic
encukou08798d0
Fix the free-threading initialization
encukou62959cd
Typo in comments
encukouf62ccc6
Add blurb
encukou86cf124
Guard call to debug function
encukouf2e857e
Avoid -bb warnings in tests
encukou6011c05
Add typing to a clinic function
encukou7e8d727
Work around build failure on macOS clang
encukouccb7f42
Silence a mypy error
encukoue0bb1c2
_PyCodec_Lookup: Immortalize key on success
encukou975e4ba
getargs.c: Immortalize the kwtuple keys
encukou1c05a60
Don't re-mortalize interned immortals at interpreter shutdown (in non…
encukou5ac3c5f
Avoid `case` label on a declaration (invalid in standard C and, fortu…
encukou686d2b6
Merge in the main branch
encukou7d79d10
Remove PyUnicode_InternImmortal from the header
encukoud4eb879
Move _Py_LATIN1_CHR to pycore_global_strings.h
encukouf7df09a
Remove mistaken check in _pickle.c
encukoufe7fb13
Comment/doc clarifications, rewordings; PEP-7 style
encukou7a75099
Add a pedantic DECREF
encukouac402d8
Use more straightforward signatures for the internal functions
encukouaa58c01
Group _PyUnicode_Intern funcs in the header
encukou929d0bc
Break out init_global_interned_strings & clear_global_interned_strings
encukou44c0192
Merge in the main branch
encukou9e3ce44
Fix function declaration
encukou2ebf8a0
Fix return value
encukoubf49f61
Convert check to assert
encukou6d668e6
Limit _PyUnicode_InternStatic to runtime initialization
encukoufd8ca83
Add a comment for _Py_hashtable_new_full destroys
encukouFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
Use _PyUnicode_InternMortal in codecs
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit2466ae926259e8ecf88a9f1b9baa0da44f66ddda
There are no files selected for viewing
7 changes: 6 additions & 1 deletionPython/codecs.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -147,7 +147,12 @@ PyObject *_PyCodec_Lookup(const char *encoding) | ||
if (v == NULL) { | ||
return NULL; | ||
} | ||
/* Intern the string. | ||
A successful lookup will insert `v` in the codecs search cache, | ||
effectively immortalizing it. We don't want to immortalize the key | ||
when lookup fails. */ | ||
_PyUnicode_InternMortal(interp, &v); | ||
encukou marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
/* First, try to lookup the name in the registry dictionary */ | ||
PyObject *result; | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.