_deprecated.py 735 B

12345678910111213141516171819202122232425262728293031
  1. """Deprecated - New code should avoid these"""
  2. import warnings
  3. from ..compat.compat_utils import passthrough_module
  4. # XXX: Implement this the same way as other DeprecationWarnings without circular import
  5. passthrough_module(__name__, '.._legacy', callback=lambda attr: warnings.warn(
  6. DeprecationWarning(f'{__name__}.{attr} is deprecated'), stacklevel=6))
  7. del passthrough_module
  8. import re
  9. import struct
  10. def bytes_to_intlist(bs):
  11. if not bs:
  12. return []
  13. if isinstance(bs[0], int): # Python 3
  14. return list(bs)
  15. else:
  16. return [ord(c) for c in bs]
  17. def intlist_to_bytes(xs):
  18. if not xs:
  19. return b''
  20. return struct.pack('%dB' % len(xs), *xs)
  21. compiled_regex_type = type(re.compile(''))