C built and raised exceptions are not being catched in Python code

Vinko Vrsalovic vinko at cprsig.cl
Wed Feb 26 18:03:23 EST 2003


On Wed, Feb 26, 2003 at 02:09:10PM -0800, A. Lloyd Flanagan wrote:
> WP <warrenpstma at _______.com.hotmail> wrote in message news:<b087a.5600$kf7.658052 at news20.bellglobal.com>...
> > > 
> > > 	Of course, I'd like to catch C raised exceptions in Python
> > > 	code also, but I don't see what might be failing.
> > 
> > 
> > What do you mean, raise exception in C? Do you mean return a NULL from a method in a C extension?
> > In C you have return codes of NULL. Any time you return NULL, an exception is raised. You set
> > the exception type (global) and return NULL.
> > 
> > Warren
> 
> It sounds to me like he means raising a C++ exception with the throw
> statement.  People tend to say 'C' when they mean 'C++', it causes a
> lot of confusion.
 
I know :-). But right now I'm not using C++ exceptions that's why I
didn't make a difference I'm using plain C/Python API, as in the
response to WP I tried to explain
 
 
> So what you'll have to do is catch your exception, set the global
> value, and return a NULL (0) from your method.  Of course, if you want
> to extend python to catch C++ exceptions, I'm sure many people would
> appreciate it. :)

I'm certainly missing this 'global value' issue...Doesn't
PyErr_SetString() set the global value? Is there somehing else besides
that call that needs to be done?

Thanks for your patience :)
-- 
Vinko Vrsalovic <el[|- at -|]vinko.cl>
http://www.cprsig.cl





More information about the Python-list mailing list