Runtime AOP injection for Python — intercept and modify local variables at any execution point
Project description
pytrace-inject: Runtime AOP injection for Python.
A lightweight framework that lets you intercept and modify local variables
at any execution point of a target function, using sys.settrace.
Quick Start
import random
from pytrace_inject import At, inject, start_trace, end_trace
@inject(At(random.randrange).atcall())
def modify(start, end):
start, end = 42, 43
return {'start': start, 'end': end}
start_trace()
print(random.randrange(100, 999)) # Output: 42
end_trace()
Key Concepts
- At — Where to inject (call time / return time / specific line / custom condition).
- Tracer — The active injection, can be
.remove()'d at any time. - Callback — Your function that receives current local variables
and returns a
dictof replacements (orNone).
License
MIT — see LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytrace_inject-0.2.0.tar.gz.
File metadata
- Download URL: pytrace_inject-0.2.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55e46f4d67f7093645822e7d529bedc76a8c5b30fa89e714bf236a10ad43615e
|
|
| MD5 |
185ea5663394feec71d0301d1af68fe9
|
|
| BLAKE2b-256 |
74baff2b4bf240ab282272730861a0e4a3707dfa1f6bd6d9f3d9660e039a3278
|
Provenance
The following attestation bundles were made for pytrace_inject-0.2.0.tar.gz:
Publisher:
python-publish.yml on YuYi-09/pytrace-inject
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytrace_inject-0.2.0.tar.gz -
Subject digest:
55e46f4d67f7093645822e7d529bedc76a8c5b30fa89e714bf236a10ad43615e - Sigstore transparency entry: 1895176237
- Sigstore integration time:
-
Permalink:
YuYi-09/pytrace-inject@d2647d975f22a27549e35d60b374b4bfa386fa7c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/YuYi-09
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d2647d975f22a27549e35d60b374b4bfa386fa7c -
Trigger Event:
release
-
Statement type:
File details
Details for the file pytrace_inject-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pytrace_inject-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a53946411220d0e226169a61c85ab036a12e6165a3c37999ca9f6717f516e8d
|
|
| MD5 |
cc7dd0db85ec7ebac9dda42ee04062f4
|
|
| BLAKE2b-256 |
0e85279cc1170bc8617c56b71e02a2159bef672e9614726ae14ebeb2b213d8e0
|
Provenance
The following attestation bundles were made for pytrace_inject-0.2.0-py3-none-any.whl:
Publisher:
python-publish.yml on YuYi-09/pytrace-inject
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytrace_inject-0.2.0-py3-none-any.whl -
Subject digest:
4a53946411220d0e226169a61c85ab036a12e6165a3c37999ca9f6717f516e8d - Sigstore transparency entry: 1895176493
- Sigstore integration time:
-
Permalink:
YuYi-09/pytrace-inject@d2647d975f22a27549e35d60b374b4bfa386fa7c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/YuYi-09
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d2647d975f22a27549e35d60b374b4bfa386fa7c -
Trigger Event:
release
-
Statement type: