Skip to content

Commit

Permalink
Merge branch '3.12' of https://github.com/python/cpython into 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Yhg1s committed Jun 6, 2023
2 parents 9824a28 + e33add4 commit 8b89592
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 83 deletions.
8 changes: 1 addition & 7 deletions Doc/library/ftplib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,14 @@ The module defines the following items:
:attr:`ssl.SSLContext.check_hostname` and *Server Name Indication* (see
:data:`ssl.HAS_SNI`).

.. deprecated:: 3.6
*keyfile* and *certfile* are deprecated in favor of *context*.
Please use :meth:`ssl.SSLContext.load_cert_chain` instead, or let
:func:`ssl.create_default_context` select the system's trusted CA
certificates for you.

.. versionchanged:: 3.9
If the *timeout* parameter is set to be zero, it will raise a
:class:`ValueError` to prevent the creation of a non-blocking socket.
The *encoding* parameter was added, and the default was changed from
Latin-1 to UTF-8 to follow :rfc:`2640`.

.. versionchanged:: 3.12
The deprecated *keyfile* and *certfile* parameters have been removed.
The deprecated *keyfile* and *certfile* parameters have been removed.

Here's a sample session using the :class:`FTP_TLS` class::

Expand Down
14 changes: 2 additions & 12 deletions Doc/library/http.client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,6 @@ The module provides the following classes:
:func:`ssl._create_unverified_context` can be passed to the *context*
parameter.

.. deprecated:: 3.6
*key_file* and *cert_file* are deprecated in favor of *context*.
Please use :meth:`ssl.SSLContext.load_cert_chain` instead, or let
:func:`ssl.create_default_context` select the system's trusted CA
certificates for you.

The *check_hostname* parameter is also deprecated; the
:attr:`ssl.SSLContext.check_hostname` attribute of *context* should
be used instead.

.. versionchanged:: 3.8
This class now enables TLS 1.3
:attr:`ssl.SSLContext.post_handshake_auth` for the default *context* or
Expand All @@ -116,8 +106,8 @@ The module provides the following classes:
ALPN protocols with :meth:`~ssl.SSLContext.set_alpn_protocol`.

.. versionchanged:: 3.12
The deprecated *key_file*, *cert_file* and *check_hostname* parameters
have been removed.
The deprecated *key_file*, *cert_file* and *check_hostname* parameters
have been removed.


.. class:: HTTPResponse(sock, debuglevel=0, method=None, url=None)
Expand Down
9 changes: 1 addition & 8 deletions Doc/library/imaplib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,11 @@ There's also a subclass for secure connections:
:attr:`ssl.SSLContext.check_hostname` and *Server Name Indication* (see
:data:`ssl.HAS_SNI`).

.. deprecated:: 3.6

*keyfile* and *certfile* are deprecated in favor of *ssl_context*.
Please use :meth:`ssl.SSLContext.load_cert_chain` instead, or let
:func:`ssl.create_default_context` select the system's trusted CA
certificates for you.

.. versionchanged:: 3.9
The optional *timeout* parameter was added.

.. versionchanged:: 3.12
The deprecated *keyfile* and *certfile* parameters have been removed.
The deprecated *keyfile* and *certfile* parameters have been removed.

The second subclass allows for connections created by a child process:

Expand Down
30 changes: 27 additions & 3 deletions Doc/library/itertools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -929,9 +929,7 @@ which incur interpreter overhead.
def sliding_window(iterable, n):
# sliding_window('ABCDEFG', 4) --> ABCD BCDE CDEF DEFG
it = iter(iterable)
window = collections.deque(islice(it, n), maxlen=n)
if len(window) == n:
yield tuple(window)
window = collections.deque(islice(it, n-1), maxlen=n)
for x in it:
window.append(x)
yield tuple(window)
Expand Down Expand Up @@ -1420,8 +1418,34 @@ The following recipes have a more mathematical flavor:
>>> list(grouper('abcdefg', n=3, incomplete='ignore'))
[('a', 'b', 'c'), ('d', 'e', 'f')]

