Boost logo

Boost :

Subject: [boost] [Python] Improved exception handling for Python embedding
From: Michael Koenig (michael.koenig_at_[hidden])
Date: 2014-08-01 07:40:19


Hey guys!

Boost.Python throws boost::python::error_already_set exceptions whenever
calls to embedding functions such as boost::python::import() or
boost::python::exec() fail.

This exception is just an empty class. It does not provide any
information on the error which occurred on the Python side. It is not
even a standard exception in the C++ sense.

As a result, debugging problems with embedded Python code or even the
Python environment (available packages etc.) with the current exception
handling mechanism is difficult. So far, in our company we wrap most
Boost.Python functions with custom exception handling code.

In our exception handling code, we basically work the CPython API to
extract details of Python exceptions such as
* Exception types,
* Error messages, and
* Stack traces.

We want to put this part of our embedding library back into the
Boost.Python project. At the EuroPython 2014 conference in Berlin, I had
a few discussions with Reinhard Wobst, Austin Bingham, and others, and
the current exception handling mechanism was perceived an impediment on
the usability of Boost.Python.

I am most grateful for feedback of seasoned Boost contributors (and
users) whether my proposal is of sufficient interest and how best to
pursue it.

Cheers

Michael

-- 
Dr. Michael König
Software Engineer
Blue Yonder GmbH
Ohiostraße 8
76149 Karlsruhe
Tel +49 (0) 721 383 117 38
Fax +49 (0) 721 383 117 69
michael.koenig_at_[hidden]
www.blue-yonder.com
Registergericht Mannheim, HRB 704547
USt-IdNr. DE 277 091 535
Geschäftsführer: Jochen Bossert, Uwe Weiss (CEO)

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk