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

2012-07-06 Thread Robert Bradshaw
On Fri, Jul 6, 2012 at 3:05 PM, Barry Warsaw wrote: > 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

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

2012-07-06 Thread Stefan Behnel
Barry Warsaw, 06.07.2012 16:21: > 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 t

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

2012-07-06 Thread Stefan Behnel
Barry Warsaw, 06.07.2012 19:14: > 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 t

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

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

2012-07-06 Thread Dag Sverre Seljebotn
Barry Warsaw wrote: >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

[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 >

Re: [Cython] [cython-users] C++: how to handle failures of 'new'?

2012-07-06 Thread mark florisson
On 6 July 2012 03:34, Dag Sverre Seljebotn wrote: > > > mark florisson wrote: > >>On 5 July 2012 21:46, Dag Sverre Seljebotn >>wrote: >>> >>> >>> mark florisson wrote: >>> On 3 July 2012 20:15, Robert Bradshaw wrote: > On Tue, Jul 3, 2012 at 11:43 AM, Dag Sverre Seljebotn > wrote: