https://github.com/rocky/python-loctraceback
Python 3.6 API traceback module adding in fragment decomplation info for more precise location information
https://github.com/rocky/python-loctraceback
Last synced: about 12 hours ago
JSON representation
Python 3.6 API traceback module adding in fragment decomplation info for more precise location information
- Host: GitHub
- URL: https://github.com/rocky/python-loctraceback
- Owner: rocky
- Created: 2018-02-15T17:04:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-11-07T09:12:43.000Z (over 3 years ago)
- Last Synced: 2025-05-12T06:25:26.143Z (about 2 months ago)
- Language: Python
- Size: 66.4 KB
- Stars: 4
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
|CI status| |PyPI Installs| |Supported Python Versions|
loctraceback
============Want to see more precisely where you are or were at in a traceback or
callstack your Python code has several places in a line it could have
errored? Even if the code was something created at runtime with say
`eval` or `exec` or if there was no source code that can be found?Then this package is for you.
Some examples of the kinds of code this module can disambiguate:
.. code-block:: python
i / j / k # which divide?
prev[prev[0]] # which prev ?
[e[0] for i in d[j] if got[i] == e[i]] # lots going on here
exec(some_code % 10, namespace) # code at runtimeSome example output given by running code in `example`:
Division example:
.. code-block:: python
Traceback (most recent call last):
File "tb-div.py", line 9, in at offset 52
a / b / c
a / b / c
-
ZeroDivisionError: float division by zeroList comprehension example:
.. code-block:: python
File "tb-comp.py", line 9, in at offset 18
[e[0] for i in d[j] if got[i] == e[i]]
return [ e[0] for i in .0 if got[i] == e[i] ]
------
IndexError: list index out of range`exec` example:
.. code-block:: python
Traceback (most recent call last):
File "tb-exec.py", line 11, in at offset 39
exec(s)
exec(s)
-------
File "", line 4, in at offset 18
z = x / y
-
ZeroDivisionError: division by zeroIsolating function in call stack example:
.. code-block:: python
File "call-fib.py", line 8, in fib at offset 58
return fib(n-1) + fib(n-2)
return fib(n - 1) + fib(n - 2)
----------
File "call-fib.py", line 10, in at offset 54
print("fib({})={}".format(2, fib(2)))
------This modules extends the Python 3.6 API traceback module by adding in
fragment decomplation info for more precise location information.Although the API is from Python 3.6, the code runs on 3.3 or greater.
Back-porting to ther Python versions is left as an exercise to the
reader.See `these slides `_ for
information on the technology behind this... |PyPI Installs| image:: https://pepy.tech/badge/loctraceback
.. |Supported Python Versions| image:: https://img.shields.io/pypi/pyversions/loctraceback.svg
.. |CI status| image:: https://github.com/rocky/python-loctraceback/workflows/loctraceback%20(ubuntu)/badge.svg