DESCRIPTION.rst 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. =============
  2. ABC-Backports
  3. =============
  4. Usage:
  5. .. code-block:: python
  6. try:
  7. # ABCs live in "collections.abc" in Python >= 3.3
  8. from collections.abc import Coroutine, Generator
  9. except ImportError:
  10. # fall back to import from "backports_abc"
  11. from backports_abc import Coroutine, Generator
  12. You can also install the ABCs into the stdlib by calling the ``patch()``
  13. function:
  14. .. code-block:: python
  15. import backports_abc
  16. backports_abc.patch()
  17. try:
  18. # ABCs live in "collections.abc" in Python >= 3.3
  19. from collections.abc import Coroutine, Generator
  20. except ImportError:
  21. # fall back to import from "collections" in Python <= 3.2
  22. from backports_abc import Coroutine, Generator
  23. Currently, ``patch()`` provides the following names if missing:
  24. * ``collections.abc.Generator``
  25. * ``collections.abc.Awaitable``
  26. * ``collections.abc.Coroutine``
  27. * ``inspect.isawaitable(obj)``
  28. All of them are also available directly from the ``backports_abc``
  29. module namespace.
  30. In Python 2.x and Python 3.2, it patches the ``collections`` module
  31. instead of the ``collections.abc`` module. Any names that are already
  32. available when importing this module will not be overwritten.
  33. The names that were previously patched by ``patch()`` can be queried
  34. through the mapping in ``backports_abc.PATCHED``.
  35. Changelog
  36. =========
  37. 0.5 (2016-11-12)
  38. ----------------
  39. * support old-style (mro-missing) classes
  40. 0.4 (2015-09-14)
  41. ----------------
  42. * direct wheel building support
  43. * make all names available at the module level instead of requiring patching
  44. 0.3 (2015-07-03)
  45. ----------------
  46. * removed patching of ``inspect.iscoroutine()`` as it is not ABC based
  47. 0.2 (2015-07-03)
  48. ----------------
  49. * require explicit ``backports_abc.patch()`` call to do the patching
  50. (avoids side-effects on import and allows future configuration)
  51. * provide access to patched names through global ``PATCHED`` dict
  52. * add ABC based implementations of inspect.iscoroutine() and
  53. inspect.isawaitable()
  54. 0.1 (2015-06-24)
  55. ----------------
  56. * initial public release
  57. * provided ABCs: Generator, Coroutine, Awaitable