crosshair-tool 0.0.99__cp312-cp312-macosx_10_13_x86_64.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.
Files changed (176) hide show
  1. _crosshair_tracers.cpython-312-darwin.so +0 -0
  2. crosshair/__init__.py +42 -0
  3. crosshair/__main__.py +8 -0
  4. crosshair/_mark_stacks.h +790 -0
  5. crosshair/_preliminaries_test.py +18 -0
  6. crosshair/_tracers.h +94 -0
  7. crosshair/_tracers_pycompat.h +522 -0
  8. crosshair/_tracers_test.py +138 -0
  9. crosshair/abcstring.py +245 -0
  10. crosshair/auditwall.py +190 -0
  11. crosshair/auditwall_test.py +77 -0
  12. crosshair/codeconfig.py +113 -0
  13. crosshair/codeconfig_test.py +117 -0
  14. crosshair/condition_parser.py +1237 -0
  15. crosshair/condition_parser_test.py +497 -0
  16. crosshair/conftest.py +30 -0
  17. crosshair/copyext.py +155 -0
  18. crosshair/copyext_test.py +84 -0
  19. crosshair/core.py +1763 -0
  20. crosshair/core_and_libs.py +149 -0
  21. crosshair/core_regestered_types_test.py +82 -0
  22. crosshair/core_test.py +1316 -0
  23. crosshair/diff_behavior.py +314 -0
  24. crosshair/diff_behavior_test.py +261 -0
  25. crosshair/dynamic_typing.py +346 -0
  26. crosshair/dynamic_typing_test.py +210 -0
  27. crosshair/enforce.py +282 -0
  28. crosshair/enforce_test.py +182 -0
  29. crosshair/examples/PEP316/__init__.py +1 -0
  30. crosshair/examples/PEP316/bugs_detected/__init__.py +0 -0
  31. crosshair/examples/PEP316/bugs_detected/getattr_magic.py +16 -0
  32. crosshair/examples/PEP316/bugs_detected/hash_consistent_with_equals.py +31 -0
  33. crosshair/examples/PEP316/bugs_detected/shopping_cart.py +24 -0
  34. crosshair/examples/PEP316/bugs_detected/showcase.py +39 -0
  35. crosshair/examples/PEP316/correct_code/__init__.py +0 -0
  36. crosshair/examples/PEP316/correct_code/arith.py +60 -0
  37. crosshair/examples/PEP316/correct_code/chess.py +77 -0
  38. crosshair/examples/PEP316/correct_code/nesting_inference.py +17 -0
  39. crosshair/examples/PEP316/correct_code/numpy_examples.py +132 -0
  40. crosshair/examples/PEP316/correct_code/rolling_average.py +35 -0
  41. crosshair/examples/PEP316/correct_code/showcase.py +104 -0
  42. crosshair/examples/__init__.py +0 -0
  43. crosshair/examples/check_examples_test.py +146 -0
  44. crosshair/examples/deal/__init__.py +1 -0
  45. crosshair/examples/icontract/__init__.py +1 -0
  46. crosshair/examples/icontract/bugs_detected/__init__.py +0 -0
  47. crosshair/examples/icontract/bugs_detected/showcase.py +41 -0
  48. crosshair/examples/icontract/bugs_detected/wrong_sign.py +8 -0
  49. crosshair/examples/icontract/correct_code/__init__.py +0 -0
  50. crosshair/examples/icontract/correct_code/arith.py +51 -0
  51. crosshair/examples/icontract/correct_code/showcase.py +94 -0
  52. crosshair/fnutil.py +391 -0
  53. crosshair/fnutil_test.py +75 -0
  54. crosshair/fuzz_core_test.py +516 -0
  55. crosshair/libimpl/__init__.py +0 -0
  56. crosshair/libimpl/arraylib.py +161 -0
  57. crosshair/libimpl/binascii_ch_test.py +30 -0
  58. crosshair/libimpl/binascii_test.py +67 -0
  59. crosshair/libimpl/binasciilib.py +150 -0
  60. crosshair/libimpl/bisectlib_test.py +23 -0
  61. crosshair/libimpl/builtinslib.py +5228 -0
  62. crosshair/libimpl/builtinslib_ch_test.py +1191 -0
  63. crosshair/libimpl/builtinslib_test.py +3735 -0
  64. crosshair/libimpl/codecslib.py +86 -0
  65. crosshair/libimpl/codecslib_test.py +86 -0
  66. crosshair/libimpl/collectionslib.py +264 -0
  67. crosshair/libimpl/collectionslib_ch_test.py +252 -0
  68. crosshair/libimpl/collectionslib_test.py +332 -0
  69. crosshair/libimpl/copylib.py +23 -0
  70. crosshair/libimpl/copylib_test.py +18 -0
  71. crosshair/libimpl/datetimelib.py +2559 -0
  72. crosshair/libimpl/datetimelib_ch_test.py +354 -0
  73. crosshair/libimpl/datetimelib_test.py +112 -0
  74. crosshair/libimpl/decimallib.py +5257 -0
  75. crosshair/libimpl/decimallib_ch_test.py +78 -0
  76. crosshair/libimpl/decimallib_test.py +76 -0
  77. crosshair/libimpl/encodings/__init__.py +23 -0
  78. crosshair/libimpl/encodings/_encutil.py +187 -0
  79. crosshair/libimpl/encodings/ascii.py +44 -0
  80. crosshair/libimpl/encodings/latin_1.py +40 -0
  81. crosshair/libimpl/encodings/utf_8.py +93 -0
  82. crosshair/libimpl/encodings_ch_test.py +83 -0
  83. crosshair/libimpl/fractionlib.py +16 -0
  84. crosshair/libimpl/fractionlib_test.py +80 -0
  85. crosshair/libimpl/functoolslib.py +34 -0
  86. crosshair/libimpl/functoolslib_test.py +56 -0
  87. crosshair/libimpl/hashliblib.py +30 -0
  88. crosshair/libimpl/hashliblib_test.py +18 -0
  89. crosshair/libimpl/heapqlib.py +47 -0
  90. crosshair/libimpl/heapqlib_test.py +21 -0
  91. crosshair/libimpl/importliblib.py +18 -0
  92. crosshair/libimpl/importliblib_test.py +38 -0
  93. crosshair/libimpl/iolib.py +216 -0
  94. crosshair/libimpl/iolib_ch_test.py +128 -0
  95. crosshair/libimpl/iolib_test.py +19 -0
  96. crosshair/libimpl/ipaddresslib.py +8 -0
  97. crosshair/libimpl/itertoolslib.py +44 -0
  98. crosshair/libimpl/itertoolslib_test.py +44 -0
  99. crosshair/libimpl/jsonlib.py +984 -0
  100. crosshair/libimpl/jsonlib_ch_test.py +42 -0
  101. crosshair/libimpl/jsonlib_test.py +51 -0
  102. crosshair/libimpl/mathlib.py +179 -0
  103. crosshair/libimpl/mathlib_ch_test.py +44 -0
  104. crosshair/libimpl/mathlib_test.py +67 -0
  105. crosshair/libimpl/oslib.py +7 -0
  106. crosshair/libimpl/pathliblib_test.py +10 -0
  107. crosshair/libimpl/randomlib.py +178 -0
  108. crosshair/libimpl/randomlib_test.py +120 -0
  109. crosshair/libimpl/relib.py +846 -0
  110. crosshair/libimpl/relib_ch_test.py +169 -0
  111. crosshair/libimpl/relib_test.py +493 -0
  112. crosshair/libimpl/timelib.py +72 -0
  113. crosshair/libimpl/timelib_test.py +82 -0
  114. crosshair/libimpl/typeslib.py +15 -0
  115. crosshair/libimpl/typeslib_test.py +36 -0
  116. crosshair/libimpl/unicodedatalib.py +75 -0
  117. crosshair/libimpl/unicodedatalib_test.py +42 -0
  118. crosshair/libimpl/urlliblib.py +23 -0
  119. crosshair/libimpl/urlliblib_test.py +19 -0
  120. crosshair/libimpl/weakreflib.py +13 -0
  121. crosshair/libimpl/weakreflib_test.py +69 -0
  122. crosshair/libimpl/zliblib.py +15 -0
  123. crosshair/libimpl/zliblib_test.py +13 -0
  124. crosshair/lsp_server.py +261 -0
  125. crosshair/lsp_server_test.py +30 -0
  126. crosshair/main.py +973 -0
  127. crosshair/main_test.py +543 -0
  128. crosshair/objectproxy.py +376 -0
  129. crosshair/objectproxy_test.py +41 -0
  130. crosshair/opcode_intercept.py +601 -0
  131. crosshair/opcode_intercept_test.py +304 -0
  132. crosshair/options.py +218 -0
  133. crosshair/options_test.py +10 -0
  134. crosshair/patch_equivalence_test.py +75 -0
  135. crosshair/path_cover.py +209 -0
  136. crosshair/path_cover_test.py +138 -0
  137. crosshair/path_search.py +161 -0
  138. crosshair/path_search_test.py +52 -0
  139. crosshair/pathing_oracle.py +271 -0
  140. crosshair/pathing_oracle_test.py +21 -0
  141. crosshair/pure_importer.py +27 -0
  142. crosshair/pure_importer_test.py +16 -0
  143. crosshair/py.typed +0 -0
  144. crosshair/register_contract.py +273 -0
  145. crosshair/register_contract_test.py +190 -0
  146. crosshair/simplestructs.py +1165 -0
  147. crosshair/simplestructs_test.py +283 -0
  148. crosshair/smtlib.py +24 -0
  149. crosshair/smtlib_test.py +14 -0
  150. crosshair/statespace.py +1199 -0
  151. crosshair/statespace_test.py +108 -0
  152. crosshair/stubs_parser.py +352 -0
  153. crosshair/stubs_parser_test.py +43 -0
  154. crosshair/test_util.py +329 -0
  155. crosshair/test_util_test.py +26 -0
  156. crosshair/tools/__init__.py +0 -0
  157. crosshair/tools/check_help_in_doc.py +264 -0
  158. crosshair/tools/check_init_and_setup_coincide.py +119 -0
  159. crosshair/tools/generate_demo_table.py +127 -0
  160. crosshair/tracers.py +544 -0
  161. crosshair/tracers_test.py +154 -0
  162. crosshair/type_repo.py +151 -0
  163. crosshair/unicode_categories.py +589 -0
  164. crosshair/unicode_categories_test.py +27 -0
  165. crosshair/util.py +741 -0
  166. crosshair/util_test.py +173 -0
  167. crosshair/watcher.py +307 -0
  168. crosshair/watcher_test.py +107 -0
  169. crosshair/z3util.py +76 -0
  170. crosshair/z3util_test.py +11 -0
  171. crosshair_tool-0.0.99.dist-info/METADATA +144 -0
  172. crosshair_tool-0.0.99.dist-info/RECORD +176 -0
  173. crosshair_tool-0.0.99.dist-info/WHEEL +6 -0
  174. crosshair_tool-0.0.99.dist-info/entry_points.txt +3 -0
  175. crosshair_tool-0.0.99.dist-info/licenses/LICENSE +93 -0
  176. crosshair_tool-0.0.99.dist-info/top_level.txt +2 -0
