Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cdd0cab

Browse filesBrowse files
gh-94773: deepfreeze: support frozensets with unsortable types (GH-94775)
(cherry picked from commit 0c66074) Co-authored-by: Christian Heimes <christian@python.org>
1 parent a4b98a7 commit cdd0cab
Copy full SHA for cdd0cab

File tree

Expand file treeCollapse file tree

2 files changed

+8
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-1
lines changed
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
``deepfreeze.py`` now supports code object with frozensets that contain
2+
incompatible, unsortable types.

‎Tools/scripts/deepfreeze.py

Copy file name to clipboardExpand all lines: Tools/scripts/deepfreeze.py
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,12 @@ def generate_complex(self, name: str, z: complex) -> str:
369369
return f"&{name}.ob_base"
370370

371371
def generate_frozenset(self, name: str, fs: FrozenSet[object]) -> str:
372-
ret = self.generate_tuple(name, tuple(sorted(fs)))
372+
try:
373+
fs = sorted(fs)
374+
except TypeError:
375+
# frozen set with incompatible types, fallback to repr()
376+
fs = sorted(fs, key=repr)
377+
ret = self.generate_tuple(name, tuple(fs))
373378
self.write("// TODO: The above tuple should be a frozenset")
374379
return ret
375380

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.