mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
gh-94773: deepfreeze: support frozensets with unsortable types (GH-94775)
This commit is contained in:
parent
ec5db539b9
commit
0c66074e9f
2 changed files with 8 additions and 1 deletions
|
@ -359,7 +359,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