>>> list(sliding_window('ABCDEFG', 1))
[('A',), ('B',), ('C',), ('D',), ('E',), ('F',), ('G',)]
>>> list(sliding_window('ABCDEFG', 2))
[('A', 'B'), ('B', 'C'), ('C', 'D'), ('D', 'E'), ('E', 'F'), ('F', 'G')]
>>> list(sliding_window('ABCDEFG', 3))
[('A', 'B', 'C'), ('B', 'C', 'D'), ('C', 'D', 'E'), ('D', 'E', 'F'), ('E', 'F', 'G')]
>>> list(sliding_window('ABCDEFG', 4))
[('A', 'B', 'C', 'D'), ('B', 'C', 'D', 'E'), ('C', 'D', 'E', 'F'), ('D', 'E', 'F', 'G')]
>>> list(sliding_window('ABCDEFG', 5))
[('A', 'B', 'C', 'D', 'E'), ('B', 'C', 'D', 'E', 'F'), ('C', 'D', 'E', 'F', 'G')]
>>> list(sliding_window('ABCDEFG', 6))
[('A', 'B', 'C', 'D', 'E', 'F'), ('B', 'C', 'D', 'E', 'F', 'G')]
>>> list(sliding_window('ABCDEFG', 7))
[('A', 'B', 'C', 'D', 'E', 'F', 'G')]
>>> list(sliding_window('ABCDEFG', 8))
[]
>>> try:
... list(sliding_window('ABCDEFG', -1))
... except ValueError:
... 'zero or negative n not supported'
...
'zero or negative n not supported'
>>> try:
... list(sliding_window('ABCDEFG', 0))
... except ValueError:
... 'zero or negative n not supported'
...
'zero or negative n not supported'

>>> list(roundrobin('abc', 'd', 'ef'))
['a', 'd', 'e', 'b', 'f', 'c']
Expand Down
9 changes: 1 addition & 8 deletions Doc/library/poplib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,12 @@ The :mod:`poplib` module provides two classes:
:attr:`ssl.SSLContext.check_hostname` and *Server Name Indication* (see
:data:`ssl.HAS_SNI`).

.. deprecated:: 3.6

*keyfile* and *certfile* are deprecated in favor of *context*.
Please use :meth:`ssl.SSLContext.load_cert_chain` instead, or let
:func:`ssl.create_default_context` select the system's trusted CA
certificates for you.

.. versionchanged:: 3.9
If the *timeout* parameter is set to be zero, it will raise a
:class:`ValueError` to prevent the creation of a non-blocking socket.

.. versionchanged:: 3.12
The deprecated *keyfile* and *certfile* parameters have been removed.
The deprecated *keyfile* and *certfile* parameters have been removed.

One exception is defined as an attribute of the :mod:`poplib` module:

Expand Down
18 changes: 2 additions & 16 deletions Doc/library/smtplib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,12 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions).
:attr:`ssl.SSLContext.check_hostname` and *Server Name Indication* (see
:data:`ssl.HAS_SNI`).

.. deprecated:: 3.6

*keyfile* and *certfile* are deprecated in favor of *context*.
Please use :meth:`ssl.SSLContext.load_cert_chain` instead, or let
:func:`ssl.create_default_context` select the system's trusted CA
certificates for you.

.. versionchanged:: 3.9
If the *timeout* parameter is set to be zero, it will raise a
:class:`ValueError` to prevent the creation of a non-blocking socket

.. versionchanged:: 3.12
The deprecated *keyfile* and *certfile* parameters have been removed.
The deprecated *keyfile* and *certfile* parameters have been removed.

.. class:: LMTP(host='', port=LMTP_PORT, local_hostname=None, \
source_address=None[, timeout])
Expand Down Expand Up @@ -407,15 +400,8 @@ An :class:`SMTP` instance has the following methods:
If there has been no previous ``EHLO`` or ``HELO`` command this session,
this method tries ESMTP ``EHLO`` first.

.. deprecated:: 3.6

*keyfile* and *certfile* are deprecated in favor of *context*.
Please use :meth:`ssl.SSLContext.load_cert_chain` instead, or let
:func:`ssl.create_default_context` select the system's trusted CA
certificates for you.

.. versionchanged:: 3.12
The deprecated *keyfile* and *certfile* parameters have been removed.
The deprecated *keyfile* and *certfile* parameters have been removed.

