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
pytrace_inject-0.1.2.tar.gz
(4.8 kB
view details)
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.1.2.tar.gz.
File metadata
- Download URL: pytrace_inject-0.1.2.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ef63e75438741326433b7c0138f1790b427e2599b15cb6017939f2d028b5092
|
|
| MD5 |
6092d03f1d2e543dcdb60ab35f3abd03
|
|
| BLAKE2b-256 |
0b34302d9bff45b815fc1ffb044e5ed8aaa36f66398bc6797fe2c7488b79dad9
|
File details
Details for the file pytrace_inject-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pytrace_inject-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5c2dc82112aad3a89ce19ca7c61a9a0eba1e0bd5911e5a81dfbfad117e3d341
|
|
| MD5 |
b818572bc94290299bccb907eb51105b
|
|
| BLAKE2b-256 |
856e27143b28d259ccfbe6a4696fb45311eb6830a817415525f04a63c936e627
|