[C++-sig] [boost.python] PyErr_Fetch and object

Olaf Peter ope-devel at gmx.de
Thu Aug 28 07:25:23 CEST 2008


>> Maybe I have to wrap this
>> after calling PyErr_Fetch?
>>   
> Yes. Something like this should work:
> 
> namespace boost
> {
> namespace python
> {
> void fetch_error(object &type, object &value, object &traceback)
> {
>  PyObject *t, *v, *b;
>  PyErr_Fetch(&t, &v, &b);
>  type = detail::new_reference(t);
>  value = v ? detail::new_reference(v) : object();
>  traceback = b ? detail::new_reference(b) : object();
> }
> }
> }
> 
> (There are more functions like this that could be added. Some day I'll 
> submit a new patch...

Thanks, would be great. Anyway, In the source of boost.python I saw a 
lot of used detail::.. stuff. The raw:pyobject header says this are to 
hide to the user. What are the correspondent user functions for
new_reference, borrowed_reference and new_non_null_reference which are 
more in common sense of the python C/API documentation.

Thanks,
Olaf





More information about the Cplusplus-sig mailing list