Patches item #1654974, was opened at 2007-02-08 09:46
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1654974&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nefarious CodeMonkey, Jr. (nejucomo)
Assigned to: Nobody/Anonymous (nobody)
Summary: sys.excepthook shows relevant bindings.

Initial Comment:
The attached module provides a suitable replacement for sys.excepthook to 
handle uncaught exceptions.

The output is the same, except after each source line shown, a list of relevant 
bindings is shown.

Here's a quick example from the tail end of a test:

  File "./test-exprann.py", line 16, in f
    assert c == 12
    # With bindings:
    # c = 42
AssertionError


The bindings shown are the intersection of the code object "co_names" and the 
non-keyword name tokens in the parsed source line.  The goal is to only show 
bindings relevant to the exception.

I hope the utility of this is self-evident to any programmer.  I tried testing 
it with crazy expressions containing nonfree bindings (such as lambda's and 
list comprehensions), so I think it behaves well in most circumstances.

The performance might be bad (it parses each line in the backtrace), but I 
figure it is worth it for uncaught exceptions.

Let me know if you find this tool useful.

Thanks,
Nejucomo

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1654974&group_id=5470
_______________________________________________
Patches mailing list
Patches@python.org
http://mail.python.org/mailman/listinfo/patches

Reply via email to