I find the supplied python traceback facilities quite awkward.
These functions provide convenient facilities.
*Latest release 20240412*:
* stack_dump: new select parameter to pick interesting frames for the listing.
* Provide StackSummary and FrameSummary if Python too old.
## 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 `Frame`s to write,
default obtained from the current stack
* `skip`: the number of `Frame`s to trim from the end of `frames`;
if `frames` 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 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/f5/03/8ede2fc10ea7e2573112fae8fb44c4866acd6fc0b10c0dde29920a5fc1da/cs.py.stack-20240412.tar.gz",
"platform": null,
"description": "I find the supplied python traceback facilities quite awkward.\nThese functions provide convenient facilities.\n\n*Latest 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## 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 list of `Frame` objects.\n\n## Function `stack_dump(f=None, indent=0, frames=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* `frames`: 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 `frames`;\n if `frames` 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 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\n",
"bugtrack_url": null,
"license": "GNU General Public License v3 or later (GPLv3+)",
"summary": "Convenience functions for the python execution stack.",
"version": "20240412",
"project_urls": {
"URL": "https://bitbucket.org/cameron_simpson/css/commits/all"
},
"split_keywords": [
"python2",
" python3"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3a0bde02e3753a060a987a17472dbdbf846b4168d72d9f01e5f165c50a76144c",
"md5": "9f325f4f3204e1187748484bc261fba9",
"sha256": "cf1b9d706e40f4a79ba23cc7b92123a4b9e448397b76208279eeb521ddc8656c"
},
"downloads": -1,
"filename": "cs.py.stack-20240412-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9f325f4f3204e1187748484bc261fba9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 3978,
"upload_time": "2024-04-12T02:36:11",
"upload_time_iso_8601": "2024-04-12T02:36:11.677640Z",
"url": "https://files.pythonhosted.org/packages/3a/0b/de02e3753a060a987a17472dbdbf846b4168d72d9f01e5f165c50a76144c/cs.py.stack-20240412-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f5038ede2fc10ea7e2573112fae8fb44c4866acd6fc0b10c0dde29920a5fc1da",
"md5": "1975628a586bdf5dc1d68d0cb2fe7054",
"sha256": "aa84eab63100e375fc286626b68b3c8b4c09db101d52b6572ae98835c3c16870"
},
"downloads": -1,
"filename": "cs.py.stack-20240412.tar.gz",
"has_sig": false,
"md5_digest": "1975628a586bdf5dc1d68d0cb2fe7054",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3745,
"upload_time": "2024-04-12T02:36:13",
"upload_time_iso_8601": "2024-04-12T02:36:13.579803Z",
"url": "https://files.pythonhosted.org/packages/f5/03/8ede2fc10ea7e2573112fae8fb44c4866acd6fc0b10c0dde29920a5fc1da/cs.py.stack-20240412.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-12 02:36:13",
"github": false,
"gitlab": false,
"bitbucket": true,
"codeberg": false,
"bitbucket_user": "cameron_simpson",
"bitbucket_project": "css",
"lcname": "cs.py.stack"
}