whatthepatch
A patch parsing and application library.
What it is and what it does
What The Patch is a Python library for parsing patch files and applying them to text. It reads diffs in standard formats (unified, context, normal, ed, rcs) and from source control systems (Git, SVN, CVS), extracting the changes into structured data that describes which lines were added, removed, or kept unchanged. You can then apply those changes to a file's text to reconstruct the patched version.
The library has been stable since its 1.0 release and requires no external dependencies. It works by default without needing the system patch command, though you can opt to use it if available. The maintainer notes that while the functions are reliable, they are not ideally implemented and active development is minimal—pull requests are welcome and will be merged and released, but reported issues may not be fixed.
Use it for:
- Parse a patch file to inspect what changes it contains before applying it to your codebase.
- Apply a Git, SVN, or CVS patch to text in memory without invoking external tools.
- Build a tool that needs to understand or manipulate diffs programmatically.
- Validate patch compatibility or extract metadata from patch files.
- Reconstruct a modified version of a file by applying a stored patch to the original text.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses and applies patch files in multiple diff formats (unified, context, normal, ed, rcs) and from several source control systems (Git, SVN, CVS).
Yes. The library is stable, has no dependencies, and solves a clear problem—parsing and applying patches—with low friction. The permissive license and active repository maintenance make it safe to rely on. The caveat is that the maintainer does not actively fix reported issues, so verify that the documented formats cover your use case before adopting it.
Install
whatthepatch on PyPI
pip
pip install whatthepatchuv
uv add whatthepatchpoetry
poetry add whatthepatchInstalling whatthepatch
Before you install
Low install friction with no runtime dependencies. Maintenance is active but minimal—the library has been stable for years with infrequent updates; pull requests are accepted and released, but issues may not be addressed by the maintainer.
License in practice
Licensed under MIT (permissive), allowing free use, modification, and distribution with minimal restrictions.
Quickstart
pip install whatthepatch
import whatthepatch
with open('somechanges.patch') as f:
text = f.read()
for diff in whatthepatch.parse_patch(text):
result = whatthepatch.apply_diff(diff, original_text)
Verify before relying
- Whether the library handles all real-world patch edge cases or only the documented diff formats
- Performance characteristics when parsing or applying very large patch files
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 636 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,648,129/month — #2,962 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: whatthepatch-1.0.7-py3-none-any.whl
Keywords: patch, diff, parser
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
patchParses and applies unified diff patches to…
permissive · top 15,000 on PyPI
patch-ngParses and applies unified diff patches to…
permissive · top 5,000 on PyPI
unidiff2Parses unified diff format into structured…
permissive · top 15,000 on PyPI
diff-match-patchProvides diff, match, and patch algorithms for…
permissive · top 5,000 on PyPI
unidiffParses unified diff format data into structured…
permissive · top 1,000 on PyPI
dictdifferDictdiffer computes and applies diffs and…
permissive · top 5,000 on PyPI
fast-diff-match-patchWraps the C++ implementation of…
permissive · top 15,000 on PyPI
bsdiff4bsdiff4 creates and applies binary patches in…
permissive · top 15,000 on PyPI
moreorlessGenerates unified diffs with correct handling…
permissive · top 5,000 on PyPI
daffCompares two tables and produces a diff summary…
permissive · top 1,000 on PyPI