Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c88feceb
Commit
c88feceb
authored
Apr 13, 2019
by
Inada Naoki
Committed by
GitHub
Apr 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Doc: define PY_SSIZE_T_CLEAN always (GH-12794)
parent
a304b136
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
22 additions
and
4 deletions
+22
-4
Doc/c-api/intro.rst
Doc/c-api/intro.rst
+5
-1
Doc/extending/embedding.rst
Doc/extending/embedding.rst
+1
-0
Doc/extending/extending.rst
Doc/extending/extending.rst
+8
-3
Doc/faq/extending.rst
Doc/faq/extending.rst
+2
-0
Doc/includes/custom.c
Doc/includes/custom.c
+1
-0
Doc/includes/custom2.c
Doc/includes/custom2.c
+1
-0
Doc/includes/custom3.c
Doc/includes/custom3.c
+1
-0
Doc/includes/custom4.c
Doc/includes/custom4.c
+1
-0
Doc/includes/run-func.c
Doc/includes/run-func.c
+1
-0
Doc/includes/sublist.c
Doc/includes/sublist.c
+1
-0
No files found.
Doc/c-api/intro.rst
View file @
c88feceb
...
...
@@ -48,7 +48,8 @@ Include Files
All function, type and macro definitions needed to use the Python/C API are
included in your code by the following line::
#include "Python.h"
#define PY_SSIZE_T_CLEAN
#include <Python.h>
This implies inclusion of the following standard headers: ``<stdio.h>``,
``<string.h>``, ``<errno.h>``, ``<limits.h>``, ``<assert.h>`` and ``<stdlib.h>``
...
...
@@ -60,6 +61,9 @@ This implies inclusion of the following standard headers: ``<stdio.h>``,
headers on some systems, you *must* include :file:`Python.h` before any standard
headers are included.
It is recommended to always define ``PY_SSIZE_T_CLEAN`` before including
``Python.h``. See :ref:`arg-parsing` for a description of this macro.
All user visible names defined by Python.h (except those defined by the included
standard headers) have one of the prefixes ``Py`` or ``_Py``. Names beginning
with ``_Py`` are for internal use by the Python implementation and should not be
...
...
Doc/extending/embedding.rst
View file @
c88feceb
...
...
@@ -53,6 +53,7 @@ interface. This interface is intended to execute a Python script without needing
to interact with the application directly. This can for example be used to
perform some operation on a file. ::
#define PY_SSIZE_T_CLEAN
#include <Python.h>
int
...
...
Doc/extending/extending.rst
View file @
c88feceb
...
...
@@ -55,8 +55,9 @@ called ``spam``, the C file containing its implementation is called
:file:`spammodule.c`; if the module name is very long, like ``spammify``, the
module name can be just :file:`spammify.c`.)
The first
line
of our file can be::
The first
two lines
of our file can be::
#define PY_SSIZE_T_CLEAN
#include <Python.h>
which 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).
headers on some systems, you *must* include :file:`Python.h` before any standard
headers are included.
It is recommended to always define ``PY_SSIZE_T_CLEAN`` before including
``Python.h``. See :ref:`parsetuple` for a description of this macro.
All user-visible symbols defined by :file:`Python.h` have a prefix of ``Py`` or
``PY``, except those defined in standard header files. For convenience, and
since they are used extensively by the Python interpreter, ``"Python.h"``
...
...
@@ -729,7 +733,8 @@ it returns false and raises an appropriate exception.
Here is an example module which uses keywords, based on an example by Geoff
Philbrick (philbrick@hks.com)::
#include "Python.h"
#define PY_SSIZE_T_CLEAN /* Make "s#" use Py_ssize_t rather than int. */
#include <Python.h>
static PyObject *
keywdarg_parrot(PyObject *self, PyObject *args, PyObject *keywds)
...
...
@@ -1228,7 +1233,7 @@ The function :c:func:`spam_system` is modified in a trivial way::
In the beginning of the module, right after the line ::
#include
"Python.h"
#include
<Python.h>
two more lines must be added::
...
...
Doc/faq/extending.rst
View file @
c88feceb
...
...
@@ -280,6 +280,7 @@ solution then is to call :c:func:`PyParser_ParseString` and test for ``e.error``
equal to ``E_EOF``, which means the input is incomplete. Here's a sample code
fragment, untested, inspired by code from Alex Farber::
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <node.h>
#include <errcode.h>
...
...
@@ -318,6 +319,7 @@ complete example using the GNU readline library (you may want to ignore
#include <stdio.h>
#include <readline.h>
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <object.h>
#include <compile.h>
...
...
Doc/includes/custom.c
View file @
c88feceb
#define PY_SSIZE_T_CLEAN
#include <Python.h>
typedef
struct
{
...
...
Doc/includes/custom2.c
View file @
c88feceb
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "structmember.h"
...
...
Doc/includes/custom3.c
View file @
c88feceb
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "structmember.h"
...
...
Doc/includes/custom4.c
View file @
c88feceb
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "structmember.h"
...
...
Doc/includes/run-func.c
View file @
c88feceb
#define PY_SSIZE_T_CLEAN
#include <Python.h>
int
...
...
Doc/includes/sublist.c
View file @
c88feceb
#define PY_SSIZE_T_CLEAN
#include <Python.h>
typedef
struct
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment