This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] python: Make Windows-specific code work with Python 3
On Tue, 2018-10-30 at 14:08 -0600, Tom Tromey wrote:
> > > > > > "Jan" == Jan Vrany <jan.vrany@fit.cvut.cz> writes:
>
> Jan> Windows workaround in python_run_simple_file() used Python 2
> Jan> APIs which were removed in Python 3. This commit adds a
> Jan> conditionally compiled variant that uses Python 3 APIs.
>
> Jan> +# ifdef IS_PY3K
> Jan> + FILE *python_file = _Py_fopen (full_path.get (), (char *) "r");
>
> I'm a bit reluctant to rely on an undocumented API.
Me to, to be honest, but I could not find any other way...
> I'd guess from the name that this is supposed to be internal...?
...and then I actually looked at the Python header file,. The _Py_fopen()
is declared as follows (see fileutils.h).
PyAPI_FUNC(FILE*) _Py_fopen(
const char *pathname,
const char *mode);
Looking at pyport.h, it says:
/* Declarations for symbol visibility.
PyAPI_FUNC(type): Declares a public Python API function and return type
PyAPI_DATA(type): Declares public Python data and its type
...
*/
which made me thing using _Py_fopen() would be okish, at least for some
time. I'm not a python hacker though.
> Also, nothing closes this new file.
Argh, good point. Will check that. Thanks!
Jan