[Python-bugs-list] [ python-Bugs-443239 ] Python 2.2 & Boost.Python
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 07 Sep 2001 14:12:03 -0700
Bugs item #443239, was opened at 2001-07-20 18:06
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=443239&group_id=5470
Category: Type/class unification
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Ralf W. Grosse-Kunstleve (rwgk)
Assigned to: Guido van Rossum (gvanrossum)
>Summary: Python 2.2 & Boost.Python
Initial Comment:
Boost.Python is a C++ library for exposing C++ classes
to Python:
http://www.boost.org/libs/python/doc/index.html
Python's metaclass feature is used to provide objects
which look almost
exactly like regular Python classes:
http://www.boost.org/libs/python/doc/extending.html
I have compiled the Boost.Python library using Python
2.2a1 under Linux
without getting any compile-time error messages.
However, with versions
earlier than 2.2, we were able to derive extension
classes from a
mixture of built-in classes and extension
classes, /even if the
built-in class was the first listed base/, but that no
longer works:
Python 2.2a1 (#1, Jul 18 2001, 16:24:59)
[GCC 2.95.2 19991024 (release)] on linux2
Type "copyright", "credits" or "license" for more
information.
>>> from boost_python_test import Bar
>>>
>>> class RealPythonClass:
... def real_python_method(self):
... print 'RealPythonClass.real_python_method
()'
...
>>> class MISubclass2(RealPythonClass, Bar):
... def new_method(self):
... print 'MISubclass2.new_method()'
...
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: PyClass_New: base must be a class
>>>
This example works if the extension class appears
first:
>>> class MISubclass2(Bar, RealPythonClass):
It is somewhat important that built-in Python classes
may appear first
in the list of bases. Would it be possible to support
this in Python 2.2?
Thanks!
Ralf
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-09-07 14:12
Message:
Logged In: YES
user_id=6380
Ralf, can you try this again with the current CVS? I've
made a bit of progress in supporting ExtensionClass.
Unfortunately, all the progress was made right after Barry
released 2.2a3, so downloading 2.2a3 won't work. (If you
don't have access to CVS, drop me a note and I'll send you a
patch.)
You need classobject.c 2.145, typeobject.c 2.57, and
abstract.c 2.73. (Or newer, of course.)
Note: I don't know if Boost uses ExtensionClass or a similar
mechanism. In either case, it's possible that there are
still problems -- that's why I'm not closing this bug report
yet. But I'm hopeful! Please help!
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=443239&group_id=5470