blob: 2536b0ad6b656493a1197eac8fa8eacc0d611175 (
plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
======================================================
:mod:`passlib.utils.compat` - Python 2/3 Compatibility
======================================================
.. module:: passlib.utils.compat
:synopsis: python 2/3 compatibility wrappers
This module contains a number of wrapper functions used by Passlib
to run under Python 2 and 3 without changes.
.. todo::
finish documenting this module.
Unicode Helpers
===============
.. autofunction:: uascii_to_str
.. autofunction:: str_to_uascii
.. function:: join_unicode
Join a sequence of unicode strings, e.g.
``join_unicode([u"a",u"b",u"c"]) -> u"abc"``.
Bytes Helpers
=============
.. autofunction:: bascii_to_str
.. autofunction:: str_to_bascii
.. function:: join_bytes
Join a sequence of byte strings, e.g.
``join_bytes([b"a",b"b",b"c"]) -> b"abc"``.
.. function:: join_byte_values
Join a sequence of integers into a byte string,
e.g. ``join_byte_values([97,98,99]) -> b"abc"``.
.. function:: join_byte_elems
Join a sequence of byte elements into a byte string.
Python 2 & 3 return different things when accessing
a single element of a byte string:
* Python 2 returns a 1-element byte string (e.g. ``b"abc"[0] -> b"a"``).
* Python 3 returns the ordinal value (e.g. ``b"abc"[0] -> 97``).
This function will join a sequence of the appropriate type
for the given python version -- under Python 2, this is an alias
for :func:`join_bytes`, under Python 3 this is an alias for :func:`join_byte_values`.
.. function:: byte_elem_value
Function to convert byte element to integer (a no-op under PY3)
|