473,386 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Sublassing in C

I'm trying to create a subclass of Exception in C, but cant figure out
what to use as tp_base in the PyTypeObject struct. Can anybody give me
directions on where to look or maybe even an answer?
--
Dennis K.
And that's the way the cookie crumbles.
Jul 18 '05 #1
2 1248
At some point, Dennis Kaarsemaker <sp******@kaarsemaker.net> wrote:
I'm trying to create a subclass of Exception in C, but cant figure out
what to use as tp_base in the PyTypeObject struct. Can anybody give me
directions on where to look or maybe even an answer?


Have a look at Python/exceptions.c in the Python source; that's where
all the subclasses of Exception (IndexError, etc.) are created.

--
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
Jul 18 '05 #2
On Sat, 14 Aug 2004 15:31:26 +0200, Dennis Kaarsemaker
<sp******@kaarsemaker.net> wrote:
I'm trying to create a subclass of Exception in C, but cant figure out
what to use as tp_base in the PyTypeObject struct. Can anybody give me
directions on where to look or maybe even an answer?


Currently, exceptions have to be old-style classes, so you cannot create a
subclass using the new type-based subclassing. Instead, you should use
PyErr_NewException, which creates a new Exception subclass with the given name,
base and attributes (despite the first sentence of the documentation, it returns
a new subclass, not a new exception object).

---
Greg Chapman

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Michael Chermside | last post by:
A few weeks ago, the suggestion was made on Python-Dev that it might be time to consider replacing the ConfigParser module and that we should hold a "shootout" (ie ask for implementations and see...
12
by: Jane Austine | last post by:
Please see the following code: -------------------------------- class rev_wrap(object): def __init__(self,l): self.l=l def __getitem__(self,i): return self.l class rev_subclass(list): def...
1
by: Maksim Kasimov | last post by:
Hi, I'm trying to write an server-application, using BaseHTTPServer/BaseHTTPRequestHandler. When application is running, some client-application can post data to the server, and...
2
by: davidj411 | last post by:
docs on urllib module say this about the FancyUrlOpener: "class FancyURLopener( ...) FancyURLopener subclasses URLopener providing default handling for ..." does that mean the FancyURLopener...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.