Skip to content

The error message for odd-length input to bytes.fromhex is cryptic #127740

Closed
@Kodiologist

Description

@Kodiologist

Bug report

Bug description:

Python 3.14.0a2+ (main, Dec  8 2024, 10:50:32) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> bytes.fromhex('deadbee')
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    bytes.fromhex('deadbee')
    ~~~~~~~~~~~~~^^^^^^^^^^^
ValueError: non-hexadecimal number found in fromhex() arg at position 7
>>> bytes.fromhex('deadbeef')
b'\xde\xad\xbe\xef'

I suggest: ValueError: fromhex() arg must be of even length.

CPython versions tested on:

3.12, CPython main branch

Operating systems tested on:

Linux

Linked PRs

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