Skip to content

Commit

Permalink
Merge branch 'main' into inlinecomp2
Browse files Browse the repository at this point in the history
* 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)
  ...
  • Loading branch information
carljm committed Mar 17, 2023
2 parents 6c5f269 + 65fb7c4 commit 1a8f4a0
Show file tree
Hide file tree
Showing 79 changed files with 1,910 additions and 817 deletions.
6 changes: 6 additions & 0 deletions Doc/c-api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ Printing and clearing
An exception must be set when calling this function.
.. c:function: void PyErr_DisplayException(PyObject *exc)
Print the standard traceback display of ``exc`` to ``sys.stderr``, including
chained exceptions and notes.
.. versionadded:: 3.12
Raising exceptions
==================
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ Process-wide parameters
program name is ``'/usr/local/bin/python'``, the prefix is ``'/usr/local'``. The
returned string points into static storage; the caller should not modify its
value. This corresponds to the :makevar:`prefix` variable in the top-level
:file:`Makefile` and the ``--prefix`` argument to the :program:`configure`
:file:`Makefile` and the :option:`--prefix` argument to the :program:`configure`
script at build time. The value is available to Python code as ``sys.prefix``.
It is only useful on Unix. See also the next function.

Expand Down
10 changes: 5 additions & 5 deletions Doc/c-api/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ used by extension writers. Structure member names do not have a reserved prefix.

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

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

C++ users should note that although the API is defined entirely using C, the
header files properly declare the entry points to be ``extern "C"``. As a result,
Expand Down
1 change: 1 addition & 0 deletions Doc/data/stable_abi.dat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,10 @@ Waiting Primitives
.. versionchanged:: 3.11
Passing coroutine objects to ``wait()`` directly is forbidden.

.. versionchanged:: 3.12
Added support for generators yielding tasks.


.. function:: as_completed(aws, *, timeout=None)

Run :ref:`awaitable objects <asyncio-awaitables>` in the *aws*
Expand Down
88 changes: 65 additions & 23 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2858,6 +2858,12 @@ features:
Added support for the :class:`~os.PathLike` interface. Added support
for :class:`bytes` paths on Windows.

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


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

Expand Down Expand Up @@ -2973,10 +2979,12 @@ features:

.. attribute:: st_ctime

Platform dependent:
Time of most recent metadata change expressed in seconds.

* the time of most recent metadata change on Unix,
* the time of creation on Windows, expressed in seconds.
.. versionchanged:: 3.12
``st_ctime`` is deprecated on Windows. Use ``st_birthtime`` for
the file creation time. In the future, ``st_ctime`` will contain
the time of the most recent metadata change, as for other platforms.

.. attribute:: st_atime_ns

Expand All @@ -2989,29 +2997,48 @@ features:

.. attribute:: st_ctime_ns

Platform dependent:
Time of most recent metadata change expressed in nanoseconds as an
integer.

.. versionchanged:: 3.12
``st_ctime_ns`` is deprecated on Windows. Use ``st_birthtime_ns``
for the file creation time. In the future, ``st_ctime`` will contain
the time of the most recent metadata change, as for other platforms.

.. attribute:: st_birthtime

Time of file creation expressed in seconds. This attribute is not
always available, and may raise :exc:`AttributeError`.

.. versionchanged:: 3.12
``st_birthtime`` is now available on Windows.

.. attribute:: st_birthtime_ns

* the time of most recent metadata change on Unix,
* the time of creation on Windows, expressed in nanoseconds as an
integer.
Time of file creation expressed in nanoseconds as an integer.
This attribute is not always available, and may raise
:exc:`AttributeError`.

.. versionadded:: 3.12

.. note::

The exact meaning and resolution of the :attr:`st_atime`,
:attr:`st_mtime`, and :attr:`st_ctime` attributes depend on the operating
system and the file system. For example, on Windows systems using the FAT
or FAT32 file systems, :attr:`st_mtime` has 2-second resolution, and
:attr:`st_atime` has only 1-day resolution. See your operating system
documentation for details.
:attr:`st_mtime`, :attr:`st_ctime` and :attr:`st_birthtime` attributes
depend on the operating system and the file system. For example, on
Windows systems using the FAT32 file systems, :attr:`st_mtime` has
2-second resolution, and :attr:`st_atime` has only 1-day resolution.
See your operating system documentation for details.

