Skip to main content

Usage:

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:

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

Release files for backports_abc 0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for backports_abc 0.5
File Size Uploaded
backports_abc-0.5.tar.gz 9.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for backports_abc 0.5
File Interpreter ABI Platform
backports_abc-0.5-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 15.0 kB

Release files / backports_abc-0.5.tar.gz

Download URL backports_abc-0.5.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
033be54514a03e255df75c5aee8f9e672f663f93abb723444caec8fe43437bde
BLAKE2b-256 checksum
How to use checksums
683c1317a9113c377d1e33711ca8de1e80afbaf4a3c950dd0edfaf61f9bfe6d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / backports_abc-0.5-py2.py3-none-any.whl

Download URL backports_abc-0.5-py2.py3-none-any.whl
Size 5.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
52089f97fe7a9aa0d3277b220c1d730a85aefd64e1b2664696fe35317c5470a7
BLAKE2b-256 checksum
How to use checksums
7d566f3ac1b816d0cd8994e83d0c4e55bc64567532f7dc543378bd87f81cebc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.5 This release

2 release files

0.4

2 release files

0.3

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page