Skip to content

Commit 1a8f4a0

Browse files
committed
Merge branch 'main' into inlinecomp2
* main: (34 commits) pythongh-102701: Fix overflow in dictobject.c (pythonGH-102750) pythonGH-78530: add support for generators in `asyncio.wait` (python#102761) Increase stack reserve size for Windows debug builds to avoid test crashes (pythonGH-102764) pythongh-102755: Add PyErr_DisplayException(exc) (python#102756) Fix outdated note about 'int' rounding or truncating (python#102736) pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (python#102760) pythongh-99726: Improves correctness of stat results for Windows, and uses faster API when available (pythonGH-102149) pythongh-102192: remove redundant exception fields from ssl module socket (python#102466) pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (python#102743) pythongh-102737: Un-ignore ceval.c in the CI globals check (pythongh-102745) pythonGH-102748: remove legacy support for generator based coroutines from `asyncio.iscoroutine` (python#102749) pythongh-102721: Improve coverage of `_collections_abc._CallableGenericAlias` (python#102722) pythonGH-102653: Make recipe docstring show the correct distribution (python#102742) Add comments to `{typing,_collections_abc}._type_repr` about each other (python#102752) pythongh-102594: PyErr_SetObject adds note to exception raised on normalization error (python#102675) pythongh-94440: Fix issue of ProcessPoolExecutor shutdown hanging (python#94468) pythonGH-100112: avoid using iterable coroutines in asyncio internally (python#100128) pythongh-102690: Use Edge as fallback in webbrowser instead of IE (python#102691) pythongh-102660: Fix Refleaks in import.c (python#102744) pythongh-102738: remove from cases generator the code related to register instructions (python#102739) ...
2 parents 6c5f269 + 65fb7c4 commit 1a8f4a0

File tree

79 files changed

+1910
-817
lines changed

Some content is hidden

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

79 files changed

+1910
-817
lines changed

Doc/c-api/exceptions.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ Printing and clearing
8686
8787
An exception must be set when calling this function.
8888
89+
.. c:function: void PyErr_DisplayException(PyObject *exc)
90+
91+
Print the standard traceback display of ``exc`` to ``sys.stderr``, including
92+
chained exceptions and notes.
93+
94+
.. versionadded:: 3.12
8995
9096
Raising exceptions
9197
==================

Doc/c-api/init.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ Process-wide parameters
513513
program name is ``'/usr/local/bin/python'``, the prefix is ``'/usr/local'``. The
514514
returned string points into static storage; the caller should not modify its
515515
value. This corresponds to the :makevar:`prefix` variable in the top-level
516-
:file:`Makefile` and the ``--prefix`` argument to the :program:`configure`
516+
:file:`Makefile` and the :option:`--prefix` argument to the :program:`configure`
517517
script at build time. The value is available to Python code as ``sys.prefix``.
518518
It is only useful on Unix. See also the next function.
519519

Doc/c-api/intro.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,19 @@ used by extension writers. Structure member names do not have a reserved prefix.
7878

7979
The header files are typically installed with Python. On Unix, these are
8080
located in the directories :file:`{prefix}/include/pythonversion/` and
81-
:file:`{exec_prefix}/include/pythonversion/`, where :envvar:`prefix` and
82-
:envvar:`exec_prefix` are defined by the corresponding parameters to Python's
81+
:file:`{exec_prefix}/include/pythonversion/`, where :option:`prefix <--prefix>` and
82+
:option:`exec_prefix <--exec-prefix>` are defined by the corresponding parameters to Python's
8383
:program:`configure` script and *version* is
8484
``'%d.%d' % sys.version_info[:2]``. On Windows, the headers are installed
85-
in :file:`{prefix}/include`, where :envvar:`prefix` is the installation
85+
in :file:`{prefix}/include`, where ``prefix`` is the installation
8686
directory specified to the installer.
8787

8888
To include the headers, place both directories (if different) on your compiler's
8989
search path for includes. Do *not* place the parent directories on the search
9090
path and then use ``#include <pythonX.Y/Python.h>``; this will break on
9191
multi-platform builds since the platform independent headers under
92-
:envvar:`prefix` include the platform specific headers from
93-
:envvar:`exec_prefix`.
92+
:option:`prefix <--prefix>` include the platform specific headers from
93+
:option:`exec_prefix <--exec-prefix>`.
9494

9595
C++ users should note that although the API is defined entirely using C, the
9696
header files properly declare the entry points to be ``extern "C"``. As a result,

Doc/data/stable_abi.dat

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

Doc/library/asyncio-task.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,10 @@ Waiting Primitives
804804
.. versionchanged:: 3.11
805805
Passing coroutine objects to ``wait()`` directly is forbidden.
806806

807+
.. versionchanged:: 3.12
808+
Added support for generators yielding tasks.
809+
810+
807811
.. function:: as_completed(aws, *, timeout=None)
808812

809813
Run :ref:`awaitable objects <asyncio-awaitables>` in the *aws*

Doc/library/os.rst

Lines changed: 65 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2858,6 +2858,12 @@ features:
28582858
Added support for the :class:`~os.PathLike` interface. Added support
28592859
for :class:`bytes` paths on Windows.
28602860

2861+
.. versionchanged:: 3.12
2862+
The ``st_ctime`` attribute of a stat result is deprecated on Windows.
2863+
The file creation time is properly available as ``st_birthtime``, and
2864+
in the future ``st_ctime`` may be changed to return zero or the
2865+
metadata change time, if available.
2866+
28612867

28622868
.. function:: stat(path, *, dir_fd=None, follow_symlinks=True)
28632869

@@ -2973,10 +2979,12 @@ features:
29732979

29742980
.. attribute:: st_ctime
29752981

2976-
Platform dependent:
2982+
Time of most recent metadata change expressed in seconds.
29772983

2978-
* the time of most recent metadata change on Unix,
2979-
* the time of creation on Windows, expressed in seconds.
2984+
.. versionchanged:: 3.12
2985+
``st_ctime`` is deprecated on Windows. Use ``st_birthtime`` for
2986+
the file creation time. In the future, ``st_ctime`` will contain
2987+
the time of the most recent metadata change, as for other platforms.
29802988

29812989
.. attribute:: st_atime_ns
29822990

@@ -2989,29 +2997,48 @@ features:
29892997

29902998
.. attribute:: st_ctime_ns
29912999

2992-
Platform dependent:
3000+
Time of most recent metadata change expressed in nanoseconds as an
3001+
integer.
3002+
3003+
.. versionchanged:: 3.12
3004+
``st_ctime_ns`` is deprecated on Windows. Use ``st_birthtime_ns``
3005+
for the file creation time. In the future, ``st_ctime`` will contain
3006+
the time of the most recent metadata change, as for other platforms.
3007+
3008+
.. attribute:: st_birthtime
3009+
3010+
Time of file creation expressed in seconds. This attribute is not
3011+
always available, and may raise :exc:`AttributeError`.
3012+
3013+
.. versionchanged:: 3.12
3014+
``st_birthtime`` is now available on Windows.
3015+
3016+
.. attribute:: st_birthtime_ns
29933017

2994-
* the time of most recent metadata change on Unix,
2995-
* the time of creation on Windows, expressed in nanoseconds as an
2996-
integer.
3018+
Time of file creation expressed in nanoseconds as an integer.
3019+
This attribute is not always available, and may raise
3020+
:exc:`AttributeError`.
3021+
3022+
.. versionadded:: 3.12
29973023

29983024
.. note::
29993025

30003026
The exact meaning and resolution of the :attr:`st_atime`,
3001-
:attr:`st_mtime`, and :attr:`st_ctime` attributes depend on the operating
3002-
system and the file system. For example, on Windows systems using the FAT
3003-
or FAT32 file systems, :attr:`st_mtime` has 2-second resolution, and
3004-
:attr:`st_atime` has only 1-day resolution. See your operating system
3005-
documentation for details.
3027+
:attr:`st_mtime`, :attr:`st_ctime` and :attr:`st_birthtime` attributes
3028+
depend on the operating system and the file system. For example, on
3029+
Windows systems using the FAT32 file systems, :attr:`st_mtime` has
3030+
2-second resolution, and :attr:`st_atime` has only 1-day resolution.
3031+
See your operating system documentation for details.
30063032

30073033
Similarly, although :attr:`st_atime_ns`, :attr:`st_mtime_ns`,
3008-
and :attr:`st_ctime_ns` are always expressed in nanoseconds, many
3009-
systems do not provide nanosecond precision. On systems that do
3010-
provide nanosecond precision, the floating-point object used to
3011-
store :attr:`st_atime`, :attr:`st_mtime`, and :attr:`st_ctime`
3012-
cannot preserve all of it, and as such will be slightly inexact.
3013-
If you need the exact timestamps you should always use
3014-
:attr:`st_atime_ns`, :attr:`st_mtime_ns`, and :attr:`st_ctime_ns`.
3034+
:attr:`st_ctime_ns` and :attr:`st_birthtime_ns` are always expressed in
3035+
nanoseconds, many systems do not provide nanosecond precision. On
3036+
systems that do provide nanosecond precision, the floating-point object
3037+
used to store :attr:`st_atime`, :attr:`st_mtime`, :attr:`st_ctime` and
3038+
:attr:`st_birthtime` cannot preserve all of it, and as such will be
3039+
slightly inexact. If you need the exact timestamps you should always use
3040+
:attr:`st_atime_ns`, :attr:`st_mtime_ns`, :attr:`st_ctime_ns` and
3041+
:attr:`st_birthtime_ns`.
30153042

30163043
On some Unix systems (such as Linux), the following attributes may also be
30173044
available:
@@ -3041,10 +3068,6 @@ features:
30413068

30423069
File generation number.
30433070

3044-
.. attribute:: st_birthtime
3045-
3046-
Time of file creation.
3047-
30483071
On Solaris and derivatives, the following attributes may also be
30493072
available:
30503073

@@ -3117,6 +3140,25 @@ features:
31173140
files as :const:`S_IFCHR`, :const:`S_IFIFO` or :const:`S_IFBLK`
31183141
as appropriate.
31193142

3143+
.. versionchanged:: 3.12
3144+
On Windows, :attr:`st_ctime` is deprecated. Eventually, it will
3145+
contain the last metadata change time, for consistency with other
3146+
platforms, but for now still contains creation time.
3147+
Use :attr:`st_birthtime` for the creation time.
3148+
3149+
.. versionchanged:: 3.12
3150+
On Windows, :attr:`st_ino` may now be up to 128 bits, depending
3151+
on the file system. Previously it would not be above 64 bits, and
3152+
larger file identifiers would be arbitrarily packed.
3153+
3154+
.. versionchanged:: 3.12
3155+
On Windows, :attr:`st_rdev` no longer returns a value. Previously
3156+
it would contain the same as :attr:`st_dev`, which was incorrect.
3157+
3158+
.. versionadded:: 3.12
3159+
Added the :attr:`st_birthtime` member on Windows.
3160+
3161+
31203162
.. function:: statvfs(path)
31213163

31223164
Perform a :c:func:`statvfs` system call on the given path. The return value is

Doc/library/random.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,8 @@ from the combinatoric iterators in the :mod:`itertools` module:
610610
return tuple(pool[i] for i in indices)
611611

612612
def random_combination_with_replacement(iterable, r):
613-
"Random selection from itertools.combinations_with_replacement(iterable, r)"
613+
"Choose r elements with replacement. Order the result to match the iterable."
614+
# Result will be in set(itertools.combinations_with_replacement(iterable, r)).
614615
pool = tuple(iterable)
615616
n = len(pool)
616617
indices = sorted(random.choices(range(n), k=r))

Doc/library/stdtypes.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,10 @@ Notes:
335335
single: ceil() (in module math)
336336
single: trunc() (in module math)
337337
pair: numeric; conversions
338-
pair: C; language
339338

340-
Conversion from floating point to integer may round or truncate
341-
as in C; see functions :func:`math.floor` and :func:`math.ceil` for
342-
well-defined conversions.
339+
Conversion from :class:`float` to :class:`int` truncates, discarding the
340+
fractional part. See functions :func:`math.floor` and :func:`math.ceil` for
341+
alternative conversions.
343342

344343
(4)
345344
float also accepts the strings "nan" and "inf" with an optional prefix "+"

Doc/library/sys.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ always available.
13231323

13241324
A string giving the site-specific directory prefix where the platform
13251325
independent Python files are installed; on Unix, the default is
1326-
``'/usr/local'``. This can be set at build time with the ``--prefix``
1326+
:file:`/usr/local`. This can be set at build time with the :option:`--prefix`
13271327
argument to the :program:`configure` script. See
13281328
:ref:`installation_paths` for derived paths.
13291329

Doc/library/venv.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ running from a virtual environment.
6161
A virtual environment may be "activated" using a script in its binary directory
6262
(``bin`` on POSIX; ``Scripts`` on Windows).
6363
This will prepend that directory to your :envvar:`!PATH`, so that running
64-
:program:`!python` will invoke the environment's Python interpreter
64+
:program:`python` will invoke the environment's Python interpreter
6565
and you can run installed scripts without having to use their full path.
6666
The invocation of the activation script is platform-specific
6767
(:samp:`{<venv>}` must be replaced by the path to the directory
@@ -84,7 +84,7 @@ containing the virtual environment):
8484
+-------------+------------+--------------------------------------------------+
8585

8686
.. versionadded:: 3.4
87-
:program:`!fish` and :program:`!csh` activation scripts.
87+
:program:`fish` and :program:`csh` activation scripts.
8888

8989
.. versionadded:: 3.8
9090
PowerShell activation scripts installed under POSIX for PowerShell Core

Doc/tutorial/modules.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ When importing the package, Python searches through the directories on
438438

439439
The :file:`__init__.py` files are required to make Python treat directories
440440
containing the file as packages. This prevents directories with a common name,
441-
such as ``string``, unintentionally hiding valid modules that occur later
441+
such as ``string``, from unintentionally hiding valid modules that occur later
442442
on the module search path. In the simplest case, :file:`__init__.py` can just be
443443
an empty file, but it can also execute initialization code for the package or
444444
set the ``__all__`` variable, described later.

Doc/using/configure.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,22 @@ WebAssembly Options
216216
Install Options
217217
---------------
218218

219+
.. cmdoption:: --prefix=PREFIX
220+
221+
Install architecture-independent files in PREFIX. On Unix, it
222+
defaults to :file:`/usr/local`.
223+
224+
This value can be retrived at runtime using :data:`sys.prefix`.
225+
226+
As an example, one can use ``--prefix="$HOME/.local/"`` to install
227+
a Python in its home directory.
228+
229+
.. cmdoption:: --exec-prefix=EPREFIX
230+
231+
Install architecture-dependent files in EPREFIX, defaults to :option:`--prefix`.
232+
233+
This value can be retrived at runtime using :data:`sys.exec_prefix`.
234+
219235
.. cmdoption:: --disable-test-modules
220236

221237
Don't build nor install test modules, like the :mod:`test` package or the

Doc/using/unix.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Python-related paths and files
9393
==============================
9494

9595
These are subject to difference depending on local installation conventions;
96-
:envvar:`prefix` (``${prefix}``) and :envvar:`exec_prefix` (``${exec_prefix}``)
96+
:option:`prefix <--prefix>` and :option:`exec_prefix <--exec-prefix>`
9797
are installation-dependent and should be interpreted as for GNU software; they
9898
may be the same.
9999

Doc/whatsnew/3.12.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,13 @@ asyncio
237237
* Add C implementation of :func:`asyncio.current_task` for 4x-6x speedup.
238238
(Contributed by Itamar Ostricher and Pranav Thulasiram Bhat in :gh:`100344`.)
239239

240+
* :func:`asyncio.iscoroutine` now returns ``False`` for generators as
241+
:mod:`asyncio` does not support legacy generator-based coroutines.
242+
(Contributed by Kumar Aditya in :gh:`102748`.)
243+
244+
* :func:`asyncio.wait` now accepts generators yielding tasks.
245+
(Contributed by Kumar Aditya in :gh:`78530`.)
246+
240247
inspect
241248
-------
242249

@@ -302,6 +309,16 @@ os
302309
functions on Windows for enumerating drives, volumes and mount points.
303310
(Contributed by Steve Dower in :gh:`102519`.)
304311

312+
* :func:`os.stat` and :func:`os.lstat` are now more accurate on Windows.
313+
The ``st_birthtime`` field will now be filled with the creation time
314+
of the file, and ``st_ctime`` is deprecated but still contains the
315+
creation time (but in the future will return the last metadata change,
316+
for consistency with other platforms). ``st_dev`` may be up to 64 bits
317+
and ``st_ino`` up to 128 bits depending on your file system, and
318+
``st_rdev`` is always set to zero rather than incorrect values.
319+
Both functions may be significantly faster on newer releases of
320+
Windows. (Contributed by Steve Dower in :gh:`99726`.)
321+
305322
os.path
306323
-------
307324

@@ -465,6 +482,12 @@ Deprecated
465482
warning at compile time. This field will be removed in Python 3.14.
466483
(Contributed by Ramvikrams and Kumar Aditya in :gh:`101193`. PEP by Ken Jin.)
467484

485+
* The ``st_ctime`` fields return by :func:`os.stat` and :func:`os.lstat` on
486+
Windows are deprecated. In a future release, they will contain the last
487+
metadata change time, consistent with other platforms. For now, they still
488+
contain the creation time, which is also available in the new ``st_birthtime``
489+
field. (Contributed by Steve Dower in :gh:`99726`.)
490+
468491
Pending Removal in Python 3.13
469492
------------------------------
470493

@@ -924,6 +947,10 @@ New Features
924947
the :attr:`~BaseException.args` passed to the exception's constructor.
925948
(Contributed by Mark Shannon in :gh:`101578`.)
926949

950+
* Add :c:func:`PyErr_DisplayException`, which takes an exception instance,
951+
to replace the legacy-api :c:func:`PyErr_Display`. (Contributed by
952+
Irit Katriel in :gh:`102755`).
953+
927954
Porting to Python 3.12
928955
----------------------
929956

@@ -982,6 +1009,11 @@ Porting to Python 3.12
9821009
effects, these side effects are no longer duplicated.
9831010
(Contributed by Victor Stinner in :gh:`98724`.)
9841011

1012+
* The interpreter's error indicator is now always normalized. This means
1013+
that :c:func:`PyErr_SetObject`, :c:func:`PyErr_SetString` and the other
1014+
functions that set the error indicator now normalize the exception
1015+
before storing it. (Contributed by Mark Shannon in :gh:`101578`.)
1016+
9851017
Deprecated
9861018
----------
9871019

@@ -1052,6 +1084,9 @@ Deprecated
10521084
:c:func:`PyErr_SetRaisedException` instead.
10531085
(Contributed by Mark Shannon in :gh:`101578`.)
10541086

1087+
* :c:func:`PyErr_Display` is deprecated. Use :c:func:`PyErr_DisplayException`
1088+
instead. (Contributed by Irit Katriel in :gh:`102755`).
1089+
10551090

10561091
Removed
10571092
-------

Include/cpython/pyerrors.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ PyAPI_FUNC(PyObject *) _PyErr_FormatFromCause(
112112

113113
/* In exceptions.c */
114114

115+
PyAPI_FUNC(int) _PyException_AddNote(
116+
PyObject *exc,
117+
PyObject *note);
118+
115119
/* Helper that attempts to replace the current exception with one of the
116120
* same type but with a prefix added to the exception text. The resulting
117121
* exception description looks like:

Include/internal/pycore_fileutils.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ PyAPI_FUNC(PyObject *) _Py_device_encoding(int);
6666

6767
#ifdef MS_WINDOWS
6868
struct _Py_stat_struct {
69-
unsigned long st_dev;
69+
uint64_t st_dev;
7070
uint64_t st_ino;
7171
unsigned short st_mode;
7272
int st_nlink;
@@ -80,8 +80,11 @@ struct _Py_stat_struct {
8080
int st_mtime_nsec;
8181
time_t st_ctime;
8282
int st_ctime_nsec;
83+
time_t st_birthtime;
84+
int st_birthtime_nsec;
8385
unsigned long st_file_attributes;
8486
unsigned long st_reparse_tag;
87+
uint64_t st_ino_high;
8588
};
8689
#else
8790
# define _Py_stat_struct stat

0 commit comments

Comments
 (0)