Skip to content

Commit 7fcac00

Browse files
Merge branch 'main' into curses-attr-get-set
2 parents 655a33b + 908f438 commit 7fcac00

11 files changed

Lines changed: 261 additions & 88 deletions

File tree

.github/workflows/reusable-emscripten.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,17 @@ jobs:
6363
run: python3 Platforms/emscripten configure-build-python -- --config-cache --with-pydebug
6464
- name: "Make build Python"
6565
run: python3 Platforms/emscripten make-build-python
66+
- name: "Display build info of the build Python"
67+
run: python3 Platforms/emscripten pythoninfo-build
6668
- name: "Make dependencies"
6769
run: >-
6870
python3 Platforms/emscripten make-dependencies
6971
${{ steps.emsdk-cache.outputs.cache-hit == 'true' && '--check-up-to-date' || '' }}
70-
- name: "Configure host Python"
72+
- name: "Configure host/Emscripten Python"
7173
run: python3 Platforms/emscripten configure-host --host-runner node -- --config-cache
72-
- name: "Make host Python"
74+
- name: "Make host/Emscripten Python"
7375
run: python3 Platforms/emscripten make-host
74-
- name: "Display build info"
75-
run: python3 Platforms/emscripten run --pythoninfo
76+
- name: "Display build info of the host/Emscripten Python"
77+
run: python3 Platforms/emscripten pythoninfo-host
7678
- name: "Test"
7779
run: python3 Platforms/emscripten run --test

.github/workflows/reusable-wasi.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
timeout-minutes: 60
1717
env:
1818
WASMTIME_VERSION: 38.0.3
19-
CROSS_BUILD_PYTHON: cross-build/build
2019
CROSS_BUILD_WASI: cross-build/wasm32-wasip1
2120
steps:
2221
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -54,14 +53,16 @@ jobs:
5453
run: python3 Platforms/WASI configure-build-python -- --config-cache --with-pydebug
5554
- name: "Make build Python"
5655
run: python3 Platforms/WASI make-build-python
57-
- name: "Configure host"
56+
- name: "Display build info of the build Python"
57+
run: python3 Platforms/WASI pythoninfo-build
58+
- name: "Configure host/WASI Python"
5859
# `--with-pydebug` inferred from configure-build-python
5960
run: python3 Platforms/WASI configure-host -- --config-cache
6061
env:
6162
WASI_SDK_PATH: ${{ steps.install-wasi-sdk.outputs.wasi-sdk-path }}
62-
- name: "Make host"
63+
- name: "Make host/WASI Python"
6364
run: python3 Platforms/WASI make-host
64-
- name: "Display build info"
65-
run: make --directory "${CROSS_BUILD_WASI}" pythoninfo
65+
- name: "Display build info of the host/WASI Python"
66+
run: python3 Platforms/WASI pythoninfo-host
6667
- name: "Test"
6768
run: make --directory "${CROSS_BUILD_WASI}" test

Doc/library/stdtypes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5757,6 +5757,13 @@ Frozen dictionaries
57575757
Like dictionaries, frozendicts are :ref:`generic <generics>` over two types,
57585758
signifying (respectively) the types of the frozendict's keys and values.
57595759

5760+
.. classmethod:: fromkeys(iterable, value=None, /)
5761+
5762+
Similar to :meth:`dict.fromkeys`, but call again the type constructor
5763+
with an initialized :class:`frozendict` if the type is a
5764+
:class:`frozendict` subclass or if the constructor returned a
5765+
:class:`frozendict`.
5766+
57605767
.. versionadded:: 3.15
57615768

57625769

Lib/test/test_dict.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,8 +1939,11 @@ def test_fromkeys(self):
19391939
# Subclass which overrides the constructor
19401940
created = frozendict(x=1)
19411941
class FrozenDictSubclass(frozendict):
1942-
def __new__(self):
1943-
return created
1942+
def __new__(cls, *args, **kwargs):
1943+
if args or kwargs:
1944+
return super().__new__(cls, *args, **kwargs)
1945+
else:
1946+
return created
19441947

19451948
fd = FrozenDictSubclass.fromkeys("abc")
19461949
self.assertEqual(fd, frozendict(x=1, a=None, b=None, c=None))
@@ -1952,6 +1955,20 @@ def __new__(self):
19521955
self.assertEqual(type(fd), FrozenDictSubclass)
19531956
self.assertEqual(created, frozendict(x=1))
19541957

1958+
# Dict subclass with a constructor which returns a frozendict
1959+
# by default
1960+
class DictSubclass(dict):
1961+
def __new__(cls, *args, **kwargs):
1962+
if args or kwargs:
1963+
return super().__new__(cls, *args, **kwargs)
1964+
else:
1965+
return created
1966+
1967+
fd = DictSubclass.fromkeys("abc")
1968+
self.assertEqual(fd, frozendict(x=1, a=None, b=None, c=None))
1969+
self.assertEqual(type(fd), DictSubclass)
1970+
self.assertEqual(created, frozendict(x=1))
1971+
19551972
# Subclass which doesn't override the constructor
19561973
class FrozenDictSubclass2(frozendict):
19571974
pass
@@ -1960,16 +1977,6 @@ class FrozenDictSubclass2(frozendict):
19601977
self.assertEqual(fd, frozendict(a=None, b=None, c=None))
19611978
self.assertEqual(type(fd), FrozenDictSubclass2)
19621979

1963-
# Dict subclass which overrides the constructor
1964-
class DictSubclass(dict):
1965-
def __new__(self):
1966-
return created
1967-
1968-
fd = DictSubclass.fromkeys("abc")
1969-
self.assertEqual(fd, frozendict(x=1, a=None, b=None, c=None))
1970-
self.assertEqual(type(fd), DictSubclass)
1971-
self.assertEqual(created, frozendict(x=1))
1972-
19731980
def test_pickle(self):
19741981
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
19751982
for fd in (
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:meth:`!frozendict.fromkeys` now only tracks the :class:`frozendict` in the
2+
garbage collector once the dictionary is fully initialized. Patch by Donghee Na
3+
and Victor Stinner.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Defer GC tracking of a :class:`set` or :class:`frozenset` to the end of its
2+
construction from iterable. Patch by Donghee Na.

0 commit comments

Comments
 (0)