[Pyrex] Re: extending built-ins

Greg Ewing greg at cosc.canterbury.ac.nz
Tue Apr 29 07:26:33 CEST 2003


Haris Bogdanovic <haris.bogdanovic at zg.hinet.hr> writes:

> I have to define extension type for exceptions. That should be a
> subclass of built-in Exception class but that's not possible yet, right?
> How can I proccess exceptions then? Will "throw" statement work even if
> the object passed to it isn't of Exception subclass?

Python currently requires exceptions to be "old-style"
classes. You can meet this requirement simply by putting
an ordinary class definition in your Pyrex file, e.g.

  class MyError(Exception):
    ...

It's recommended that exceptions be derived from 
Exception, but it's not currently enforced.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+




More information about the Pyrex mailing list