mirror of
https://github.com/python/cpython
synced 2024-09-15 23:26:29 +00:00
gh-94773: deepfreeze: support frozensets with unsortable types (GH-94775)
This commit is contained in:
parent
ec5db539b9
commit
0c66074e9f
|
@ -0,0 +1,2 @@
|
|||
``deepfreeze.py`` now supports code object with frozensets that contain
|
||||
incompatible, unsortable types.
|
|
@ -359,7 +359,12 @@ def generate_complex(self, name: str, z: complex) -> str:
|
|||
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…
Reference in a new issue