Skip to main content

traceback with more exact location info

Project description

CI status PyPI Installs Supported Python Versions


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:

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 runtime

Some example output given by running code in example:

Division example:

Traceback (most recent call last):
  File "", line 9, in <module> at offset 52
    a / b / c
    a / b / c
ZeroDivisionError: float division by zero

List comprehension example:

File "", line 9, in <listcomp> 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:

Traceback (most recent call last):
 File "", line 11, in <module> at offset 39
  File "<string>", line 4, in <module> at offset 18
  z = x / y
  ZeroDivisionError: division by zero

Isolating function in call stack example:

File "", line 8, in fib at offset 58
  return fib(n-1) + fib(n-2)
  return fib(n - 1) + fib(n - 2)
    File "", line 10, in <module> 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.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

loctraceback-1.1.1.tar.gz (24.3 kB view hashes)

Uploaded source

Built Distributions

loctraceback-1.1.1-py37-none-any.whl (12.8 kB view hashes)

Uploaded py37

loctraceback-1.1.1-py35-none-any.whl (12.8 kB view hashes)

Uploaded py35

loctraceback-1.1.1-py34-none-any.whl (12.8 kB view hashes)

Uploaded py34

loctraceback-1.1.1-py33-none-any.whl (14.8 kB view hashes)

Uploaded py33

loctraceback-1.1.1-py3.8.egg (25.5 kB view hashes)

Uploaded 3 8

loctraceback-1.1.1-py3.7.egg (25.4 kB view hashes)

Uploaded 3 7

loctraceback-1.1.1-py3.6.egg (25.4 kB view hashes)

Uploaded 3 6

loctraceback-1.1.1-py3.5.egg (25.8 kB view hashes)

Uploaded 3 5

loctraceback-1.1.1-py3.4.egg (25.9 kB view hashes)

Uploaded 3 4

loctraceback-1.1.1-py3.3.egg (26.1 kB view hashes)

Uploaded 3 3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page