Re: [Boost-bugs] [Boost C++ Libraries] #2049: extracting c++ pointer from python object with multiple parents

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #2049: extracting c++ pointer from python object with multiple parents
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-06-26 14:27:59


#2049: extracting c++ pointer from python object with multiple parents
-----------------------------------+----------------------------------------
  Reporter: bloodyfanatic_at_[hidden] | Owner: dave
      Type: Bugs | Status: closed
 Milestone: Boost 1.35.1 | Component: Python
   Version: Boost 1.35.0 | Severity: Problem
Resolution: invalid | Keywords:
-----------------------------------+----------------------------------------
Changes (by dave):

 * cc: stefan (added)
  * status: new => closed
  * resolution: => invalid

Comment:

 Replying to [comment:2 bloodyfanatic_at_[hidden]]:
> Replying to [comment:1 dave]:
> > Does this fail even when the dtors are non-virtual?
>
> yes it does, with the same error as always:

 In that case, please post the ''fully reduced'' test case

 Also, you need an __init__ method in both1 and both2 that initializes
 *both* bases or this can never work, because a wrapped class' __init__
 function is what actually constructs the C++ base object. Without it,
 there is no base object to which a pointer can be returned from
 {{{extract}}}:
 {{{
   def __init__(self):
      Base1.__init__(self)
      Base2.__init__(self)
 }}}
 I don't know how to do this properly with super (the technique Stefan was
 suggesting), but his suggestion as written didn't take care of both bases,
 as the following demonstrates:

 {{{
 #!python
>>> class X(object):
 ... def __init__(self):
 ... print 'X'
 ...
>>> class Y(object):
 ... def __init__(self):
 ... print 'Y'
 ...
>>> class Z(X,Y): pass # essentially what you posted
 ...
>>> z = Z()
 X
>>> class Z(X,Y):
 ... def __init__(self):
 ... super(Z,self).__init__() # Stefan's suggestion
 ...
>>> z = Z()
 X
>>> class Z(X,Y):
 ... def __init__(self):
 ... X.__init__(self)
 ... Y.__init__(self)
 ...
>>> z = Z()
 X
 Y
>>>
 }}}

 I'm pretty sure this solves your problem so I'm closing the ticket, but if
 it doesn't, please re-open it.

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/2049#comment:3>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.


This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:58 UTC