SWIG - python.exe crash

Discussion in 'Python' started by Java and Swing, Oct 4, 2005.

  1. When I try to print an object in Python, python.exe crashes. Below
    are my files.

    defs.h
    ------------------------------------------------------------------------------------------------------
    typedef unsigned long MY_DIGIT;


    myapp.c
    ------------------------------------------------------------------------------------------------------
    void MakeDigits(MY_DIGIT digits[]) {
    ....
    }

    char* GetString(char *inMessage, MY_DIGIT *digit) {
    char *results;
    ...
    ...
    return results;
    }


    MyApp.i
    ------------------------------------------------------------------------------------------------------
    %module MyApp
    %{
    #include "math.h"
    %}

    extern void MakeDigits(MY_DIGIT digits[]);
    extern char* GetString(char *inMessage, MY_DIGIT *digit);

    /* allows for the creation of a MY_DIGIT array */
    %inline %{
    MY_DIGIT *my_digit_array(int size) {
    return (MY_DIGIT *) malloc(size * sizeof(int));
    }
    %}


    ....I have two questions.

    1) One, I call MakeDigits which should populate the "digits" array with
    some values. It seems the first time I try it the digits array is
    populated. Then if I try to re-use the digits array i get some garbage
    output. But if I recall MakeDigits...I can then re-use the digits
    array over and over without anymore problems? Any idea?
    here is how I was trying it...
    digits = my_digit_array(10)
    MakeDigits(digits)

    2) When I try to print the "my_digit_array" object, python.exe
    crashes...below is the code I use to cause this problem: (within
    python)
    digits = my_digit_array(10)
    print digits

    I am using Python 2.4.1, Swig 1.3.25 on Win XP Pro.

    I tried sending a message on the SWIG mailing list...but so far it
    hasn't shown up on the list...I've sent it three times now. I'll keep
    trying.
     
    Java and Swing, Oct 4, 2005
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon Moldover
    Replies:
    0
    Views:
    364
    Jon Moldover
    Oct 28, 2003
  2. Emile van Sebille

    python.exe vs pythonw.exe difference?

    Emile van Sebille, Mar 1, 2004, in forum: Python
    Replies:
    0
    Views:
    1,388
    Emile van Sebille
    Mar 1, 2004
  3. Tim Peters
    Replies:
    1
    Views:
    6,805
    Bengt Richter
    Mar 3, 2004
  4. Chaos
    Replies:
    1
    Views:
    550
  5. Metalone
    Replies:
    5
    Views:
    402
    Thomas Heller
    Oct 19, 2007
  6. whatazor

    pythonw.exe and python.exe

    whatazor, Nov 30, 2007, in forum: Python
    Replies:
    1
    Views:
    830
    Tim Roberts
    Dec 2, 2007
  7. waldek

    python.exe crash and ctypes use

    waldek, Jul 23, 2008, in forum: Python
    Replies:
    3
    Views:
    373
    waldek
    Jul 24, 2008
  8. Replies:
    1
    Views:
    155
    Tim Golden
    Jul 3, 2013
Loading...