@@ -55,8 +55,9 @@ called ``spam``, the C file containing its implementation is called
5555:file: `spammodule.c `; if the module name is very long, like ``spammify ``, the
5656module name can be just :file: `spammify.c `.)
5757
58- The first line of our file can be::
58+ The first two lines of our file can be::
5959
60+ #define PY_SSIZE_T_CLEAN
6061 #include <Python.h>
6162
6263which pulls in the Python API (you can add a comment describing the purpose of
@@ -68,6 +69,9 @@ the module and a copyright notice if you like).
6869 headers on some systems, you *must * include :file: `Python.h ` before any standard
6970 headers are included.
7071
72+ It is recommended to always define ``PY_SSIZE_T_CLEAN `` before including
73+ ``Python.h ``. See :ref: `parsetuple ` for a description of this macro.
74+
7175All user-visible symbols defined by :file: `Python.h ` have a prefix of ``Py `` or
7276``PY ``, except those defined in standard header files. For convenience, and
7377since they are used extensively by the Python interpreter, ``"Python.h" ``
@@ -729,7 +733,8 @@ it returns false and raises an appropriate exception.
729733Here is an example module which uses keywords, based on an example by Geoff
730734731735
732- #include "Python.h"
736+ #define PY_SSIZE_T_CLEAN /* Make "s#" use Py_ssize_t rather than int. */
737+ #include <Python.h>
733738
734739 static PyObject *
735740 keywdarg_parrot(PyObject *self, PyObject *args, PyObject *keywds)
@@ -1228,7 +1233,7 @@ The function :c:func:`spam_system` is modified in a trivial way::
12281233
12291234In the beginning of the module, right after the line ::
12301235
1231- #include " Python.h"
1236+ #include < Python.h>
12321237
12331238two more lines must be added::
12341239
0 commit comments