crosshair-tool 0.0.87__cp311-cp311-win32.whl → 0.0.88__cp311-cp311-win32.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.87" # Do not forget to update in setup.py!
18
+ __version__ = "0.0.88" # Do not forget to update in setup.py!
19
19
  __author__ = "Phillip Schanely"
20
20
  __license__ = "MIT"
21
21
  __status__ = "Alpha"
crosshair/_tracers.h CHANGED
@@ -50,10 +50,11 @@ typedef struct HandlerTable {
50
50
  } HandlerTable;
51
51
 
52
52
 
53
- typedef struct FrameAndCallback {
54
- PyObject* frame;
53
+ typedef struct FrameNextIandCallback {
54
+ PyFrameObject* frame;
55
+ int expected_i;
55
56
  PyObject* callback;
56
- } FrameAndCallback;
57
+ } FrameNextIandCallback;
57
58
 
58
59
 
59
60
  typedef struct CodeAndStacks {
@@ -62,7 +63,7 @@ typedef struct CodeAndStacks {
62
63
  } CodeAndStacks;
63
64
 
64
65
 
65
- DEFINE_VEC(FrameAndCallbackVec, FrameAndCallback, init_framecbvec, push_framecb);
66
+ DEFINE_VEC(FrameNextIandCallbackVec, FrameNextIandCallback, init_framecbvec, push_framecb);
66
67
  DEFINE_VEC(ModuleVec, PyObject*, init_modulevec, push_module);
67
68
  DEFINE_VEC(TableVec, HandlerTable, init_tablevec, push_table_entry)
68
69
 
@@ -70,7 +71,7 @@ typedef struct CTracer {
70
71
  PyObject_HEAD
71
72
  ModuleVec modules;
72
73
  TableVec handlers;
73
- FrameAndCallbackVec postop_callbacks;
74
+ FrameNextIandCallbackVec postop_callbacks;
74
75
  BOOL enabled;
75
76
  BOOL handling;
76
77
  BOOL trace_all_opcodes;
@@ -1425,6 +1425,10 @@ class PreciseIeeeSymbolicFloat(SymbolicFloat):
1425
1425
  # __hash__ has to be explicitly reassigned because we define __eq__
1426
1426
  __hash__ = SymbolicFloat.__hash__
1427
1427
 
1428
+ def __bool__(self):
1429
+ with NoTracing():
1430
+ return not SymbolicBool(z3.fpIsZero(self.var))
1431
+
1428
1432
  def __ne__(self, other):
1429
1433
  with NoTracing():
1430
1434
  coerced = type(self)._coerce_to_smt_sort(other)
@@ -85,7 +85,6 @@ from crosshair.util import (
85
85
  CrossHairValue,
86
86
  IgnoreAttempt,
87
87
  UnknownSatisfiability,
88
- set_debug,
89
88
  )
90
89
 
91
90
 
@@ -3618,18 +3617,29 @@ def test_deep_realization(space, typ):
3618
3617
  assert concrete == symbolic
3619
3618
 
3620
3619
 
3621
- def TODO_test_float_precision_issues(a, b):
3622
- # Does not yet work: floating point is modeled with infinite precision at the moment
3623
- def f(a: int, b: int):
3624
- """
3625
- pre: b !=0
3626
- post: a == b * _
3620
+ def test_float_round_to_zero(space):
3621
+ space.extra(ModelingDirector).global_representations[
3622
+ float
3623
+ ] = PreciseIeeeSymbolicFloat
3624
+ n = proxy_for_type(float, "n")
3625
+ d = proxy_for_type(float, "d")
3626
+ with ResumedTracing():
3627
+ space.add(d != 0.0)
3628
+ # This is possible for floats, but not reals:
3629
+ assert space.is_possible(n / d != 0.0)
3630
+ assert space.is_possible(n / d == 0.0)
3627
3631
 
3628
- Postcondition holds in a math-sense, but not when floating point precision
3629
- comes into play (e.g. it's false for 13 / 99)
3630
- """
3631
3632
 
3632
- return a / b
3633
+ def test_float_neg_zero_is_falsey(space):
3634
+ space.extra(ModelingDirector).global_representations[
3635
+ float
3636
+ ] = PreciseIeeeSymbolicFloat
3637
+ x = proxy_for_type(float, "x")
3638
+ with ResumedTracing():
3639
+ space.add(x == -10.0)
3640
+ negzero = x / math.inf
3641
+ assert not space.is_possible(negzero != 0.0)
3642
+ assert bool(negzero) is False
3633
3643
 
3634
3644
 
3635
3645
  def TODO_test_int_mod_float():
@@ -0,0 +1,18 @@
1
+ import copy
2
+ import datetime
3
+
4
+ from crosshair.core import proxy_for_type
5
+ from crosshair.statespace import StateSpace
6
+ from crosshair.tracers import ResumedTracing
7
+ from crosshair.util import debug
8
+
9
+
10
+ def test_date_copy(space: StateSpace) -> None:
11
+ concrete_date = datetime.date(2000, 2, 3)
12
+ symbolic_date = proxy_for_type(datetime.date, "d")
13
+ with ResumedTracing():
14
+ copied_symbolic = copy.deepcopy(symbolic_date)
15
+ copied_concrete = copy.deepcopy(concrete_date)
16
+ assert not space.is_possible(copied_concrete != concrete_date)
17
+ assert not space.is_possible(copied_concrete != datetime.date(2000, 2, 3))
18
+ assert not space.is_possible(copied_symbolic != symbolic_date)
@@ -855,7 +855,7 @@ class date:
855
855
 
856
856
  """
857
857
 
858
- def __init__(self, year, month, day):
858
+ def __init__(self, year, month=None, day=None):
859
859
  """
860
860
  Constructor.
861
861
 
@@ -863,7 +863,13 @@ class date:
863
863
  :param month: month, starting at 1
864
864
  :param day: day, starting at 1
865
865
  """
866
- year, month, day = _check_date_fields(year, month, day)
866
+ if month is None:
867
+ # We can receive a string/bytes single argument when unpickling a concrete date
868
+ with NoTracing():
869
+ dt = real_date(realize(year)) # type: ignore
870
+ year, month, day = dt.year, dt.month, dt.day
871
+ else:
872
+ year, month, day = _check_date_fields(year, month, day)
867
873
  self._year = year
868
874
  self._month = month
869
875
  self._day = day
crosshair/main_test.py CHANGED
@@ -515,7 +515,7 @@ def test_mypycrosshair_command():
515
515
  capture_output=True,
516
516
  text=True,
517
517
  )
518
- assert completion.stderr.strip() == ""
518
+ assert completion.stderr.strip() == "", f"stderr was '''{completion.stderr}'''"
519
519
  if completion.returncode != 1:
520
520
  print(completion.stdout)
521
521
  assert False, f"Return code was {completion.returncode}"
@@ -286,3 +286,19 @@ def test_identity_operator_does_not_realize_on_differing_types():
286
286
  fourty_two = 42 # assignment just to avoid lint errors
287
287
  b1 is fourty_two
288
288
  assert len(space.choices_made) == choices_made_at_start
289
+
290
+
291
+ class IExplodeOnRepr:
292
+ def __repr__(self):
293
+ raise ValueError("boom")
294
+
295
+
296
+ def test_postop_callback_skipped_on_exception_handler_jump(space):
297
+ with ResumedTracing():
298
+ elements = IExplodeOnRepr()
299
+ try:
300
+ ret = f"these are them: {elements!r}"
301
+ except ValueError: # pragma: no cover
302
+ ret = None
303
+ # need to do something(anything) with elements so that it's on the stack:
304
+ type(elements)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: crosshair-tool
3
- Version: 0.0.87
3
+ Version: 0.0.88
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
@@ -1,9 +1,9 @@
1
- _crosshair_tracers.cp311-win32.pyd,sha256=KUxlg7BHw9UOIBNJcSOat7-8RA4co4h01KCDImJtfuo,16896
2
- crosshair/__init__.py,sha256=tt_dO_b86vGhi_5l7U5LXiR_mvAfXCM5Y-YtgaIRxIY,978
1
+ _crosshair_tracers.cp311-win32.pyd,sha256=FtCbfmi1aEOPzPZQC2ROGuf58dFxHMqQSbhJk759QOw,16896
2
+ crosshair/__init__.py,sha256=aoBTLbJ7tIqXmDmoBuAAVQkH2YErTHwp2Ji0ctl4OiI,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
6
- crosshair/_tracers.h,sha256=IJNUQ01LQurzap8qCgqLcOhkRpeY1BIRKrVj-OUlIj8,2217
6
+ crosshair/_tracers.h,sha256=z1dln1ftrz9ofaBgiYLn1SZ13QNxpNYRE586XogsX_o,2268
7
7
  crosshair/_tracers_pycompat.h,sha256=KqJHbya8zi1Z4Qrk2S6P-FfmC_Ew5LYvTxbA-V9TWPw,14878
8
8
  crosshair/_tracers_test.py,sha256=l0WYk74xtr5tlT9ID0kq11jUmw_Ai-hevNX7eZHg4RY,3734
9
9
  crosshair/abcstring.py,sha256=Jvnnm7xsHGTcZvu5mbV_eL5IVEvbNNbeCauM6f7QYEI,6794
@@ -32,11 +32,11 @@ crosshair/fuzz_core_test.py,sha256=wWILaE5cpxfiRl89WgCWMpNIGS8BnWcQmgartQYCCJ8,1
32
32
  crosshair/lsp_server.py,sha256=Kl6z-Nudt2ZkzV0ojfzvGGa3cukXLOYKTCHYJUxzrRk,8920
33
33
  crosshair/lsp_server_test.py,sha256=yHp7JtJLpF2G049lwhNlgAYXnVM88CtsudVVHVY7Hs0,999
34
34
  crosshair/main.py,sha256=Dibj8nGZeNe010vCU0j1v-h8IhcUJyyED_dVKQZaIj0,35341
35
- crosshair/main_test.py,sha256=YDnAaAm6A8g-3D5qVTQJ69wnBEx7Ag33AlJmrf-pifk,14917
35
+ crosshair/main_test.py,sha256=zzNANuPZd9SWr15jSWfHVsGFKTWMlyREgnxKojJj-eo,14958
36
36
  crosshair/objectproxy.py,sha256=qYPVvH3EVUmh7GI9-73mfmOTzcTH_gyn5DhK44hp8KI,9286
37
37
  crosshair/objectproxy_test.py,sha256=P5N28U5l9ngozqLr2EgtVOII3PS3fB2dOOPc9LLt8Zo,590
38
38
  crosshair/opcode_intercept.py,sha256=RGcwx4f5-KKjY2C3Do4mBm4S8rEpn6nWtOQvaSKQnoM,22453
39
- crosshair/opcode_intercept_test.py,sha256=Tb99WUyMOnS9sPhP12n43he9IPtivsvOFjBiGEKJNGQ,9078
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
42
  crosshair/patch_equivalence_test.py,sha256=JsJkKSjjyXynTAnZBGIJsFN_vyoiZfNTeiq5FjRVXIE,2579
@@ -100,16 +100,17 @@ 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=uqSMGkTa33Fz-CLLMRFhM-Ixv_JNR5jYYmHOjUT6WFc,176599
103
+ crosshair/libimpl/builtinslib.py,sha256=rZGm31Z5g7OzI_Orpp-haAwxWhnhrhlOBtbll2XkKVE,176713
104
104
  crosshair/libimpl/builtinslib_ch_test.py,sha256=Do8kWNgfosLfI3yzZvTZ3ceuKTF0axN1ckkNZyn4ozE,31685
105
- crosshair/libimpl/builtinslib_test.py,sha256=Ex-3f9n06fTaZPxO6UE_AqcoJcoHyisQWmb7fDtA3dE,93933
105
+ crosshair/libimpl/builtinslib_test.py,sha256=yqNE0027NV7-5l9JI-YdsZ8_TPx4F6kOrYxA5Czu2XQ,94322
106
106
  crosshair/libimpl/codecslib.py,sha256=cvpCbieFRB4BdfLqmKeJzpvm35qZ0ONqtilXPmN8OWI,2754
107
107
  crosshair/libimpl/codecslib_test.py,sha256=3_uqcxEYK3BONdga0skZ1BkSPkIHRCgdoMB8NM3oUVY,2622
108
108
  crosshair/libimpl/collectionslib.py,sha256=ltywQks-W56CkxvUawvcGZwsBcm6t2u5JLbA56nzqPs,8847
109
109
  crosshair/libimpl/collectionslib_ch_test.py,sha256=A6-qeCU1zTcvuS6HkmF48Q45F3SvQJkh-BTUc2DKxJo,6107
110
110
  crosshair/libimpl/collectionslib_test.py,sha256=Wm67Bw1Lg6ts5DF2ii98SUr4f8YZa0zzK0IiwhdFExg,9496
111
111
  crosshair/libimpl/copylib.py,sha256=s2q6jMCT2bvzyq5kQyT40TsmOeeJmLI4Corz4qWDZyE,550
112
- crosshair/libimpl/datetimelib.py,sha256=fN-w40BapjLSOiGYpjBsJOvui14_VQvdwx-wKHKoDOU,81411
112
+ crosshair/libimpl/copylib_test.py,sha256=BnQgUSd5Oiw68jk2fRrhPRlIt9HaBXxUeroZPZj64yM,723
113
+ crosshair/libimpl/datetimelib.py,sha256=Hqq9Ksm4z-pHxyw8ngnkm4eUmFQmo_yxiFAzaCHHYQg,81716
113
114
  crosshair/libimpl/datetimelib_ch_test.py,sha256=NpZjUJgM08gB04d2gXkbrm7Y7Pdh3aso9GYb9iZtq6o,9632
114
115
  crosshair/libimpl/datetimelib_test.py,sha256=q27sPMNNJr3kBcIIkigsQbxslt-2qYhFUxc9PRVVf9E,2771
115
116
  crosshair/libimpl/decimallib.py,sha256=PP1ZznK1e2xtuvC3Fo8GODr6O5oz6Sq9a043QExpbnE,182605
@@ -166,9 +167,9 @@ crosshair/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
166
167
  crosshair/tools/check_help_in_doc.py,sha256=An-2EJ0_Xr-Szo431AoEgJafoFWwnPl8HoT4bi86dd8,8499
167
168
  crosshair/tools/check_init_and_setup_coincide.py,sha256=f4TvPg1Q3C_BQYtGgPfY_fqxo_ZTeU7QCy7WwQjaIlA,3621
168
169
  crosshair/tools/generate_demo_table.py,sha256=qm4ZUXjUBKkVZ3bVVK9h6dJMDKYme8zMl-7at_aG7b0,3958
169
- crosshair_tool-0.0.87.dist-info/licenses/LICENSE,sha256=qQLSJN48eqvalILMr3uzkg0p74FtK7WSwkux-0twy-s,4552
170
- crosshair_tool-0.0.87.dist-info/METADATA,sha256=Pf0T9cCV5baDPQutBYunWoi_a4pGfhSV8-z-PBof_EU,6871
171
- crosshair_tool-0.0.87.dist-info/WHEEL,sha256=Ri8zddKrjGdgjlj1OpSsvpDnvHfnQhMQWi3E_v2pqng,97
172
- crosshair_tool-0.0.87.dist-info/entry_points.txt,sha256=u5FIPVn1jqn4Kzg5K_iNnbP6L4hQw5FWjQ0UMezG2VE,96
173
- crosshair_tool-0.0.87.dist-info/top_level.txt,sha256=2jLWtM-BWg_ZYNbNfrcds0HFZD62a6J7ZIbcgcQrRk4,29
174
- crosshair_tool-0.0.87.dist-info/RECORD,,
170
+ crosshair_tool-0.0.88.dist-info/licenses/LICENSE,sha256=qQLSJN48eqvalILMr3uzkg0p74FtK7WSwkux-0twy-s,4552
171
+ crosshair_tool-0.0.88.dist-info/METADATA,sha256=cUC5UYnQOq1z8CxQn-MECRuIECyUW5H04tHwBzKJN64,6871
172
+ crosshair_tool-0.0.88.dist-info/WHEEL,sha256=Ri8zddKrjGdgjlj1OpSsvpDnvHfnQhMQWi3E_v2pqng,97
173
+ crosshair_tool-0.0.88.dist-info/entry_points.txt,sha256=u5FIPVn1jqn4Kzg5K_iNnbP6L4hQw5FWjQ0UMezG2VE,96
174
+ crosshair_tool-0.0.88.dist-info/top_level.txt,sha256=2jLWtM-BWg_ZYNbNfrcds0HFZD62a6J7ZIbcgcQrRk4,29
175
+ crosshair_tool-0.0.88.dist-info/RECORD,,