Skip to main content

I find the supplied python traceback facilities quite awkward. These functions provide convenient facilities.

Latest release 20240519: Drop Frame.funcname property.

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 list of Frame objects.

Function stack_dump(f=None, indent=0, frames=None, skip=None, select=None, format_frame=None)

Recite current or supplied stack to f, default sys.stderr.

Parameters:

  • f: the output file object, default sys.stderr
  • indent: how many spaces to indent the stack lines, default 0
  • frames: the stack Frames to write, default obtained from the current stack
  • skip: the number of Frames to trim from the end of frames; if frames is None this defaults to 2 to trim the Frames for the stack_dump function and its call to frames(), otherwise the default is 0 to use the supplied Frames as is
  • select: if not None, select particular frames; if select is a str it must be present in the frame filename; otherwise select(frame) must be true

Release Log

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 20240519

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cs-py-stack 20240519
File Size Uploaded
cs.py.stack-20240519.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cs-py-stack 20240519
File Interpreter ABI Platform
cs.py.stack-20240519-py3-none-any.whl Python 3 none any Details

Total release size: 7.7 kB

Release files / cs.py.stack-20240519.tar.gz

Download URL cs.py.stack-20240519.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d310a0e5c7bd0300bc6486ff36c372c1224d39b3ae15715b73851f12bd64b9ed
BLAKE2b-256 checksum
How to use checksums
7779aae81d834d7e0c0d8e5a8249f915736e661dc53e2eda3b25c5f36d07eb84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.6

Release files / cs.py.stack-20240519-py3-none-any.whl

Download URL cs.py.stack-20240519-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e6255f9efb1c8f2cc44f71c57b2ea567dd22c1e35ef0e9d751c592d2044ccc48
BLAKE2b-256 checksum
How to use checksums
b2090c2c0b1bfec0d757f7171790a299f016a6a4e11a8ccc772ce08f2ddcce09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.6

Release history Release notifications | RSS feed

This release

20240519 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page