[C++-sig] What's wrong here? (BPL V2)

David Abrahams david.abrahams at rcn.com
Fri Jun 14 02:44:46 CEST 2002


From: "Dominic Sacré" <bugcreator at gmx.de>

<<Ah, you're right, it's indeed an exception I didn't catch:
ReferenceError: Attempt to return dangling internal reference>>

That's still strange. What was the context? The built-in handle_exception()
function should have converted this to something visible in Python.

<<<Constructing an additional handle<> doesn't change anything, I still get
the same error...>>

First remember that a handle<> adopts by default; to get it to increment
the reference count you need to pass the PyObject* through the borrow()
function.

<<In which situations would no converter be registered? Or do I somehow
have
to register a converter myself? Should/could these not be registered
automatically, at least for simple classes?>>

No, it's not possible to determine how simple a class is and register
converters automatically on that basis

Converters are registered for classes declared with class_<>.
There are also built-in converters registered for complex<T> and
std::string, though not lvalue converters (these are converted to/from the
corresponding Python types).

-Dave







More information about the Cplusplus-sig mailing list