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, 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 stack
* `skip`: 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 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 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.
Raw data
{
"_id": null,
"home_page": null,
"name": "cs.py.stack",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python2, python3",
"author": null,
"author_email": "Cameron Simpson <cs@cskk.id.au>",
"download_url": "https://files.pythonhosted.org/packages/30/7a/061b660de22c558690284561078c7ff936ab2b8bf47789659a9ce9b35fb8/cs.py.stack-20240630.tar.gz",
"platform": null,
"description": "I find the supplied python traceback facilities quite awkward.\nThese functions provide convenient facilities.\n\n*Latest release 20240630*:\n* The fallback StackSummary: add format_frame_summary(frame) static method.\n* stack_dump: updates to avoid a name conflict, expect to work off a StackSummary or a list of frames.\n\n## Function `caller(frame_index=-3)`\n\nReturn the `Frame` of the caller's caller.\nReturns `None` if `frame_index` is out of range.\n\nUseful `frame_index` values:\n* `-1`: caller, this function\n* `-2`: invoker, who wants to know the caller\n* `-3`: the calling function of the invoker\n\nThe default `from_index` value is `-3`.\n\n## Function `frames()`\n\nReturn the current stack as a `StackSummary` instance, a list\nof `FrameSummary` instances.\n\n## Function `stack_dump(f=None, indent=0, summary=None, skip=None, select=None, format_frame=None)`\n\nRecite current or supplied stack to `f`, default `sys.stderr`.\n\nParameters:\n* `f`: the output file object, default `sys.stderr`\n* `indent`: how many spaces to indent the stack lines, default `0`\n* `summary`: the stack `Frame`s to write,\n default obtained from the current stack\n* `skip`: the number of `Frame`s to trim from the end of `summary`;\n if `summary` is `None` this defaults to `2` to trim the `Frame`s\n for the `stack_dump` function and its call to `frames()`,\n otherwise the default is `0` to use the supplied `Frame`s as is\n* `select`: if not `None`, select particular frames;\n if `select` is a `str` it must be present in the frame filename;\n otherwise `select(frame)` must be true\n\n# Release Log\n\n\n\n*Release 20240630*:\n* The fallback StackSummary: add format_frame_summary(frame) static method.\n* stack_dump: updates to avoid a name conflict, expect to work off a StackSummary or a list of frames.\n\n*Release 20240519*:\nDrop Frame.funcname property.\n\n*Release 20240412*:\n* stack_dump: new select parameter to pick interesting frames for the listing.\n* Provide StackSummary and FrameSummary if Python too old.\n\n*Release 20220918*:\ncaller(): return None if the frame offset is out of range.\n\n*Release 20220429*:\ncaller: return None if the stack index is out of range.\n\n*Release 20190812*:\nstack_dump(): trim the last 2 frames from the listing by default (they are part of stack_dump's implementation).\n\n*Release 20190101*:\n* _Frame: rename .functionname to .funcname; caller: turn raw frames into Frames.\n* caller(): accept optional frame_index, default -3.\n\n*Release 20160827*:\nAdd stack_dump().\n\n*Release 20150115*:\nPyPI metadata fixups.\n\n*Release 20150111*:\nTag for initial PyPI release of cs.py.stack.\n",
"bugtrack_url": null,
"license": "GNU General Public License v3 or later (GPLv3+)",
"summary": "Convenience functions for the python execution stack.",
"version": "20240630",
"project_urls": {
"MonoRepo Commits": "https://bitbucket.org/cameron_simpson/css/commits/branch/main",
"Monorepo Git Mirror": "https://github.com/cameron-simpson/css",
"Monorepo Hg/Mercurial Mirror": "https://hg.sr.ht/~cameron-simpson/css",
"Source": "https://github.com/cameron-simpson/css/blob/main/lib/python/cs/py/stack.py"
},
"split_keywords": [
"python2",
" python3"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d8a07772770b2216ec787f91e50d40f21ddf33bc1b11617d2c3089d617883288",
"md5": "1e1b0ce177c368398b5dc66b0715a5ec",
"sha256": "6d81a19d058a981cb5a882e7b978642e461b3a9a0ad9ee1cb86645c0b704d1e8"
},
"downloads": -1,
"filename": "cs.py.stack-20240630-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1e1b0ce177c368398b5dc66b0715a5ec",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4285,
"upload_time": "2024-06-30T01:09:18",
"upload_time_iso_8601": "2024-06-30T01:09:18.259473Z",
"url": "https://files.pythonhosted.org/packages/d8/a0/7772770b2216ec787f91e50d40f21ddf33bc1b11617d2c3089d617883288/cs.py.stack-20240630-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "307a061b660de22c558690284561078c7ff936ab2b8bf47789659a9ce9b35fb8",
"md5": "02bf238bbe54dc418028245efe08c167",
"sha256": "edaf11737c330a52f5d6c6e493e174b75ade23d13d6779bed4e6c0a14a15ecac"
},
"downloads": -1,
"filename": "cs.py.stack-20240630.tar.gz",
"has_sig": false,
"md5_digest": "02bf238bbe54dc418028245efe08c167",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4077,
"upload_time": "2024-06-30T01:09:19",
"upload_time_iso_8601": "2024-06-30T01:09:19.666470Z",
"url": "https://files.pythonhosted.org/packages/30/7a/061b660de22c558690284561078c7ff936ab2b8bf47789659a9ce9b35fb8/cs.py.stack-20240630.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-30 01:09:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cameron-simpson",
"github_project": "css",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "cs.py.stack"
}