Custom C Exception Subclasses

2008-12-24 Thread Ross
For a project that I am doing, it would be useful to have an exception class that stores some additional data along with the message. However, I want to be able to store a couple pointers to C++ classes, so I can't just use an exception created with PyExc_NewException. If I were to subclass the

Re: Custom C Exception Subclasses

2008-12-24 Thread Ivan Illarionov
On Dec 24, 6:42 pm, Ross rlig...@gmail.com wrote: For a project that I am doing, it would be useful to have an exception class that stores some additional data along with the message. However, I want to be able to store a couple pointers to C++ classes, so I can't just use an exception created

Re: Custom C Exception Subclasses

2008-12-24 Thread Gabriel Genellina
En Wed, 24 Dec 2008 13:42:38 -0200, Ross rlig...@gmail.com escribió: For a project that I am doing, it would be useful to have an exception class that stores some additional data along with the message. However, I want to be able to store a couple pointers to C++ classes, so I can't just use an

Re: Custom C Exception Subclasses

2008-12-24 Thread Gabriel Genellina
En Wed, 24 Dec 2008 15:00:36 -0200, Ivan Illarionov ivan.illario...@gmail.com escribió: On Dec 24, 6:42 pm, Ross rlig...@gmail.com wrote: For a project that I am doing, it would be useful to have an exception class that stores some additional data along with the message. However, I want to

Re: Custom C Exception Subclasses

2008-12-24 Thread Ross
On Dec 24, 9:24 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: In fact you can, you could store those pointers as attributes of the exception object, using a PyCObject. Excellent. I was not aware of the PyCObject type. Accessing those attributes isn't as easy as doing exc-field, but I

Re: Custom C Exception Subclasses

2008-12-24 Thread Gabriel Genellina
En Wed, 24 Dec 2008 15:48:34 -0200, Gabriel Genellina gagsl-...@yahoo.com.ar escribió: En Wed, 24 Dec 2008 15:00:36 -0200, Ivan Illarionov ivan.illario...@gmail.com escribió: When you raise an exception in C++ you can set it to ANY Python object via PyErr_SetObject and that object could

Re: Custom C Exception Subclasses

2008-12-24 Thread Ivan Illarionov
On Dec 24, 10:43 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Wed, 24 Dec 2008 15:48:34 -0200, Gabriel Genellina   gagsl-...@yahoo.com.ar escribió: En Wed, 24 Dec 2008 15:00:36 -0200, Ivan Illarionov   ivan.illario...@gmail.com escribió: When you raise an exception in C++ you