2023-05-20 21:56:23 +00:00
|
|
|
"""Deprecated - New code should avoid these"""
|
2023-07-15 09:00:08 +00:00
|
|
|
import warnings
|
|
|
|
|
|
|
|
from ..compat.compat_utils import passthrough_module
|
|
|
|
|
|
|
|
# XXX: Implement this the same way as other DeprecationWarnings without circular import
|
|
|
|
passthrough_module(__name__, '.._legacy', callback=lambda attr: warnings.warn(
|
|
|
|
DeprecationWarning(f'{__name__}.{attr} is deprecated'), stacklevel=6))
|
|
|
|
del passthrough_module
|
|
|
|
|
2023-05-20 21:56:23 +00:00
|
|
|
|
2024-11-16 23:24:11 +00:00
|
|
|
import re
|
|
|
|
import struct
|
2023-07-15 09:00:08 +00:00
|
|
|
|
2023-05-20 21:56:23 +00:00
|
|
|
|
2024-11-16 23:24:11 +00:00
|
|
|
def bytes_to_intlist(bs):
|
|
|
|
if not bs:
|
|
|
|
return []
|
|
|
|
if isinstance(bs[0], int): # Python 3
|
|
|
|
return list(bs)
|
|
|
|
else:
|
|
|
|
return [ord(c) for c in bs]
|
2023-05-20 21:56:23 +00:00
|
|
|
|
|
|
|
|
2024-11-16 23:24:11 +00:00
|
|
|
def intlist_to_bytes(xs):
|
|
|
|
if not xs:
|
|
|
|
return b''
|
2024-11-22 22:11:00 +00:00
|
|
|
return struct.pack('%dB' % len(xs), *xs) # noqa: UP031
|
2023-05-20 21:56:23 +00:00
|
|
|
|
|
|
|
|
2024-11-16 23:24:11 +00:00
|
|
|
compiled_regex_type = type(re.compile(''))
|