:exc:`SMTPHeloError`
The server didn't reply properly to the ``HELO`` greeting.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/socket.rst
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ Constants
HV_GUID_BROADCAST
HV_GUID_CHILDREN
HV_GUID_LOOPBACK
HV_GUID_LOOPBACK
HV_GUID_PARENT

Constants for Windows Hyper-V sockets for host/guest communications.

Expand Down
9 changes: 9 additions & 0 deletions Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,15 @@ Build Changes
:file:`!configure`.
(Contributed by Christian Heimes in :gh:`89886`.)

* C extensions built with the :ref:`limited C API <limited-c-api>`
on :ref:`Python build in debug mode <debug-build>` no longer support Python
3.9 and older. In this configuration, :c:func:`Py_INCREF` and
:c:func:`Py_DECREF` are now always implemented as opaque function calls,
but the called functions were added to Python 3.10. Build C extensions
with a release build of Python or with Python 3.12 and older, to keep support
for Python 3.9 and older.
(Contributed by Victor Stinner in :gh:`102304`.)


C API Changes
=============
Expand Down
22 changes: 8 additions & 14 deletions Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -585,20 +585,14 @@ decision that's up to the implementer of each new type so if you want,
you can count such references to the type object.)
*/

#ifdef Py_REF_DEBUG
# if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030A0000
extern Py_ssize_t _Py_RefTotal;
# define _Py_INC_REFTOTAL() _Py_RefTotal++
# define _Py_DEC_REFTOTAL() _Py_RefTotal--
# elif !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000
#if defined(Py_REF_DEBUG) && !defined(Py_LIMITED_API)
PyAPI_FUNC(void) _Py_NegativeRefcount(const char *filename, int lineno,
PyObject *op);
PyAPI_FUNC(void) _Py_IncRefTotal_DO_NOT_USE_THIS(void);
PyAPI_FUNC(void) _Py_DecRefTotal_DO_NOT_USE_THIS(void);
# define _Py_INC_REFTOTAL() _Py_IncRefTotal_DO_NOT_USE_THIS()
# define _Py_DEC_REFTOTAL() _Py_DecRefTotal_DO_NOT_USE_THIS()
# endif
PyAPI_FUNC(void) _Py_NegativeRefcount(const char *filename, int lineno,
PyObject *op);
#endif /* Py_REF_DEBUG */
#endif // Py_REF_DEBUG && !Py_LIMITED_API

PyAPI_FUNC(void) _Py_Dealloc(PyObject *);

Expand All @@ -616,8 +610,8 @@ PyAPI_FUNC(void) _Py_DecRef(PyObject *);

static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
{
#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030A0000
// Stable ABI for Python 3.10 built in debug mode.
#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API)
// Stable ABI for Python built in debug mode
_Py_IncRef(op);
#else
// Non-limited C API and limited C API for Python 3.9 and older access
Expand Down Expand Up @@ -647,8 +641,8 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
# define Py_INCREF(op) Py_INCREF(_PyObject_CAST(op))
#endif

#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030A0000
// Stable ABI for limited C API version 3.10 of Python debug build
#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API)
// Stable ABI for Python built in debug mode
static inline void Py_DECREF(PyObject *op) {
_Py_DecRef(op);
}
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -2566,7 +2566,7 @@ def testHyperVConstants(self):
socket.HV_GUID_BROADCAST
socket.HV_GUID_CHILDREN
socket.HV_GUID_LOOPBACK
socket.HV_GUID_LOOPBACK
socket.HV_GUID_PARENT

def testCreateHyperVSocketWithUnknownProtoFailure(self):
expected = r"\[WinError 10041\]"
Expand Down
2 changes: 0 additions & 2 deletions Lib/test/test_stable_abi_ctypes.py

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

9 changes: 0 additions & 9 deletions Misc/stable_abi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2406,12 +2406,3 @@
added = '3.12'
[const.Py_TPFLAGS_ITEMS_AT_END]
added = '3.12'

[function._Py_IncRefTotal_DO_NOT_USE_THIS]
added = '3.12'
ifdef = 'Py_REF_DEBUG'
abi_only = true
[function._Py_DecRefTotal_DO_NOT_USE_THIS]
added = '3.12'
ifdef = 'Py_REF_DEBUG'
abi_only = true
2 changes: 0 additions & 2 deletions PC/python3dll.c

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

0 comments on commit 8b89592

Please sign in to comment.