[Python-Dev] PEP 384 status

Nick Coghlan ncoghlan at gmail.com
Thu Sep 2 23:48:35 CEST 2010

On Wed, Sep 1, 2010 at 10:54 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> Please consider this: even without relying on PEP 384, using FILE*
> is /already/ dangerous; because you might compile an extension with a
> different compiler version than Python was compiled with. So, if we were
> following you, we should rip out PyObject_Print() of the whole C API,
> not only the limited subset which is defined by PEP 384.
> (now I have nothing against completely ripping out PyObject_Print() if
> we find out that it's not really useful...)

I finally took the obvious step of grepping the include directory to
see what APIs were even affected by this question. Turns out there are
more APIs than I thought, but most extension modules aren't going to
need most of them (since they're related to code parsing, compilation
and execution directly from files). For the remainder, I propose as a
starting point that users of the stable ABI be directed to the Python
equivalents, with the possibility of later adding inline functions for
more commonly used API elements. PyObject_Print is the only one I
would bother providing as part of the initial stable ABI


Search criteria: grep "FILE \?\*" *

object.h:typedef int (*printfunc)(PyObject *, FILE *, int);
object.h:PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int);
  - should provide inline equivalent

fileobject.h:PyAPI_FUNC(char *) Py_UniversalNewlineFgets(char *, int,
FILE*, PyObject *);
marshal.h:PyAPI_FUNC(void) PyMarshal_WriteLongToFile(long, FILE *, int);
marshal.h:PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *, int);
marshal.h:PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *);
marshal.h:PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *);
marshal.h:PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *);
marshal.h:PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *);
parsetok.h:PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char
*, grammar *, int,
parsetok.h:PyAPI_FUNC(node *) PyParser_ParseFileFlags(FILE *, const char *,
parsetok.h:PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(FILE *, const char *,
pythonrun.h:PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *,
PyCompilerFlags *);
pythonrun.h:PyAPI_FUNC(int) PyRun_AnyFileExFlags(FILE *, const char *,
int, PyCompilerFlags *);
pythonrun.h:PyAPI_FUNC(int) PyRun_SimpleFileExFlags(FILE *, const char
*, int, PyCompilerFlags *);
pythonrun.h:PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *, const
char *, PyCompilerFlags *);
pythonrun.h:PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *, const
char *, PyCompilerFlags *);
pythonrun.h:PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(FILE *, const char *,
pythonrun.h:PyAPI_FUNC(struct _node *)
PyParser_SimpleParseFileFlags(FILE *, const char *,
pythonrun.h:PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int,
pythonrun.h:PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
pythonrun.h:PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *);
pythonrun.h:PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *,
FILE *, char *);
  - omit from stable ABI, recommend equivalent Python calls (may add
inline versions to stable ABI over time if requested by developers)

abstract.h:     int PyObject_Print(PyObject *o, FILE *fp, int flags);
  - comment, not declaration (actual declaration is in object.h)

grammar.h:void printgrammar(grammar *g, FILE *fp);
grammar.h:void printnonterminals(grammar *g, FILE *fp);
object.h:PyAPI_FUNC(void) _Py_PrintReferences(FILE *);
object.h:PyAPI_FUNC(void) _Py_PrintReferenceAddresses(FILE *);
Python.h:PyAPI_FUNC(FILE *) _Py_wfopen(const wchar_t *path, const
wchar_t *mode);
Python.h:PyAPI_FUNC(FILE*) _Py_fopen(PyObject *unicode, const char *mode);
  - private, omit from stable ABI

Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list