xdrlib3
raw JSON → 0.1.1 verified Fri May 01 auth: no python
A Python library for encoding and decoding XDR (External Data Representation) data. It is a forked version of Python's standard library `xdrlib` (removed in Python 3.13), intended as a drop-in replacement. Current version 0.1.1, requires Python 3.7+.
pip install xdrlib3 Common errors
error ModuleNotFoundError: No module named 'xdrlib' ↓
cause Python 3.13 removed the deprecated xdrlib module.
fix
Install and use xdrlib3 instead:
pip install xdrlib3 and change imports to from xdrlib3 import Packer. error ImportError: cannot import name 'Packer' from 'xdrlib3' ↓
cause Typo or incorrect submodule path. The correct import is `from xdrlib3 import Packer`.
fix
Use
from xdrlib3 import Packer (not from xdrlib3.xdrlib import Packer). error TypeError: pack_int() missing 1 required positional argument: 'value' ↓
cause Forgetting to pass the value to pack methods.
fix
Call
p.pack_int(42) with an argument. Warnings
breaking xdrlib is removed from Python stdlib starting Python 3.13. Code using `from xdrlib import ...` will fail. Migrate to xdrlib3. ↓
fix Replace `from xdrlib import Packer, Unpacker` with `from xdrlib3 import Packer, Unpacker`.
gotcha The library is a fork of the old stdlib module. It is not maintained by Python core developers. Check for compatibility if using Python <3.7. ↓
fix Ensure Python >=3.7, as specified in requires_python.
gotcha The package name on PyPI is `xdrlib3`, but the import module is also `xdrlib3`. Do not confuse with `xdrlib` (the old stdlib) or other XDR libraries. ↓
fix Use `pip install xdrlib3` and `import xdrlib3`.
Imports
- Packer wrong
from xdrlib import Packercorrectfrom xdrlib3 import Packer - Unpacker wrong
from xdrlib import Unpackercorrectfrom xdrlib3 import Unpacker
Quickstart
from xdrlib3 import Packer, Unpacker
p = Packer()
p.pack_int(42)
data = p.get_buffer()
u = Unpacker(data)
print(u.unpack_int()) # 42