Skip to content

Commit c07c3c6

Browse files
committed
Merge branch 'main' into gh-130614-test-read
2 parents 380b1d7 + 93fc3d3 commit c07c3c6

40 files changed

+822
-301
lines changed

Doc/extending/windows.rst

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ gives you access to spam's names, but does not create a separate copy. On Unix,
9696
linking with a library is more like ``from spam import *``; it does create a
9797
separate copy.
9898

99+
.. c:macro:: Py_NO_LINK_LIB
100+
101+
Turn off the implicit, ``#pragma``-based linkage with the Python
102+
library, performed inside CPython header files.
103+
104+
.. versionadded:: 3.14
105+
99106

100107
.. _win-dlls:
101108

@@ -108,21 +115,46 @@ Using DLLs in Practice
108115
Windows Python is built in Microsoft Visual C++; using other compilers may or
109116
may not work. The rest of this section is MSVC++ specific.
110117

111-
When creating DLLs in Windows, you must pass :file:`pythonXY.lib` to the linker.
112-
To build two DLLs, spam and ni (which uses C functions found in spam), you could
113-
use these commands::
118+
When creating DLLs in Windows, you can use the CPython library in two ways:
119+
120+
1. By default, inclusion of :file:`PC/pyconfig.h` directly or via
121+
:file:`Python.h` triggers an implicit, configure-aware link with the
122+
library. The header file chooses :file:`pythonXY_d.lib` for Debug,
123+
:file:`pythonXY.lib` for Release, and :file:`pythonX.lib` for Release with
124+
the `Limited API <stable-application-binary-interface>`_ enabled.
125+
126+
To build two DLLs, spam and ni (which uses C functions found in spam), you
127+
could use these commands::
128+
129+
cl /LD /I/python/include spam.c
130+
cl /LD /I/python/include ni.c spam.lib
131+
132+
The first command created three files: :file:`spam.obj`, :file:`spam.dll`
133+
and :file:`spam.lib`. :file:`Spam.dll` does not contain any Python
134+
functions (such as :c:func:`PyArg_ParseTuple`), but it does know how to find
135+
the Python code thanks to the implicitly linked :file:`pythonXY.lib`.
136+
137+
The second command created :file:`ni.dll` (and :file:`.obj` and
138+
:file:`.lib`), which knows how to find the necessary functions from spam,
139+
and also from the Python executable.
140+
141+
2. Manually by defining :c:macro:`Py_NO_LINK_LIB` macro before including
142+
:file:`Python.h`. You must pass :file:`pythonXY.lib` to the linker.
143+
144+
To build two DLLs, spam and ni (which uses C functions found in spam), you
145+
could use these commands::
114146

115-
cl /LD /I/python/include spam.c ../libs/pythonXY.lib
116-
cl /LD /I/python/include ni.c spam.lib ../libs/pythonXY.lib
147+
cl /LD /DPy_NO_LINK_LIB /I/python/include spam.c ../libs/pythonXY.lib
148+
cl /LD /DPy_NO_LINK_LIB /I/python/include ni.c spam.lib ../libs/pythonXY.lib
117149

118-
The first command created three files: :file:`spam.obj`, :file:`spam.dll` and
119-
:file:`spam.lib`. :file:`Spam.dll` does not contain any Python functions (such
120-
as :c:func:`PyArg_ParseTuple`), but it does know how to find the Python code
121-
thanks to :file:`pythonXY.lib`.
150+
The first command created three files: :file:`spam.obj`, :file:`spam.dll`
151+
and :file:`spam.lib`. :file:`Spam.dll` does not contain any Python
152+
functions (such as :c:func:`PyArg_ParseTuple`), but it does know how to find
153+
the Python code thanks to :file:`pythonXY.lib`.
122154

123-
The second command created :file:`ni.dll` (and :file:`.obj` and :file:`.lib`),
124-
which knows how to find the necessary functions from spam, and also from the
125-
Python executable.
155+
The second command created :file:`ni.dll` (and :file:`.obj` and
156+
:file:`.lib`), which knows how to find the necessary functions from spam,
157+
and also from the Python executable.
126158

127159
Not every identifier is exported to the lookup table. If you want any other
128160
modules (including Python) to be able to see your identifiers, you have to say

Doc/library/asyncio-subprocess.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Creating Subprocesses
6868
Create a subprocess.
6969

7070
The *limit* argument sets the buffer limit for :class:`StreamReader`
71-
wrappers for :attr:`Process.stdout` and :attr:`Process.stderr`
71+
wrappers for :attr:`~asyncio.subprocess.Process.stdout` and :attr:`~asyncio.subprocess.Process.stderr`
7272
(if :const:`subprocess.PIPE` is passed to *stdout* and *stderr* arguments).
7373

