crosshair-tool 0.0.92__cp312-cp312-win_amd64.whl → 0.0.93__cp312-cp312-win_amd64.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.

Potentially problematic release.


This version of crosshair-tool might be problematic. Click here for more details.

Binary file
crosshair/__init__.py CHANGED
@@ -15,7 +15,7 @@ from crosshair.statespace import StateSpace
15
15
  from crosshair.tracers import NoTracing, ResumedTracing
16
16
  from crosshair.util import IgnoreAttempt, debug
17
17
 
18
- __version__ = "0.0.92" # Do not forget to update in setup.py!
18
+ __version__ = "0.0.93" # Do not forget to update in setup.py!
19
19
  __author__ = "Phillip Schanely"
20
20
  __license__ = "MIT"
21
21
  __status__ = "Alpha"
crosshair/core.py CHANGED
@@ -329,9 +329,10 @@ def with_realized_args(fn: Callable, deep=False) -> Callable:
329
329
 
330
330
  def realizer(*a, **kw):
331
331
  with NoTracing():
332
- a = map(realize_fn, a)
332
+ a = [realize_fn(arg) for arg in a]
333
333
  kw = {k: realize_fn(v) for (k, v) in kw.items()}
334
- return fn(*a, **kw)
334
+ # You might think we don't need tracing here, but some operations can invoke user-defined behavior:
335
+ return fn(*a, **kw)
335
336
 
336
337
  functools.update_wrapper(realizer, fn)
337
338
  return realizer
@@ -4441,10 +4441,11 @@ def _int(val: Any = 0, base=_MISSING):
4441
4441
  else:
4442
4442
  ret = (ret * base) + ch_num
4443
4443
  return ret
4444
- if base is _MISSING:
4445
- return int(deep_realize(val))
4446
- else:
4447
- return int(deep_realize(val), base=realize(base))
4444
+ elif isinstance(val, CrossHairValue):
4445
+ val = deep_realize(val)
4446
+ base = deep_realize(base)
4447
+
4448
+ return int(val) if base is _MISSING else int(val, base=base)
4448
4449
 
4449
4450
 
