Skip to content

Commit

Permalink
Merge branch 'main' into PyObject_GetOptionalAttr
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka committed Jul 9, 2023
2 parents 0429d55 + 93d292c commit 749d962
Show file tree
Hide file tree
Showing 45 changed files with 1,133 additions and 397 deletions.
32 changes: 16 additions & 16 deletions Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.

Set by the :option:`-b` option.

.. deprecated:: 3.12
.. deprecated-removed:: 3.12 3.14

.. c:var:: int Py_DebugFlag
Expand All @@ -101,7 +101,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
Set by the :option:`-d` option and the :envvar:`PYTHONDEBUG` environment
variable.

.. deprecated:: 3.12
.. deprecated-removed:: 3.12 3.14

.. c:var:: int Py_DontWriteBytecodeFlag
Expand All @@ -115,7 +115,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
Set by the :option:`-B` option and the :envvar:`PYTHONDONTWRITEBYTECODE`
environment variable.

.. deprecated:: 3.12
.. deprecated-removed:: 3.12 3.14

.. c:var:: int Py_FrozenFlag
Expand All @@ -128,7 +128,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.

Private flag used by ``_freeze_module`` and ``frozenmain`` programs.

.. deprecated:: 3.12
.. deprecated-removed:: 3.12 3.14

.. c:var:: int Py_HashRandomizationFlag
Expand All @@ -143,7 +143,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
If the flag is non-zero, read the :envvar:`PYTHONHASHSEED` environment
variable to initialize the secret hash seed.

.. deprecated:: 3.12
.. deprecated-removed:: 3.12 3.14

.. c:var:: int Py_IgnoreEnvironmentFlag
Expand All @@ -156,7 +156,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.

Set by the :option:`-E` and :option:`-I` options.

.. deprecated:: 3.12
.. deprecated-removed:: 3.12 3.14

.. c:var:: int Py_InspectFlag
Expand All @@ -171,7 +171,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
Set by the :option:`-i` option and the :envvar:`PYTHONINSPECT` environment
variable.

.. deprecated:: 3.12
.. deprecated-removed:: 3.12 3.14

.. c:var:: int Py_InteractiveFlag
Expand All @@ -196,7 +196,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.

.. versionadded:: 3.4

.. deprecated:: 3.12
.. deprecated-removed:: 3.12 3.14

.. c:var:: int Py_LegacyWindowsFSEncodingFlag
Expand All @@ -215,7 +215,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.

.. availability:: Windows.

.. deprecated:: 3.12
.. deprecated-removed:: 3.12 3.14

.. c:var:: int Py_LegacyWindowsStdioFlag
Expand All @@ -233,7 +233,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.

.. availability:: Windows.

.. deprecated:: 3.12
.. deprecated-removed:: 3.12 3.14

.. c:var:: int Py_NoSiteFlag
Expand All @@ -248,7 +248,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.

Set by the :option:`-S` option.

.. deprecated:: 3.12
.. deprecated-removed:: 3.12 3.14

.. c:var:: int Py_NoUserSiteDirectory
Expand All @@ -262,7 +262,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
Set by the :option:`-s` and :option:`-I` options, and the
:envvar:`PYTHONNOUSERSITE` environment variable.

.. deprecated:: 3.12
.. deprecated-removed:: 3.12 3.14

.. c:var:: int Py_OptimizeFlag
Expand All @@ -273,7 +273,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
Set by the :option:`-O` option and the :envvar:`PYTHONOPTIMIZE` environment
variable.

.. deprecated:: 3.12
.. deprecated-removed:: 3.12 3.14

.. c:var:: int Py_QuietFlag
Expand All @@ -287,7 +287,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.

.. versionadded:: 3.2

.. deprecated:: 3.12
.. deprecated-removed:: 3.12 3.14

.. c:var:: int Py_UnbufferedStdioFlag
Expand All @@ -300,7 +300,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
Set by the :option:`-u` option and the :envvar:`PYTHONUNBUFFERED`
environment variable.

.. deprecated:: 3.12
.. deprecated-removed:: 3.12 3.14

.. c:var:: int Py_VerboseFlag
Expand All @@ -316,7 +316,7 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
Set by the :option:`-v` option and the :envvar:`PYTHONVERBOSE` environment
variable.

.. deprecated:: 3.12
.. deprecated-removed:: 3.12 3.14


