Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionally format values for matching #9

Merged
merged 1 commit into from
Jul 14, 2022
Merged

Conditionally format values for matching #9

merged 1 commit into from
Jul 14, 2022

Conversation

jparise
Copy link
Collaborator

@jparise jparise commented Jul 14, 2022

We previously always string-ified syscall values in preparation for
filtering them with 'match' checkers. This isn't the behavior we want
for 'byte' and 'byterray' values, however, because we'd end up matching
against their __str__ representations (e.g. bytearray(b'abc')).

We now only format the value when it isn't one of (bytes, bytearray,
str), and we require the matcher to be bytes- or string-aware. (This is
something we could consider revisiting by attempting to decode bytes to
strings, to make matching more natural, but I don't know if that level
of implicit conversion is really needed for such a low-level library.)

Fixes #7

We previously always string-ified syscall values in preparation for
filtering them with 'match' checkers. This isn't the behavior we want
for 'byte' and 'byterray' values, however, because we'd end up matching
against their `__str__` representations (e.g. `bytearray(b'abc')`).

We now only format the value when it isn't one of (bytes, bytearray,
str), and we require the matcher to be bytes- or string-aware. (This is
something we could consider revisiting by attempting to decode bytes to
strings, to make matching more natural, but I don't know if that level
of implicit conversion is really needed for such a low-level library.)
@jparise jparise merged commit 67b0e38 into master Jul 14, 2022
@jparise jparise deleted the maybe_format branch July 14, 2022 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: cannot use a bytes pattern on a string-like object
1 participant