Compatibility & Deprecations
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The python-multipart library maintains a strict compatibility policy focused on supporting modern Python environments while providing transition paths for legacy integrations. The project has undergone significant structural changes, including a package rename and the removal of legacy parser classes, to improve maintainability and security.
Compatibility is managed through a combination of backward-compatible import shims, case-insensitive header handling, and explicit version-based support for Python runtimes. This ensures that downstream web frameworks and applications can upgrade with minimal friction.
Package Renaming and Import Compatibility
A major transition in the project's history was the move from the top-level package name multipart to python_multipart. To prevent breaking existing codebases, the project maintains a backward-compatibility layer.
Import Migration Flow
The following diagram illustrates how the project handles the transition between the old and new package names.
The migration involved renaming the primary import to python_multipart in version 0.0.13, while version 0.0.14 and subsequent releases included fixes and dunder attributes to ensure the multipart package remains functional for legacy users.
Sources: CHANGELOG.md:52-61, scripts/README.md:8
Python Version Support
The library follows a proactive End-of-Life (EOL) policy for Python versions. It currently targets modern Python 3 environments exclusively.
| Feature | Supported Versions | Notes |
|---|---|---|
| Current Support | Python 3.10 - 3.14 | Includes pre-release support for 3.14. |
| Dropped (v0.0.21) | Python 3.8, 3.9 | Dropped upon reaching EOL. |
| Dropped (v0.0.9) | Python 3.7 | Removed to leverage newer language features. |
| Dropped (v0.0.6) | Python 2.7 - 3.6 | Legacy versions removed during modernization. |
Sources: CHANGELOG.md:34-35, CHANGELOG.md:113-114, pyproject.toml:11-18
Deprecated and Removed Components
As part of the refactoring process to simplify the codebase, several older structures and parameters have been removed or replaced with modern equivalents.
Legacy FormParser Classes
In version 0.0.25, custom FormParser subclasses were removed in favor of a unified FormParser implementation that dynamically selects an internal parser based on the Content-Type.
Sources: CHANGELOG.md:25, python_multipart/multipart.py:1126-1127
Removed Parameters and Fallbacks
trust_x_headers: This parameter and its associatedX-File-Namefallback were removed in version 0.0.23 to improve security and standard compliance.- Dunder Metadata: Metadata dunders were cleaned up from
__init__.pyto streamline the package interface. - Custom RegEx Parsers: The header option parser was refactored in version 0.0.7 to use the standard library instead of custom Regular Expressions to mitigate potential ReDoS (Regular Expression Denial of Service) risks.
Evolution of Parser Logic
The logic for handling multipart data has evolved to be more lenient with non-critical RFC violations while being stricter with security boundaries.
Standards Compliance & Fixes
The library implements specific compatibility logic for various clients and RFC standards to ensure interoperability.
Header Handling
- Case Insensitivity: Multipart headers and Content-Transfer-Encoding (CTE) values are handled case-insensitively to ensure compatibility with varied client implementations.
- RFC 2231: The
parse_options_headerfunction includes logic to handle RFC 2231 continuations and encodes parameters intolatin-1as expected by WSGI. - IE6 Path Bug: A specific fix exists in
parse_options_headerto strip full directory paths from filenames sent by Internet Explorer 6.
Resource Limits and Security
To prevent resource exhaustion, the library introduced several limits that act as "breaking changes" for non-compliant or malicious payloads:
- Boundary Length: Capped at 256 bytes.
- Header Limits: Maximum header count and size limits were introduced in version 0.0.27 to prevent memory-based attacks.
Sources: CHANGELOG.md:7-12, python_multipart/multipart.py:101-115, python_multipart/multipart.py:165-170
Conclusion
python-multipart prioritizes a secure-by-default approach while maintaining significant backward compatibility for Python 3.x environments. By providing import shims for the package rename and handling legacy browser quirks (like IE6 pathing), it remains a stable choice for web frameworks. Users are encouraged to migrate to the python_multipart namespace and Python 3.10+ to ensure continued support.