Commit 135abec
committed
Fix interpreter lifecycle cleanup paths
Fix multiple resource-management and error-path bugs in the interpreter lifecycle.
Release the builtins module reference on builtin initialization failures and keep it owned until default import initialization succeeds, avoiding an extra NULL assignment. Also DECREF results from non-dict sys.modules clear calls, route subinterpreter initialization failures through cleanup after thread-state detach, release __main__ setup references on PyDict_SetItemString failures, and check stdin/stdout sys object setup failures consistently with stderr.
Tests run:
- ./configure --with-pydebug
- git diff --check
- make -j2 Python/pylifecycle.o
- make -j2 python Programs/_testembed
- make -j2
- Programs/_testembed test_repeated_init_and_subinterpreters
- ./python - <<'PY'
import _interpreters
interp = _interpreters.create()
_interpreters.destroy(interp)
print('ok')
PY
- make patchcheck (fails because this checkout has no upstream remote matching https://github.com/python/cpython)1 parent cc5cf14 commit 135abec
1 file changed
Lines changed: 28 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
909 | 909 | | |
910 | 910 | | |
911 | 911 | | |
| 912 | + | |
912 | 913 | | |
913 | 914 | | |
914 | 915 | | |
915 | 916 | | |
| 917 | + | |
916 | 918 | | |
917 | 919 | | |
918 | 920 | | |
919 | 921 | | |
920 | 922 | | |
921 | 923 | | |
922 | 924 | | |
923 | | - | |
924 | 925 | | |
925 | 926 | | |
926 | 927 | | |
927 | 928 | | |
928 | 929 | | |
| 930 | + | |
929 | 931 | | |
930 | 932 | | |
931 | 933 | | |
| |||
1823 | 1825 | | |
1824 | 1826 | | |
1825 | 1827 | | |
1826 | | - | |
| 1828 | + | |
| 1829 | + | |
1827 | 1830 | | |
1828 | 1831 | | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
1829 | 1835 | | |
1830 | 1836 | | |
1831 | 1837 | | |
| |||
2702 | 2708 | | |
2703 | 2709 | | |
2704 | 2710 | | |
2705 | | - | |
| 2711 | + | |
2706 | 2712 | | |
2707 | 2713 | | |
2708 | 2714 | | |
2709 | 2715 | | |
2710 | 2716 | | |
2711 | 2717 | | |
2712 | | - | |
| 2718 | + | |
2713 | 2719 | | |
2714 | 2720 | | |
2715 | 2721 | | |
| |||
2929 | 2935 | | |
2930 | 2936 | | |
2931 | 2937 | | |
| 2938 | + | |
2932 | 2939 | | |
2933 | 2940 | | |
2934 | 2941 | | |
| |||
2952 | 2959 | | |
2953 | 2960 | | |
2954 | 2961 | | |
| 2962 | + | |
2955 | 2963 | | |
2956 | 2964 | | |
2957 | 2965 | | |
| |||
3186 | 3194 | | |
3187 | 3195 | | |
3188 | 3196 | | |
3189 | | - | |
3190 | | - | |
| 3197 | + | |
| 3198 | + | |
| 3199 | + | |
| 3200 | + | |
| 3201 | + | |
| 3202 | + | |
| 3203 | + | |
| 3204 | + | |
3191 | 3205 | | |
3192 | 3206 | | |
3193 | 3207 | | |
| |||
3197 | 3211 | | |
3198 | 3212 | | |
3199 | 3213 | | |
3200 | | - | |
3201 | | - | |
| 3214 | + | |
| 3215 | + | |
| 3216 | + | |
| 3217 | + | |
| 3218 | + | |
| 3219 | + | |
| 3220 | + | |
| 3221 | + | |
3202 | 3222 | | |
3203 | 3223 | | |
3204 | 3224 | | |
| |||
0 commit comments