Re: Generating exceptions from C

2006-03-18 Thread Jacob Kroon
Just wrote: >>Does the comments above make sense? >> >> > >Not quite: when raising an exception, an instance of the exception class >_is_ created. Just like this: > > raise SomeException(msg) > >With the old (deprecated) spelling the instantiation is done implicitly: > > raise SomeExcepti

Re: Generating exceptions from C

2006-03-18 Thread Jacob Kroon
I'll just reply to myself what I've found out so far: > 1. PyErr_NewException() creates the exception _class_, not the > instance right ? > Looks like it does yes. It doesn't even seem right to talk about an _instance_ of an exception... > 2. Is PyErr_SetString() the correct way to raise except

Generating exceptions from C

2006-03-18 Thread Jacob Kroon
Hi, I'm working on a python module written in C, and I'm trying to figure out how to raise python exceptions if a function fails. So far I've read http://docs.python.org/ext/errors.html and http://docs.python.org/api/exceptionHandling.html , but I've not fully understood it. I've managed to c

Python cleanup on exit

2006-03-10 Thread Jacob Kroon
Hi, I'm working on a library written in C using GObject, which i provide python bindings for using pygtk. When I checked the library for memory leaks using valgrind, I noticed that none of the objects I created in the script (that is they are global in the script) were deleted on exit. After some

Help designing reading/writing a xml-fileformat

2005-12-13 Thread Jacob Kroon
I'm writing a block-diagram editor, and could use some tips about writing/reading diagrams to/from an xml file format. The basic layout of my code : class Diagram { Blocks blocks[] } class Block { int x, y } class Square(Block) { int width, height } class Circle(Block) { int ra

Dynamical loading of modules

2005-10-03 Thread Jacob Kroon
the instantiated objects class-names becomes fruit.apple.Apple/fruit.banana.Banana, whild I want it to be fruit.Apple/fruit.Banana. Is there a smarter way of accomplishing what I am trying to do ? If someone could give me a small example of how to achieve this I would be very grateful.