Mysterious argument count error to __new__

C

Clarence

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top