1 | n/a | """Compatibility helpers for the different Python versions.""" |
---|
2 | n/a | |
---|
3 | n/a | import sys |
---|
4 | n/a | |
---|
5 | n/a | PY34 = sys.version_info >= (3, 4) |
---|
6 | n/a | PY35 = sys.version_info >= (3, 5) |
---|
7 | n/a | PY352 = sys.version_info >= (3, 5, 2) |
---|
8 | n/a | |
---|
9 | n/a | |
---|
10 | n/a | def flatten_list_bytes(list_of_data): |
---|
11 | n/a | """Concatenate a sequence of bytes-like objects.""" |
---|
12 | n/a | if not PY34: |
---|
13 | n/a | # On Python 3.3 and older, bytes.join() doesn't handle |
---|
14 | n/a | # memoryview. |
---|
15 | n/a | list_of_data = ( |
---|
16 | n/a | bytes(data) if isinstance(data, memoryview) else data |
---|
17 | n/a | for data in list_of_data) |
---|
18 | n/a | return b''.join(list_of_data) |
---|