7474
Return a :class:`~asyncio.subprocess.Process` instance.
@@ -87,7 +87,7 @@ Creating Subprocesses
8787
Run the *cmd* shell command.
8888

8989
The *limit* argument sets the buffer limit for :class:`StreamReader`
90-
wrappers for :attr:`Process.stdout` and :attr:`Process.stderr`
90+
wrappers for :attr:`~asyncio.subprocess.Process.stdout` and :attr:`~asyncio.subprocess.Process.stderr`
9191
(if :const:`subprocess.PIPE` is passed to *stdout* and *stderr* arguments).
9292

9393
Return a :class:`~asyncio.subprocess.Process` instance.
@@ -132,12 +132,12 @@ Constants
132132

133133
If *PIPE* is passed to *stdin* argument, the
134134
:attr:`Process.stdin <asyncio.subprocess.Process.stdin>` attribute
135-
will point to a :class:`StreamWriter` instance.
135+
will point to a :class:`~asyncio.StreamWriter` instance.
136136

137137
If *PIPE* is passed to *stdout* or *stderr* arguments, the
138138
:attr:`Process.stdout <asyncio.subprocess.Process.stdout>` and
139139
:attr:`Process.stderr <asyncio.subprocess.Process.stderr>`
140-
attributes will point to :class:`StreamReader` instances.
140+
attributes will point to :class:`~asyncio.StreamReader` instances.
141141

142142
.. data:: asyncio.subprocess.STDOUT
143143
:module:
@@ -165,7 +165,7 @@ their completion.
165165
:module:
166166

167167
An object that wraps OS processes created by the
168-
:func:`create_subprocess_exec` and :func:`create_subprocess_shell`
168+
:func:`~asyncio.create_subprocess_exec` and :func:`~asyncio.create_subprocess_shell`
169169
functions.
170170

171171
This class is designed to have a similar API to the
@@ -263,24 +263,24 @@ their completion.
263263

264264
Kill the child process.
265265

266-
On POSIX systems this method sends :py:data:`SIGKILL` to the child
266+
On POSIX systems this method sends :py:data:`~signal.SIGKILL` to the child
267267
process.
268268

269269
On Windows this method is an alias for :meth:`terminate`.
270270

271271
.. attribute:: stdin
272272

273-
Standard input stream (:class:`StreamWriter`) or ``None``
273+
Standard input stream (:class:`~asyncio.StreamWriter`) or ``None``
274274
if the process was created with ``stdin=None``.
275275

276276
.. attribute:: stdout
277277

278-
Standard output stream (:class:`StreamReader`) or ``None``
278+
Standard output stream (:class:`~asyncio.StreamReader`) or ``None``
279279
if the process was created with ``stdout=None``.
280280

281281
.. attribute:: stderr
282282

283-
Standard error stream (:class:`StreamReader`) or ``None``
283+
Standard error stream (:class:`~asyncio.StreamReader`) or ``None``
284284
if the process was created with ``stderr=None``.
285285

286286
.. warning::
@@ -296,7 +296,7 @@ their completion.
296296

297297
Process identification number (PID).
298298

299-
Note that for processes created by the :func:`create_subprocess_shell`
299+
Note that for processes created by the :func:`~asyncio.create_subprocess_shell`
300300
function, this attribute is the PID of the spawned shell.
301301

302302
.. attribute:: returncode

Doc/library/time.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ An explanation of some terminology and conventions is in order.
5252
single: Coordinated Universal Time
5353
single: Greenwich Mean Time
5454

55-
* UTC is Coordinated Universal Time (formerly known as Greenwich Mean Time, or
56-
GMT). The acronym UTC is not a mistake but a compromise between English and
57-
French.
55+
* UTC is `Coordinated Universal Time`_ and superseded `Greenwich Mean Time`_ or
56+
GMT as the basis of international timekeeping. The acronym UTC is not a
57+
mistake but conforms to an earlier, language-agnostic naming scheme for time
58+
standards such as UT0, UT1, and UT2.
59+
60+
.. _Coordinated Universal Time: https://en.wikipedia.org/wiki/Coordinated_Universal_Time
61+
.. _Greenwich Mean Time: https://en.wikipedia.org/wiki/Greenwich_Mean_Time
5862

