Registry / http-networking / rfc3987

rfc3987

JSON →
library1.3.8pypypi✓ verified 25d ago

The `rfc3987` Python library provides regular expressions and utilities for parsing and validating Uniform Resource Identifiers (URIs) as per RFC 3986 and Internationalized Resource Identifiers (IRIs) according to RFC 3987. The current version is 1.3.8. Development on the original GitHub repository has ceased, and the project is now archived, with development reportedly moved to Codeberg, implying a largely unmaintained or very slow release cadence on PyPI.

pip install rfc3987
INSTALL
IMPORT
SIG · RFC3987
R
rfc3987
http-networkingpythonv1.3.8
Install
1.5s avg
Import
10ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.3.8 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.010s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.008s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

match
from rfc3987 import match
parse
from rfc3987 import parse
compose
from rfc3987 import compose
resolve
from rfc3987 import resolve

Demonstrates parsing an IRI, matching a component against a rule, and resolving a relative URI reference. The `parse` function extracts components into a dictionary, `match` checks if a string conforms to a specific ABNF rule, and `resolve` combines a base URI with a relative reference.

from rfc3987 import parse, match, resolve # Parse an IRI and get its components iri_string = 'http://example.com/path?query=value#fragment' parsed_iri = parse(iri_string, rule='IRI') print(f"Parsed Scheme: {parsed_iri.get('scheme')}") print(f"Parsed Authority: {parsed_iri.get('authority')}") print(f"Parsed Path: {parsed_iri.get('path')}") # Check if a string matches a specific rule is_pct_encoded = match('%C7', 'pct_encoded') print(f"Is '%C7' percent-encoded? {bool(is_pct_encoded)}") # Resolve a relative URI reference base_uri = 'http://a/b/c/d;p?q' relative_ref = '../../g' resolved_uri = resolve(base_uri, relative_ref) print(f"Resolved URI: {resolved_uri}")
Debug
Known issues
breakingThe original GitHub repository for `rfc3987` has been archived by its owner, and development has reportedly moved to a different platform (Codeberg). This indicates that the PyPI package might not receive future updates or active maintenance from the original author, potentially leading to stagnation or unaddressed issues for newer Python versions or RFC amendments.
fix
Be aware that active development has shifted. For new projects, evaluate if the current 1.3.8 version meets your needs, or consider forks/alternative libraries if active maintenance is critical. The Codeberg repository (https://codeberg.org/atufi/rfc3987/) might contain more up-to-date information or development.
affects: 1.3.8 and potentially future versions on PyPI.
gotchaThe `parse` and `match` functions have different capabilities depending on whether the optional `regex` package is installed. If `regex` is available, any RFC 3986/3987 rule can be used. If only Python's built-in `re` module is present, only specific, special-cased rules (like 'IRI_reference', 'IRI', 'absolute_IRI', 'URI_reference', 'URI', etc.) are supported.
fix
If you need to validate or parse strings against arbitrary or less common RFC 3986/3987 rules, ensure you install the `regex` package: `pip install rfc3987 regex`. Otherwise, restrict rule usage to those explicitly supported by the `re` module fallback.
affects: All versions of rfc3987.
deprecatedThe library primarily lists Python 2.x and Python 3.2-3.6 for compatibility testing in its PyPI metadata. While it generally works with newer Python 3 versions, explicit support, testing, and potential edge-case fixes for Python 3.7+ are not officially documented due to the lack of recent updates and archived status of the original repository.
fix
Test thoroughly on your target Python 3.x version. While the core regex patterns are stable, be mindful of potential unexpected behavior or lack of optimizations on newer Python runtimes.
affects: All versions, particularly when used with Python 3.7+.
gotchaFor older Python versions (<=3.2), characters beyond the Basic Multilingual Plane (BMP) might not be fully supported on 'narrow' Python builds, which can lead to issues when processing internationalized characters in IRIs. This is a Python interpreter limitation, not specific to `rfc3987` itself.
fix
Ensure you are using a modern Python 3.x version (preferably 3.7+) which typically supports a 'wide' Unicode build, resolving this limitation. This warning is less relevant for contemporary Python environments.
affects: Python <= 3.2, especially on narrow builds.
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'rfc3987'
The rfc3987 package is not installed in the current Python environment.
fix
Install the package using pip: `pip install rfc3987`
ValueError: invalid IRI
The `rfc3987.validate()` function raises this exception when the input string does not conform to the RFC 3987 (IRI) or RFC 3986 (URI) specifications.
fix
Either ensure the input string is a valid IRI/URI, or use `rfc3987.is_valid(iri_string)` if you only need a boolean result and prefer not to handle exceptions for invalid inputs.
TypeError: expected string or bytes-like object
The functions `rfc3987.parse`, `rfc3987.validate`, and `rfc3987.is_valid` expect a string or bytes-like object as their first argument, but received an incompatible type (e.g., an integer, list, or None).
fix
Ensure that the input provided to `rfc3987` functions is a string or bytes-like object representing the URI/IRI.
NameError: name 'rfc3987' is not defined
The `rfc3987` module was not imported before attempting to use its functions or attributes.
fix
Add `import rfc3987` at the beginning of your Python script or interactive session before using the module.
Upgrade
Version history
1.3.8latest on PyPI · released Jul 29, 2018
Audit
Dependencies
regexoptionalRequired for full support of all ABNF rules; without it, the standard 're' module is used, which has limitations on supported rules for parsing.
Agent activity
15 hits · last 30 days
node
12
OpenAI (training)
1
Resources