Skip to main content

Display helpful information for debbugging in case of errors/exceptions

Project description

tbdump Package

tbdump - display helpful information for debbugging in case of errors/exceptions

DESCRIPTION

This manual page documents tbdump module, a Python module that displays detailed information, which should be useful for debugging, when the Python interpreter is aborted due to errors or traps.

Python displays minimal information in case of errors such as the type of exception and the line number of the source code where the program execution is terminated. tbdump replaces the Python's hook sys.excepthook which will be called when an exception is occured, so that more detailed information on the program status (i.e., the location at which the exception occurred, all variables and objects as well as their attributes defined in the scope), which significantly helps your debugging.

Also, at the exception, tbdump invokes pdb, Python debugger. So, you can freely examine the state of the program using many pdb debugger commands.

EXAMPLE

By default, Python tells little about the error.

test.py:

import sys
from collections import namedtuple

Record = namedtuple('Record', 'name year size note')
x = Record('John', 2019, 123, 'Good')
y = Record('Mike', 2018, 456)
$ python3 test.py
Traceback (most recent call last):
  File "test.py", line 6, in <module>
    y = Record('Mike', 2018, 456)
TypeError: __new__() missing 1 required positional argument: 'note'

With tbdump, you can have details.

test-tbdump.py:

import sys
from collections import namedtuple

import tbdump

Record = namedtuple('Record', 'name year size note')
x = Record('John', 2019, 123, 'Good')
y = Record('Mike', 2018, 456)
$ python3 test-tbdump.py
---- <module> /tmp/foo.py
    4 import tbdump
    5 
    6 Record = namedtuple('Record', 'name year size note')
    7 x = Record('John', 2019, 123, 'Good')
    8 y = Record('Mike', 2018, 456)
              Record = <class '__main__.Record'>
                     _asdict <function Record._asdict at 0x7ffff7383ee0>
             _field_defaults {}
                     _fields ('name', 'year', 'size', 'note')
                       _make <classmethod object at 0x7ffff737b970>
                    _replace <function Record._replace at 0x7ffff7383dc0>
                        name _tuplegetter(0, 'Alias for field number 0')
                        note _tuplegetter(3, 'Alias for field number 3')
                        size _tuplegetter(2, 'Alias for field number 2')
                        year _tuplegetter(1, 'Alias for field number 1')
                     __doc__ 'Record(name, year, size, note)'
              __getnewargs__ <function Record.__getnewargs__ at 0x7ffff7383f70>
                  __module__ '__main__'
                     __new__ <staticmethod object at 0x7ffff737b8e0>
                    __repr__ <function Record.__repr__ at 0x7ffff7383e50>
                   __slots__ ()
          namedtuple = <function namedtuple at 0x7ffff752e3a0>
                 sys = ...
              tbdump = ...
                   x = Record(name='John', year=2019, size=123, note='Good')
     __annotations__ = {}
        __builtins__ = ...
          __cached__ = None
             __doc__ = None
            __file__ = '/tmp/foo.py'
          __loader__ = <_frozen_importlib_external.SourceFileLoader object at 0x7ff...
                        name '__main__'
                        path '/tmp/foo.py'
            __name__ = '__main__'
         __package__ = None
            __spec__ = None
TypeError: <lambda>() missing 1 required positional argument: 'note'

> /tmp/foo.py(8)<module>()
-> y = Record('Mike', 2018, 456)

You are now in the pdb debugger. You can examine the internals:

(Pdb) x
Record(name='John', year=2019, size=123, note='Good')
(Pdb) x.name
'John'
(Pdb) Record
<class '__main__.Record'>
(Pdb) list
  3  	
  4  	import tbdump
  5  	
  6  	Record = namedtuple('Record', 'name year size note')
  7  	x = Record('John', 2019, 123, 'Good')
  8  ->	y = Record('Mike', 2018, 456)
[EOF]
(Pdb) 

INSTALLATION

pip3 install tbdump

AVAILABILITY

The latest version of tbdump module is available at PyPI (https://pypi.org/project/tbdump/) .

SEE ALSO

pdb - The Python Debugger (https://docs.python.org/3.7/library/pdb.html)

traceback - Print or retrieve a stack traceback (https://docs.python.org/3.7/library/traceback.html)

AUTHOR

Hiroyuki Ohsaki <ohsaki[atmark]lsnl.jp>

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

tbdump-1.4.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

tbdump-1.4-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file tbdump-1.4.tar.gz.

File metadata

  • Download URL: tbdump-1.4.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for tbdump-1.4.tar.gz
Algorithm Hash digest
SHA256 f002f49dfbea446e276ccd468292300001da82e59b495b15f697ecd03eacc491
MD5 daedb9e3a4f514a17d91b0e7ec72c7e1
BLAKE2b-256 641239aee77422a9917f05cd95acc247534afaac7ccb4509034ab889911b3085

See more details on using hashes here.

File details

Details for the file tbdump-1.4-py3-none-any.whl.

File metadata

  • Download URL: tbdump-1.4-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for tbdump-1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 542f010dcec9c7c0fa589d8f15c2d5d4fb7deb6b86808a39796bbd7808bbad6f
MD5 6b07bfd3a2efcec3817bcda52f6bbdc2
BLAKE2b-256 054e38590a33d1d17deb89188655e5b188c4d75d968f68cdcc7374283b162107

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page