Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Lib/test/test_capi/test_mem.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ def check(self, code):
out = assert_python_failure(
'-c', code,
PYTHONMALLOC=self.PYTHONMALLOC,
# FreeBSD: instruct jemalloc to not fill freed() memory
# with junk byte 0x5a, see JEMALLOC(3)
# Instruct the system allocator to not fill freed() memory
# with junk bytes:
# FreeBSD: jemalloc, see JEMALLOC(3).
MALLOC_CONF="junk:false",
# OpenBSD: see MALLOC.CONF(5).
MALLOC_OPTIONS="j",
)
stderr = out.err
return stderr.decode('ascii', 'replace')
Expand Down Expand Up @@ -102,7 +105,9 @@ def check_pyobject_is_freed(self, func_name):
assert_python_ok(
'-c', code,
PYTHONMALLOC=self.PYTHONMALLOC,
# See the comment in check() above.
MALLOC_CONF="junk:false",
MALLOC_OPTIONS="j",
)

def test_pyobject_null_is_freed(self):
Expand Down
5 changes: 3 additions & 2 deletions Lib/test/test_concurrent_futures/test_init.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import contextlib
import logging
import multiprocessing
import queue
import time
import unittest
Expand Down Expand Up @@ -147,8 +148,8 @@ def test_spawn(self):
self._test(ProcessPoolSpawnFailingInitializerTest)

@support.skip_if_sanitizer("TSAN doesn't support threads after fork", thread=True)
@unittest.skipIf(sys.platform == "cygwin",
"Forkserver is not available on Cygwin")
@unittest.skipUnless("forkserver" in multiprocessing.get_all_start_methods(),
"forkserver start method is not available")
def test_forkserver(self):
self._test(ProcessPoolForkserverFailingInitializerTest)

Expand Down
5 changes: 3 additions & 2 deletions Lib/test/test_profiling/test_tracing_profiler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test suite for the cProfile module."""
import multiprocessing
import sys
import unittest

Expand Down Expand Up @@ -220,8 +221,8 @@ def test_process_spawn_pickle(self):
# gh-140729: test use Process in cProfile.
self._test_process_run_pickle('spawn')

@unittest.skipIf(sys.platform == 'win32',
"No 'forkserver' start method on Windows")
@unittest.skipUnless("forkserver" in multiprocessing.get_all_start_methods(),
"forkserver start method is not available")
def test_process_forkserver_pickle(self):
# gh-140729: test use Process in cProfile.
self._test_process_run_pickle('forkserver')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Slightly speed up deallocation of objects that are not tracked by the garbage
collector, such as :class:`int`, :class:`float` and :class:`str`.
19 changes: 13 additions & 6 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -3292,13 +3292,20 @@ _Py_Dealloc(PyObject *op)
PyTypeObject *type = Py_TYPE(op);
unsigned long gc_flag = type->tp_flags & Py_TPFLAGS_HAVE_GC;
destructor dealloc = type->tp_dealloc;
PyThreadState *tstate = _PyThreadState_GET();
intptr_t margin = _Py_RecursionLimit_GetMargin(tstate);
if (margin < 2 && gc_flag) {
_PyTrash_thread_deposit_object(tstate, (PyObject *)op);
return;
PyThreadState *tstate = NULL;
intptr_t margin = 0;
if (gc_flag) {
tstate = _PyThreadState_GET();
margin = _Py_RecursionLimit_GetMargin(tstate);
if (margin < 2) {
_PyTrash_thread_deposit_object(tstate, (PyObject *)op);
return;
}
}
#ifdef Py_DEBUG
if (tstate == NULL) {
tstate = _PyThreadState_GET();
}
#if !defined(Py_GIL_DISABLED) && !defined(Py_STACKREF_DEBUG)
/* This assertion doesn't hold for the free-threading build, as
* PyStackRef_CLOSE_SPECIALIZED is not implemented */
Expand Down Expand Up @@ -3340,7 +3347,7 @@ _Py_Dealloc(PyObject *op)
Py_XDECREF(old_exc);
Py_DECREF(type);
#endif
if (tstate->delete_later && margin >= 4 && gc_flag) {
if (gc_flag && tstate->delete_later && margin >= 4) {
_PyTrash_thread_destroy_chain(tstate);
}
}
Expand Down
Loading