Skip to content

Setting 100 to ord() gets the error message only saying string but not saying byte string #138078

@hyperkai

Description

@hyperkai

Bug report

Bug description:

ord() accepts one character of a string or byte string as shown below:

print(ord('A'))  # string
print(ord(b'A')) # byte string
# 65

But setting 100 to ord() gets the error message only saying string but not saying byte string as shown below:

print(ord(100))
# Error

TypeError: ord() expected string of length 1, but int found

So, the error message should be like below:

TypeError: ord() expected string or byte string of length 1, but int found

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions