1# -*- coding: utf-8 -*-
2"""
3hpack/compat
4~~~~~~~~~~~~
5
6Normalizes the Python 2/3 API for internal use.
7"""
8import sys
9
10
11_ver = sys.version_info
12is_py2 = _ver[0] == 2
13is_py3 = _ver[0] == 3
14
15if is_py2:
16    def to_byte(char):
17        return ord(char)
18
19    def decode_hex(b):
20        return b.decode('hex')
21
22    unicode = unicode
23    bytes = str
24
25elif is_py3:
26    def to_byte(char):
27        return char
28
29    def decode_hex(b):
30        return bytes.fromhex(b)
31
32    unicode = str
33    bytes = bytes
34