/usr/lib/python3/dist-packages/hpack/compat.py is in python3-hpack 2.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # -*- 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)
unicode = unicode
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)
unicode = str
bytes = bytes
|