mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-94773: deepfreeze: support frozensets with unsortable types (GH-94775)
(cherry picked from commit 0c66074e9f
)
Co-authored-by: Christian Heimes <christian@python.org>
This commit is contained in:
parent
a4b98a792f
commit
cdd0cabf92
2 changed files with 8 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
``deepfreeze.py`` now supports code object with frozensets that contain
|
||||
incompatible, unsortable types.
|
|
@ -369,7 +369,12 @@ class Printer:
|
|||
return f"&{name}.ob_base"
|
||||
|
||||
def generate_frozenset(self, name: str, fs: FrozenSet[object]) -> str:
|
||||
ret = self.generate_tuple(name, tuple(sorted(fs)))
|
||||
try:
|
||||
fs = sorted(fs)
|
||||
except TypeError:
|
||||
# frozen set with incompatible types, fallback to repr()
|
||||
fs = sorted(fs, key=repr)
|
||||
ret = self.generate_tuple(name, tuple(fs))
|
||||
self.write("// TODO: The above tuple should be a frozenset")
|
||||
return ret
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue