retracesoftware-proxy 0.2.16__py3-none-any.whl → 0.2.18__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- retracesoftware/__main__.py +7 -2
- retracesoftware/install/patcher.py +27 -0
- {retracesoftware_proxy-0.2.16.dist-info → retracesoftware_proxy-0.2.18.dist-info}/METADATA +1 -1
- {retracesoftware_proxy-0.2.16.dist-info → retracesoftware_proxy-0.2.18.dist-info}/RECORD +6 -6
- {retracesoftware_proxy-0.2.16.dist-info → retracesoftware_proxy-0.2.18.dist-info}/WHEEL +0 -0
- {retracesoftware_proxy-0.2.16.dist-info → retracesoftware_proxy-0.2.18.dist-info}/top_level.txt +0 -0
retracesoftware/__main__.py
CHANGED
|
@@ -75,8 +75,10 @@ def checksum(path):
|
|
|
75
75
|
return file_md5(path) if path.is_file() else {entry.name: checksum(entry) for entry in path.iterdir() if entry.name != '__pycache__'}
|
|
76
76
|
|
|
77
77
|
def retrace_extension_paths():
|
|
78
|
-
names = ['
|
|
79
|
-
|
|
78
|
+
names = ['_retracesoftware_utils_release', '_retracesoftware_utils_debug',
|
|
79
|
+
'_retracesoftware_functional_release', '_retracesoftware_functional_debug',
|
|
80
|
+
'_retracesoftware_stream_release', '_retracesoftware_stream_debug']
|
|
81
|
+
return {name: Path(sys.modules[name].__file__) for name in names if name in sys.modules}
|
|
80
82
|
|
|
81
83
|
def retrace_module_paths():
|
|
82
84
|
paths = retrace_extension_paths()
|
|
@@ -88,6 +90,9 @@ def checksums():
|
|
|
88
90
|
|
|
89
91
|
def record(options, args):
|
|
90
92
|
|
|
93
|
+
if options.verbose:
|
|
94
|
+
print(f"Retrace enabled, recording to {options.recording}", file=sys.stderr)
|
|
95
|
+
|
|
91
96
|
path = Path(expand_recording_path(options.recording))
|
|
92
97
|
# ensure the path exists
|
|
93
98
|
path.mkdir(parents=True, exist_ok=True)
|
|
@@ -61,12 +61,39 @@ def create_patcher(system):
|
|
|
61
61
|
|
|
62
62
|
per_thread = PerThread()
|
|
63
63
|
|
|
64
|
+
# Hash patching for deterministic record/replay
|
|
65
|
+
#
|
|
66
|
+
# Why we patch __hash__:
|
|
67
|
+
# Python's default object hashes are based on memory addresses, which vary
|
|
68
|
+
# between runs. Sets iterate in hash order, so iteration order is
|
|
69
|
+
# non-deterministic. For record/replay to work correctly, we need identical
|
|
70
|
+
# set iteration order during both phases, so we replace __hash__ with a
|
|
71
|
+
# deterministic counter-based hash that returns stable values.
|
|
72
|
+
# (Note: dicts maintain insertion order since Python 3.7, so they're stable.)
|
|
73
|
+
#
|
|
74
|
+
# The hashfunc dispatches based on thread state:
|
|
75
|
+
# - disabled: returns None (unhashable, triggers fallback)
|
|
76
|
+
# - internal: counter for when thread is inside the sandbox (proxied code)
|
|
77
|
+
# - external: counter for when thread is outside the sandbox (user code)
|
|
78
|
+
#
|
|
79
|
+
# IMPORTANT - Python 3.12 compatibility:
|
|
80
|
+
# Python 3.12 changed typing._tp_cache to use a global _caches dict with
|
|
81
|
+
# functions as keys (see bpo GH-98253). If typing is imported BEFORE we
|
|
82
|
+
# patch FunctionType.__hash__, those functions won't be in our internal
|
|
83
|
+
# hash cache, and lookups will fail. utils.patch_hash handles this by
|
|
84
|
+
# pre-populating the cache with all existing instances of the patched type.
|
|
85
|
+
#
|
|
64
86
|
hashfunc = system.thread_state.dispatch(
|
|
65
87
|
functional.constantly(None),
|
|
66
88
|
internal = functional.repeatedly(functional.partial(getattr, per_thread, 'internal')),
|
|
67
89
|
external = functional.repeatedly(functional.partial(getattr, per_thread, 'external')))
|
|
68
90
|
|
|
69
91
|
def patch_hash(obj):
|
|
92
|
+
"""Patch __hash__ on a type to use deterministic counter-based hashing.
|
|
93
|
+
|
|
94
|
+
This ensures stable set iteration order for instances of this type,
|
|
95
|
+
which is required for record/replay consistency.
|
|
96
|
+
"""
|
|
70
97
|
if not isinstance(obj, type):
|
|
71
98
|
raise Exception("TODO")
|
|
72
99
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
retracesoftware/__init__.py,sha256=jQw15XBREFZX93BHpvREfc-hQmMUHYtO6gO-qZmdW1o,482
|
|
2
|
-
retracesoftware/__main__.py,sha256=
|
|
2
|
+
retracesoftware/__main__.py,sha256=FwxTltjG1CnARYD4bdPLNiTTc8cF7WryLdBSDSg0zF0,9871
|
|
3
3
|
retracesoftware/autoenable.py,sha256=6KxpaPpeleSN7-qmekA4w2HJQaet_9Flt9WikQvyN04,1808
|
|
4
4
|
retracesoftware/config.json,sha256=Cw5YZCfTo8GLmtbTH2LYwST7wNe7925DAwsTtRIGhBE,3817
|
|
5
5
|
retracesoftware/config.yaml,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -16,7 +16,7 @@ retracesoftware/install/edgecases.py,sha256=Ry3BETJ4Hmqpw9xXTlNeUgBL9q-sumaazqjm
|
|
|
16
16
|
retracesoftware/install/globals.py,sha256=F8XvIoZQQ10gSRalk30dvdKllxlwxkaggYY6FogLDxY,510
|
|
17
17
|
retracesoftware/install/install.py,sha256=fP7E9OWiQd1Dgi4jL8rL9T5SXW5AL62BM3NEW61fisw,4969
|
|
18
18
|
retracesoftware/install/modulepatcher.py,sha256=yBXrbfr5J9JQXCVbcNpDm8H17bsPbL6DY54bImFjBKM,16715
|
|
19
|
-
retracesoftware/install/patcher.py,sha256=
|
|
19
|
+
retracesoftware/install/patcher.py,sha256=Z98ux8SDw53wyRKCevOT-tPOFcwcM3KH1dyR7Tg_TJ4,5859
|
|
20
20
|
retracesoftware/install/patchfindspec.py,sha256=uQkfdOQOY20hFAcwDAqx7m8rbtGM2rBKOfC3Szb1zhw,4942
|
|
21
21
|
retracesoftware/install/phases.py,sha256=OWaw86xzC924tdIA9C-12Qdr3sCx67hEOn-Ih9FM--4,9359
|
|
22
22
|
retracesoftware/install/predicate.py,sha256=tX7NQc0rGkyyHYO3mduYHcJHbw1wczT53m_Dpkzo6do,2679
|
|
@@ -39,7 +39,7 @@ retracesoftware/proxy/serializer.py,sha256=S5yhHoP2iYaXBY7Jr8Ei630Z31521x0IO6Deu
|
|
|
39
39
|
retracesoftware/proxy/startthread.py,sha256=YKUcOSjA-9_5ZsDHhyP0fXJSP3RWDKV-ajX-I0SI-bU,1270
|
|
40
40
|
retracesoftware/proxy/stubfactory.py,sha256=fyQtCZnkXvLaTlGcxE0Lx8od09ZOgnPWPn0YvNFfVeQ,6219
|
|
41
41
|
retracesoftware/proxy/thread.py,sha256=AAj6BL4kw-KMHX4fV66LuePQbTYvPmI3IY8ZwV069nI,3073
|
|
42
|
-
retracesoftware_proxy-0.2.
|
|
43
|
-
retracesoftware_proxy-0.2.
|
|
44
|
-
retracesoftware_proxy-0.2.
|
|
45
|
-
retracesoftware_proxy-0.2.
|
|
42
|
+
retracesoftware_proxy-0.2.18.dist-info/METADATA,sha256=KZeS6LA5Mqcp9H-ofq3949xU3ad9DmQdhp7sDmuw1k0,227
|
|
43
|
+
retracesoftware_proxy-0.2.18.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
44
|
+
retracesoftware_proxy-0.2.18.dist-info/top_level.txt,sha256=hYHsR6txLidmqvjBMITpIHvmJJbmoCAgr76-IpZPRz8,16
|
|
45
|
+
retracesoftware_proxy-0.2.18.dist-info/RECORD,,
|
|
File without changes
|
{retracesoftware_proxy-0.2.16.dist-info → retracesoftware_proxy-0.2.18.dist-info}/top_level.txt
RENAMED
|
File without changes
|