Initializing and finalizing the interpreter
Expand Down
15 changes: 15 additions & 0 deletions Doc/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,21 @@ Glossary
when several are given, such as in ``variable_name[1:3:5]``. The bracket
(subscript) notation uses :class:`slice` objects internally.

soft deprecated
A soft deprecation can be used when using an API which should no longer
be used to write new code, but it remains safe to continue using it in
existing code. The API remains documented and tested, but will not be
developed further (no enhancement).

The main difference between a "soft" and a (regular) "hard" deprecation
is that the soft deprecation does not imply scheduling the removal of the
deprecated API.

Another difference is that a soft deprecation does not issue a warning.

See `PEP 387: Soft Deprecation
<https://peps.python.org/pep-0387/#soft-deprecation>`_.

special method
.. index:: pair: special; method

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ are always available. They are listed here in alphabetical order.

For objects with custom :meth:`__hash__` methods, note that :func:`hash`
truncates the return value based on the bit width of the host machine.
See :meth:`__hash__` for details.
See :meth:`__hash__ <object.__hash__>` for details.

.. function:: help()
help(request)
Expand Down
21 changes: 13 additions & 8 deletions Doc/library/getopt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@

**Source code:** :source:`Lib/getopt.py`

.. deprecated:: 3.13
The :mod:`getopt` module is :term:`soft deprecated` and will not be
developed further; development will continue with the :mod:`argparse`
module.

.. note::

The :mod:`getopt` module is a parser for command line options whose API is
designed to be familiar to users of the C :c:func:`getopt` function. Users who
are unfamiliar with the C :c:func:`getopt` function or who would like to write
designed to be familiar to users of the C :c:func:`!getopt` function. Users who
are unfamiliar with the C :c:func:`!getopt` function or who would like to write
less code and get better help and error messages should consider using the
:mod:`argparse` module instead.

--------------

