From 6f6c95e55c9d2c49d797fcfd24feb4b227822784 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Wed, 3 Apr 2024 00:32:52 -0500 Subject: [PATCH 1/3] gh-117215 Make the fromskey() signature match dict.fromkeys(). --- Lib/collections/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py index 2a35989ee25a5e..0ab98e682a64a1 100644 --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -1038,9 +1038,9 @@ def __repr__(self): return f'{self.__class__.__name__}({", ".join(map(repr, self.maps))})' @classmethod - def fromkeys(cls, iterable, *args): + def fromkeys(cls, iterable, value=None, /): 'Create a ChainMap with a single dict created from the iterable.' - return cls(dict.fromkeys(iterable, *args)) + return cls(dict.fromkeys(iterable, value)) def copy(self): 'New ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]' From 7af30eacb17955cd64f1f19217c60783fd419084 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Wed, 3 Apr 2024 00:40:34 -0500 Subject: [PATCH 2/3] Sync docstring as well. --- Lib/collections/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py index 0ab98e682a64a1..0d2cf0814ea4a4 100644 --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -1039,7 +1039,7 @@ def __repr__(self): @classmethod def fromkeys(cls, iterable, value=None, /): - 'Create a ChainMap with a single dict created from the iterable.' + 'Create a new ChainMap with keys from thhe iterable and values set to value.' return cls(dict.fromkeys(iterable, value)) def copy(self): From 9d548791118e993c149b37e55c20cd192aca0555 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Wed, 3 Apr 2024 09:12:02 -0500 Subject: [PATCH 3/3] Update Lib/collections/__init__.py Co-authored-by: Serhiy Storchaka --- Lib/collections/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py index 0d2cf0814ea4a4..d06d84cbdfcc36 100644 --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -1039,7 +1039,7 @@ def __repr__(self): @classmethod def fromkeys(cls, iterable, value=None, /): - 'Create a new ChainMap with keys from thhe iterable and values set to value.' + 'Create a new ChainMap with keys from iterable and values set to value.' return cls(dict.fromkeys(iterable, value)) def copy(self):