Changelog

Next Version

  • Nothing yet!

Version 0.0.29

  • Add support for symbolic containment checks in concrete dictionaries.

  • Fix several issues with the LSP server on windows.

  • Fix cover command errors when applied to wrapped functions and methods of dataclasses.

Version 0.0.28

  • Do not manually set typing.TYPE_CHECKING to True. This is a breaking change - unfortunately, too many regular and correct typing guards will not work at runtime with TYPE_CHECKING on. (for one, you can use a guard to protect an import of a .pyi module, e.g. pytorch in #172 ) CrossHair will now only be able to understand types that are present and resolvable at runtime. (previously it might have been able to resolve types in more cases, e.g. the circular dependencies in #32 )

Version 0.0.27

  • Automatically disable lru_cache and cache decorations during analysis. (this prevents nondeterministic errors when analyzing code that uses them!)

  • Disable side-effect detection when importing modules. (fixes #172)

  • Reduce path explosions when checking for symbolic string containment in a concrete string.

  • Fix unexpected nondeterminism exception when calling urllib.parse.

  • Finish making sure unicodedata functions are tolerant to symbolic string arguments.

  • Make heapq functions tolerant to symbolic list arguments.

Version 0.0.26

  • Fix crash when running crosshair cover over functions that raise exceptions. (fixes #171)

  • Add symbolic handling when the callback used in map, filter, reduce, or partial is native and intolerant to symbolics. (string functions, most commonly)

  • Allow writes to the “nul” file on Windows.

  • Add various preparations for Python 3.11.

Version 0.0.25

  • Add the crosshair server command. This starts a Language Server Protocol (LSP) server that can simplify integration with several IDEs. (look for new versions of the VSCode extension that use this soon; consider contributing one for your favorite editor!)

  • Present counterexamples that describe argument aliasing using the “walrus” operator, e.g. foo([a:=[], [], a]) to describe a counterexample that takes a list of three empty sublists, where the frist and third are the same list. (fixes #48) Note that CrossHair does not yet reliably detect all kinds of aliasing problems; see this issue in particular.

  • Fix code parse error over docstrings with blank lines.

  • Fix bug when get() is called with a numeric symbolic key on a concrete dictionary.

  • Fix crash when re.match() or re.finditer() is invoked on a sliced string.

  • Ensure the key= function of itertools.groupby can be itercepted with register_patch().

  • Correctly lowercase mid-word, mixed-case characters when titlecasing a string.

  • Fix a crash when the checked code imports additional modules at runtime which define new namedtuples.

Version 0.0.24

  • CrossHair can now invent symbolic return values for many calls like time.time and random.randrange. See this issue for what’s supported.

  • Allow subprocess spawning by standard library modules like uuid, plaftorm, and ctypes. Previously, CrossHair would crash on some calls/platforms, complaining about side effects. (fixes #163)

Version 0.0.23

  • Add support for attaching a contract to an external function. Among other things, this can help you check code involving nondeterministic functions like time.time(). See the docs for all the details. (thanks to lmontand for this massive effort!)

  • Upgrade code health internally: added isort and expanded flake8 checks. (thanks to nicpayne713 and orsinium!)

  • Correctly handle preconditions with recursive calls to the contracted function. (see this test)

  • Fix symbolic str.capitalize() behavior in python 3.7.

  • CrossHair now has datetime support that doesn’t destructively modify the system’s datetime module. (fixes #159)

Version 0.0.22

  • Added a new specs_complete directive: use this to let functions return any value confirming to their contract. This can be useful for (ensuring you don’t depend on implementation details).

  • Fix formatting symbolic enums as decimals.

  • Use comparisons to guess types for untyped values.

  • Permit writes to /dev/null, allowing imports for pytorch. (see #157)

  • Resolve types dependent on TYPE_CHECKING guards in more cases. (see #158)

  • Made various diagnosic improvements for -v output.

  • Mix up the message-of-the-day when exiting crosshair watch.

  • Implemented minor performance and search heuristic improvements.

Version 0.0.21

  • Add support for memoryview. (see #153)

  • Use pure-python code for Cython modules that distribute it. This enables symbolic reasoning for modules like Pydantic that include both pure and binary versions.

  • Add path search hueristics to bias for code coverage.

  • Fix bug in newline detection for str.splitlines.

  • Fix bug for title-case characters in str.capitalize.

  • Correctly model when isinstance/issubclass over symbolics raise exceptions.

  • Completed Python 3.10 support.

Version 0.0.20

  • Complete symbolic support for all string methods! (see #39)

  • Complete symbolic support JSON encode and decode!

  • Add symbolic support for ascii, latin-1, and utf8 encode and decode.

  • Add symbolic support for StringIO.

  • Fix bugs in string comparisons, re.finditer, isinstance, delete-by-slice.

  • Add symbolic support for set comprehensions.

  • Add minor optimizations for tracing and repeated slicing.

  • Skip copies for uncopy-able arguments (see #146)

  • Fix bug for special cases when __new__ should be called without __init__

Version 0.0.19

  • Completed full symbolic regex support!

    • The remaining features were non-greedy matching (.*?), word boundaries (\b), and negated sets ([^abc]).

  • Fixed crash on clean installation which expected Deal to be installed - that dependency is now fully optional. (issue)

  • Avoid crash when crosshair watch has been running for a while on trivial cases. (issue)

  • Add symbolic support for f-strings.

  • Add symbolic support for dictionary comprehensions with symbolic keys.

Version 0.0.18

  • Add support for counterexamples in full unicode! (previously, we’d only find counterexamples in latin-1)

  • Add support for checking Deal contracts! (details)

  • Add fixes for collections.deque, float rounding false-positives, dict.pop, and nondeterminism detection.

  • Give reproducible failures for code involving random number generation.

  • Add symbolic support for string predicates: isalpha, isspace, isascii, isdecimal, isdigit, islower, isnumeric, isprintable, isalnum, and istitle.

  • Expand symbolic regex support: search, sub, subn, finditer, re.MULTILINE, lookahead/lookbehind, and lastindex/lastgroup.

Version 0.0.17

  • Add support for checking Hypothesis tests! (details)

  • Important: The --analysis_kind=assert option is no longer enabled by default. (it was spuriously detecting functions for analysis too regularly) Enable assert-mode explicitly on the command line if you use CrossHair this way.

  • Support the analysis_kind option in code comment “directives.”

  • Add some minimal symbolic support for the standard library array module.

  • Add symbolic support for bytearray.

  • Expand symbolic support for ord(), chr(), and integer round().

  • Expand symbolic support for some bitwise operations and int.bit_length.

Version 0.0.16

  • Add new crosshair cover command. (details)

  • Implement and document CrossHair’s plugin system. (details)

  • 3rd party Cython modules sometimes include both binary and pure versions of the code. Now CrossHair can access the pure Python code in such distributions, allowing it to symbolically execute them.

  • Add symbolic support for integer and float parsing.

  • Add symbolic support for indexing into concrete dictionaries with symbolic keys.

  • Add regex support for the whitespace (”\s”) class. (regex support is still ASCII-only right now though)

  • Miscellaneous fixes: string indexing, numeric promotions, named regex groups

Version 0.0.15

  • Fix regression for watch command, which crashed when watched files have a syntax error.

  • Fix watch command to consistently detect when files are deleted.

  • Expand symbolic handling for some string containment use cases.

  • Refactored tracing intercept logic to support arbitrary opcode interceptions (will unlock new symbolic strategies)

Version 0.0.14

  • The type() function is now patched (it no longer reveals symbolic types).

  • Completed Python 3.9 support.

  • Refined (make less magical) and documented custom class suggestions.

  • Fixed out-of-bounds slicing in certain cases.

  • Fixed regression breaking check by class name.

  • Fixed crash on “watch .” and an excessive auditwall block on os.walk.

  • Fixed issue targeting by line number.

  • Fixed error on no command line arguments.

Version 0.0.13

  • Further simplification of crosshair watch output for broader terminal support.

Version 0.0.12

  • Use simpler crosshair watch screen clearing mechanism for terminals like Thonny’s.

  • Several string methods can now be reasoned about symbolically: split, find, replace, index, partition, count, and more. (thanks Rik-de-Kort!)

  • Fixed various bugs, including a few specific to icontract analysis.

  • Modestly increased regex cases that CrossHair handles. (including named groups!)

Version 0.0.11

  • Enable analysis when only preconditions exist. (this is useful if you just want to catch exceptions!)

  • Added --report_verbose option to customize whether you get verbose multi-line counterexample reports or the single-line, machine-readable reporting. (command help)

  • Added workaround for missing crosshair watch output in the PyCharm terminal.

  • Assorted bug fixes: 1, 2, 3, 4

Version 0.0.10

  • Added support for checking icontract postconditions. (details)

  • Added support for checking plain assert statements. (details)

  • Expanded & refactored the documentation. (thanks mristin!)

  • Advanced internal code standards: black, mypy, pydocstyle, and more. (thanks mristin!)

  • Added basic protection against dangerous side-effects with sys.addaudithook.

  • Analysis can now be targeted by function at line number; e.g. crosshair check foo.py:42

  • Modules and functions may include a directive comment like # crosshair: on or # crosshair: off to customize targeting.

  • Realization heuristics enable solutions for some use cases like this that are challenging for Z3.

  • Enable symbolic reasoning about getattr and friends. (example)

  • Fixes or improvements related to:

    • builtin tolerance for symbolic values

    • User-defined class proxy generation

    • Classmethods on int & float.

    • Floordiv and mod operators

    • list.index() and list ordering

    • The Final[] typing annotation

    • xor operations over sets

Version 0.0.9