Embedded Python 3 porting issues when passing FILE* toPyRun_SimpleFile() in Windows mixed-compiler e

Discussion in 'Python' started by Deron Meranda, Oct 5, 2012.

  1. Hi. I'm trying to convert a large C application that embeds Python so it works with Python 3, and am running into an new API limitation I can't solve.. I have a report from Windows users that there is a crashing problem occurring with calls to PyRun_SimpleFile (and similar functions). This appearsto happen when people are using a Python DLL compiled with one compiler (e..g., MicroSoft's) and the application with another compiler (e.g., MinGW/gcc).

    The basic problem is that C type (FILE*) is not defined by the Windows OS, but instead is specific to the compiler and its associated runtime-environment. So therefore it is not safe to pass a FILE* across DLL boundaries. However many of the Python C API functions only accept a FILE*.

    Under Python 2 a work-around was used by calling the PyFile_FromString() then PyFile_AsFile(), to effectively get the underlying fopen() to occur inside the Python DLL so that an incompatible FILE* is not passed across the DLL boundary.

    However many of those PyFile functions, including PyFile_FromFile(), were removed from the Python 3 API. So how can one safely call PyRun_SimpleFile() in Python 3 in Windows where different compilers could be used?

    Thanks
    --
    Deron Meranda
    http://deron.meranda.us/
    Deron Meranda, Oct 5, 2012
    #1
    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. nobody
    Replies:
    1
    Views:
    778
    Martin Honnen
    Jul 18, 2004
  2. navin_2016

    porting issues ?

    navin_2016, Dec 8, 2003, in forum: C Programming
    Replies:
    19
    Views:
    575
    Dan Pop
    Dec 10, 2003
  3. jpw
    Replies:
    1
    Views:
    356
    Gabriel Genellina
    Feb 5, 2008
  4. Wilde, Donald S

    porting Ruby to an embedded target

    Wilde, Donald S, May 27, 2011, in forum: Ruby
    Replies:
    4
    Views:
    382
    Wilde, Donald S
    May 31, 2011
  5. Justin Drake

    Porting Python to an embedded system

    Justin Drake, Mar 4, 2012, in forum: Python
    Replies:
    3
    Views:
    1,074
    88888 Dihedral
    Mar 5, 2012
Loading...

Share This Page