{ "info": { "author": "Michael Moser", "author_email": "moser.michael@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Topic :: Utilities" ], "description": "utilities for debugging of python scripts. prints stack backtraces that look similar to gdb stacktrace (gdb commands bt and bt full); \ncan be used instead of traceback.\n \nWritten by Michael Moser (c) 2015\n\nFunctions\n \t \t\ndie(*msg)\n receives a variable number of arguments; prints each argument (with pprint) to standard error stream, \n shows a detailed stack trace (also to standard error, see print_stack_ex, does not follow objects (follow_objects = 0); \n exit program with error (status 1)\n this is similar to die built in function in perl\n\ndie2(*msg)\n receives a variable number of arguments; prints each argument (with pprint) to standard error stream, \n shows a detailed stack trace (also to standard error, see print_stack_ex, does follow objects (follow_objects = 1); \n exit program with error (status 1)\n this is similar to die built in function in perl\n\nprint_exception_ex(follow_objects=0, file=None)\n prints an exception with more detailed stack trace, is used as follows:\n the function is similar to traceback.print_exception , just with more detailed stack trace\n \n import pd\n \n try:\n \n except BaseException: \n\tpd.print_exception_ex()\n\t \n\t\n\t parameters:\n\t \n\t follow_objects - if not 0 then representation of object values is printed \n\t Please note that follow_objects=1 can generate a lot of output, and can take a lot of time. (default 0)\n\t \n\t file - print to file (default value None - print to standard error stream)\n \n\t example stack trace:\n \n Exception: got it\n \n #1 def kuku2(self = {'a': 42, 'b': [1, 2, 3, 4]}, depth = 1) at test_pd.py:29\n Calls next frame at:\n\t raise Exception('got it') at: test_pd.py:29\n \n #2 def kuku2(self = {'a': 42, 'b': [1, 2, 3, 4]}, depth = 2) at test_pd.py:28\n Calls next frame at:\n\t kuku2( depth - 1 ) at: test_pd.py:28\n \n #3 def kuku2(self = {'a': 42, 'b': [1, 2, 3, 4]}, depth = 3) at test_pd.py:28\n Calls next frame at:\n\t kuku2( depth - 1 ) at: test_pd.py:28\n \n #4 def kuku2(self = {'a': 42, 'b': [1, 2, 3, 4]}, depth = 4) at test_pd.py:28\n Calls next frame at:\n\t kuku2( depth - 1 ) at: test_pd.py:28\n \n #5 def kuku2(self = {'a': 42, 'b': [1, 2, 3, 4]}, depth = 5) at test_pd.py:28\n Calls next frame at:\n\t kuku2( depth - 1 ) at: test_pd.py:28\n \n #6 def kuku2(self = {'a': 42, 'b': [1, 2, 3, 4]}, depth = 6) at test_pd.py:28\n Calls next frame at:\n\t kuku2( depth - 1 ) at: test_pd.py:28\n \n #7 def main() at test_pd.py:44\n Local variables:\n n = {'a': 42, 'b': [1, 2, 3, 4]}\n Calls next frame at:\n\t pd.print_exception_ex( follow_objects = 1 ) at: test_pd.py:44\n\n\nprint_stack_ex(skipframes=0, follow_objects=0, file=None, frame=None)\n\tprint stack trace from an arbitrary point in the program;\n the function is similar to traceback.print_stack , just with more detailed stack trace\n \n the stack trace includes function names, values of parameters and values of local variables. i find it easier to debug with this stack trace.\n \n parameters:\n skipframes - skip a number of frames if is not 0 (default 0)\n \n follow_objects - if not 0 then representation of object values is printed \n Please note that follow_objects=1 can generate a lot of output, and can take a lot of time. (default 0)\n \n file - print to file (default value None - print to standard error stream)\n \n frame - specify a start frame (default None - show from calling function; deepest frame on top marked with #1)\n \n this function is similar to traceback.print_stack , just with more detailed stack trace.\n \n works for python 2.7, should work for other versions as well\n \n example stack trace:\n\n #1 def fact(n = 1) at test_pd.py:10\n Local variables:\n loc 2\n loc2 [0]\n Calls next frame at:\n\t pd.print_stack_ex() at: test_pd.py:10\n \n #2 def fact(n = 2) at test_pd.py:8\n Local variables:\n loc 4\n loc2 [0, 1]\n Calls next frame at:\n\t return n * fact( n - 1 ) at: test_pd.py:8\n \n #3 def fact(n = 3) at test_pd.py:8\n Local variables:\n loc 6\n loc2 [0, 1, 2]\n Calls next frame at:\n\t return n * fact( n - 1 ) at: test_pd.py:8\n \n #4 def fact(n = 4) at test_pd.py:8\n Local variables:\n loc 8\n loc2 [0, 1, 2, 3]\n Calls next frame at:\n\t return n * fact( n - 1 ) at: test_pd.py:8\n \n #5 def main() at test_pd.py:36\n Local variables:\n Calls next frame at:\n\t print fact(4) at: test_pd.py:36\n \n #6 def () at test_pd.py:53\n Calls next frame at:\n\t main() at: test_pd.py:53", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://mosermichael.github.io/cstuff/all/projects/2015/02/24/python-backtrace.html", "keywords": "backtrace,debugging", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "pd", "package_url": "https://pypi.org/project/pd/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pd/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://mosermichael.github.io/cstuff/all/projects/2015/02/24/python-backtrace.html" }, "release_url": "https://pypi.org/project/pd/0.0.1/", "requires_dist": null, "requires_python": null, "summary": "more detailed python backtraces (similar to backtrace module)", "version": "0.0.1" }, "last_serial": 1475778, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "77b5423074655beb32863752cd87c000", "sha256": "8533b40173978f7b7be521bb6c92fd03c5af7cca3171e1eff02af0e213cfa480" }, "downloads": -1, "filename": "pd-0.0.1.tar.gz", "has_sig": false, "md5_digest": "77b5423074655beb32863752cd87c000", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5251, "upload_time": "2015-03-24T18:32:51", "url": "https://files.pythonhosted.org/packages/0e/35/38af4831c03c44765f7cd87e43ced67c000fa6673ef06739872de07eb00a/pd-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "77b5423074655beb32863752cd87c000", "sha256": "8533b40173978f7b7be521bb6c92fd03c5af7cca3171e1eff02af0e213cfa480" }, "downloads": -1, "filename": "pd-0.0.1.tar.gz", "has_sig": false, "md5_digest": "77b5423074655beb32863752cd87c000", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5251, "upload_time": "2015-03-24T18:32:51", "url": "https://files.pythonhosted.org/packages/0e/35/38af4831c03c44765f7cd87e43ced67c000fa6673ef06739872de07eb00a/pd-0.0.1.tar.gz" } ] }