forked frompython/cpython
- Notifications
You must be signed in to change notification settings - Fork0
Commit407e3df
pythongh-113993: Allow interned strings to be mortal, and fix related issues (pythonGH-120520)
* Add an InternalDocs file describing how interning should work and how to use it.* Add internal functions to *explicitly* request what kind of interning is done: - `_PyUnicode_InternMortal` - `_PyUnicode_InternImmortal` - `_PyUnicode_InternStatic`* Switch uses of `PyUnicode_InternInPlace` to those.* Disallow using `_Py_SetImmortal` on strings directly. You should use `_PyUnicode_InternImmortal` instead: - Strings should be interned before immortalization, otherwise you're possibly interning a immortalizing copy. - `_Py_SetImmortal` doesn't handle the `SSTATE_INTERNED_MORTAL` to `SSTATE_INTERNED_IMMORTAL` update, and those flags can't be changed in backports, as they are now part of public API and version-specific ABI.* Add private `_only_immortal` argument for `sys.getunicodeinternedsize`, used in refleak test machinery.* Make sure the statically allocated string singletons are unique. This means these sets are now disjoint: - `_Py_ID` - `_Py_STR` (including the empty string) - one-character latin-1 singletons Now, when you intern a singleton, that exact singleton will be interned.* Add a `_Py_LATIN1_CHR` macro, use it instead of `_Py_ID`/`_Py_STR` for one-character latin-1 singletons everywhere (including Clinic).* Intern `_Py_STR` singletons at startup.* For free-threaded builds, intern `_Py_LATIN1_CHR` singletons at startup.* Beef up the tests. Cover internal details (marked with `@cpython_only`).* Add lots of assertionsCo-Authored-By: Eric Snow <ericsnowcurrently@gmail.com>1 parent48d7ef9 commit407e3df
File tree
42 files changed
+2460
-1136
lines changed- Include/internal
- InternalDocs
- Lib/test
- libregrtest
- Misc/NEWS.d/next/Core and Builtins
- Modules
- _io
- _sqlite/clinic
- clinic
- Objects
- Parser
- Python
- clinic
- Tools
- build
- clinic/libclinic
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
42 files changed
+2460
-1136
lines changedLines changed: 1 addition & 19 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Lines changed: 5 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
37 | 37 |
| |
38 | 38 |
| |
39 | 39 |
| |
40 |
| - | |
41 | 40 |
| |
42 | 41 |
| |
43 | 42 |
| |
44 | 43 |
| |
45 |
| - | |
46 | 44 |
| |
47 | 45 |
| |
48 | 46 |
| |
49 | 47 |
| |
50 | 48 |
| |
51 | 49 |
| |
52 | 50 |
| |
53 |
| - | |
54 |
| - | |
55 |
| - | |
56 | 51 |
| |
57 | 52 |
| |
58 | 53 |
| |
| |||
67 | 62 |
| |
68 | 63 |
| |
69 | 64 |
| |
70 |
| - | |
71 | 65 |
| |
72 | 66 |
| |
73 | 67 |
| |
| |||
261 | 255 |
| |
262 | 256 |
| |
263 | 257 |
| |
| 258 | + | |
264 | 259 |
| |
265 | 260 |
| |
266 | 261 |
| |
| |||
273 | 268 |
| |
274 | 269 |
| |
275 | 270 |
| |
276 |
| - | |
277 | 271 |
| |
278 | 272 |
| |
279 | 273 |
| |
| |||
297 | 291 |
| |
298 | 292 |
| |
299 | 293 |
| |
300 |
| - | |
301 | 294 |
| |
302 | 295 |
| |
303 | 296 |
| |
| |||
315 | 308 |
| |
316 | 309 |
| |
317 | 310 |
| |
318 |
| - | |
319 | 311 |
| |
320 | 312 |
| |
321 | 313 |
| |
| |||
371 | 363 |
| |
372 | 364 |
| |
373 | 365 |
| |
374 |
| - | |
375 | 366 |
| |
376 | 367 |
| |
377 | 368 |
| |
| |||
400 | 391 |
| |
401 | 392 |
| |
402 | 393 |
| |
403 |
| - | |
404 | 394 |
| |
405 | 395 |
| |
406 | 396 |
| |
| |||
424 | 414 |
| |
425 | 415 |
| |
426 | 416 |
| |
427 |
| - | |
428 | 417 |
| |
429 | 418 |
| |
430 | 419 |
| |
| |||
457 | 446 |
| |
458 | 447 |
| |
459 | 448 |
| |
460 |
| - | |
461 | 449 |
| |
462 | 450 |
| |
463 | 451 |
| |
| |||
471 | 459 |
| |
472 | 460 |
| |
473 | 461 |
| |
474 |
| - | |
475 | 462 |
| |
476 | 463 |
| |
477 | 464 |
| |
| |||
582 | 569 |
| |
583 | 570 |
| |
584 | 571 |
| |
585 |
| - | |
586 | 572 |
| |
587 | 573 |
| |
588 | 574 |
| |
| |||
628 | 614 |
| |
629 | 615 |
| |
630 | 616 |
| |
631 |
| - | |
632 | 617 |
| |
633 | 618 |
| |
634 | 619 |
| |
| |||
656 | 641 |
| |
657 | 642 |
| |
658 | 643 |
| |
659 |
| - | |
660 | 644 |
| |
661 | 645 |
| |
662 | 646 |
| |
| |||
680 | 664 |
| |
681 | 665 |
| |
682 | 666 |
| |
683 |
| - | |
684 | 667 |
| |
685 | 668 |
| |
686 | 669 |
| |
| |||
787 | 770 |
| |
788 | 771 |
| |
789 | 772 |
| |
790 |
| - | |
791 | 773 |
| |
792 | 774 |
| |
793 | 775 |
| |
| |||
810 | 792 |
| |
811 | 793 |
| |
812 | 794 |
| |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
813 | 799 |
| |
814 | 800 |
| |
815 | 801 |
| |
|
0 commit comments
Comments
(0)