Similarly, although :attr:`st_atime_ns`, :attr:`st_mtime_ns`,
and :attr:`st_ctime_ns` are always expressed in nanoseconds, many
systems do not provide nanosecond precision. On systems that do
provide nanosecond precision, the floating-point object used to
store :attr:`st_atime`, :attr:`st_mtime`, and :attr:`st_ctime`
cannot preserve all of it, and as such will be slightly inexact.
If you need the exact timestamps you should always use
:attr:`st_atime_ns`, :attr:`st_mtime_ns`, and :attr:`st_ctime_ns`.
:attr:`st_ctime_ns` and :attr:`st_birthtime_ns` are always expressed in
nanoseconds, many systems do not provide nanosecond precision. On
systems that do provide nanosecond precision, the floating-point object
used to store :attr:`st_atime`, :attr:`st_mtime`, :attr:`st_ctime` and
:attr:`st_birthtime` cannot preserve all of it, and as such will be
slightly inexact. If you need the exact timestamps you should always use
:attr:`st_atime_ns`, :attr:`st_mtime_ns`, :attr:`st_ctime_ns` and
:attr:`st_birthtime_ns`.

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

File generation number.

.. attribute:: st_birthtime

Time of file creation.

On Solaris and derivatives, the following attributes may also be
available:

Expand Down Expand Up @@ -3117,6 +3140,25 @@ features:
files as :const:`S_IFCHR`, :const:`S_IFIFO` or :const:`S_IFBLK`
as appropriate.

.. versionchanged:: 3.12
On Windows, :attr:`st_ctime` is deprecated. Eventually, it will
contain the last metadata change time, for consistency with other
platforms, but for now still contains creation time.
Use :attr:`st_birthtime` for the creation time.

.. versionchanged:: 3.12
On Windows, :attr:`st_ino` may now be up to 128 bits, depending
on the file system. Previously it would not be above 64 bits, and
larger file identifiers would be arbitrarily packed.

.. versionchanged:: 3.12
On Windows, :attr:`st_rdev` no longer returns a value. Previously
it would contain the same as :attr:`st_dev`, which was incorrect.

.. versionadded:: 3.12
Added the :attr:`st_birthtime` member on Windows.


.. function:: statvfs(path)

Perform a :c:func:`statvfs` system call on the given path. The return value is
Expand Down
3 changes: 2 additions & 1 deletion Doc/library/random.rst
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,8 @@ from the combinatoric iterators in the :mod:`itertools` module:
return tuple(pool[i] for i in indices)

def random_combination_with_replacement(iterable, r):
"Random selection from itertools.combinations_with_replacement(iterable, r)"
"Choose r elements with replacement. Order the result to match the iterable."
# Result will be in set(itertools.combinations_with_replacement(iterable, r)).
pool = tuple(iterable)
n = len(pool)
indices = sorted(random.choices(range(n), k=r))
Expand Down
7 changes: 3 additions & 4 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,10 @@ Notes:
single: ceil() (in module math)
single: trunc() (in module math)
pair: numeric; conversions
pair: C; language

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

(4)
float also accepts the strings "nan" and "inf" with an optional prefix "+"
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ always available.

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

Expand Down
4 changes: 2 additions & 2 deletions Doc/library/venv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ running from a virtual environment.
A virtual environment may be "activated" using a script in its binary directory
(``bin`` on POSIX; ``Scripts`` on Windows).
This will prepend that directory to your :envvar:`!PATH`, so that running
:program:`!python` will invoke the environment's Python interpreter
:program:`python` will invoke the environment's Python interpreter
and you can run installed scripts without having to use their full path.
The invocation of the activation script is platform-specific
(:samp:`{<venv>}` must be replaced by the path to the directory
Expand All @@ -84,7 +84,7 @@ containing the virtual environment):
+-------------+------------+--------------------------------------------------+

.. versionadded:: 3.4
:program:`!fish` and :program:`!csh` activation scripts.
:program:`fish` and :program:`csh` activation scripts.

.. versionadded:: 3.8
PowerShell activation scripts installed under POSIX for PowerShell Core
Expand Down
2 changes: 1 addition & 1 deletion Doc/tutorial/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ When importing the package, Python searches through the directories on

