Skip to content

Commit 948bc68

Browse files
authored
Merge branch 'master' into die-idna-die
2 parents f49055d + b2a6083 commit 948bc68

File tree

765 files changed

+29947
-16410
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

765 files changed

+29947
-16410
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,8 @@ Python/bootstrap_hash.c @python/crypto-team
5050
**/*functools* @ncoghlan @rhettinger
5151
**/*decimal* @rhettinger @skrah
5252

53+
**/*dataclasses* @ericvsmith
54+
5355
**/*idlelib* @terryjreedy
56+
57+
**/*typing* @gvanrossum @ilevkivskyi

Doc/bugs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ taken on the bug.
6868

6969
.. seealso::
7070

71-
`How to Report Bugs Effectively <http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>`_
71+
`How to Report Bugs Effectively <https://www.chiark.greenend.org.uk/~sgtatham/bugs.html>`_
7272
Article which goes into some detail about how to create a useful bug report.
7373
This describes what kind of information is useful and why it is useful.
7474

Doc/c-api/datetime.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ not be *NULL*, and the type is not checked:
188188
.. versionadded:: 3.3
189189
190190
191-
.. c:function:: int PyDateTime_DELTA_GET_MICROSECOND(PyDateTime_Delta *o)
191+
.. c:function:: int PyDateTime_DELTA_GET_MICROSECONDS(PyDateTime_Delta *o)
192192
193193
Return the number of microseconds, as an int from 0 through 999999.
194194

Doc/c-api/init.rst

Lines changed: 214 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,213 @@
77
Initialization, Finalization, and Threads
88
*****************************************
99

10+
.. _pre-init-safe:
11+
12+
Before Python Initialization
13+
============================
14+
15+
In an application embedding Python, the :c:func:`Py_Initialize` function must
16+
be called before using any other Python/C API functions; with the exception of
17+
a few functions and the :ref:`global configuration variables
18+
<global-conf-vars>`.
19+
20+
The following functions can be safely called before Python is initialized:
21+
22+
* Configuration functions:
23+
24+
* :c:func:`PyImport_AppendInittab`
25+
* :c:func:`PyImport_ExtendInittab`
26+
* :c:func:`PyInitFrozenExtensions`
27+
* :c:func:`PyMem_SetAllocator`
28+
* :c:func:`PyMem_SetupDebugHooks`
29+
* :c:func:`PyObject_SetArenaAllocator`
30+
* :c:func:`Py_SetPath`
31+
* :c:func:`Py_SetProgramName`
32+
* :c:func:`Py_SetPythonHome`
33+
* :c:func:`Py_SetStandardStreamEncoding`
34+
35+
* Informative functions:
36+
37+
* :c:func:`PyMem_GetAllocator`
38+
* :c:func:`PyObject_GetArenaAllocator`
39+
* :c:func:`Py_GetBuildInfo`
40+
* :c:func:`Py_GetCompiler`
41+
* :c:func:`Py_GetCopyright`
42+
* :c:func:`Py_GetPlatform`
43+
* :c:func:`Py_GetVersion`
44+
45+
* Utilities:
46+
47+
* :c:func:`Py_DecodeLocale`
48+
49+
* Memory allocators:
50+
51+
* :c:func:`PyMem_RawMalloc`
52+
* :c:func:`PyMem_RawRealloc`
53+
* :c:func:`PyMem_RawCalloc`
54+
* :c:func:`PyMem_RawFree`
55+
56+
.. note::
57+
58+
The following functions **should not be called** before
59+
:c:func:`Py_Initialize`: :c:func:`Py_EncodeLocale`, :c:func:`Py_GetPath`,
60+
:c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`,
61+
:c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome`,
62+
:c:func:`Py_GetProgramName` and :c:func:`PyEval_InitThreads`.
63+
64+
65+
.. _global-conf-vars:
66+
67+
Global configuration variables
68+
==============================
69+
70+
Python has variables for the global configuration to control different features
71+
and options. By default, these flags are controlled by :ref:`command line
72+
options <using-on-interface-options>`.
73+
74+
When a flag is set by an option, the value of the flag is the number of times
75+
that the option was set. For example, ``-b`` sets :c:data:`Py_BytesWarningFlag`
76+
to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
77+
78+
.. c:var:: Py_BytesWarningFlag
79+
80+
Issue a warning when comparing :class:`bytes` or :class:`bytearray` with
81+
:class:`str` or :class:`bytes` with :class:`int`. Issue an error if greater
82+
or equal to ``2``.
83+
84+
Set by the :option:`-b` option.
85+
86+
.. c:var:: Py_DebugFlag
87+
88+
Turn on parser debugging output (for expert only, depending on compilation
89+
options).
90+
91+
Set by the :option:`-d` option and the :envvar:`PYTHONDEBUG` environment
92+
variable.
93+
94+
.. c:var:: Py_DontWriteBytecodeFlag
95+
96+
If set to non-zero, Python won't try to write ``.pyc`` files on the
97+
import of source modules.
98+
99+
Set by the :option:`-B` option and the :envvar:`PYTHONDONTWRITEBYTECODE`
100+
environment variable.
101+
102+
.. c:var:: Py_FrozenFlag
103+
104+
Suppress error messages when calculating the module search path in
105+
:c:func:`Py_GetPath`.
106+
107+
Private flag used by ``_freeze_importlib`` and ``frozenmain`` programs.
108+
109+
.. c:var:: Py_HashRandomizationFlag
110+
111+
Set to ``1`` if the :envvar:`PYTHONHASHSEED` environment variable is set to
112+
a non-empty string.
113+
114+
If the flag is non-zero, read the :envvar:`PYTHONHASHSEED` environment
115+
variable to initialize the secret hash seed.
116+
117+
.. c:var:: Py_IgnoreEnvironmentFlag
118+
119+
Ignore all :envvar:`PYTHON*` environment variables, e.g.
120+
:envvar:`PYTHONPATH` and :envvar:`PYTHONHOME`, that might be set.
121+
122+
Set by the :option:`-E` and :option:`-I` options.
123+
124+
.. c:var:: Py_InspectFlag
125+
126+
When a script is passed as first argument or the :option:`-c` option is used,
127+
enter interactive mode after executing the script or the command, even when
128+
:data:`sys.stdin` does not appear to be a terminal.
129+
130+
Set by the :option:`-i` option and the :envvar:`PYTHONINSPECT` environment
131+
variable.
132+
133+
.. c:var:: Py_InteractiveFlag
134+
135+
Set by the :option:`-i` option.
136+
137+
.. c:var:: Py_IsolatedFlag
138+
139+
Run Python in isolated mode. In isolated mode :data:`sys.path` contains
140+
neither the script's directory nor the user's site-packages directory.
141+
142+
Set by the :option:`-I` option.
143+
144+
.. versionadded:: 3.4
145+
146+
.. c:var:: Py_LegacyWindowsFSEncodingFlag
147+
148+
If the flag is non-zero, use the ``mbcs`` encoding instead of the UTF-8
149+
encoding for the filesystem encoding.
150+
151+
Set to ``1`` if the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment
152+
variable is set to a non-empty string.
153+
154+
See :pep:`529` for more details.
155+
156+
Availability: Windows.
157+
158+
.. c:var:: Py_LegacyWindowsStdioFlag
159+
160+
If the flag is non-zero, use :class:`io.FileIO` instead of
161+
:class:`WindowsConsoleIO` for :mod:`sys` standard streams.
162+
163+
Set to ``1`` if the :envvar:`PYTHONLEGACYWINDOWSSTDIO` environment
164+
variable is set to a non-empty string.
165+
166+
See :pep:`528` for more details.
167+
168+
Availability: Windows.
169+
170+
.. c:var:: Py_NoSiteFlag
171+
172+
Disable the import of the module :mod:`site` and the site-dependent
173+
manipulations of :data:`sys.path` that it entails. Also disable these
174+
manipulations if :mod:`site` is explicitly imported later (call
175+
:func:`site.main` if you want them to be triggered).
176+
177+
Set by the :option:`-S` option.
178+
179+
.. c:var:: Py_NoUserSiteDirectory
180+
181+
Don't add the :data:`user site-packages directory <site.USER_SITE>` to
182+
:data:`sys.path`.
183+
184+
Set by the :option:`-s` and :option:`-I` options, and the
185+
:envvar:`PYTHONNOUSERSITE` environment variable.
186+
187+
.. c:var:: Py_OptimizeFlag
188+
189+
Set by the :option:`-O` option and the :envvar:`PYTHONOPTIMIZE` environment
190+
variable.
191+
192+
.. c:var:: Py_QuietFlag
193+
194+
Don't display the copyright and version messages even in interactive mode.
195+
196+
Set by the :option:`-q` option.
197+
198+
.. versionadded:: 3.2
199+
200+
.. c:var:: Py_UnbufferedStdioFlag
201+
202+
Force the stdout and stderr streams to be unbuffered.
203+
204+
Set by the :option:`-u` option and the :envvar:`PYTHONUNBUFFERED`
205+
environment variable.
206+
207+
.. c:var:: Py_VerboseFlag
208+
209+
Print a message each time a module is initialized, showing the place
210+
(filename or built-in module) from which it is loaded. If greater or equal
211+
to ``2``, print a message for each file that is checked for when
212+
searching for a module. Also provides information on module cleanup at exit.
213+
214+
Set by the :option:`-v` option and the :envvar:`PYTHONVERBOSE` environment
215+
variable.
216+
10217

11218
Initializing and finalizing the interpreter
12219
===========================================
@@ -27,9 +234,11 @@ Initializing and finalizing the interpreter
27234
single: PySys_SetArgvEx()
28235
single: Py_FinalizeEx()
29236
30-
Initialize the Python interpreter. In an application embedding Python, this
31-
should be called before using any other Python/C API functions; with the
32-
exception of :c:func:`Py_SetProgramName`, :c:func:`Py_SetPythonHome` and :c:func:`Py_SetPath`. This initializes
237+
Initialize the Python interpreter. In an application embedding Python,
238+
this should be called before using any other Python/C API functions; see
239+
:ref:`Before Python Initialization <pre-init-safe>` for the few exceptions.
240+
241+
This initializes
33242
the table of loaded modules (``sys.modules``), and creates the fundamental
34243
modules :mod:`builtins`, :mod:`__main__` and :mod:`sys`. It also initializes
35244
the module search path (``sys.path``). It does not set ``sys.argv``; use
@@ -129,7 +338,7 @@ Process-wide parameters
129338
.. versionadded:: 3.4
130339
131340
132-
.. c:function:: void Py_SetProgramName(wchar_t *name)
341+
.. c:function:: void Py_SetProgramName(const wchar_t *name)
133342
134343
.. index::
135344
single: Py_Initialize()
@@ -396,7 +605,7 @@ Process-wide parameters
396605
.. versionchanged:: 3.4 The *updatepath* value depends on :option:`-I`.
397606
398607
399-
.. c:function:: void Py_SetPythonHome(wchar_t *home)
608+
.. c:function:: void Py_SetPythonHome(const wchar_t *home)
400609
401610
Set the default "home" directory, that is, the location of the standard
402611
Python libraries. See :envvar:`PYTHONHOME` for the meaning of the

Doc/c-api/intro.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,27 +106,39 @@ complete listing.
106106
all possible values are covered in ``case`` statements. Use this in places
107107
where you might be tempted to put an ``assert(0)`` or ``abort()`` call.
108108

109+
.. versionadded:: 3.7
110+
109111
.. c:macro:: Py_ABS(x)
110112
111113
Return the absolute value of ``x``.
112114

115+
.. versionadded:: 3.3
116+
113117
.. c:macro:: Py_MIN(x, y)
114118
115119
Return the minimum value between ``x`` and ``y``.
116120

121+
.. versionadded:: 3.3
122+
117123
.. c:macro:: Py_MAX(x, y)
118124
119125
Return the maximum value between ``x`` and ``y``.
120126

127+
.. versionadded:: 3.3
128+
121129
.. c:macro:: Py_STRINGIFY(x)
122130
123131
Convert ``x`` to a C string. E.g. ``Py_STRINGIFY(123)`` returns
124132
``"123"``.
125133

134+
.. versionadded:: 3.4
135+
126136
.. c:macro:: Py_MEMBER_SIZE(type, member)
127137
128138
Return the size of a structure (``type``) ``member`` in bytes.
129139

140+
.. versionadded:: 3.6
141+
130142
.. c:macro:: Py_CHARMASK(c)
131143
132144
Argument must be a character or an integer in the range [-128, 127] or [0,
@@ -137,6 +149,13 @@ complete listing.
137149
Like ``getenv(s)``, but returns *NULL* if :option:`-E` was passed on the
138150
command line (i.e. if ``Py_IgnoreEnvironmentFlag`` is set).
139151

152+
.. c:macro:: Py_UNUSED(arg)
153+
154+
Use this for unused arguments in a function definition to silence compiler
155+
warnings, e.g. ``PyObject* func(PyObject *Py_UNUSED(ignored))``.
156+
157+
.. versionadded:: 3.4
158+
140159

141160
.. _api-objects:
142161

0 commit comments

Comments
 (0)