/
githubmirror
/
XX-Net
Обзор
Документация
Войти
/
githubmirror
/
XX-Net
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
code/default/lib/noarch/hyper/packages/hpack/compat.py
42 строки
667 B
Michael.X
4.0.0 upgrade to python3
27 мар 2020, 13:14
27 мар 2020, 13:14
57fd3bd
Код
Авторство
О чём код?
# -*- coding: utf-8 -*- """ hpack/compat ~~~~~~~~~~~~ Normalizes the Python 2/3 API for internal use. """ import sys _ver = sys.version_info is_py2 = _ver[0] == 2 is_py3 = _ver[0] == 3 if is_py2: def to_byte(char): return ord(char) def decode_hex(b): return b.decode('hex') def to_bytes(b): if isinstance(b, memoryview): return b.tobytes() else: return bytes(b) str = str # noqa bytes = str elif is_py3: def to_byte(char): return char def decode_hex(b): return bytes.fromhex(b) def to_bytes(b): return bytes(b) str = str bytes = bytes