
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
I find the supplied python traceback facilities quite awkward. These functions provide convenient facilities.
Latest release 20250724: frames: tweak the exception frame access.
Short summary:
caller
: Return the Frame
of the caller's caller. Returns None
if frame_index
is out of range.frames
: Return the current stack as a StackSummary
instance, a list of FrameSummary
instances.stack_dump
: Recite current or supplied stack to f
, default sys.stderr
.Module contents:
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 invokerThe default from_index
value is -3
.
frames(source=None, limit=None)
: Return the current stack as a StackSummary
instance, a list
of FrameSummary
instances. Crop the returned list at limit
if it is not None
.
If source
is omitted or None
, obtain the source stack
from traceback.extract_stack()
.
Otherwise if source
has a .tb_frame
attribute (like a
traceback
object) or source
has a .__traceback__
attribute
(like an exception), call traceback.extract_stack
with that
to obtain the source stack.
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, default sys.stderr
indent
: how many spaces to indent the stack lines, default 0
summary
: the stack Frame
s to write,
default obtained from the current stackskip
: the number of Frame
s to trim from the end of summary
;
if summary
is None
this defaults to 2
to trim the Frame
s
for the stack_dump
function and its call to frames()
,
otherwise the default is 0
to use the supplied Frame
s as isselect
: if not None
, select particular frames;
if select
is a str
it must be present in the frame filename;
otherwise select(frame)
must be trueRelease 20250724: frames: tweak the exception frame access.
Release 20250306: frame: accept an optional traceback object or exception as a source from which to obtain the stack, add optional limit to crop the stack.
Release 20240630:
Release 20240519: Drop Frame.funcname property.
Release 20240412:
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:
Release 20160827: Add stack_dump().
Release 20150115: PyPI metadata fixups.
Release 20150111: Tag for initial PyPI release of cs.py.stack.
FAQs
Convenience functions for the python execution stack.
We found that cs-py-stack demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.