#1177 side effect between classes

closed-invalid
nobody
python (259)
5
2011-06-27
2011-06-25
No

Hi,

I observe some side effect when instantiating two C++ class from Python and
making them working together is a particular manner.

There are files attached to reproduce the problem. However, because it is about
memory allocation, I'm not sure the behaviour will be the same as I observe...

Compiling and running in pure C++:
make cpp
make testcpp

I get this ouput:
_the_set: 1 5
_the_set: 1 5

But using Swig:
make py
make testpy

I get this ouptut, showing that writting into "another_set" also write, by side
effect, into "_the_set":
_the_set: 1 5
_the_set: 1 222

SWIG Version 1.3.36
Linux ange 2.6.31-22-generic #73-Ubuntu SMP Fri Feb 11 19:18:05 UTC 2011 x86_64 GNU/Linux

Best,

David

Discussion

  • David Froger

    David Froger - 2011-06-25

    how to reproduce the bug

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2011-06-27

    Ok, this was not a bug... The good main.py is :

    a = ab.A()
    b = ab.B()
    b.thisown = 0
    a.set_b( b )
    a.dosomething()

    And the documentation explains it very well:
    http://swig.org/Doc2.0/Python.html#Python_nn30

    :-)

     
  • William Fulton

    William Fulton - 2011-06-27
    • status: open --> closed-invalid
     
  • William Fulton

    William Fulton - 2011-06-27

    Closing

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks