From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 12 Jul 2022 16:35:43 +0000 (-0700) Subject: gh-94773: deepfreeze: support frozensets with unsortable types (GH-94775) X-Git-Tag: v3.11.0b5~89 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cdd0cabf92e731518ab1ff842673a4578213c1b5;p=thirdparty%2FPython%2Fcpython.git gh-94773: deepfreeze: support frozensets with unsortable types (GH-94775) (cherry picked from commit 0c66074e9f8c9728e1d920910d35da0c62f30403) Co-authored-by: Christian Heimes --- diff --git a/Misc/NEWS.d/next/Build/2022-07-12-13-39-18.gh-issue-94773.koHKm5.rst b/Misc/NEWS.d/next/Build/2022-07-12-13-39-18.gh-issue-94773.koHKm5.rst new file mode 100644 index 000000000000..ed7e40c91103 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2022-07-12-13-39-18.gh-issue-94773.koHKm5.rst @@ -0,0 +1,2 @@ +``deepfreeze.py`` now supports code object with frozensets that contain +incompatible, unsortable types. diff --git a/Tools/scripts/deepfreeze.py b/Tools/scripts/deepfreeze.py index 5a64c1ec2e61..c300c3019eef 100644 --- a/Tools/scripts/deepfreeze.py +++ b/Tools/scripts/deepfreeze.py @@ -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