This module helps scripts to parse the command line arguments in ``sys.argv``.
It supports the same conventions as the Unix :c:func:`getopt` function (including
It supports the same conventions as the Unix :c:func:`!getopt` function (including
the special meanings of arguments of the form '``-``' and '``--``'). Long
options similar to those supported by GNU software may be used as well via an
optional third argument.
Expand All @@ -33,11 +38,11 @@ exception:
be parsed, without the leading reference to the running program. Typically, this
means ``sys.argv[1:]``. *shortopts* is the string of option letters that the
script wants to recognize, with options that require an argument followed by a
colon (``':'``; i.e., the same format that Unix :c:func:`getopt` uses).
colon (``':'``; i.e., the same format that Unix :c:func:`!getopt` uses).

.. note::

Unlike GNU :c:func:`getopt`, after a non-option argument, all further
Unlike GNU :c:func:`!getopt`, after a non-option argument, all further
arguments are considered also non-options. This is similar to the way
non-GNU Unix systems work.

Expand Down Expand Up @@ -71,7 +76,7 @@ exception:
non-option argument is encountered.

If the first character of the option string is ``'+'``, or if the environment
variable :envvar:`POSIXLY_CORRECT` is set, then option processing stops as
variable :envvar:`!POSIXLY_CORRECT` is set, then option processing stops as
soon as a non-option argument is encountered.


Expand All @@ -81,9 +86,9 @@ exception:
an option requiring an argument is given none. The argument to the exception is
a string indicating the cause of the error. For long options, an argument given
to an option which does not require one will also cause this exception to be
raised. The attributes :attr:`msg` and :attr:`opt` give the error message and
raised. The attributes :attr:`!msg` and :attr:`!opt` give the error message and
related option; if there is no specific option to which the exception relates,
:attr:`opt` is an empty string.
:attr:`!opt` is an empty string.

.. XXX deprecated?
.. exception:: error
Expand Down
8 changes: 8 additions & 0 deletions Doc/library/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,10 @@ interchangeably.
Attribute :attr:`manager` and method :meth:`_log` were added, which
delegate to the underlying logger and allow adapters to be nested.

.. versionchanged:: 3.13
Remove the undocumented ``warn()`` method which was an alias to the
``warning()`` method.


Thread Safety
-------------
Expand Down Expand Up @@ -1162,6 +1166,10 @@ functions.
identical to ``warning``. As ``warn`` is deprecated, please do not use
it - use ``warning`` instead.

.. versionchanged:: 3.13
Remove the undocumented ``warn()`` function which was an alias to the
:func:`warning` function.


.. function:: error(msg, *args, **kwargs)

Expand Down
5 changes: 3 additions & 2 deletions Doc/library/optparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
**Source code:** :source:`Lib/optparse.py`

.. deprecated:: 3.2
The :mod:`optparse` module is deprecated and will not be developed further;
development will continue with the :mod:`argparse` module.
The :mod:`optparse` module is :term:`soft deprecated` and will not be
developed further; development will continue with the :mod:`argparse`
module.

--------------

Expand Down
92 changes: 88 additions & 4 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,11 @@ Removed
use ``locale.setlocale(locale.LC_ALL, "")`` instead.
(Contributed by Victor Stinner in :gh:`104783`.)

* Remove the undocumented and untested ``logging.Logger.warn()`` method,
deprecated since Python 3.3, which was an alias to the
:meth:`logging.Logger.warning` method: use the :meth:`logging.Logger.warning`
method instead.
* :mod:`logging`: Remove undocumented and untested ``Logger.warn()`` and
``LoggerAdapter.warn()`` methods and ``logging.warn()`` function. Deprecated
since Python 3.3, they were aliases to the :meth:`logging.Logger.warning`
method, :meth:`!logging.LoggerAdapter.warning` method and
:func:`logging.warning` function.
(Contributed by Victor Stinner in :gh:`105376`.)

* Remove *cafile*, *capath* and *cadefault* parameters of the
Expand Down Expand Up @@ -478,6 +479,7 @@ Deprecated
* :c:func:`Py_GetPythonHome`: get :c:member:`PyConfig.home` or
:envvar:`PYTHONHOME` environment variable instead.

Functions scheduled for removal in Python 3.15.
(Contributed by Victor Stinner in :gh:`105145`.)

* Deprecate the :c:func:`PyImport_ImportModuleNoBlock` function which is just
Expand Down Expand Up @@ -620,3 +622,85 @@ Removed
<https://github.com/python/pythoncapi-compat/>`__ can be used to get
:c:func:`PyInterpreterState_Get()` on Python 3.8 and older.
(Contributed by Victor Stinner in :gh:`106320`.)

Pending Removal in Python 3.14
------------------------------

* Global configuration variables:

* :c:var:`Py_DebugFlag`: use :c:member:`PyConfig.parser_debug`
* :c:var:`Py_VerboseFlag`: use :c:member:`PyConfig.verbose`
* :c:var:`Py_QuietFlag`: use :c:member:`PyConfig.quiet`
* :c:var:`Py_InteractiveFlag`: use :c:member:`PyConfig.interactive`
* :c:var:`Py_InspectFlag`: use :c:member:`PyConfig.inspect`
* :c:var:`Py_OptimizeFlag`: use :c:member:`PyConfig.optimization_level`
* :c:var:`Py_NoSiteFlag`: use :c:member:`PyConfig.site_import`
* :c:var:`Py_BytesWarningFlag`: use :c:member:`PyConfig.bytes_warning`
* :c:var:`Py_FrozenFlag`: use :c:member:`PyConfig.pathconfig_warnings`
* :c:var:`Py_IgnoreEnvironmentFlag`: use :c:member:`PyConfig.use_environment`
* :c:var:`Py_DontWriteBytecodeFlag`: use :c:member:`PyConfig.write_bytecode`
* :c:var:`Py_NoUserSiteDirectory`: use :c:member:`PyConfig.user_site_directory`
* :c:var:`Py_UnbufferedStdioFlag`: use :c:member:`PyConfig.buffered_stdio`
* :c:var:`Py_HashRandomizationFlag`: use :c:member:`PyConfig.use_hash_seed`
and :c:member:`PyConfig.hash_seed`
* :c:var:`Py_IsolatedFlag`: use :c:member:`PyConfig.isolated`
* :c:var:`Py_LegacyWindowsFSEncodingFlag`: use :c:member:`PyPreConfig.legacy_windows_fs_encoding`
* :c:var:`Py_LegacyWindowsStdioFlag`: use :c:member:`PyConfig.legacy_windows_stdio`
* :c:var:`!Py_FileSystemDefaultEncoding`: use :c:member:`PyConfig.filesystem_encoding`
* :c:var:`!Py_HasFileSystemDefaultEncoding`: use :c:member:`PyConfig.filesystem_encoding`
* :c:var:`!Py_FileSystemDefaultEncodeErrors`: use :c:member:`PyConfig.filesystem_errors`
* :c:var:`!Py_UTF8Mode`: use :c:member:`PyPreConfig.utf8_mode` (see :c:func:`Py_PreInitialize`)

The :c:func:`Py_InitializeFromConfig` API should be used with
:c:type:`PyConfig` instead.

Pending Removal in Python 3.15
------------------------------

* :c:func:`PyImport_ImportModuleNoBlock`: use :c:func:`PyImport_ImportModule`.
* :c:func:`PyWeakref_GET_OBJECT`: use :c:func:`PyWeakref_GetRef` instead.
* :c:func:`PyWeakref_GetObject`: use :c:func:`PyWeakref_GetRef` instead.
* :c:type:`!Py_UNICODE_WIDE` type: use ``wchar_t`` instead.
* :c:type:`Py_UNICODE` type: use ``wchar_t`` instead.
* Python initialization functions:

* :c:func:`PySys_ResetWarnOptions`: clear :data:`sys.warnoptions` and
:data:`!warnings.filters` instead.
* :c:func:`Py_GetExecPrefix`: get :data:`sys.exec_prefix` instead.
* :c:func:`Py_GetPath`: get :data:`sys.path` instead.
* :c:func:`Py_GetPrefix`: get :data:`sys.prefix` instead.
* :c:func:`Py_GetProgramFullPath`: get :data:`sys.executable` instead.
* :c:func:`Py_GetProgramName`: get :data:`sys.executable` instead.
* :c:func:`Py_GetPythonHome`: get :c:member:`PyConfig.home` or
:envvar:`PYTHONHOME` environment variable instead.

Pending Removal in Future Versions
----------------------------------

The following APIs were deprecated in earlier Python versions and will be
removed, although there is currently no date scheduled for their removal.

* :const:`Py_TPFLAGS_HAVE_FINALIZE`: no needed since Python 3.8.
* :c:func:`PyErr_Fetch`: use :c:func:`PyErr_GetRaisedException`.
* :c:func:`PyErr_NormalizeException`: use :c:func:`PyErr_GetRaisedException`.
* :c:func:`PyErr_Restore`: use :c:func:`PyErr_SetRaisedException`.
* :c:func:`PyModule_GetFilename`: use :c:func:`PyModule_GetFilenameObject`.
* :c:func:`PyOS_AfterFork`: use :c:func:`PyOS_AfterFork_Child()`.
* :c:func:`PySlice_GetIndicesEx`.
* :c:func:`!PyUnicode_AsDecodedObject`.
* :c:func:`!PyUnicode_AsDecodedUnicode`.
* :c:func:`!PyUnicode_AsEncodedObject`.
* :c:func:`!PyUnicode_AsEncodedUnicode`.
* :c:func:`PyUnicode_READY`: not needed since Python 3.12.
* :c:func:`!_PyErr_ChainExceptions`.
* :c:member:`!PyBytesObject.ob_shash` member:
call :c:func:`PyObject_Hash` instead.
* :c:member:`!PyDictObject.ma_version_tag` member.
* TLS API:

* :c:func:`PyThread_create_key`: use :c:func:`PyThread_tss_alloc`.
* :c:func:`PyThread_delete_key`: use :c:func:`PyThread_tss_free`.
* :c:func:`PyThread_set_key_value`: use :c:func:`PyThread_tss_set`.
* :c:func:`PyThread_get_key_value`: use :c:func:`PyThread_tss_get`.
* :c:func:`PyThread_delete_key_value`: use :c:func:`PyThread_tss_delete`.
* :c:func:`PyThread_ReInitTLS`: no longer needed.
1 change: 1 addition & 0 deletions Include/internal/pycore_global_objects_fini_generated.h

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

1 change: 1 addition & 0 deletions Include/internal/pycore_global_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(__lshift__)
STRUCT_FOR_ID(__lt__)
STRUCT_FOR_ID(__main__)
STRUCT_FOR_ID(__match_args__)
STRUCT_FOR_ID(__matmul__)
STRUCT_FOR_ID(__missing__)
STRUCT_FOR_ID(__mod__)
Expand Down
Loading

0 comments on commit 749d962

Please sign in to comment.