Mysterious argument count error to __new__

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Clarence

    #1

    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 "inconsiste nt 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__(ty pe, name+"$$Static" , tuple(meta_base s),
    static_fields)
    members['__metaclass__'] = metaclass
    result = type.__new__(me taclass, 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__(ty pe, '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__(ty pe, '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

Working...