"""Regenerate with CPython 3.12.14: python3 -I -S produce.py [--check]. Only compile, replace, serialize, and load inert code objects; never execute them. Marshal v0 avoids reference sharing, so every retained member is a distinct object. Two-member frozensets are framed before loading: constructing a Python frozenset first would deduplicate the inputs and conceal the behavior being tested. """ import base64 import hashlib import importlib.util import json import marshal import struct import sys from pathlib import Path if sys.implementation.name != "cpython" or sys.version_info[:3] != (3, 12, 14): raise SystemExit("This recorded oracle requires CPython 3.12.14.") base = compile("def f(a, b):\n return a + b\n", "equality.py", "exec").co_consts[0] handler = compile( "def f(a, b):\n try: return a / b\n except ZeroDivisionError: return None\n", "equality.py", "exec", ).co_consts[0] cases = [ ("qualified name is ignored", base, base.replace(co_qualname="other.f")), ("stack size is ignored", base, base.replace(co_stacksize=base.co_stacksize + 1)), ("line table distinguishes members", base, base.replace(co_linetable=b"")), ("exception table distinguishes members", handler, handler.replace(co_exceptiontable=b"")), ( "first line distinguishes members", base, base.replace(co_firstlineno=base.co_firstlineno + 1), ), ( "bool and int constants stay distinct", base.replace(co_consts=(True,)), base.replace(co_consts=(1,)), ), ( "int and float constants stay distinct", base.replace(co_consts=(1,)), base.replace(co_consts=(1.0,)), ), ( "signed zero constants stay distinct", base.replace(co_consts=(0.0,)), base.replace(co_consts=(-0.0,)), ), ] def frozen_pair(left, right): return b">" + struct.pack("