The :file:`__init__.py` files are required to make Python treat directories
containing the file as packages. This prevents directories with a common name,
such as ``string``, unintentionally hiding valid modules that occur later
such as ``string``, from unintentionally hiding valid modules that occur later
on the module search path. In the simplest case, :file:`__init__.py` can just be
an empty file, but it can also execute initialization code for the package or
set the ``__all__`` variable, described later.
Expand Down
16 changes: 16 additions & 0 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@ WebAssembly Options
Install Options
---------------

.. cmdoption:: --prefix=PREFIX

Install architecture-independent files in PREFIX. On Unix, it
defaults to :file:`/usr/local`.

This value can be retrived at runtime using :data:`sys.prefix`.

As an example, one can use ``--prefix="$HOME/.local/"`` to install
a Python in its home directory.

.. cmdoption:: --exec-prefix=EPREFIX

Install architecture-dependent files in EPREFIX, defaults to :option:`--prefix`.

This value can be retrived at runtime using :data:`sys.exec_prefix`.

.. cmdoption:: --disable-test-modules

Don't build nor install test modules, like the :mod:`test` package or the
Expand Down
2 changes: 1 addition & 1 deletion Doc/using/unix.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Python-related paths and files
==============================

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

Expand Down
35 changes: 35 additions & 0 deletions Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ asyncio
* Add C implementation of :func:`asyncio.current_task` for 4x-6x speedup.
(Contributed by Itamar Ostricher and Pranav Thulasiram Bhat in :gh:`100344`.)

* :func:`asyncio.iscoroutine` now returns ``False`` for generators as
:mod:`asyncio` does not support legacy generator-based coroutines.
(Contributed by Kumar Aditya in :gh:`102748`.)

* :func:`asyncio.wait` now accepts generators yielding tasks.
(Contributed by Kumar Aditya in :gh:`78530`.)

inspect
-------

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

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

os.path
-------

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

* The ``st_ctime`` fields return by :func:`os.stat` and :func:`os.lstat` on
Windows are deprecated. In a future release, they will contain the last
metadata change time, consistent with other platforms. For now, they still
contain the creation time, which is also available in the new ``st_birthtime``
field. (Contributed by Steve Dower in :gh:`99726`.)

Pending Removal in Python 3.13
------------------------------

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

* Add :c:func:`PyErr_DisplayException`, which takes an exception instance,
to replace the legacy-api :c:func:`PyErr_Display`. (Contributed by
Irit Katriel in :gh:`102755`).

Porting to Python 3.12
----------------------

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

* The interpreter's error indicator is now always normalized. This means
that :c:func:`PyErr_SetObject`, :c:func:`PyErr_SetString` and the other
functions that set the error indicator now normalize the exception
before storing it. (Contributed by Mark Shannon in :gh:`101578`.)

Deprecated
----------

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

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


Removed
-------
Expand Down
4 changes: 4 additions & 0 deletions Include/cpython/pyerrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ PyAPI_FUNC(PyObject *) _PyErr_FormatFromCause(

/* In exceptions.c */

PyAPI_FUNC(int) _PyException_AddNote(
PyObject *exc,
PyObject *note);

/* Helper that attempts to replace the current exception with one of the
* same type but with a prefix added to the exception text. The resulting
* exception description looks like:
Expand Down
5 changes: 4 additions & 1 deletion Include/internal/pycore_fileutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ PyAPI_FUNC(PyObject *) _Py_device_encoding(int);

#ifdef MS_WINDOWS
struct _Py_stat_struct {
unsigned long st_dev;
uint64_t st_dev;
uint64_t st_ino;
unsigned short st_mode;
int st_nlink;
Expand All @@ -80,8 +80,11 @@ struct _Py_stat_struct {
int st_mtime_nsec;
time_t st_ctime;
int st_ctime_nsec;
time_t st_birthtime;
int st_birthtime_nsec;
unsigned long st_file_attributes;
unsigned long st_reparse_tag;
uint64_t st_ino_high;
};
#else
# define _Py_stat_struct stat
Expand Down
Loading

0 comments on commit 1a8f4a0

Please sign in to comment.