Tested in Python version 3.14, not sure if other versions have the same behavior.
html.escape has the following signature:
def escape(s: AnyStr, quote: bool = True) -> AnyStr: ...
But calling html.escape with a bytes or bytearray argument raises the following exception:
File ".../lib/python3.14/html/__init__.py", line 19, in escape
s = s.replace("&", "&") # Must be done first!
TypeError: a bytes-like object is required, not 'str'
Either the type annotation should be changed to str instead of AnyStr, or someone could update the standard library to support bytes
Tested in Python version 3.14, not sure if other versions have the same behavior.
html.escapehas the following signature:But calling
html.escapewith abytesorbytearrayargument raises the following exception:Either the type annotation should be changed to
strinstead ofAnyStr, or someone could update the standard library to support bytes