Skip to main content

cborx

CI CodeQL OpenSSF Scorecard PyPI License: 0BSD

Pure-Python CBOR (RFC 8949) encoder/decoder. No dependencies, no Rust.

A hardened, fully typed replacement for cbor2 without a native extension. The decoder is iterative, bounds every claimed length against the remaining input, and enforces a configurable nesting limit, so hostile input fails fast instead of exhausting memory or the call stack.

Install

pip install cborx

Usage

import cborx

data = cborx.dumps({"a": [1, 2, 3], "b": None})
assert cborx.loads(data) == {"a": [1, 2, 3], "b": None}

# Deterministic encoding: shortest-form integers and floats, map keys
# sorted by encoded key bytes (RFC 8949 section 4.2).
canonical = cborx.dumps({"b": 1, "a": 2}, canonical=True)

# Strict canonical validation on decode, duplicate-key policy, depth
# and indefinite-length controls.
cborx.loads(data, canonical=True, duplicate_keys="error", max_depth=100)

# Unhandled semantic tags round-trip as CBORTag. A tag_hook overrides
# all built-in tag handling.
cborx.loads(b"\xd8\x2a\x01", tag_hook=lambda decoder, tag: (tag.tag, tag.value))
assert cborx.loads(cborx.dumps(cborx.CBORTag(42, "x"))) == cborx.CBORTag(42, "x")

# A default callback handles otherwise unencodable objects, like cbor2.
cborx.dumps(object(), default=lambda encoder, obj: {"type": type(obj).__name__})

# Simple values and the undefined sentinel.
assert cborx.loads(b"\xf7") is cborx.undefined
assert cborx.loads(b"\xf0") == cborx.CBORSimpleValue(16)

Built-in semantic tags: 0 (ISO 8601 datetime), 1 (epoch datetime), 2/3 (bignum integers beyond the 64-bit range), 32 (URI, decoded to a plain str since Python has no URI scalar), 1004 (calendar date) and 55799 (self-described CBOR, passed through). All other tags decode to CBORTag. See RFC 8949: https://www.rfc-editor.org/rfc/rfc8949

Development

uv sync --group dev
make check

License: 0BSD. Quad4 Software, https://quad4.io

Release files for cborx 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cborx 0.1.1
File Size Uploaded
cborx-0.1.1.tar.gz 84.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cborx 0.1.1
File Interpreter ABI Platform
cborx-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 97.4 kB

Release files / cborx-0.1.1.tar.gz

Download URL cborx-0.1.1.tar.gz
Size 84.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3eee489da17e133e4e5e8ede12b462e6ff5c853181b8f432326e93b5e413a082
BLAKE2b-256 checksum
How to use checksums
9263272de67cf1df67af273d386ce782f7bc436dc377898ac0d148d307d33f2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release files / cborx-0.1.1-py3-none-any.whl

Download URL cborx-0.1.1-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b6343a6e60763deef81d5fb23f6c8f4c5745419b5c48eff6d3bc1ae050aedb5
BLAKE2b-256 checksum
How to use checksums
1ecf91db0662898a3a33bff894203b8ccf198f799debb0ef1703235ca6c20cdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.5

64 release files

0.2.4

64 release files

0.2.3

64 release files

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page