blob: 40e0734c37e972ed7dac31ba1f1eae9d90b539aa (
plain) (
blame)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
Metadata-Version: 2.0
Name: backports-abc
Version: 0.5
Summary: A backport of recent additions to the 'collections.abc' module.
Home-page: https://github.com/cython/backports_abc
Author: Stefan Behnel et al.
Author-email: cython-devel@python.org
License: UNKNOWN
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Python Software Foundation License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 3
=============
ABC-Backports
=============
Usage:
.. code-block:: python
try:
# ABCs live in "collections.abc" in Python >= 3.3
from collections.abc import Coroutine, Generator
except ImportError:
# fall back to import from "backports_abc"
from backports_abc import Coroutine, Generator
You can also install the ABCs into the stdlib by calling the ``patch()``
function:
.. code-block:: python
import backports_abc
backports_abc.patch()
try:
# ABCs live in "collections.abc" in Python >= 3.3
from collections.abc import Coroutine, Generator
except ImportError:
# fall back to import from "collections" in Python <= 3.2
from backports_abc import Coroutine, Generator
Currently, ``patch()`` provides the following names if missing:
* ``collections.abc.Generator``
* ``collections.abc.Awaitable``
* ``collections.abc.Coroutine``
* ``inspect.isawaitable(obj)``
All of them are also available directly from the ``backports_abc``
module namespace.
In Python 2.x and Python 3.2, it patches the ``collections`` module
instead of the ``collections.abc`` module. Any names that are already
available when importing this module will not be overwritten.
The names that were previously patched by ``patch()`` can be queried
through the mapping in ``backports_abc.PATCHED``.
Changelog
=========
0.5 (2016-11-12)
----------------
* support old-style (mro-missing) classes
0.4 (2015-09-14)
----------------
* direct wheel building support
* make all names available at the module level instead of requiring patching
0.3 (2015-07-03)
----------------
* removed patching of ``inspect.iscoroutine()`` as it is not ABC based
0.2 (2015-07-03)
----------------
* require explicit ``backports_abc.patch()`` call to do the patching
(avoids side-effects on import and allows future configuration)
* provide access to patched names through global ``PATCHED`` dict
* add ABC based implementations of inspect.iscoroutine() and
inspect.isawaitable()
0.1 (2015-06-24)
----------------
* initial public release
* provided ABCs: Generator, Coroutine, Awaitable
|