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 0c66074

Browse filesBrowse files
authored
gh-94773: deepfreeze: support frozensets with unsortable types (GH-94775)
1 parent ec5db53 commit 0c66074
Copy full SHA for 0c66074

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
@@ -359,7 +359,12 @@ def generate_complex(self, name: str, z: complex) -> str:
359359
return f"&{name}.ob_base"
360360

361361
def generate_frozenset(self, name: str, fs: FrozenSet[object]) -> str:
362-
ret = self.generate_tuple(name, tuple(sorted(fs)))
362+
try:
363+
fs = sorted(fs)
364+
except TypeError:
365+
# frozen set with incompatible types, fallback to repr()
366+
fs = sorted(fs, key=repr)
367+
ret = self.generate_tuple(name, tuple(fs))
363368
self.write("// TODO: The above tuple should be a frozenset")
364369
return ret
365370

0 commit comments

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