5963
.. index:: single: Daylight Saving Time
6064

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Doc/c-api/typeobj.rst
1414
Doc/extending/extending.rst
1515
Doc/library/ast.rst
1616
Doc/library/asyncio-extending.rst
17-
Doc/library/asyncio-subprocess.rst
1817
Doc/library/decimal.rst
1918
Doc/library/email.charset.rst
2019
Doc/library/email.compat32-message.rst

Doc/whatsnew/3.14.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,10 @@ Build changes
14151415
* GNU Autoconf 2.72 is now required to generate :file:`configure`.
14161416
(Contributed by Erlend Aasland in :gh:`115765`.)
14171417

1418+
* ``#pragma``-based linking with ``python3*.lib`` can now be switched off
1419+
with :c:expr:`Py_NO_LINK_LIB`. (Contributed by Jean-Christophe
1420+
Fillion-Robin in :gh:`82909`.)
1421+
14181422
.. _whatsnew314-pep761:
14191423

14201424
PEP 761: Discontinuation of PGP signatures

Include/internal/pycore_ceval.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ _Py_eval_breaker_bit_is_set(PyThreadState *tstate, uintptr_t bit)
342342
void _Py_set_eval_breaker_bit_all(PyInterpreterState *interp, uintptr_t bit);
343343
void _Py_unset_eval_breaker_bit_all(PyInterpreterState *interp, uintptr_t bit);
344344

345-
PyAPI_FUNC(PyObject *) _PyFloat_FromDouble_ConsumeInputs(_PyStackRef left, _PyStackRef right, double value);
345+
PyAPI_FUNC(_PyStackRef) _PyFloat_FromDouble_ConsumeInputs(_PyStackRef left, _PyStackRef right, double value);
346346

347347
#ifdef __cplusplus
348348
}

Include/internal/pycore_frame.h

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,26 @@ _PyFrame_NumSlotsForCodeObject(PyCodeObject *code)
148148

149149
static inline void _PyFrame_Copy(_PyInterpreterFrame *src, _PyInterpreterFrame *dest)
150150
{
151-
*dest = *src;
151+
dest->f_executable = PyStackRef_MakeHeapSafe(src->f_executable);
152+
// Don't leave a dangling pointer to the old frame when creating generators
153+
// and coroutines:
154+
dest->previous = NULL;
155+
dest->f_funcobj = PyStackRef_MakeHeapSafe(src->f_funcobj);
156+
dest->f_globals = src->f_globals;
157+
dest->f_builtins = src->f_builtins;
158+
dest->f_locals = src->f_locals;
159+
dest->frame_obj = src->frame_obj;
160+
dest->instr_ptr = src->instr_ptr;
161+
#ifdef Py_GIL_DISABLED
162+
dest->tlbc_index = src->tlbc_index;
163+
#endif
152164
assert(src->stackpointer != NULL);
153165
int stacktop = (int)(src->stackpointer - src->localsplus);
154-
assert(stacktop >= _PyFrame_GetCode(src)->co_nlocalsplus);
166+
assert(stacktop >= 0);
155167
dest->stackpointer = dest->localsplus + stacktop;
156-
for (int i = 1; i < stacktop; i++) {
157-
dest->localsplus[i] = src->localsplus[i];
168+
for (int i = 0; i < stacktop; i++) {
169+
dest->localsplus[i] = PyStackRef_MakeHeapSafe(src->localsplus[i]);
158170
}
159-
// Don't leave a dangling pointer to the old frame when creating generators
160-
// and coroutines:
161-
dest->previous = NULL;
162171
}
163172

164173
#ifdef Py_GIL_DISABLED
@@ -393,7 +402,7 @@ _PyFrame_PushTrampolineUnchecked(PyThreadState *tstate, PyCodeObject *code, int
393402

394403
PyAPI_FUNC(_PyInterpreterFrame *)
395404
_PyEvalFramePushAndInit(PyThreadState *tstate, _PyStackRef func,
396-
PyObject *locals, _PyStackRef const* args,
405+
PyObject *locals, _PyStackRef const *args,
397406
size_t argcount, PyObject *kwnames,
398407
_PyInterpreterFrame *previous);
399408

Include/internal/pycore_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ PyAPI_FUNC(int) _PyObject_IsFreed(PyObject *);
8282
#define _PyObject_HEAD_INIT(type) \
8383
{ \
8484
.ob_refcnt = _Py_IMMORTAL_INITIAL_REFCNT, \
85-
.ob_flags = _Py_STATICALLY_ALLOCATED_FLAG, \
85+
.ob_flags = _Py_STATIC_FLAG_BITS, \
8686
.ob_type = (type) \
8787
}
8888
#else

Include/internal/pycore_opcode_metadata.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)