Skip to content

Commit aa8ef2e

Browse files
authored
Merge branch 'main' into fix-pythongh-144681
2 parents c36251c + 255e79f commit aa8ef2e

File tree

15 files changed

+101
-27
lines changed

15 files changed

+101
-27
lines changed

Doc/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ htmlhelp: build
8888
"build/htmlhelp/pydoc.hhp project file."
8989

9090
.PHONY: latex
91+
latex: _ensure-sphinxcontrib-svg2pdfconverter
9192
latex: BUILDER = latex
9293
latex: build
9394
@echo "Build finished; the LaTeX files are in build/latex."
@@ -231,7 +232,7 @@ dist-text:
231232
@echo "Build finished and archived!"
232233

233234
.PHONY: dist-pdf
234-
dist-pdf:
235+
dist-pdf: _ensure-sphinxcontrib-svg2pdfconverter
235236
# archive the A4 latex
236237
@echo "Building LaTeX (A4 paper)..."
237238
mkdir -p dist
@@ -292,6 +293,10 @@ _ensure-pre-commit:
292293
_ensure-sphinx-autobuild:
293294
$(MAKE) _ensure-package PACKAGE=sphinx-autobuild
294295

296+
.PHONY: _ensure-sphinxcontrib-svg2pdfconverter
297+
_ensure-sphinxcontrib-svg2pdfconverter:
298+
$(MAKE) _ensure-package PACKAGE=sphinxcontrib-svg2pdfconverter
299+
295300
.PHONY: check
296301
check: _ensure-pre-commit
297302
$(VENVDIR)/bin/python3 -m pre_commit run --all-files

Doc/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
'linklint.ext',
4747
'notfound.extension',
4848
'sphinxext.opengraph',
49+
'sphinxcontrib.rsvgconverter',
4950
)
5051
for optional_ext in _OPTIONAL_EXTENSIONS:
5152
try:
@@ -556,6 +557,7 @@
556557
# mapping unique short aliases to a base URL and a prefix.
557558
# https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html
558559
extlinks = {
560+
"oss-fuzz": ("https://issues.oss-fuzz.com/issues/%s", "#%s"),
559561
"pypi": ("https://pypi.org/project/%s/", "%s"),
560562
"source": (SOURCE_URI, "%s"),
561563
}

Doc/library/concurrent.futures.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ And::
156156
print(f.result())
157157

158158
executor = ThreadPoolExecutor(max_workers=1)
159-
executor.submit(wait_on_future)
159+
future = executor.submit(wait_on_future)
160+
# Note: calling future.result() would also cause a deadlock because
161+
# the single worker thread is already waiting for wait_on_future().
160162

161163

162164
.. class:: ThreadPoolExecutor(max_workers=None, thread_name_prefix='', initializer=None, initargs=())

Doc/library/profiling.sampling.rst

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,10 +1194,12 @@ data, similar to the ``top`` command for system processes::
11941194
python -m profiling.sampling run --live script.py
11951195
python -m profiling.sampling attach --live 12345
11961196

1197-
.. figure:: tachyon-live-mode-2.gif
1198-
:alt: Tachyon live mode showing all threads
1199-
:align: center
1200-
:width: 100%
1197+
.. only:: not latex
1198+
1199+
.. figure:: tachyon-live-mode-2.gif
1200+
:alt: Tachyon live mode showing all threads
1201+
:align: center
1202+
:width: 100%
12011203

12021204
Live mode displays real-time profiling statistics, showing combined
12031205
data from multiple threads in a multi-threaded application.
@@ -1217,10 +1219,12 @@ main table, showing instruction-level statistics for the currently selected
12171219
function. This panel displays which bytecode instructions are executing most
12181220
frequently, including specialized variants and their base opcodes.
12191221

1220-
.. figure:: tachyon-live-mode-1.gif
1221-
:alt: Tachyon live mode with opcode panel
1222-
:align: center
1223-
:width: 100%
1222+
.. only:: not latex
1223+
1224+
.. figure:: tachyon-live-mode-1.gif
1225+
:alt: Tachyon live mode with opcode panel
1226+
:align: center
1227+
:width: 100%
12241228

12251229
Live mode with ``--opcodes`` enabled shows an opcode panel with a bytecode
12261230
instruction breakdown for the selected function.

Lib/_ast_unparse.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,9 +738,13 @@ def visit_SetComp(self, node):
738738

739739
def visit_DictComp(self, node):
740740
with self.delimit("{", "}"):
741-
self.traverse(node.key)
742-
self.write(": ")
743-
self.traverse(node.value)
741+
if node.value:
742+
self.traverse(node.key)
743+
self.write(": ")
744+
self.traverse(node.value)
745+
else:
746+
self.write("**")
747+
self.traverse(node.key)
744748
for gen in node.generators:
745749
self.traverse(gen)
746750

Lib/test/test_future_stmt/test_future.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ def test_annotations(self):
349349
eq("(i ** 2 + j for i in (1, 2, 3) for j in (1, 2, 3))")
350350
eq("{i: 0 for i in (1, 2, 3)}")
351351
eq("{i: j for i, j in ((1, 'a'), (2, 'b'), (3, 'c'))}")
352+
eq("{**x for x in ()}")
353+
eq("[*x for x in ()]")
352354
eq("[(x, y) for x, y in (a, b)]")
353355
eq("[(x,) for x, in (a,)]")
354356
eq("Python3 > Python2 > COBOL")

Lib/test/test_unparse.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,11 @@ def test_set_comprehension(self):
403403
def test_dict_comprehension(self):
404404
self.check_ast_roundtrip("{x: x*x for x in range(10)}")
405405

406+
def test_dict_comprehension_unpacking(self):
407+
self.check_ast_roundtrip("{**x for x in ()}")
408+
self.check_ast_roundtrip("{**x for x in range(10)}")
409+
self.check_ast_roundtrip("[*x for x in ()]")
410+
406411
def test_class_decorators(self):
407412
self.check_ast_roundtrip(class_decorator)
408413

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix crash in AST unparser when unparsing dict comprehension unpacking.
2+
Found by OSS Fuzz in :oss-fuzz:`489790200`.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed a memory leak in the :term:`free-threaded build` where mimalloc pages
2+
could become permanently unreclaimable until the owning thread exited.

Objects/mimalloc/heap.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ static bool mi_heap_page_collect(mi_heap_t* heap, mi_page_queue_t* pq, mi_page_t
100100
// note: this will free retired pages as well.
101101
bool freed = _PyMem_mi_page_maybe_free(page, pq, collect >= MI_FORCE);
102102
if (!freed && collect == MI_ABANDON) {
103-
_mi_page_abandon(page, pq);
103+
// _PyMem_mi_page_maybe_free may have moved the page to a different
104+
// page queue, so we need to re-fetch the correct queue.
105+
uint8_t bin = (mi_page_is_in_full(page) ? MI_BIN_FULL : _mi_bin(page->xblock_size));
106+
_mi_page_abandon(page, &heap->pages[bin]);
104107
}
105108
}
106109
else if (collect == MI_ABANDON) {

0 commit comments

Comments
 (0)