Hi,
Python 3.13 removed the private function _Py_wfopen(). A possible replacement is the private _Py_fopen_obj() function. Instead, I propose adding a clean public tested and documented Py_fopen() function, with a companion Py_fclose() function.
API:
FILE* Py_fopen(PyObject *path, const char *mode)
int Py_fclose(FILE *file)
Py_fopen() is similar to the fopen() function, but the path argument is a Python object (instead of char*), and an exception is set on error.
On Windows, files opened by Py_fopen() in the Python DLL must be closed by the Python DLL to use the same C runtime version. Otherwise, calling fclose() directly can cause undefined behavior. So I also propose adding a Py_close() function to avoid this problem.
Finally, I propose to remove the untested and undocumented _Py_fopen_obj() function, to promote the usage of the public tested and documented Py_fopen() function.
Py_fopen() and Py_fclose() are needed by the long list of C API functions which expect a FILE* argument.
Add Py_fopen() and Py_close():
Remove _Py_fopen_obj():
Hi,
Python 3.13 removed the private function
_Py_wfopen(). A possible replacement is the private_Py_fopen_obj()function. Instead, I propose adding a clean public tested and documentedPy_fopen()function, with a companionPy_fclose()function.API:
Py_fopen()is similar to thefopen()function, but the path argument is a Python object (instead ofchar*), and an exception is set on error.On Windows, files opened by
Py_fopen()in the Python DLL must be closed by the Python DLL to use the same C runtime version. Otherwise, callingfclose()directly can cause undefined behavior. So I also propose adding aPy_close()function to avoid this problem.Finally, I propose to remove the untested and undocumented
_Py_fopen_obj()function, to promote the usage of the public tested and documentedPy_fopen()function.Py_fopen()andPy_fclose()are needed by the long list of C API functions which expect aFILE*argument.Add Py_fopen() and Py_close():
Remove
_Py_fopen_obj():