From b1375be8e9296137748db2e6321c9109553f2fd2 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 24 Nov 2017 14:17:33 +0100 Subject: [PATCH 1/7] bpo-32124: Document C functions safe before init Explicitly document C functions and C variables that can be set before Py_Initialize(). --- Doc/c-api/init.rst | 118 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 115 insertions(+), 3 deletions(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index dc1939db17e4c3..8532894e09c560 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -7,6 +7,116 @@ Initialization, Finalization, and Threads ***************************************** +.. _pre-init-safe: + +Before Python Initialization +============================ + +In an application embedding Python, the :c:func:`Py_Initialize` function must +be called before using any other Python/C API functions; with the exception of +a few functions and flags listed below. + +The following functions can be safetely called before Python is initialized: + +* Configuration functions: + + * :c:func:`Py_SetStandardStreamEncoding` + * :c:func:`Py_GetProgramName`, :c:func:`Py_SetProgramName` + * :c:func:`Py_SetPythonHome` + * :c:func:`Py_SetPath` + +* Memory allocators functions: + + * :c:func:`PyMem_GetAllocator`, :c:func:`PyMem_SetAllocator` + * :c:func:`PyMem_SetupDebugHooks` + * :c:func:`PyObject_GetArenaAllocator`, :c:func:`PyObject_SetArenaAllocator` + * :c:func:`PyMem_RawMalloc`, :c:func:`PyMem_RawRealloc`, + :c:func:`PyMem_RawCalloc`, :c:func:`PyMem_RawFree` + * :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc`, :c:func:`PyMem_Calloc`, + :c:func:`PyMem_Free` + * :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc`, + :c:func:`PyObject_Calloc`, :c:func:`PyObject_Free` + +The following flags can also be set: + +* :c:data:`Py_BytesWarningFlag` +* :c:data:`Py_DebugFlag` +* :c:data:`Py_InspectFlag` +* :c:data:`Py_InteractiveFlag` +* :c:data:`Py_IsolatedFlag` +* :c:data:`Py_OptimizeFlag` +* :c:data:`Py_DontWriteBytecodeFlag` +* :c:data:`Py_NoUserSiteDirectory` +* :c:data:`Py_NoSiteFlag` +* :c:data:`Py_UnbufferedStdioFlag` +* :c:data:`Py_VerboseFlag` +* :c:data:`Py_QuietFlag` +* :c:data:`Py_IgnoreEnvironmentFlag` + + +Global configuration variables +============================== + +Python has variables for the global configuration to control different features +and options. By default, these flags are controlled by :ref:`command line +options `. + +.. :c:data: Py_BytesWarningFlag + + The :option:`-b` option. + +.. :c:data: Py_DebugFlag + + The :option:`-d` option. + +.. :c:data: Py_InspectFlag + + The :option:`-i` option. + +.. :c:data: Py_InteractiveFlag + + The :option:`-i` option. + +.. :c:data: Py_IsolatedFlag + + The :option:`-I` option. + + .. versionadded:: 3.4 + +.. :c:data: Py_OptimizeFlag + + The :option:`-O` option. + +.. :c:data: Py_DontWriteBytecodeFlag + + The :option:`-B` option. + +.. :c:data: Py_NoUserSiteDirectory + + The :option:`-s` option. + +.. :c:data: Py_NoSiteFlag + + The :option:`-S` option. + +.. :c:data: Py_UnbufferedStdioFlag + + The :option:`-u` option. + +.. :c:data: Py_VerboseFlag + + The :option:`-v` option. + +.. :c:data: Py_QuietFlag + + The :option:`-q` option. + + .. versionadded:: 3.2 + +.. :c:data: Py_IgnoreEnvironmentFlag + + The :option:`-E` and :option:`-I` options. + Initializing and finalizing the interpreter =========================================== @@ -27,9 +137,11 @@ Initializing and finalizing the interpreter single: PySys_SetArgvEx() single: Py_FinalizeEx() - Initialize the Python interpreter. In an application embedding Python, this - should be called before using any other Python/C API functions; with the - exception of :c:func:`Py_SetProgramName`, :c:func:`Py_SetPythonHome` and :c:func:`Py_SetPath`. This initializes + Initialize the Python interpreter. In an application embedding Python, + this should be called before using any other Python/C API functions; see + :ref:`Before Python Initialization ` for the few exceptions. + + This initializes the table of loaded modules (``sys.modules``), and creates the fundamental modules :mod:`builtins`, :mod:`__main__` and :mod:`sys`. It also initializes the module search path (``sys.path``). It does not set ``sys.argv``; use From 938684e452f0ba788de11f78c8a60848b3089087 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 24 Nov 2017 14:26:48 +0100 Subject: [PATCH 2/7] Add Py_DecodeLocale() Change also how functions are listed: one per line. --- Doc/c-api/init.rst | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 8532894e09c560..6eac6c75e940b2 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -18,24 +18,34 @@ a few functions and flags listed below. The following functions can be safetely called before Python is initialized: -* Configuration functions: +* Functions: - * :c:func:`Py_SetStandardStreamEncoding` - * :c:func:`Py_GetProgramName`, :c:func:`Py_SetProgramName` - * :c:func:`Py_SetPythonHome` + * :c:func:`PyMem_GetAllocator` + * :c:func:`PyMem_SetAllocator` + * :c:func:`PyMem_SetupDebugHooks` + * :c:func:`PyObject_GetArenaAllocator` + * :c:func:`PyObject_SetArenaAllocator` + * :c:func:`Py_DecodeLocale` + * :c:func:`Py_GetProgramName` * :c:func:`Py_SetPath` + * :c:func:`Py_SetProgramName` + * :c:func:`Py_SetPythonHome` + * :c:func:`Py_SetStandardStreamEncoding` -* Memory allocators functions: - - * :c:func:`PyMem_GetAllocator`, :c:func:`PyMem_SetAllocator` - * :c:func:`PyMem_SetupDebugHooks` - * :c:func:`PyObject_GetArenaAllocator`, :c:func:`PyObject_SetArenaAllocator` - * :c:func:`PyMem_RawMalloc`, :c:func:`PyMem_RawRealloc`, - :c:func:`PyMem_RawCalloc`, :c:func:`PyMem_RawFree` - * :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc`, :c:func:`PyMem_Calloc`, - :c:func:`PyMem_Free` - * :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc`, - :c:func:`PyObject_Calloc`, :c:func:`PyObject_Free` +* Memory allocators: + + * :c:func:`PyMem_RawMalloc` + * :c:func:`PyMem_RawRealloc` + :c:func:`PyMem_RawCalloc` + * :c:func:`PyMem_RawFree` + * :c:func:`PyMem_Malloc` + * :c:func:`PyMem_Realloc` + * :c:func:`PyMem_Calloc` + * :c:func:`PyMem_Free` + * :c:func:`PyObject_Malloc` + * :c:func:`PyObject_Realloc` + * :c:func:`PyObject_Calloc` + * :c:func:`PyObject_Free` The following flags can also be set: From 12b3b5fdb3ad268dfd728154edf9ba1be3b051c7 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 24 Nov 2017 16:38:59 +0100 Subject: [PATCH 3/7] Complete and fix the Preinit doc --- Doc/c-api/init.rst | 203 +++++++++++++++++++++++++++++++++------------ 1 file changed, 152 insertions(+), 51 deletions(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 6eac6c75e940b2..5c25d4a3b5a0f2 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -14,29 +14,40 @@ Before Python Initialization In an application embedding Python, the :c:func:`Py_Initialize` function must be called before using any other Python/C API functions; with the exception of -a few functions and flags listed below. +a few functions and the :ref:`global configuration variables `: The following functions can be safetely called before Python is initialized: -* Functions: +* Configuration functions: + * :c:func:`PyImport_AppendInittab` + * :c:func:`PyImport_ExtendInittab` + * :c:func:`PyInitFrozenExtensions` * :c:func:`PyMem_GetAllocator` * :c:func:`PyMem_SetAllocator` * :c:func:`PyMem_SetupDebugHooks` * :c:func:`PyObject_GetArenaAllocator` * :c:func:`PyObject_SetArenaAllocator` - * :c:func:`Py_DecodeLocale` + * :c:func:`Py_GetBuildInfo` + * :c:func:`Py_GetCompiler` + * :c:func:`Py_GetCopyright` + * :c:func:`Py_GetPlatform` * :c:func:`Py_GetProgramName` + * :c:func:`Py_GetVersion` * :c:func:`Py_SetPath` * :c:func:`Py_SetProgramName` * :c:func:`Py_SetPythonHome` * :c:func:`Py_SetStandardStreamEncoding` +* Utilities: + + * :c:func:`Py_DecodeLocale` + * Memory allocators: * :c:func:`PyMem_RawMalloc` * :c:func:`PyMem_RawRealloc` - :c:func:`PyMem_RawCalloc` + * :c:func:`PyMem_RawCalloc` * :c:func:`PyMem_RawFree` * :c:func:`PyMem_Malloc` * :c:func:`PyMem_Realloc` @@ -47,22 +58,15 @@ The following functions can be safetely called before Python is initialized: * :c:func:`PyObject_Calloc` * :c:func:`PyObject_Free` -The following flags can also be set: -* :c:data:`Py_BytesWarningFlag` -* :c:data:`Py_DebugFlag` -* :c:data:`Py_InspectFlag` -* :c:data:`Py_InteractiveFlag` -* :c:data:`Py_IsolatedFlag` -* :c:data:`Py_OptimizeFlag` -* :c:data:`Py_DontWriteBytecodeFlag` -* :c:data:`Py_NoUserSiteDirectory` -* :c:data:`Py_NoSiteFlag` -* :c:data:`Py_UnbufferedStdioFlag` -* :c:data:`Py_VerboseFlag` -* :c:data:`Py_QuietFlag` -* :c:data:`Py_IgnoreEnvironmentFlag` +.. note:: + + :c:func:`Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix` and + :c:func:`Py_GetProgramFullPath` and :c:func:`Py_GetPythonHome` **should not + be called** before :c:func:`Py_Initialize`. + +.. _global-conf-vars: Global configuration variables ============================== @@ -71,61 +75,158 @@ Python has variables for the global configuration to control different features and options. By default, these flags are controlled by :ref:`command line options `. -.. :c:data: Py_BytesWarningFlag +When a flag is set by an option, the value of the flag is the number of times +that the option was set. For example, ``-b`` sets :c:data:`Py_BytesWarningFlag` +to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2. + +.. c:var:: Py_BytesWarningFlag + + Issue a warning when comparing :class:`bytes` or :class:`bytearray` with + :class:`str` or :class:`bytes` with :class:`int`. Issue an error if greater + or equal to ``2``. + + Set by the :option:`-b` option. + +.. c:var:: Py_DebugFlag + + Turn on parser debugging output (for wizards only, depending on compilation + options). + + Set by the :option:`-d` option and the :envvar:`PYTHONDEBUG` environment + variable. + +.. c:var:: Py_DontWriteBytecodeFlag + + If set to non-zero, Python won't try to write ``.pyc`` files on the + import of source modules. + + Set by the :option:`-B` option and the :envvar:`PYTHONDONTWRITEBYTECODE` + environment variable. + +.. c:var:: Py_HashRandomizationFlag + + Set to ``1`` if the :envvar:`PYTHONHASHSEED` environment variable is set to + a non-empty string. + + If the flag is non-zero, read the :envvar:`PYTHONHASHSEED` environment + variable to initialize the secret hash seed. + +.. c:var:: Py_IgnoreEnvironmentFlag - The :option:`-b` option. + Ignore all :envvar:`PYTHON*` environment variables, e.g. + :envvar:`PYTHONPATH` and :envvar:`PYTHONHOME`, that might be set. -.. :c:data: Py_DebugFlag + Set by the :option:`-E` and :option:`-I` options. - The :option:`-d` option. +.. c:var:: Py_InspectFlag -.. :c:data: Py_InspectFlag + When a script is passed as first argument or the :option:`-c` option is used, + enter interactive mode after executing the script or the command, even when + :data:`sys.stdin` does not appear to be a terminal. - The :option:`-i` option. + Set by the :option:`-i` option and the :envvar:`PYTHONINSPECT` environment + variable. -.. :c:data: Py_InteractiveFlag +.. c:var:: Py_InteractiveFlag - The :option:`-i` option. + Set by the :option:`-i` option. -.. :c:data: Py_IsolatedFlag +.. c:var:: Py_IsolatedFlag - The :option:`-I` option. + Run Python in isolated mode. In isolated mode :data:`sys.path` contains + neither the script's directory nor the user's site-packages directory. + + Set by the :option:`-I` option. .. versionadded:: 3.4 -.. :c:data: Py_OptimizeFlag +.. c:var:: Py_LegacyWindowsFSEncodingFlag + + If the flag is non-zero, use the ``mbcs`` encoding instead of the UTF-8 + encoding for the filesystem encoding. + + Set to ``1`` if the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment + variable is set to a non-empty string. + + See also the :pep:`529`. + + Availability: Windows. - The :option:`-O` option. +.. c:var:: Py_LegacyWindowsStdioFlag -.. :c:data: Py_DontWriteBytecodeFlag + If the flag is non-zero, use :class:`io.FileIO` instead of + :class:`WindowsConsoleIO` for :mod:`sys` standard streams. - The :option:`-B` option. + Set to ``1`` if the :envvar:`PYTHONLEGACYWINDOWSSTDIO` environment + variable is set to a non-empty string. -.. :c:data: Py_NoUserSiteDirectory + See also the :pep:`528`. - The :option:`-s` option. + Availability: Windows. -.. :c:data: Py_NoSiteFlag +.. c:var:: Py_NoSiteFlag - The :option:`-S` option. + Disable the import of the module :mod:`site` and the site-dependent + manipulations of :data:`sys.path` that it entails. Also disable these + manipulations if :mod:`site` is explicitly imported later (call + :func:`site.main` if you want them to be triggered). -.. :c:data: Py_UnbufferedStdioFlag + Set by the :option:`-S` option. - The :option:`-u` option. +.. c:var:: Py_NoUserSiteDirectory -.. :c:data: Py_VerboseFlag + Don't add the :data:`user site-packages directory ` to + :data:`sys.path`. - The :option:`-v` option. + Set by the :option:`-s` and :option:`-I` options, and the + :envvar:`PYTHONNOUSERSITE` environment variable. -.. :c:data: Py_QuietFlag +.. c:var:: Py_OptimizeFlag - The :option:`-q` option. + Set by the :option:`-O` option and the :envvar:`PYTHONOPTIMIZE` environment + variable. + +.. c:var:: Py_QuietFlag + + Don't display the copyright and version messages even in interactive mode. + + Set by the :option:`-q` option. .. versionadded:: 3.2 -.. :c:data: Py_IgnoreEnvironmentFlag +.. c:var:: Py_UnbufferedStdioFlag + + Force the stdout and stderr streams to be unbuffered. + + Set by the :option:`-u` option and the :envvar:`PYTHONUNBUFFERED` + environment variable. + +.. c:var:: Py_VerboseFlag + + Print a message each time a module is initialized, showing the place + (filename or built-in module) from which it is loaded. If greater or equal + to ``2``, print a message for each file that is checked for when + searching for a module. Also provides information on module cleanup at exit. + + Set by the :option:`-v` option and the :envvar:`PYTHONVERBOSE` environment + variable. + + +Other variables: + +.. c:var:: Py_FrozenFlag + + Suppress error messages when calculating the module search path in + :c:func:`Py_GetPath`. + + Private flag used by ``_freeze_importlib`` and ``frozenmain`` programs. + +.. c:var:: Py_UseClassExceptionsFlag + + Deprecated and ignored flag, used to enable class exceptions prior Python + 2.0. - The :option:`-E` and :option:`-I` options. + .. deprecated:: 2.0 Initializing and finalizing the interpreter @@ -1214,7 +1315,7 @@ Python-level trace functions in previous versions. +------------------------------+--------------------------------------+ -.. c:var:: int PyTrace_CALL +.. c:var::: int PyTrace_CALL The value of the *what* parameter to a :c:type:`Py_tracefunc` function when a new call to a function or method is being reported, or a new entry into a generator. @@ -1223,7 +1324,7 @@ Python-level trace functions in previous versions. frame. -.. c:var:: int PyTrace_EXCEPTION +.. c:var::: int PyTrace_EXCEPTION The value of the *what* parameter to a :c:type:`Py_tracefunc` function when an exception has been raised. The callback function is called with this value for @@ -1234,31 +1335,31 @@ Python-level trace functions in previous versions. these events; they are not needed by the profiler. -.. c:var:: int PyTrace_LINE +.. c:var::: int PyTrace_LINE The value passed as the *what* parameter to a trace function (but not a profiling function) when a line-number event is being reported. -.. c:var:: int PyTrace_RETURN +.. c:var::: int PyTrace_RETURN The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a call is returning without propagating an exception. -.. c:var:: int PyTrace_C_CALL +.. c:var::: int PyTrace_C_CALL The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a C function is about to be called. -.. c:var:: int PyTrace_C_EXCEPTION +.. c:var::: int PyTrace_C_EXCEPTION The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a C function has raised an exception. -.. c:var:: int PyTrace_C_RETURN +.. c:var::: int PyTrace_C_RETURN The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a C function has returned. From b58aba44198100417a467a4f78638c71743b36d5 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 24 Nov 2017 21:13:06 +0100 Subject: [PATCH 4/7] Address new round of comments --- Doc/c-api/init.rst | 68 ++++++++++++++++++++----------------------- Doc/using/cmdline.rst | 2 +- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 5c25d4a3b5a0f2..ab40a39aaa4150 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -16,28 +16,31 @@ In an application embedding Python, the :c:func:`Py_Initialize` function must be called before using any other Python/C API functions; with the exception of a few functions and the :ref:`global configuration variables `: -The following functions can be safetely called before Python is initialized: +The following functions can be safely called before Python is initialized: * Configuration functions: * :c:func:`PyImport_AppendInittab` * :c:func:`PyImport_ExtendInittab` * :c:func:`PyInitFrozenExtensions` - * :c:func:`PyMem_GetAllocator` * :c:func:`PyMem_SetAllocator` * :c:func:`PyMem_SetupDebugHooks` - * :c:func:`PyObject_GetArenaAllocator` * :c:func:`PyObject_SetArenaAllocator` + * :c:func:`Py_SetPath` + * :c:func:`Py_SetProgramName` + * :c:func:`Py_SetPythonHome` + * :c:func:`Py_SetStandardStreamEncoding` + +* Informative functions: + + * :c:func:`PyMem_GetAllocator` + * :c:func:`PyObject_GetArenaAllocator` * :c:func:`Py_GetBuildInfo` * :c:func:`Py_GetCompiler` * :c:func:`Py_GetCopyright` * :c:func:`Py_GetPlatform` * :c:func:`Py_GetProgramName` * :c:func:`Py_GetVersion` - * :c:func:`Py_SetPath` - * :c:func:`Py_SetProgramName` - * :c:func:`Py_SetPythonHome` - * :c:func:`Py_SetStandardStreamEncoding` * Utilities: @@ -61,9 +64,10 @@ The following functions can be safetely called before Python is initialized: .. note:: - :c:func:`Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix` and - :c:func:`Py_GetProgramFullPath` and :c:func:`Py_GetPythonHome` **should not - be called** before :c:func:`Py_Initialize`. + The following functions **should not be called** before + :c:func:`Py_Initialize`: :c:func:`Py_EncodeLocale`, :c:func:`Py_GetPath`, + :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix` and + :c:func:`Py_GetProgramFullPath` and :c:func:`Py_GetPythonHome`. .. _global-conf-vars: @@ -89,7 +93,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2. .. c:var:: Py_DebugFlag - Turn on parser debugging output (for wizards only, depending on compilation + Turn on parser debugging output (for expert only, depending on compilation options). Set by the :option:`-d` option and the :envvar:`PYTHONDEBUG` environment @@ -103,6 +107,13 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2. Set by the :option:`-B` option and the :envvar:`PYTHONDONTWRITEBYTECODE` environment variable. +.. c:var:: Py_FrozenFlag + + Suppress error messages when calculating the module search path in + :c:func:`Py_GetPath`. + + Private flag used by ``_freeze_importlib`` and ``frozenmain`` programs. + .. c:var:: Py_HashRandomizationFlag Set to ``1`` if the :envvar:`PYTHONHASHSEED` environment variable is set to @@ -148,7 +159,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2. Set to ``1`` if the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment variable is set to a non-empty string. - See also the :pep:`529`. + See :pep:`529` for more details. Availability: Windows. @@ -160,7 +171,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2. Set to ``1`` if the :envvar:`PYTHONLEGACYWINDOWSSTDIO` environment variable is set to a non-empty string. - See also the :pep:`528`. + See :pep:`528` for more details. Availability: Windows. @@ -212,23 +223,6 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2. variable. -Other variables: - -.. c:var:: Py_FrozenFlag - - Suppress error messages when calculating the module search path in - :c:func:`Py_GetPath`. - - Private flag used by ``_freeze_importlib`` and ``frozenmain`` programs. - -.. c:var:: Py_UseClassExceptionsFlag - - Deprecated and ignored flag, used to enable class exceptions prior Python - 2.0. - - .. deprecated:: 2.0 - - Initializing and finalizing the interpreter =========================================== @@ -1315,7 +1309,7 @@ Python-level trace functions in previous versions. +------------------------------+--------------------------------------+ -.. c:var::: int PyTrace_CALL +.. c:var:: int PyTrace_CALL The value of the *what* parameter to a :c:type:`Py_tracefunc` function when a new call to a function or method is being reported, or a new entry into a generator. @@ -1324,7 +1318,7 @@ Python-level trace functions in previous versions. frame. -.. c:var::: int PyTrace_EXCEPTION +.. c:var:: int PyTrace_EXCEPTION The value of the *what* parameter to a :c:type:`Py_tracefunc` function when an exception has been raised. The callback function is called with this value for @@ -1335,31 +1329,31 @@ Python-level trace functions in previous versions. these events; they are not needed by the profiler. -.. c:var::: int PyTrace_LINE +.. c:var:: int PyTrace_LINE The value passed as the *what* parameter to a trace function (but not a profiling function) when a line-number event is being reported. -.. c:var::: int PyTrace_RETURN +.. c:var:: int PyTrace_RETURN The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a call is returning without propagating an exception. -.. c:var::: int PyTrace_C_CALL +.. c:var:: int PyTrace_C_CALL The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a C function is about to be called. -.. c:var::: int PyTrace_C_EXCEPTION +.. c:var:: int PyTrace_C_EXCEPTION The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a C function has raised an exception. -.. c:var::: int PyTrace_C_RETURN +.. c:var:: int PyTrace_C_RETURN The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a C function has returned. diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index fc557eebe4ac3e..d022e2cd2a0ace 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -212,7 +212,7 @@ Miscellaneous options .. cmdoption:: -d - Turn on parser debugging output (for wizards only, depending on compilation + Turn on parser debugging output (for expert only, depending on compilation options). See also :envvar:`PYTHONDEBUG`. From b2fc1664b20a749feb617a5c6c799204c1ee6d09 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 24 Nov 2017 21:23:37 +0100 Subject: [PATCH 5/7] Fix typo --- Doc/c-api/init.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index ab40a39aaa4150..e62a4def0520c2 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -14,7 +14,8 @@ Before Python Initialization In an application embedding Python, the :c:func:`Py_Initialize` function must be called before using any other Python/C API functions; with the exception of -a few functions and the :ref:`global configuration variables `: +a few functions and the :ref:`global configuration variables +`. The following functions can be safely called before Python is initialized: From e01c316996881fdb33fd2cb7387393c0790a11a8 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 24 Nov 2017 21:38:00 +0100 Subject: [PATCH 6/7] Only keep PyMem_Raw memory allocators --- Doc/c-api/init.rst | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index e62a4def0520c2..2f77bb359d24e5 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -53,15 +53,6 @@ The following functions can be safely called before Python is initialized: * :c:func:`PyMem_RawRealloc` * :c:func:`PyMem_RawCalloc` * :c:func:`PyMem_RawFree` - * :c:func:`PyMem_Malloc` - * :c:func:`PyMem_Realloc` - * :c:func:`PyMem_Calloc` - * :c:func:`PyMem_Free` - * :c:func:`PyObject_Malloc` - * :c:func:`PyObject_Realloc` - * :c:func:`PyObject_Calloc` - * :c:func:`PyObject_Free` - .. note:: From f1c305bfb0c10412f95cf7794bae45a7022de163 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 24 Nov 2017 22:21:41 +0100 Subject: [PATCH 7/7] man page: wizards => expert --- Misc/python.man | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/python.man b/Misc/python.man index 9f71d69dfaf260..b4110295536606 100644 --- a/Misc/python.man +++ b/Misc/python.man @@ -124,7 +124,7 @@ This terminates the option list (following options are passed as arguments to the command). .TP .B \-d -Turn on parser debugging output (for wizards only, depending on +Turn on parser debugging output (for expert only, depending on compilation options). .TP .B \-E