Skip to content

Commit 762c603

Browse files
pythongh-126881: fix finalization of dtoa state (python#126904)
1 parent dd3a87d commit 762c603

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix crash in finalization of dtoa state. Patch by Kumar Aditya.

Python/pylifecycle.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1888,7 +1888,6 @@ finalize_interp_clear(PyThreadState *tstate)
18881888
_PyXI_Fini(tstate->interp);
18891889
_PyExc_ClearExceptionGroupType(tstate->interp);
18901890
_Py_clear_generic_types(tstate->interp);
1891-
_PyDtoa_Fini(tstate->interp);
18921891

18931892
/* Clear interpreter state and all thread states */
18941893
_PyInterpreterState_Clear(tstate);
@@ -1910,6 +1909,9 @@ finalize_interp_clear(PyThreadState *tstate)
19101909

19111910
finalize_interp_types(tstate->interp);
19121911

1912+
/* Finalize dtoa at last so that finalizers calling repr of float doesn't crash */
1913+
_PyDtoa_Fini(tstate->interp);
1914+
19131915
/* Free any delayed free requests immediately */
19141916
_PyMem_FiniDelayed(tstate->interp);
19151917

0 commit comments

Comments
 (0)