I find the supplied python traceback facilities quite awkward. These functions provide convenient facilities.
Latest release 20240630:
- The fallback StackSummary: add format_frame_summary(frame) static method.
- stack_dump: updates to avoid a name conflict, expect to work off a StackSummary or a list of frames.
Function caller(frame_index=-3)
Return the Frame of the caller's caller.
Returns None if frame_index is out of range.
Useful frame_index values:
-1: caller, this function-2: invoker, who wants to know the caller-3: the calling function of the invoker
The default from_index value is -3.
Function frames()
Return the current stack as a StackSummary instance, a list
of FrameSummary instances.
Function stack_dump(f=None, indent=0, summary=None, skip=None, select=None, format_frame=None)
Recite current or supplied stack to f, default sys.stderr.
Parameters:
f: the output file object, defaultsys.stderrindent: how many spaces to indent the stack lines, default0summary: the stackFrames to write, default obtained from the current stackskip: the number ofFrames to trim from the end ofsummary; ifsummaryisNonethis defaults to2to trim theFrames for thestack_dumpfunction and its call toframes(), otherwise the default is0to use the suppliedFrames as isselect: if notNone, select particular frames; ifselectis astrit must be present in the frame filename; otherwiseselect(frame)must be true
Release Log
Release 20240630:
- The fallback StackSummary: add format_frame_summary(frame) static method.
- stack_dump: updates to avoid a name conflict, expect to work off a StackSummary or a list of frames.
Release 20240519: Drop Frame.funcname property.
Release 20240412:
- stack_dump: new select parameter to pick interesting frames for the listing.
- Provide StackSummary and FrameSummary if Python too old.
Release 20220918: caller(): return None if the frame offset is out of range.
Release 20220429: caller: return None if the stack index is out of range.
Release 20190812: stack_dump(): trim the last 2 frames from the listing by default (they are part of stack_dump's implementation).
Release 20190101:
- _Frame: rename .functionname to .funcname; caller: turn raw frames into Frames.
- caller(): accept optional frame_index, default -3.
Release 20160827: Add stack_dump().
Release 20150115: PyPI metadata fixups.
Release 20150111: Tag for initial PyPI release of cs.py.stack.
Release files for cs-py-stack 20240630
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cs.py.stack-20240630.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cs.py.stack-20240630-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.4 kB
Release files / cs.py.stack-20240630.tar.gz
| Download URL | cs.py.stack-20240630.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
edaf11737c330a52f5d6c6e493e174b75ade23d13d6779bed4e6c0a14a15ecac
|
|
BLAKE2b-256 checksum How to use checksums |
307a061b660de22c558690284561078c7ff936ab2b8bf47789659a9ce9b35fb8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Release files / cs.py.stack-20240630-py3-none-any.whl
| Download URL | cs.py.stack-20240630-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d81a19d058a981cb5a882e7b978642e461b3a9a0ad9ee1cb86645c0b704d1e8
|
|
BLAKE2b-256 checksum How to use checksums |
d8a07772770b2216ec787f91e50d40f21ddf33bc1b11617d2c3089d617883288
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|