[C++-sig] Re: Pickling problem

Pierre Barbier de Reuille pierre.barbier at cirad.fr
Mon Mar 1 16:09:06 CET 2004


Just the python part to reproduce my problem :

from test_abstract import *

class TestDerived(Base):
  def __init__(self, a):
    Base.__init__(self)
    self.a = a
  def __eq__(self, other):
    print "TestDerived.__eq__"
    print "with %s and %s" % (self, other)
    if isinstance(other, TestDerived):
      return self.a == other.a
    return False
  def __neq__(self, other):
    print "TestDerived.__neq__"
    print "with %s and %s" % (self, other)
    if isinstance(other, TestDerived):
      return self.a != other.a
    return True
  def getCopy(self):
    return TestDerived(self.a)
  def __hash__(self):
    return hash(self.a)

t1 = TestDerived(10)
p1 = Proxy(t1)
p2 = Proxy(TestDerived(10))
p3 = Proxy(TestDerived(11))
print p1 == p1 # This is ok
print p1 == p2 # Crash here
print p1 == p3 # And there

Thanks,

Pierre


-- 
Pierre Barbier de Reuille

INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP
Botanique et Bio-informatique de l'Architecture des Plantes
TA40/PSII, Boulevard de la Lironde
34398 MONTPELLIER CEDEX 5, France

tel   : (33) 4 67 61 65 77    fax   : (33) 4 67 61 56 68 





More information about the Cplusplus-sig mailing list