Skip to content

Commit edfad2f

Browse files
generatedunixname1734921407115435meta-codesync[bot]
authored andcommitted
Sync pre-release CPython 3.15 branch from GitHub (2026-08-22)
Summary: Imported python/cpython `3.15.0rc1+dev` from upstream rev [`e839679`](https://www.github.com/python/cpython/commit/e8396792a79adeb2dd6fe523b1722fe8ec6e50f7) (committed 2026-08-22 09:41:27+00:00). # Commit Info - Base: (`3.15.0rc1+dev`) - [`f71fbc5`](https://www.github.com/python/cpython/commit/f71fbc558a3051781297106f53820b04c217c13d) (commit date: 2026-08-21 01:40:43+00:00) - Imported: (`3.15.0rc1+dev`) - [`e839679`](https://www.github.com/python/cpython/commit/e8396792a79adeb2dd6fe523b1722fe8ec6e50f7) (commit date: 2026-08-22 09:41:27+00:00) # Noteworthy file changes - Low-signal files (1 added) (NEWS.d, docs, .github) Complete list of added/removed files: https://www.internalfb.com/intern/everpaste/?color=0&handle=GATlhiA0isQYmQkFAMUtbKmNEENdbr0LAAAz Differential Revision: D117103754 fbshipit-source-id: a14fa01d6927ebf87b55a52800519d5754ece469
1 parent 1c1c85a commit edfad2f

5 files changed

Lines changed: 37 additions & 12 deletions

File tree

Doc/library/csv.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ The :mod:`!csv` module defines the following classes:
314314

315315
If several delimiters fit the sample equally well ---
316316
for example if both ``','`` and ``';'`` split every row consistently ---
317-
the delimiters ``','``, ``'\t'``, ``';'``, ``' '`` and ``':'``
318-
are preferred, in this order,
317+
the delimiters listed in the :attr:`~Sniffer.preferred` attribute
318+
are preferred, in that order,
319319
no matter how many times each of them occurs.
320320

321321
.. method:: has_header(sample)
@@ -337,6 +337,15 @@ The :mod:`!csv` module defines the following classes:
337337
This method is a rough heuristic and may produce both false positives and
338338
negatives.
339339

340+
The :class:`Sniffer` class has the following attribute:
341+
342+
.. attribute:: preferred
343+
344+
The list of the delimiters preferred for breaking ties,
345+
in the order of preference.
346+
It can be modified.
347+
Its initial value is ``[',', '\t', ';', ' ', ':']``.
348+
340349
An example for :class:`Sniffer` use::
341350

342351
with open('example.csv', newline='') as csvfile:

Include/internal/pycore_code.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,10 @@ PyAPI_FUNC(_Py_CODEUNIT *) _PyCode_GetTLBC(PyCodeObject *co);
582582
// Returns the reserved index or -1 on error.
583583
extern int32_t _Py_ReserveTLBCIndex(PyInterpreterState *interp);
584584

585+
// Release an index returned by _Py_ReserveTLBCIndex() that was never stored
586+
// in a PyThreadState.
587+
extern void _Py_UnreserveTLBCIndex(PyInterpreterState *interp, int32_t index);
588+
585589
// Release the current thread's index into thread-local bytecode arrays
586590
extern void _Py_ClearTLBCIndex(_PyThreadStateImpl *tstate);
587591

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fix a leak in the :term:`free-threaded build` when creating a thread state
2+
fails after an internal QSBR slot has been reserved for it. The slot could
3+
never be reclaimed, so the QSBR array grew without bound across repeated
4+
failures.

Objects/codeobject.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3313,14 +3313,20 @@ _Py_ReserveTLBCIndex(PyInterpreterState *interp)
33133313
}
33143314

33153315
void
3316-
_Py_ClearTLBCIndex(_PyThreadStateImpl *tstate)
3316+
_Py_UnreserveTLBCIndex(PyInterpreterState *interp, int32_t index)
33173317
{
3318-
PyInterpreterState *interp = ((PyThreadState *)tstate)->interp;
33193318
if (interp->config.tlbc_enabled) {
3320-
_PyIndexPool_FreeIndex(&interp->tlbc_indices, tstate->tlbc_index);
3319+
_PyIndexPool_FreeIndex(&interp->tlbc_indices, index);
33213320
}
33223321
}
33233322

3323+
void
3324+
_Py_ClearTLBCIndex(_PyThreadStateImpl *tstate)
3325+
{
3326+
PyInterpreterState *interp = ((PyThreadState *)tstate)->interp;
3327+
_Py_UnreserveTLBCIndex(interp, tstate->tlbc_index);
3328+
}
3329+
33243330
static _PyCodeArray *
33253331
_PyCodeArray_New(Py_ssize_t size)
33263332
{

Python/pystate.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,21 +1645,23 @@ new_threadstate(PyInterpreterState *interp, int whence)
16451645
return NULL;
16461646
}
16471647

1648-
#ifdef Py_GIL_DISABLED
1649-
Py_ssize_t qsbr_idx = _Py_qsbr_reserve(interp);
1650-
if (qsbr_idx < 0) {
1648+
#ifdef Py_STATS
1649+
// The PyStats structure is quite large and is allocated separated from
1650+
// tstate.
1651+
if (!_PyStats_ThreadInit(interp, tstate)) {
16511652
free_threadstate(tstate);
16521653
return NULL;
16531654
}
1655+
#endif
1656+
#ifdef Py_GIL_DISABLED
16541657
int32_t tlbc_idx = _Py_ReserveTLBCIndex(interp);
16551658
if (tlbc_idx < 0) {
16561659
free_threadstate(tstate);
16571660
return NULL;
16581661
}
1659-
#endif
1660-
#ifdef Py_STATS
1661-
// The PyStats structure is quite large and is allocated separated from tstate.
1662-
if (!_PyStats_ThreadInit(interp, tstate)) {
1662+
Py_ssize_t qsbr_idx = _Py_qsbr_reserve(interp);
1663+
if (qsbr_idx < 0) {
1664+
_Py_UnreserveTLBCIndex(interp, tlbc_idx);
16631665
free_threadstate(tstate);
16641666
return NULL;
16651667
}

0 commit comments

Comments
 (0)