@@ -0,0 +1,376 @@
1
+ import copy
2
+ import operator
3
+ import sys
4
+
5
+ from crosshair.tracers import NoTracing
6
+
7
+ #
8
+ # Adapted from:
9
+ # https://github.com/GrahamDumpleton/wrapt/blob/develop/src/wrapt/wrappers.py
10
+ # (which is BSD licenced)
11
+ #
12
+
13
+ _MISSING = object()
14
+
15
+
16
+ def proxy_inplace_op(proxy, op, *args):
17
+ my_original_value = proxy._wrapped()
18
+ my_new_value = op(my_original_value, *args)
19
+ # We need to return our own identity if (and only if!) the underlying value does.
20
+ if my_new_value is my_original_value:
21
+ return proxy
22
+ else:
23
+ object.__setattr__(proxy, "_inner", my_new_value)
24
+ return my_new_value
25
+
26
+
27
+ class ObjectProxy:
28
+ def _realize(self):
29
+ raise NotImplementedError
30
+
31
+ def _wrapped(self):
32
+ with NoTracing():
33
+ inner = _MISSING
34
+ try:
35
+ inner = object.__getattribute__(self, "_inner")
36
+ except AttributeError:
37
+ pass
38
+ if inner is _MISSING:
39
+ inner = self._realize()
40
+ object.__setattr__(self, "_inner", inner)
41
+ return inner
42
+
43
+ def __get_module__(self) -> str:
44
+ return self._wrapped().__module__
45
+
46
+ def __set_module__(self, value: str) -> None:
47
+ self._wrapped().__module__ = value
48
+
49
+ __module__ = property(__get_module__, __set_module__) # type: ignore
50
+
51
+ def __get_doc__(self):
52
+ return self._wrapped().__doc__
53
+
54
+ def __set_doc__(self, value):
55
+ self._wrapped().__doc__ = value
56
+
57
+ __doc__ = property(__get_doc__, __set_doc__) # type: ignore
58
+
59
+ # We similar use a property for __dict__. We need __dict__ to be
60
+ # explicit to ensure that vars() works as expected.
61
+
62
+ @property
63
+ def __dict__(self):
64
+ return self._wrapped().__dict__
65
+
66
+ # Need to also propagate the special __weakref__ attribute for case
67
+ # where decorating classes which will define this. If do not define
68
+ # it and use a function like inspect.getmembers() on a decorator
69
+ # class it will fail. This can't be in the derived classes.
70
+
71
+ @property
72
+ def __weakref__(self):
73
+ return self._wrapped().__weakref__
74
+
75
+ @property
76
+ def __name__(self):
77
+ return self._wrapped().__name__
78
+
79
+ @__name__.setter
80
+ def __name__(self, value):
81
+ self._wrapped().__name__ = value
82
+
83
+ @property
84
+ def __class__(self):
85
+ return self._wrapped().__class__
86
+
87
+ @__class__.setter
88
+ def __class__(self, value):
89
+ self._wrapped().__class__ = value
90
+
91
+ def __get_annotations__(self):
92
+ return self._wrapped().__annotations__
93
+
94
+ def __set_annotations__(self, value):
95
+ self._wrapped().__annotations__ = value
96
+
97
+ __annotations__ = property(__get_annotations__, __set_annotations__) # type: ignore
98
+
99
+ def __dir__(self):
100
+ return dir(self._wrapped())
101
+
102
+ def __str__(self):
103
+ return str(self._wrapped())
104
+
105
+ def __bytes__(self):
106
+ return bytes(self._wrapped())
107
+
108
+ def __repr__(self):
109
+ return repr(self._wrapped())
110
+
111
+ def __reversed__(self):
112
+ return reversed(self._wrapped())
113
+
114
+ def __round__(self):
115
+ return round(self._wrapped())
116
+
117
+ if sys.hexversion >= 0x03070000:
118
+
119
+ def __mro_entries__(self, bases):
120
+ return (self._wrapped(),)
121
+
122
+ def __lt__(self, other):
123
+ return self._wrapped() < other
124
+
125
+ def __le__(self, other):
126
+ return self._wrapped() <= other
127
+
128
+ def __eq__(self, other):
129
+ return self._wrapped() == other
130
+
131
+ def __ne__(self, other):
132
+ return self._wrapped() != other
133
+
134
+ def __gt__(self, other):
135
+ return self._wrapped() > other
136
+
137
+ def __ge__(self, other):
138
+ return self._wrapped() >= other
139
+
140
+ def __hash__(self):
141
+ return hash(self._wrapped())
142
+
143
+ def __nonzero__(self):
144
+ return bool(self._wrapped())
145
+
146
+ def __bool__(self):
147
+ return bool(self._wrapped())
148
+
149
+ def __setattr__(self, name, value):
150
+ if hasattr(type(self), name):
151
+ object.__setattr__(self, name, value)
152
+
153
+ else:
154
+ setattr(self._wrapped(), name, value)
155
+
156
+ def __getattr__(self, name):
157
+ with NoTracing():
158
+ if name == "_wrapped":
159
+ return object.__getattribute__(self, "_wrapped")
160
+ else:
161
+ return getattr(self._wrapped(), name)
162
+
163
+ def __delattr__(self, name):
164
+ if hasattr(type(self), name):
165
+ object.__delattr__(self, name)
166
+
167
+ else:
168
+ delattr(self._wrapped(), name)
169
+
170
+ def __add__(self, other):
171
+ return self._wrapped() + other
172
+
173
+ def __sub__(self, other):
174
+ return self._wrapped() - other
175
+
176
+ def __mul__(self, other):
177
+ return self._wrapped() * other
178
+
179
+ def __matmul__(self, other):
180
+ return self._wrapped() @ other
181
+
182
+ def __div__(self, other):
183
+ return operator.div(self._wrapped(), other)
184
+
185
+ def __truediv__(self, other):
186
+ return operator.truediv(self._wrapped(), other)
187
+
188
+ def __floordiv__(self, other):
189
+ return self._wrapped() // other
190
+
191
+ def __mod__(self, other):
192
+ return self._wrapped() % other
193
+
194
+ def __divmod__(self, other):
195
+ return divmod(self._wrapped(), other)
196
+
197
+ def __pow__(self, other, *args):
198
+ return pow(self._wrapped(), other, *args)
199
+
200
+ def __lshift__(self, other):
201
+ return self._wrapped() << other
202
+
203
+ def __rshift__(self, other):
204
+ return self._wrapped() >> other
205
+
206
+ def __and__(self, other):
207
+ return self._wrapped() & other
208
+
209
+ def __xor__(self, other):
210
+ return self._wrapped() ^ other
211
+
212
+ def __or__(self, other):
213
+ return self._wrapped() | other
214
+
215
+ def __radd__(self, other):
216
+ return other + self._wrapped()
217
+
218
+ def __rsub__(self, other):
219
+ return other - self._wrapped()
220
+
221
+ def __rmul__(self, other):
222
+ return other * self._wrapped()
223
+
224
+ def __rmatmul__(self, other):
225
+ return other @ self._wrapped()
226
+
227
+ def __rdiv__(self, other):
228
+ return operator.div(other, self._wrapped())
229
+
230
+ def __rtruediv__(self, other):
231
+ return operator.truediv(other, self._wrapped())
232
+
233
+ def __rfloordiv__(self, other):
234
+ return other // self._wrapped()
235
+
236
+ def __rmod__(self, other):
237
+ return other % self._wrapped()
238
+
239
+ def __rdivmod__(self, other):
240
+ return divmod(other, self._wrapped())
241
+
242
+ def __rpow__(self, other, *args):
243
+ return pow(other, self._wrapped(), *args)
244
+
245
+ def __rlshift__(self, other):
246
+ return other << self._wrapped()
247
+
248
+ def __rrshift__(self, other):
249
+ return other >> self._wrapped()
250
+
251
+ def __rand__(self, other):
252
+ return other & self._wrapped()
253
+
254
+ def __rxor__(self, other):
255
+ return other ^ self._wrapped()
256
+
257
+ def __ror__(self, other):
258
+ return other | self._wrapped()
259
+
260
+ def __iadd__(self, other):
261
+ return proxy_inplace_op(self, operator.iadd, other)
262
+
263
+ def __isub__(self, other):
264
+ return proxy_inplace_op(self, operator.isub, other)
265
+
266
+ def __imul__(self, other):
267
+ return proxy_inplace_op(self, operator.imul, other)
268
+
269
+ def __itruediv__(self, other):
270
+ return proxy_inplace_op(self, operator.itruediv, other)
271
+
272
+ def __ifloordiv__(self, other):
273
+ return proxy_inplace_op(self, operator.ifloordiv, other)
274
+
275
+ def __imod__(self, other):
276
+ return proxy_inplace_op(self, operator.imod, other)
277
+
278
+ def __ipow__(self, other, *args):
279
+ return proxy_inplace_op(self, operator.ipow, other, *args)
280
+
281
+ def __ilshift__(self, other):
282
+ return proxy_inplace_op(self, operator.ilshift, other)
283
+
284
+ def __irshift__(self, other):
285
+ return proxy_inplace_op(self, operator.irshift, other)
286
+
287
+ def __iand__(self, other):
288
+ return proxy_inplace_op(self, operator.iand, other)
289
+
290
+ def __ixor__(self, other):
291
+ return proxy_inplace_op(self, operator.ixor, other)
292
+
293
+ def __ior__(self, other):
294
+ return proxy_inplace_op(self, operator.ior, other)
295
+
296
+ def __neg__(self):
297
+ return -self._wrapped()
298
+
299
+ def __pos__(self):
300
+ return +self._wrapped()
301
+
302
+ def __abs__(self):
303
+ return abs(self._wrapped())
304
+
305
+ def __invert__(self):
306
+ return ~self._wrapped()
307
+
308
+ def __int__(self):
309
+ return int(self._wrapped())
310
+
311
+ def __float__(self):
312
+ return float(self._wrapped())
313
+
314
+ def __complex__(self):
315
+ return complex(self._wrapped())
316
+
317
+ def __oct__(self):
318
+ return oct(self._wrapped())
319
+
320
+ def __hex__(self):
321
+ return hex(self._wrapped())
322
+
323
+ def __index__(self):
324
+ return operator.index(self._wrapped())
325
+
326
+ def __len__(self):
327
+ return len(self._wrapped())
328
+
329
+ def __contains__(self, value):
330
+ return value in self._wrapped()
331
+
332
+ def __getitem__(self, key):
333
+ return self._wrapped()[key]
334
+
335
+ def __setitem__(self, key, value):
336
+ self._wrapped()[key] = value
337
+
338
+ def __delitem__(self, key):
339
+ del self._wrapped()[key]
340
+
341
+ def __getslice__(self, i, j):
342
+ return self._wrapped()[i:j]
343
+
344
+ def __setslice__(self, i, j, value):
345
+ self._wrapped()[i:j] = value
346
+
347
+ def __delslice__(self, i, j):
348
+ del self._wrapped()[i:j]
349
+
350
+ def __enter__(self):
351
+ return self._wrapped().__enter__()
352
+
353
+ def __exit__(self, *args, **kwargs):
354
+ return self._wrapped().__exit__(*args, **kwargs)
355
+
356
+ def __iter__(self):
357
+ return iter(self._wrapped())
358
+
359
+ def __copy__(self):
360
+ return copy.copy(self._wrapped())
361
+
362
+ def __deepcopy__(self, memo):
363
+ ret = copy.deepcopy(self._wrapped(), memo)
364
+ memo[id(self)] = ret
365
+ return ret
366
+
367
+ def __reduce__(self):
368
+ raise NotImplementedError(f"object proxy {type(self)} must define __reduce__()")
369
+
370
+ def __reduce_ex__(self, protocol):
371
+ raise NotImplementedError(
372
+ f"object proxy {type(self)} must define __reduce_ex__()"
373
+ )
374
+
375
+ def __call__(self, *args, **kwargs):
376
+ return self._wrapped()(*args, **kwargs)
@@ -0,0 +1,41 @@
1
+ import pytest
2
+
3
+ from crosshair.objectproxy import ObjectProxy
4
+
5
+
6
+ class ObjectWrap(ObjectProxy):
7
+ def __init__(self, obj):
8
+ object.__setattr__(self, "_o", obj)
9
+
10
+ def _realize(self):
11
+ return object.__getattribute__(self, "_o")
12
+
13
+
14
+ class TestObjectProxy:
15
+ def test_object_proxy_over_list(self) -> None:
16
+ i = [1, 2, 3]
17
+ proxy = ObjectWrap(i)
18
+ assert i == proxy
19
+ proxy.append(4)
20
+ assert [1, 2, 3, 4] == proxy
21
+ assert [1, 2, 3, 4, 5] == proxy + [5]
22
+ assert [2, 3] == proxy[1:3]
23
+ assert [1, 2, 3, 4] == proxy
24
+
25
+ def test_inplace_identities(self) -> None:
26
+ proxy = ObjectWrap(3.0)
27
+ orig_proxy = proxy
28
+ proxy += 1.0
29
+ assert proxy is not orig_proxy
30
+ proxy = ObjectWrap([1, 2])
31
+ orig_proxy = proxy
32
+ proxy += [3, 4]
33
+ assert proxy is orig_proxy
34
+
35
+ def test_object_proxy_over_float(self) -> None:
36
+ proxy = ObjectWrap(4.5)
37
+ proxy //= 2.0
38
+ assert 2.0 == proxy
39
+ proxy = ObjectWrap(5.0)
40
+ proxy /= 2.0
41
+ assert 2.5 == proxy