Skip to content

Commit e061960

Browse files
Merge branch 'main' into 145247-pytuple-from-pair
2 parents ba64a3e + 63eaaf9 commit e061960

23 files changed

Lines changed: 178 additions & 157 deletions

Doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@
557557
# mapping unique short aliases to a base URL and a prefix.
558558
# https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html
559559
extlinks = {
560+
"oss-fuzz": ("https://issues.oss-fuzz.com/issues/%s", "#%s"),
560561
"pypi": ("https://pypi.org/project/%s/", "%s"),
561562
"source": (SOURCE_URI, "%s"),
562563
}

Doc/faq/programming.rst

Lines changed: 68 additions & 62 deletions
Large diffs are not rendered by default.

Doc/installing/index.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
Installing Python Modules
77
*************************
88

9-
:Email: distutils-sig@python.org
10-
119
As a popular open source development project, Python has an active
1210
supporting community of contributors and users that also make their software
1311
available for other Python developers to use under open source license terms.

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_listcomps.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,18 @@ def test_references___class___defined(self):
180180
code, outputs={"res": [2]}, scopes=["module", "function"])
181181
self._check_in_scopes(code, raises=NameError, scopes=["class"])
182182

183+
def test_references___classdict__(self):
184+
code = """
185+
class i: [__classdict__ for x in y]
186+
"""
187+
self._check_in_scopes(code, raises=NameError)
188+
189+
def test_references___conditional_annotations__(self):
190+
code = """
191+
class i: [__conditional_annotations__ for x in y]
192+
"""
193+
self._check_in_scopes(code, raises=NameError)
194+
183195
def test_references___class___enclosing(self):
184196
code = """
185197
__class__ = 2

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

Makefile.pre.in

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,9 +1729,6 @@ FROZEN_FILES_IN = \
17291729
Lib/zipimport.py \
17301730
Lib/abc.py \
17311731
Lib/codecs.py \
1732-
Lib/encodings/__init__.py \
1733-
Lib/encodings/aliases.py \
1734-
Lib/encodings/utf_8.py \
17351732
Lib/io.py \
17361733
Lib/_collections_abc.py \
17371734
Lib/_sitebuiltins.py \
@@ -1741,7 +1738,6 @@ FROZEN_FILES_IN = \
17411738
Lib/os.py \
17421739
Lib/site.py \
17431740
Lib/stat.py \
1744-
Lib/linecache.py \
17451741
Lib/importlib/util.py \
17461742
Lib/importlib/machinery.py \
17471743
Lib/runpy.py \
@@ -1758,9 +1754,6 @@ FROZEN_FILES_OUT = \
17581754
Python/frozen_modules/zipimport.h \
17591755
Python/frozen_modules/abc.h \
17601756
Python/frozen_modules/codecs.h \
1761-
Python/frozen_modules/encodings.h \
1762-
Python/frozen_modules/encodings.aliases.h \
1763-
Python/frozen_modules/encodings.utf_8.h \
17641757
Python/frozen_modules/io.h \
17651758
Python/frozen_modules/_collections_abc.h \
17661759
Python/frozen_modules/_sitebuiltins.h \
@@ -1770,7 +1763,6 @@ FROZEN_FILES_OUT = \
17701763
Python/frozen_modules/os.h \
17711764
Python/frozen_modules/site.h \
17721765
Python/frozen_modules/stat.h \
1773-
Python/frozen_modules/linecache.h \
17741766
Python/frozen_modules/importlib.util.h \
17751767
Python/frozen_modules/importlib.machinery.h \
17761768
Python/frozen_modules/runpy.h \
@@ -1810,15 +1802,6 @@ Python/frozen_modules/abc.h: Lib/abc.py $(FREEZE_MODULE_DEPS)
18101802
Python/frozen_modules/codecs.h: Lib/codecs.py $(FREEZE_MODULE_DEPS)
18111803
$(FREEZE_MODULE) codecs $(srcdir)/Lib/codecs.py Python/frozen_modules/codecs.h
18121804

1813-
Python/frozen_modules/encodings.h: Lib/encodings/__init__.py $(FREEZE_MODULE_DEPS)
1814-
$(FREEZE_MODULE) encodings $(srcdir)/Lib/encodings/__init__.py Python/frozen_modules/encodings.h
1815-
1816-
Python/frozen_modules/encodings.aliases.h: Lib/encodings/aliases.py $(FREEZE_MODULE_DEPS)
1817-
$(FREEZE_MODULE) encodings.aliases $(srcdir)/Lib/encodings/aliases.py Python/frozen_modules/encodings.aliases.h
1818-
1819-
Python/frozen_modules/encodings.utf_8.h: Lib/encodings/utf_8.py $(FREEZE_MODULE_DEPS)
1820-
$(FREEZE_MODULE) encodings.utf_8 $(srcdir)/Lib/encodings/utf_8.py Python/frozen_modules/encodings.utf_8.h
1821-
18221805
Python/frozen_modules/io.h: Lib/io.py $(FREEZE_MODULE_DEPS)
18231806
$(FREEZE_MODULE) io $(srcdir)/Lib/io.py Python/frozen_modules/io.h
18241807

@@ -1846,9 +1829,6 @@ Python/frozen_modules/site.h: Lib/site.py $(FREEZE_MODULE_DEPS)
18461829
Python/frozen_modules/stat.h: Lib/stat.py $(FREEZE_MODULE_DEPS)
18471830
$(FREEZE_MODULE) stat $(srcdir)/Lib/stat.py Python/frozen_modules/stat.h
18481831

1849-
Python/frozen_modules/linecache.h: Lib/linecache.py $(FREEZE_MODULE_DEPS)
1850-
$(FREEZE_MODULE) linecache $(srcdir)/Lib/linecache.py Python/frozen_modules/linecache.h
1851-
18521832
Python/frozen_modules/importlib.util.h: Lib/importlib/util.py $(FREEZE_MODULE_DEPS)
18531833
$(FREEZE_MODULE) importlib.util $(srcdir)/Lib/importlib/util.py Python/frozen_modules/importlib.util.h
18541834

Misc/NEWS.d/next/Core_and_Builtins/2026-02-26-21-22-34.gh-issue-145278.DHkYqt.rst

Lines changed: 0 additions & 4 deletions
This file was deleted.
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`.

0 commit comments

Comments
 (0)