Re: [Cython] Higher fidelity translations from C++ exception to Python exception?

2012-07-06 Thread Barry Warsaw
On Jul 06, 2012, at 11:59 PM, Dag Sverre Seljebotn wrote: >>The generated code does a `catch(...)` so you lose that useful information. >>AFAICT, there's no way to find out within the catch clause (or anything >>called by that clause) what C++ exception occurred. > >But that requires something mor

[Cython] Higher fidelity translations from C++ exception to Python exception?

2012-07-06 Thread Barry Warsaw
So if you have code like the following: cdef class Database: cdef open(self, path) except +raise_py_error: something_that_can_throw_a_cpp_exception(path) you can write cdef int raise_py_error(): raise Something to kind of turn a C++ exception into a Python exception. The proble

Re: [Cython] Odd behavior with std::string and .decode()

2012-07-06 Thread Barry Warsaw
Thanks for the follow up Stefan, On Jul 06, 2012, at 06:48 AM, Stefan Behnel wrote: >This is very weird behaviour indeed. I wouldn't know why that should >happen. What "return as_bytes.decode('utf-8')" does is that is calls >strlen() to see how long the string is, then it calls the UTF-8 decode >

[Cython] Odd behavior with std::string and .decode()

2012-07-05 Thread Barry Warsaw
I'm currently exploring using Cython to provide new Python 3 bindings for Xapian. I'm pretty much a Cython n00b but the documentation is great, and I was able to pretty quickly get something really simple working. I'm using Cython 0.15 on Ubuntu 12.04 with Python 3.2 and Xapian 1.2.12. I've push