Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #30779
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2012-10-04 21:13 -0700 |
| Message-ID | <cf01deb3-e062-443b-a6cc-49b61c664ded@googlegroups.com> (permalink) |
| Subject | Embedded Python 3 porting issues when passing FILE* to PyRun_SimpleFile() in Windows mixed-compiler environment |
| From | Deron Meranda <deron.meranda@gmail.com> |
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 appears to 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/
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Embedded Python 3 porting issues when passing FILE* to PyRun_SimpleFile() in Windows mixed-compiler environment Deron Meranda <deron.meranda@gmail.com> - 2012-10-04 21:13 -0700
csiph-web