Meta-class inheritance problem (Python2.0 bug?)

David Abrahams abrahams at mediaone.net
Sat Mar 17 22:58:45 EST 2001


"Lorien Dunn" <loriendNOSPAM at bigpond.com> wrote in message
news:6Kzs6.35062$v5.73895 at newsfeeds.bigpond.com...
> Hullo all,
>         I've been using boost::python for a little while now- long enough
to have
> seemingly successfully wrapped my extension, and I've run into a bug in
> python 2.0. The real code that the following pseudo code represents throws
> a TypeError.
>
> class MyDerivedClass(MyPurePythonClass, MyBoostClass):
>         def __init__(self):
>                 MyPurePythonClass.__init__(self)
>                 MyBoostClass.__init__(self)
>
> The problem occurs in MyPurePythonClass- Python says "unbound method must
> be called with class instance 1st argument". This makes sense: I'm passing
> a meta-class instead of a class. David Abrahams (the main author of
> boost::python) agrees that this is a Python problem, and that it should
> affect Zope as well.

Just to be absolutely clear, I never said it was a bug in Python. I'm sure
Python doesn't purport to support this feature, and as such I would never
claim it was a bug. However, it does seem place some serious -and avoidable-
limitations on the use of Python class methods on extension class instances.

> He also said that it should be an easy modification, but he doesn't know
> what ramifications it would have throughout the rest of the python
> interpreter.

It isn't completely obvious to me why the check is there at all. Removing it
would be easy, though that may not be the best way to address the problem.

I guess there's always MyBoostClass.__dict__["__init__"](self)
 :-(

-Dave





More information about the Python-list mailing list