4450
4451
  _FLOAT_REGEX = re.compile(
@@ -4549,7 +4550,7 @@ def _len(ls):
4549
4550
  def _map(fn, *iters):
4550
4551
  # Wrap the `map` callback in a pure Python lambda.
4551
4552
  # This de-optimization ensures that the callback can be intercepted.
4552
- return map(lambda x: fn(x), *iters)
4553
+ return map(lambda *a: fn(*a), *iters)
4553
4554
 
4554
4555
 
4555
4556
  def _memoryview(source):
@@ -5,7 +5,8 @@ from crosshair.core import deep_realize
5
5
  from crosshair.core_and_libs import proxy_for_type
6
6
  from crosshair.statespace import POST_FAIL
7
7
  from crosshair.test_util import check_states
8
- from crosshair.tracers import ResumedTracing
8
+ from crosshair.tracers import ResumedTracing, is_tracing
9
+ from crosshair.util import CrossHairInternal
9
10
 
10
11
 
11
12
  def test_fraction_realize(space):
@@ -16,6 +17,28 @@ def test_fraction_realize(space):
16
17
  deep_realize(Fraction(n, d))
17
18
 
18
19
 
20
+ class UserFraction(Fraction):
21
+ def __int__(self):
22
+ if not is_tracing():
23
+ raise CrossHairInternal("tracing required while in user code")
24
+ return 1
25
+
26
+ def __round__(self, *a, **kw):
27
+ if not is_tracing():
28
+ raise CrossHairInternal("tracing required while in user code")
29
+ return super().__round__(*a, **kw)
30
+
31
+
32
+ def test_user_fraction_tracing(space):
33
+ n = proxy_for_type(int, "n")
34
+ d = proxy_for_type(int, "d")
35
+ with ResumedTracing():
36
+ space.add(d != 0)
37
+ fraction = UserFraction(n, d)
38
+ round(fraction) # (works via with_realized_args)
39
+ int(fraction) # (custom interception)
40
+
41
+
19
42
  def test_fraction_copy_doesnt_realize(space):
20
43
  n = proxy_for_type(int, "n")
21
44
  with ResumedTracing():
@@ -1,5 +1,6 @@
1
1
  import copy
2
2
  import itertools
3
+ import operator
3
4
  import re
4
5
  import sys
5
6
  from dataclasses import dataclass
@@ -39,6 +40,7 @@ possible_args = [
39
40
  (42, int), # isinstance
40
41
  (re.compile("(ab|a|b)"), r"\n", ""), # re methods
41
42
  (bool, [1, 1, 0]), # itertools.takewhile and friends
43
+ (operator.add, [1, 0], [1, 1]), # multi-iterable map
42
44
  ([(1, 2), (3, 4)]), # key-value pairs
43
45
  ([(1, 2), ([], 4)]), # key-value pairs w/ unhashable key
44
46
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: crosshair-tool
3
- Version: 0.0.92
3
+ Version: 0.0.93
4
4
  Summary: Analyze Python code for correctness using symbolic execution.
5
5
  Home-page: https://github.com/pschanely/CrossHair
6
6
  Author: Phillip Schanely
@@ -47,6 +47,7 @@ Requires-Dist: setuptools; extra == "dev"
47
47
  Requires-Dist: sphinx>=3.4.3; extra == "dev"
48
48
  Requires-Dist: sphinx-rtd-theme>=0.5.1; extra == "dev"
49
49
  Requires-Dist: rst2pdf>=0.102; extra == "dev"
50
+ Requires-Dist: z3-solver==4.14.1.0; extra == "dev"
50
51
  Dynamic: author
51
52
  Dynamic: author-email
52
53
  Dynamic: classifier
@@ -1,5 +1,5 @@
1
- _crosshair_tracers.cp312-win_amd64.pyd,sha256=LcjC2pF8Ld3nI-TTxubmIYlrptGQ_wq5gq4LFUEK8Os,24576
2
- crosshair/__init__.py,sha256=mzpwHlTeoIXywefkRFC4MWcUKncsWA7Y3iy4m_sd3WY,978
1
+ _crosshair_tracers.cp312-win_amd64.pyd,sha256=74lTtL_H_fECYFlnjUbJML78PwEAMBSS2ygvKOdPvDU,24576
2
+ crosshair/__init__.py,sha256=aNQs81VDq95_ZF8wWBUtdIO4BNRcGH-CkBCuKIy37dE,978
3
3
  crosshair/__main__.py,sha256=i4pjsZlXvtieQHJTEB0sF3e40qJjLoOm1z5rm-u70Uo,260
4
4
  crosshair/_mark_stacks.h,sha256=IImygydFK9qethf41gUZDjySHR3WLXs-YsqWCHK9UFg,29468
5
5
  crosshair/_preliminaries_test.py,sha256=klkzKGpyyVDGctCXdvq1xyXbGa4PRnXda1jfgE-7LLY,522
@@ -16,7 +16,7 @@ crosshair/condition_parser_test.py,sha256=kosW60A4HnBBT3sOHxWCl_cixpbO1kmsjgNuNU
16
16
  crosshair/conftest.py,sha256=JjUauvXnjERszuS46iskuBRHBx-0uHacwKHeQ-gEQ2c,683
17
17
  crosshair/copyext.py,sha256=_SRnS6UrUFl2-CHl8uRIOq-Y0MKYNQTFK132S3Ru34A,5044
18
18
  crosshair/copyext_test.py,sha256=VSIoVeqAf18g2RNuLTbyNWJiMBgzHeab7LNX1KHCWZU,2182
19
- crosshair/core.py,sha256=uVUz_SUye6EeV9EKGSnBFfK9G0MaZ2kLCjFUqorGR_c,65380
19
+ crosshair/core.py,sha256=bUkWzbyhEvk24_UJ7tYo489ccq-Q6V0Pnpj4aY165qg,65497
20
20
  crosshair/core_and_libs.py,sha256=U9GDCBE9Ecxy7T7bmJT7IYiQTdY1C8qbcoIoMMocu5U,4112
21
21
  crosshair/core_regestered_types_test.py,sha256=3o1GrtjCEWSW-paPp5-yVdE2K1_ZIviGCff7KVZ0VS0,2181
22
22
  crosshair/core_test.py,sha256=bHpq_OcUsVWFWGnsCUX4AEM22vLfoCzCsPaEnsbAzYc,33490
@@ -39,7 +39,7 @@ crosshair/opcode_intercept.py,sha256=RGcwx4f5-KKjY2C3Do4mBm4S8rEpn6nWtOQvaSKQnoM
39
39
  crosshair/opcode_intercept_test.py,sha256=giJ9HK0jJ4r41epJMZ4PPT6-qn8nqDjS-900ULxIlLM,9545
40
40
  crosshair/options.py,sha256=y3lYP5AfwkHFXjF7zl0kUrTH1_C5u1DMo_yAH_mivm8,6993
41
41
  crosshair/options_test.py,sha256=eTlaTqNb29I3ZyyV0yCq_kEeE441l4xh-jKF_W6cWqs,389
42
- crosshair/patch_equivalence_test.py,sha256=JsJkKSjjyXynTAnZBGIJsFN_vyoiZfNTeiq5FjRVXIE,2579
42
+ crosshair/patch_equivalence_test.py,sha256=2obUF4jZWlF_HBawn6uOb53XuD7qNRiX6f8Y1A5-fUI,2655
43
43
  crosshair/path_cover.py,sha256=rHWsTLVr-LR5rEBu18xRSJbpWk3ZTl11OG_QOkgRrxI,6915
44
44
  crosshair/path_cover_test.py,sha256=DFB_fIC2d1waNfyUAP4wVv-hdbNkHAKRxgBcftxcKLY,4227
45
45
  crosshair/path_search.py,sha256=5gsiY41aMcTnO5XONgjsnVulWbRIw0mYcpmRYedqORo,5749
@@ -100,7 +100,7 @@ crosshair/libimpl/binascii_ch_test.py,sha256=qWAYU1Sid3muwYL8pvVoCsMQtm5t3J8jFto
100
100
  crosshair/libimpl/binascii_test.py,sha256=Yg37_B-eywcLq7EbsJZR3BUYYF6A1PGxE4qsmeBMyXg,2037
101
101
  crosshair/libimpl/binasciilib.py,sha256=kBFH5-W_q1gCTC-wusSq0cAsUsB_xOUpcW0XQbLzkSQ,5220
102
102
  crosshair/libimpl/bisectlib_test.py,sha256=rVpcalZ4g3xr_b6z1Bv2FU1N07vPZyWhU9_CPzC8sBk,776
103
- crosshair/libimpl/builtinslib.py,sha256=rZGm31Z5g7OzI_Orpp-haAwxWhnhrhlOBtbll2XkKVE,176713
103
+ crosshair/libimpl/builtinslib.py,sha256=oW9VY8DBOOouWmw6tjvVZp01-GFZ7aFwr_BW4EM3c7Y,176755
104
104
  crosshair/libimpl/builtinslib_ch_test.py,sha256=Do8kWNgfosLfI3yzZvTZ3ceuKTF0axN1ckkNZyn4ozE,31685
105
105
  crosshair/libimpl/builtinslib_test.py,sha256=yqNE0027NV7-5l9JI-YdsZ8_TPx4F6kOrYxA5Czu2XQ,94322
106
106
  crosshair/libimpl/codecslib.py,sha256=cvpCbieFRB4BdfLqmKeJzpvm35qZ0ONqtilXPmN8OWI,2754
@@ -118,7 +118,7 @@ crosshair/libimpl/decimallib_ch_test.py,sha256=8iQpb1c0-TNqtY4EznYkgAGnBV2uOitFj
118
118
  crosshair/libimpl/decimallib_test.py,sha256=gbLoEtgpkq6Xod-9Am18mTpVH1VY_cZHvktS4_z2yQ4,2314
119
119
  crosshair/libimpl/encodings_ch_test.py,sha256=jZM2XqiGd-40kDiC1YSlDoQafRrbtx6BBBeHTIRx3TE,2596
120
120
  crosshair/libimpl/fractionlib.py,sha256=lGqUcl5S9lPC18pKP8Ihzirmgn8hf2QNPvdZejzK8IM,474
121
- crosshair/libimpl/fractionlib_test.py,sha256=fl4Ka9m5UV_-pYtsC0JDQWJLpPk4GhZapArRDLub7Wc,1695
121
+ crosshair/libimpl/fractionlib_test.py,sha256=gl9PIZFoKyA10KMhfmA4SSK1i1y2yUO_IDvxIr-8lBc,2437
122
122
  crosshair/libimpl/functoolslib.py,sha256=szPJ4ZB0CevfCxMBvVfD_3RX-BwDp0Sv5YchWncmnu4,811
123
123
  crosshair/libimpl/functoolslib_test.py,sha256=OSeY-C9zYhFMfDHJ9QNaXxx6sVJ-CLOgrYIyXBl-vvk,1154
124
124
  crosshair/libimpl/hashliblib.py,sha256=0s4yx2l-hNkqWEd1Xbmxf-2w_E3LmjHn0SShni_r_-8,1264
@@ -167,9 +167,9 @@ crosshair/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
167
167
  crosshair/tools/check_help_in_doc.py,sha256=An-2EJ0_Xr-Szo431AoEgJafoFWwnPl8HoT4bi86dd8,8499
168
168
  crosshair/tools/check_init_and_setup_coincide.py,sha256=f4TvPg1Q3C_BQYtGgPfY_fqxo_ZTeU7QCy7WwQjaIlA,3621
169
169
  crosshair/tools/generate_demo_table.py,sha256=qm4ZUXjUBKkVZ3bVVK9h6dJMDKYme8zMl-7at_aG7b0,3958
170
- crosshair_tool-0.0.92.dist-info/licenses/LICENSE,sha256=qQLSJN48eqvalILMr3uzkg0p74FtK7WSwkux-0twy-s,4552
171
- crosshair_tool-0.0.92.dist-info/METADATA,sha256=9iIHFUEpQv7Q6P_2yIcJMsPmipZKRAlxaLZhFGrC87M,6871
172
- crosshair_tool-0.0.92.dist-info/WHEEL,sha256=8UP9x9puWI0P1V_d7K2oMTBqfeLNm21CTzZ_Ptr0NXU,101
173
- crosshair_tool-0.0.92.dist-info/entry_points.txt,sha256=u5FIPVn1jqn4Kzg5K_iNnbP6L4hQw5FWjQ0UMezG2VE,96
174
- crosshair_tool-0.0.92.dist-info/top_level.txt,sha256=2jLWtM-BWg_ZYNbNfrcds0HFZD62a6J7ZIbcgcQrRk4,29
175
- crosshair_tool-0.0.92.dist-info/RECORD,,
170
+ crosshair_tool-0.0.93.dist-info/licenses/LICENSE,sha256=qQLSJN48eqvalILMr3uzkg0p74FtK7WSwkux-0twy-s,4552
171
+ crosshair_tool-0.0.93.dist-info/METADATA,sha256=wU-Na0XKBWSJJwBqDh4EsyZzqsW21lerfZqHpKXYIs8,6923
172
+ crosshair_tool-0.0.93.dist-info/WHEEL,sha256=8UP9x9puWI0P1V_d7K2oMTBqfeLNm21CTzZ_Ptr0NXU,101
173
+ crosshair_tool-0.0.93.dist-info/entry_points.txt,sha256=u5FIPVn1jqn4Kzg5K_iNnbP6L4hQw5FWjQ0UMezG2VE,96
174
+ crosshair_tool-0.0.93.dist-info/top_level.txt,sha256=2jLWtM-BWg_ZYNbNfrcds0HFZD62a6J7ZIbcgcQrRk4,29
175
+ crosshair_tool-0.0.93.dist-info/RECORD,,