Skip to main content

Introduction

globexc is a library which makes the Python interpreter write a detailed stack trace if an unhandled exception occurs in a script. This trace is written to a separate file and includes, for each level of the stack, the values of local variables and a few lines of context code. This allows the developer to perform a basic post-mortem analysis of an error without having to recreate the scenario inside a debugger or using verbose logging.

The output is similar to the in-browser stack trace given by the Werkzeug or Django web frameworks but available to any Python program even if it’s not a web server.

Example

To generate a stack trace:

import globexc

# install the exception handler
globexc.init_globexc()

# cause an unhandled exception
a = 1 / 0

And the resulting terminal output:

CRITICAL Exception <type ‘exceptions.ZeroDivisionError’> (tests/sample.py:15) integer division or modulo by zero. Trace file written to ‘/home/user/trace.dump’.

And for the stack trace see https://github.com/mjem/globexc/blob/master/extra/trace.dump.

Installation

Install using setuptools:

python setup.py build
python setup.py install

Or from pypi:

pip install globexc

Usage

Call init_globexc() during program startup to install the global exception handler. The stack trace will then be generated when any unhandled exception occurs. The output works whether or not the Python logging system has been initialised.

Environment variables

You can set the following environment variable to configure the library:

GLOBEXC

Choose an alternative filename for stack traces.

Requirements

None

Compatibility

This code has been tested under Linux and using Python 2.7 only.

ChangeLog

0.1.1 (2013-11-11)

  • Fixed pypi index page

0.1 (2013-11-11)

  • Initial release

Release files for globexc 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for globexc 0.1.1
File Size Uploaded
globexc-0.1.1.tar.gz 10.9 kB Details

Release files / globexc-0.1.1.tar.gz

Download URL globexc-0.1.1.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a1c0b86046bfd5b5b5b6a9a1296008c6c391921f3f4d8c827dbdcc26114fe349
BLAKE2b-256 checksum
How to use checksums
dde5c63bd7cd330ef84cd000fecf06375ec4c06c566bccbe0ef345e1ce590c5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page