Skip to content

Accept more hexstring formats in binascii.unhexlify and bytes.fromhex #137083

@kohlrabi

Description

@kohlrabi

Feature or enhancement

Proposal:

Currently both binascii.hexlify and bytes.hex offer the options to set the separator and the bytes-per-separator.

The inverse functions for both, binascii.unhexlify and bytes.fromhex respectively, do not offer these switches though, and do not ignore non-hexstring [^0-9A-Fa-f] characters either (bytes.fromhex at least ignores whitespace, but only that).

Both should be improved to either ignore any non-hexstring characters, or have the options to set the separator and bytes-per-separator (like the inverse functions), or some other method to enable them to work with any hexstrings that can be generated by their inverse functions.

I am willing to look into this issue and implement either suggested method or something else entirely.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions