Registry / serialization / rust-demangler

rust-demangler

JSON →
library1.0pypypi✓ verified 85d ago

A package for demangling Rust symbols, written in Python. It provides a simple interface to convert Rust's compiler-generated symbol names into human-readable forms. The current version is 1.0, last updated in April 2021, suggesting a low release cadence.

pip install rust-demangler
INSTALL
IMPORT
SIG · RUST-DEMANGLER
R
rust-demangler
serializationpythonv1.0
Install
1.5s avg
Import
5ms
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.0 · 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.920 runs
installs and imports cleanly · install 0.0s · import 0.003s · 17.9MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.001s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

demangle
from rust_demangler import demangle
import rust_demangler.demangle
The 'demangle' function is directly exposed at the top-level package namespace, not within a sub-module named 'demangle'.

This quickstart demonstrates how to import the `demangle` function and use it to demangle common Rust symbol names. It includes examples for both older and newer mangling styles for illustrative purposes.

from rust_demangler import demangle mangled_name_v0 = '_ZN3foo3barE' mangled_name_legacy = '_ZN4core3fmt9Arguments9new_const17hf7eafdf6c5e03508E' demangled_v0 = demangle(mangled_name_v0) demangled_legacy = demangle(mangled_name_legacy) print(f"Original mangled (v0): {mangled_name_v0} -> Demangled: {demangled_v0}") print(f"Original mangled (legacy): {mangled_name_legacy} -> Demangled: {demangled_legacy}") # Example of expected output for '_ZN3foo3barE' is 'foo::bar'
Debug
Known issues
gotchaRust's symbol mangling scheme has evolved (e.g., from legacy to v0). This Python wrapper was last updated in April 2021, and might not fully support all newer mangling formats or edge cases introduced or stabilized in Rust since then, potentially leading to incorrect or incomplete demangling for recent binaries.
fix
Manually verify demangled output for critical paths. If issues persist, consider using a more actively maintained demangling tool or the native `rustc-demangle` Rust crate directly.
affects: All versions (1.0) against newer Rust compilers
gotchaUsers might encounter incomplete demangling for symbols specifically from certain target architectures (e.g., i686-pc-windows-msvc) on stable Rust versions. This can be due to platform-specific symbol prefixes or conventions that the demangler might not fully handle.
fix
Test demangling against known symbols from the specific target architecture. If problems arise, investigate platform-specific demangling behavior or alternative tools like `rustfilt`.
affects: All versions (1.0)
gotchaThe Python `rust-demangler` library has not been updated since April 2021. While the underlying Rust `rustc-demangle` crate is actively maintained by the Rust project, this Python binding may lag behind, potentially missing updates for new Rust symbol mangling formats, performance improvements, or bug fixes from the Rust side.
fix
Be aware of potential mismatches with very recent Rust compiler outputs. If the demangling functionality is critical and needs to be perfectly aligned with the absolute latest Rust compiler changes, consider direct integration with the `rustc-demangle` Rust crate if your project allows for it.
affects: All versions (1.0)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'rust_demangler'
The `rust-demangler` package is not installed in the current Python environment.
fix
Run `pip install rust-demangler` to install the library.
AttributeError: module 'rust_demangler' has no attribute 'demangle'
The `demangle` function is imported incorrectly. It is available directly from the `rust_demangler` package, not as an attribute of a submodule or the package itself when imported as `import rust_demangler`.
fix
Change your import statement to `from rust_demangler import demangle`.
Mangled symbol not correctly demangled (output is still mangled or partially demangled).
The input symbol uses a Rust mangling scheme (e.g., a very new 'v0' variant) that the `rust-demangler` library's current version (1.0, last updated 2021) does not fully support.
fix
Verify that the `rust-demangler` library is the most up-to-date available. If the issue persists with modern Rust binaries, consider that the library might not support the latest mangling standards due to its last update date. Alternative tools like `rustfilt` (a Rust CLI tool) may offer more up-to-date demangling capabilities.
Upgrade
Version history
1.0latest on PyPI · released Apr 24, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
rust-demangler — pip install rust-demangler · libregistry