how to add_exception with inheritance
Hello all,
I'm trying to understand the correct syntax for exceptions that inherit from other exceptions.
Do you think that this pybindgen code
std_
module.
is a proper description for this header?
-------
#include <exception>
#include <stdexcept>
namespace gdf {
namespace exception
{
class general : public std::exception
{
------------ ... ---------------
With this code, I am getting errors as follows:
>>> looking at class gdf::exception:
C:\libgdf\
{
Any thoughts on whether that is related or unrelated to add_exception statements?
Thanks and regards,
Owen
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- PyBindGen Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Owen Kelly
- Solved:
- Last query:
- Last reply:
Related bugs
Related FAQ:
None Link to a FAQ
Revision history for this message
|
#1 |
Sorry, the problem is that gccxmlparser is like a layer on top of pybindgen, and has its own separate type registry.
If parser is the ModuleParser object, you should register any manually defined classes with it, thus:
where class_wrapper is the object returned by module.
Revision history for this message
|
#2 |
Thank you for that suggestion.
Changing my code to
std_
general_
module_
module_
The error (on the first pass of workflow 3) becomes
Traceback (most recent call last):
File "..\exc_
my_module_gen()
File "..\exc_
module_
File "C:\Python26\
if isinstance(
AttributeError: 'CppException' object has no attribute 'gccxml_definition'
Which class do you think gccxml has not seen, the base, or the derived? Hmm...
The error is similar regardless of which of the two class_registered calls are used above (or both, as shown).
Owen
-------- full traceback -------
C:\Python26\
import md5
INFO Parsing source file "C:\Users\
INFO gccxml cmd: ""C:\Program Files (x86)\gccxml 0.9\bin\gccxml.exe" -I"." -I"C:\Users\
INFO GCCXML version - 0.9
C:\Python26\
warnings.warn( msg )
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class gdf::exception:
C:\Users\
{
>>> looking at class std::bad_alloc [class]
>>> class std::bad_alloc [class] is being postponed (waiting for base class std::exception [class] to be registered first)
>>> looking at class std::bad_exception [class]
>>> class std::bad_exception [class] is being postponed (waiting for base class std::exception [class] to be registered first)
>>> looking at class std::domain_error [class]
>>> class std::domain_error [class] is being postponed (waiting for base class std::logic_error [class] to be registered first)
>>> looking at class std::exception [class]
>>> looking at class std::invalid_
>>> class std::invalid_
>>> looking at class std::length_error [class]
>>> class std::length_error [class] is being postponed (waiting for base class std::logic_error [class] to be registered first)
>>> looking at class std::logic_error [class]
>>> looking at class std::out_of_range [class]
>>> looking at class std::overflow_error [class]
>>> class std::overflow_error [class] is being postponed (waiting for base class std::runtime_error [class] to be registered first)
>>> looking at class std::range_error [class]
>>> class std::range_error [class] is being postponed (waiting for base class std::runtime_error [class] to be registered first)
>>> looking at class std::runtime_error [class]
>>> looking at class std::underflow_
>>> looking at class std::bad_alloc [class]
>>> looking at class std::bad_exception [class]
>>> looking at class std::domain_error [class]
>>> looking at class std::invalid_
>>> looking at class std::length_error [class]
>>> looking at class std::overflow_error [class]
>>> looking at class std::range_error [class]
Traceback (most recent call last):
File "..\exc_
my_module_gen()
File "..\exc_
module_
File "C:\Python26\
if isinstance(
AttributeError: 'CppException' object has no attribute 'gccxml_definition'
Revision history for this message
|
#3 |
*sigh* sorry, I tried to help, but I didn't fully check it. I guess pybindgen would need a bit of hacking to allow manually registered classes to be used as base classes for automatically scanned ones. My advice is to manually register the whole hierarchy of C++ exception classes, and forget about the parser.
Revision history for this message
|
#4 |
Hi Gustavo,
Your information is a big help. Please help me understand your advice:
By the "whole hierarchy of C++ exceptions", do you mean
<include/stdexcept> + <include/exception> OR
<include/stdexcept> + <include/exception> + <libgdf/
(Exception.h is all my exceptions that inherit from the standard exception.)
By "manually registered", do you mean using statements like this (and using Workflow 3)? :
std_
module.
Or by "manually", do you mean Workflow 1?
Thanks,
Owen
Revision history for this message
|
#5 |
I mean the module.
Revision history for this message
|
#6 |
Hi Gustavo,
I tried a few variations, and the solution seems beyond my current understanding.
So I have reduced the problem to the minimum setup and captured that information in a bug (1044185) that is linked to this Answer.
The problem is not solved, but further discussion should be in bug 1044185, so I will mark this questions as "Problem Solved".
Many thanks for the time you have spent on this issue.
Regards,
Owen