Go Back   ZeroC Forums > Patches

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 08-19-2005
ckohnert ckohnert is offline
Registered User
 
 
Join Date: Aug 2005
Posts: 9
Patch to print traceback of python exceptions

Since python exceptions can occur for so many reasons in a complex setup, it's near impossible to track them down without a traceback. This patch simply hooks into the Ice exception catching to do a quick print to stderr before doing things normally.

I didn't add a config option because I'm not sure what sort of policies there are for choosing them (nor the best way to hook into it via the API). Something like Ice.Trace.UnknownExceptions=1 would be great to have for languages that can do it relatively easily (java and python that I know of).

(Diff generated against IcePy-2.1.2)
Attached Files
File Type: txt patch.txt (763 Bytes, 292 views)
Reply With Quote
  #2 (permalink)  
Old 08-19-2005
ckohnert ckohnert is offline
Registered User
 
 
Join Date: Aug 2005
Posts: 9
Ah, looks like those INCREFs aren't actually necessary (and causes a memory leak warning when you quit). Makes it even simpler without them:

Code:
if( <config trace option> )
{
   PyErr_Restore(t, val, tb);
   PyErr_Print();
}
Reply With Quote
  #3 (permalink)  
Old 08-19-2005
ckohnert ckohnert is offline
Registered User
 
 
Join Date: Aug 2005
Posts: 9
Mutter, okay, just got a seg fault that I cannot reproduce, so obviously one or more of the refs are needed (as I originally thought), but it's not obvious which. Ah well, I'll look again when I get some time.
Reply With Quote
  #4 (permalink)  
Old 08-20-2005
ckohnert ckohnert is offline
Registered User
 
 
Join Date: Aug 2005
Posts: 9
After looking at the python source, it looks like the proper way to do this is:

Code:
if( <print traceback> )
{
        Py_XINCREF(t);
        Py_XINCREF(val);
        Py_XINCREF(tb);
        PyErr_Restore(t, val, tb);
        PyErr_PrintEx(0);
}
The difference is in the last call which tells it not to 'save' the current exception values when printing them, thus allowing the ref counts to clear normally. Been using this for better part of a day now with no trouble.
Reply With Quote
  #5 (permalink)  
Old 09-09-2005
mes's Avatar
mes mes is online now
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 967
Hi Chris,

The next release will include a solution, but we're doing it a bit differently. If a server raises an unknown or invalid exception, the Ice run time returns Ice.UnknownException (or one of its derived types) to the client. This exception has a member named 'unknown' which can be used to provide additional information. IcePy will format the exception stack trace and include it in the 'unknown' member.

If you define the property Ice.Warn.Dispatch=1, the Ice run time will display these unknown exceptions automatically (including the 'unknown' member). The stack trace information is also available to the client.

Take care,
- Mark
Reply With Quote
  #6 (permalink)  
Old 09-09-2005
ckohnert ckohnert is offline
Registered User
 
 
Join Date: Aug 2005
Posts: 9
Quote:
Originally Posted by mes
The next release will include a solution, but we're doing it a bit differently.
That works too. Good stuff! It was/is darn hard to debug this stuff otherwise.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
C# exceptions wrobbie Help Center 7 09-25-2005 07:03 PM
Catching Exceptions chuatecksiong Help Center 3 04-06-2005 01:02 PM
Exceptions cannot be unmarshalled on client robert Bug Reports 4 10-17-2004 11:46 PM
Classes vs. Exceptions andreynech Comments 7 02-28-2003 10:12 AM


All times are GMT -4. The time now is 12:47 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.