fputs in tp_print crashes under Win32

Discussion in 'Python' started by Petr Gotthard, Nov 12, 2008.

  1. Hello,
    my C++ extension crashes under Win32 when the tp_print is called.

    It crashes with both Python 2.5.2 and 2.6. The crash occurs in
    system32\ntdll.dll, with exception code 0xc0000005.

    I found out that this works fine:

    int ulonghandle_print(RtiULongHandleObject *v, FILE *fp, int flags)
    {
    fputc('c', stdout);
    return 0;
    }

    But this causes the error:

    int ulonghandle_print(RtiULongHandleObject *v, FILE *fp, int flags)
    {
    fputc('c', fp); // <-- "fp" instead of "stdout"
    return 0;
    }

    It occurs under Windows (XP SP2) only. Under Linux everything works
    fine.


    Do you have any idea what could be wrong?

    Thanks,
    Petr
    Petr Gotthard, Nov 12, 2008
    #1
    1. Advertising

  2. En Wed, 12 Nov 2008 08:58:05 -0200, Petr Gotthard
    <> escribió:

    > Hello,
    > my C++ extension crashes under Win32 when the tp_print is called.
    >
    > It crashes with both Python 2.5.2 and 2.6. The crash occurs in
    > system32\ntdll.dll, with exception code 0xc0000005.
    >
    > I found out that this works fine:
    >
    > int ulonghandle_print(RtiULongHandleObject *v, FILE *fp, int flags)
    > {
    > fputc('c', stdout);
    > return 0;
    > }
    >
    > But this causes the error:
    >
    > int ulonghandle_print(RtiULongHandleObject *v, FILE *fp, int flags)
    > {
    > fputc('c', fp); // <-- "fp" instead of "stdout"
    > return 0;
    > }
    >
    > It occurs under Windows (XP SP2) only. Under Linux everything works
    > fine.


    Short answer: compile your extension with the *same* compiler used to
    compile Python itself: Visual Studio 2008 for 2.6, Visual Studio .NET 2003
    for 2.5
    For the long answer search http://wiki.python.org/moin/

    --
    Gabriel Genellina
    Gabriel Genellina, Nov 15, 2008
    #2
    1. Advertising

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. xoinki
    Replies:
    1
    Views:
    377
  2. dave
    Replies:
    4
    Views:
    661
  3. Chad

    A question about fputs()

    Chad, Jun 22, 2008, in forum: C Programming
    Replies:
    17
    Views:
    656
    Keith Thompson
    Jun 23, 2008
  4. _JusSx_

    fputs and fprintf

    _JusSx_, Feb 28, 2010, in forum: C Programming
    Replies:
    10
    Views:
    4,850
    santosh
    Feb 28, 2010
  5. hassan

    fputs

    hassan, Jun 5, 2012, in forum: Python
    Replies:
    1
    Views:
    262
    Ulrich Eckhardt
    Jun 5, 2012
Loading...

Share This Page