legacy-cgi

Standalone fork of Python's removed standard-library cgi and cgitb modules.

Library
PyPI
v2.6.4
48stars
Python Software Foundation License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
31/100Needs Attention
Development Activity0
Maintenance20
Community36
Maturity56
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
68/100Good
Architecture70
Code Quality72
Innovation55
Learning Curve85

legacy-cgi is a maintained fork of the cgi and cgitb modules that were removed from the Python standard library in Python 3.13 as part of PEP 594 (“dead batteries”). It packages those modules so existing CGI scripts continue to run unchanged on modern Python versions.

The project’s explicit goal is compatibility rather than new features: it preserves the historic API for parsing form data, handling file uploads, and rendering traceback pages so that legacy web scripts do not break when upgrading interpreters. New applications are pointed toward modern WSGI/ASGI frameworks instead.

What You Get

  • The cgi module for parsing CGI form data, query strings, and multipart file uploads
  • The cgitb module for rich, formatted traceback pages during CGI script debugging
  • A drop-in installation that lets existing CGI scripts run unmodified on Python 3.13+
  • A recommended python_version >= '3.13' install marker so it only activates where the built-ins are gone
  • A stability-focused maintenance policy prioritizing bug fixes over new features

Common Use Cases

  • Keeping legacy CGI scripts alive when upgrading to Python 3.13 or later
  • Providing the cgi.FieldStorage API to old code without rewriting it for WSGI
  • Restoring cgitb traceback pages for debugging inherited CGI applications

Under The Hood

Architecture — The package is intentionally minimal: two top-level modules, cgi.py and cgitb.py, lifted from the CPython standard library, plus a cgi-bin/ example directory and packaging metadata. cgi.py centers on FieldStorage, which parses application/x-www-form-urlencoded and multipart/form-data request bodies from the CGI environment; cgitb.py formats uncaught exceptions into HTML or text traceback reports. There is no reimplementation — behavior mirrors the original modules exactly.

Tech Stack — Pure Python packaged with a modern pyproject.toml and a uv.lock. It has no third-party runtime dependencies and is meant to be installed with a python_version >= '3.13' environment marker so the built-in modules take precedence on older interpreters.

Code Quality — Because compatibility is the stated goal, changes are limited to bug fixes; a tests/ directory guards the preserved behavior. The code reflects its standard-library heritage rather than modern refactoring, which is deliberate for a drop-in replacement.

API Design — The API is exactly the historic cgi/cgitb surface (cgi.FieldStorage, cgitb.enable()), so developers migrating legacy scripts need learn nothing new — the value is precisely that the public interface is unchanged.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search