diff options
author | Christian Heimes <christian@python.org> | 2022-07-12 16:09:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-12 16:09:47 (GMT) |
commit | 0c66074e9f8c9728e1d920910d35da0c62f30403 (patch) | |
tree | 441c87ae58761de8fd0ac0f24d799c278f4e0c9c /Tools | |
parent | ec5db539b9df99c8b96149768dc2e8598dce2afa (diff) | |
download | cpython-0c66074e9f8c9728e1d920910d35da0c62f30403.zip cpython-0c66074e9f8c9728e1d920910d35da0c62f30403.tar.gz cpython-0c66074e9f8c9728e1d920910d35da0c62f30403.tar.bz2 |
gh-94773: deepfreeze: support frozensets with unsortable types (GH-94775)
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/scripts/deepfreeze.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Tools/scripts/deepfreeze.py b/Tools/scripts/deepfreeze.py index f9fd4e3..62eeafa 100644 --- a/Tools/scripts/deepfreeze.py +++ b/Tools/scripts/deepfreeze.py @@ -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 |