$npx skillfedfor your agent

contextlib2

Backports and enhancements for the contextlib module

SkipPyPI Software DevelopmentReleased Jun 202112.3M downloads / moPSF LicensePure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — contextlib2-21.6.0-py2.py3-none-any.whl
v21.6.0 · released 2021-06-27 · Python >=3.6

No, unless you are maintaining legacy code on Python 3.6–3.10 and need a specific backported feature not yet in your target Python version. For modern Python, use the standard library contextlib directly. The package is abandoned and receives no maintenance.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Low install friction with no runtime dependencies.
  • However, the package is abandoned—last release was 1874 days ago.
  • For modern Python versions, the standard library contextlib is available natively; this backport is primarily useful for legacy codebases or edge-case compatibility scenarios.

License · maintenance · safety

PSF License (permissive) — Dual-licensed under the Python Software Foundation License (for the backported code) and Apache License 2.0 (for type hints from typeshed). Both are permissive; no restriction on commercial or proprietary use.

last release 2021-06-27 (1874 days)

0 known vulnerabilities (OSV.dev, 2026-08-14) · 12,264,081 downloads/mo, #1,330 on PyPI

Verify before relying

pip install contextlib2

import contextlib2

@contextlib2.contextmanager
def my_context():
    print('enter')
    yield
    print('exit')

with my_context():
    pass
  • Whether the backported APIs differ meaningfully from the current standard library contextlib.
  • Whether Python 3.6, 3.7, 3.8, 3.9, or 3.10 versions targeted by this package remain in active use in your codebase.
Same gist for agents: .md · .json

What it is and what it does

contextlib2 is a backport of Python's standard library contextlib module, designed to make context manager utilities available on Python versions earlier than those in which they were added to the standard library. It includes both the core context manager decorators and utilities, plus type hints from the typeshed project.

Since the package requires Python 3.6 or later and the standard library has included contextlib since the earliest Python 3 releases, this package is most relevant for maintaining compatibility in legacy codebases. The package is no longer actively maintained, with its last release in 2021-06-27.

Use it for

  • Maintaining legacy code that must run on Python 3.6–3.10 while using a unified contextlib interface.
  • Providing type hints for contextlib usage in projects that need static type checking across multiple Python versions.
  • Serving as a reference implementation or testing ground for proposed enhancements to the standard library contextlib.
  • Supporting projects that pin to older Python versions and need backported context manager utilities.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Skip

No, unless you are maintaining legacy code on Python 3.6–3.10 and need a specific backported feature not yet in your target Python version.

For modern Python, use the standard library contextlib directly. The package is abandoned and receives no maintenance.

Install

contextlib2 on PyPI

Before you install

Low install friction with no runtime dependencies. However, the package is abandoned—last release was 1874 days ago. For modern Python versions, the standard library contextlib is available natively; this backport is primarily useful for legacy codebases or edge-case compatibility scenarios.

License in practice

Dual-licensed under the Python Software Foundation License (for the backported code) and Apache License 2.0 (for type hints from typeshed). Both are permissive; no restriction on commercial or proprietary use.

Quickstart

pip install contextlib2

import contextlib2

@contextlib2.contextmanager
def my_context():
    print('enter')
    yield
    print('exit')

with my_context():
    pass

Verify before relying

  • Whether the backported APIs differ meaningfully from the current standard library contextlib.
  • Whether Python 3.6, 3.7, 3.8, 3.9, or 3.10 versions targeted by this package remain in active use in your codebase.

Package facts

LicensePSF License permissive
Python supportSupports the current Python release >=3.6
Install frictionLow. Pure-Python wheel
Runtime dependenciesNone
MaintenanceAbandoned 1,874 days since the last release
First released
Downloads12,264,081 / month, #1,330 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 5 - Production/StableLicense :: OSI Approved :: Apache Software LicenseLicense :: OSI Approved :: Python Software Foundation LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Evidence: contextlib2-21.6.0-py2.py3-none-any.whl

Tags

Capabilities
context manager backportcontextlib for older pythonresource management utilitiespython standard library backportcontext manager enhancementscontextlib compatibilityasync context manager support
Topics
backportcontext-managerslegacy-support

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “context manager backport”

  • contextlib2contextlib2 backports the Python standard library's contextlib module…
  • async-exit-stackProvides AsyncExitStack, a backport of Python 3.7's asynchronous…
  • backports.tempfileProvides the TemporaryDirectory context manager for Python 2.7 and…

Give your agent the search over MCP, or paste the wish link into any chat.

More Software Development packages

typing-extensions Worth it
PyPI · Software Development · released Jul 2026

Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.

PSF-2.0pure Python · 3.9+
1.9Bdownloads / mo
numpy Worth it
PyPI · Software Development · released Aug 2026

NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.

BSD-3-Clause AND 0BSD AND MIT AND Zlib AND CC0-1.0compiled wheel · 3.12+
1.1Bdownloads / mo
fastapi Worth it
PyPI · Software Development · released Jul 2026

FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.

MITpure Python · 3.10+
568.6Mdownloads / mo
annotated-doc With conditions
PyPI · Software Development · released Jul 2026

Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.

MITpure Python · 3.9+
456.2Mdownloads / mo
typer Worth it
PyPI · Software Development · released Aug 2026

Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.

Install it if you are building CLIs in Python.

MITpure Python · 3.10+
369.3Mdownloads / mo
distlib With conditions
PyPI · Software Development · released Jun 2026

Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.

permissive licensepure Python
323.3Mdownloads / mo

See also backports.tempfile · pickle5 · async_generator · asyncio · logutils · linecache2 · pyasyncore · traceback2 · textwrap3 · importlib-resources