469,275 Members | 1,552 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

Mysterious argument count error to __new__

I'm having problems with JPype and am trying to change the way
it creates Python classes as proxies for Java classes and interfaces.
I'm trying to get around "inconsistent mro" problems, but in doing
so, I've run into a real mystery.

Here's the original code. It first makes a metaclass, then makes a
class using that metaclass.

##############
metaclass = type.__new__(type, name+"$$Static", tuple(meta_bases),
static_fields)
members['__metaclass__'] = metaclass
result = type.__new__(metaclass, name, tuple(bases), members)
##############

I'm getting an error on the first call to __new__, but I want to see
if my "bases" list is acceptable, putting aside for the moment that
"meta_bases" is having a problem.

So I put this line directly ahead of the three quoted above:
##############
type.__new__(type, 'aoeu', tuple(bases), members)
##############
You can see that this is essentially exactly the same as the first of
the three, just using a different name, a diffent bases tuple, and a
different dictionary. Whereas the first of the three gets an mro kind
of error, when I insert this new line, it gets:
type.__new__(type, 'aoeu', tuple(bases), members)
TypeError: __new__() takes exactly 2 arguments (4 given)

How is it possible that I get a number-of-arguments error when the
following line, with the same number of arguments, does not?
(This can't even be relevant, really, but I also printed out the
value of "type" before the line, and got <type 'type'as it should
be.)

Thanks for any help.
Clarence

Apr 10 '07 #1
0 959

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Tobiah | last post: by
5 posts views Thread by could ildg | last post: by
12 posts views Thread by Bob Stearns | last post: by
33 posts views Thread by Martin Jørgensen | last post: by
5 posts views Thread by Ken Schutte | last post: by
18 posts views Thread by Paulo da Silva | last post: by
1 post views Thread by Frank Benkstein | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.