[Python-bugs-list] [ python-Bugs-680429 ] __module__ broken for extension classes
SourceForge.net
noreply@sourceforge.net
Wed, 05 Feb 2003 06:34:21 -0800
Bugs item #680429, was opened at 2003-02-04 19:55
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=680429&group_id=5470
Category: Python Interpreter Core
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Ralf W. Grosse-Kunstleve (rwgk)
>Assigned to: Michael Hudson (mwh)
Summary: __module__ broken for extension classes
Initial Comment:
We are having problems using Boost.Python with Python
2.3a1 because
under some circumstances the result of __module__ is
different compared
to earlier Python versions:
Python 2.2.1 (#2, Jun 17 2002, 12:06:51)
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-110)] on
linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>> import simple
>>> simple.empty.__module__
'simple'
>>>
Python 2.3a1 (#1, Jan 6 2003, 14:17:56)
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-110)] on
linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>> import simple
>>> simple.empty.__module__
'__main__'
>>>
Because of this we can no longer pickle our extension
classes.
For your reference the code for the simple module is
attached.
This is using Boost release 1.29.0 (www.boost.org).
We have done some debugging. Boost.Python's internal
idea of the module
associated with an extension class is still correct even when
using
Python 2.3a1. David Abrahams (main Boost.Python author)
is telling me
that he "changed Boost.Python to work the way Guido
suggested before
2.2.2." Therefore we suspect that the __module__ problem
is due to
a change/bug in Python 2.3a1.
Ralf
#include <boost/python/module.hpp>
#include <boost/python/class.hpp>
namespace sandbx { namespace {
struct empty {};
void init_module()
{
using namespace boost::python;
class_<empty>("empty");
}
}} // namespace sandbx::<anonymous>
BOOST_PYTHON_MODULE(simple)
{
sandbx::init_module();
}
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2003-02-05 14:10
Message:
Logged In: YES
user_id=6656
There has certainly been a change here.
Look at typeobject.c:type_module() (about 100 lines in).
If you can tell me what you want that function to do, I can
have a go at it.
Is simple.empty a HEAPTYPE?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=680429&group_id=5470