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 <code[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.6.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tbdump-1.6-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tbdump-1.6.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for tbdump-1.6.tar.gz
Algorithm Hash digest
SHA256 8689d31dbf0b3dcb24b5a615890e2ee325a6bafec54f82929ab7539f3cd961ed
MD5 96294970e08b5730de5abb6faf63242c
BLAKE2b-256 3f765bcfb64b8ecef4b82365b6c54e5e135895e5dadb70f984e5d9b6af947660

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tbdump-1.6-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for tbdump-1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 40006a374b87d5635aca7dcd17d0bbd813dc9f66d41a8c7cdc240c48eeab4a3d
MD5 c596a3c73e6e512d297e02866d9004e2
BLAKE2b-256 2f31b580a0855e8c8602282decac22088c67c187a9456e4b4c4a1b7b4897e220

See more details on using hashes here.

Supported by

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