[C++-sig] What's wrong here? (BPL V2)
Dominic Sacré
bugcreator at gmx.de
Fri Jun 14 04:04:49 CEST 2002
On Friday 14 June 2002 02:44, David Abrahams wrote:
> <<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.
Well, I don't use handle_exception(), at least not directly.
I'm embedding Python in a C++ program, and not vice versa. I'm not quite
sure what the correct way to handle exceptions is in this case, but the
"usual" way won't work.
I was calling the extractor directly from C++, so there was no
handle_exception() involved, and the exception wasn't caught.
> <<<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.
Whoops :O
No wonder that handle<> didn't help... But borrow() solves the problem
indeed, the extractor works now!
Thanks,
Dominic
More information about the Cplusplus-sig
mailing list