Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into pep702
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Nov 29, 2023
2 parents 6ab4584 + e723700 commit e60ad5c
Show file tree
Hide file tree
Showing 80 changed files with 1,774 additions and 435 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ jobs:
build_windows_free_threaded:
name: 'Windows (free-threaded)'
needs: check_source
if: needs.check_source.outputs.run_tests == 'true' && contains(github.event.pull_request.labels.*.name, 'topic-free-threaded')
if: needs.check_source.outputs.run_tests == 'true'
uses: ./.github/workflows/reusable-windows.yml
with:
free-threaded: true
Expand All @@ -206,7 +206,7 @@ jobs:
build_macos_free_threaded:
name: 'macOS (free-threaded)'
needs: check_source
if: needs.check_source.outputs.run_tests == 'true' && contains(github.event.pull_request.labels.*.name, 'topic-free-threaded')
if: needs.check_source.outputs.run_tests == 'true'
uses: ./.github/workflows/reusable-macos.yml
with:
config_hash: ${{ needs.check_source.outputs.config_hash }}
Expand All @@ -228,7 +228,7 @@ jobs:
build_ubuntu_free_threaded:
name: 'Ubuntu (free-threaded)'
needs: check_source
if: needs.check_source.outputs.run_tests == 'true' && contains(github.event.pull_request.labels.*.name, 'topic-free-threaded')
if: needs.check_source.outputs.run_tests == 'true'
uses: ./.github/workflows/reusable-ubuntu.yml
with:
config_hash: ${{ needs.check_source.outputs.config_hash }}
Expand Down Expand Up @@ -521,10 +521,7 @@ jobs:
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
with:
allowed-failures: >-
build_macos_free_threaded,
build_ubuntu_free_threaded,
build_ubuntu_ssltests,
build_windows_free_threaded,
cifuzz,
test_hypothesis,
allowed-skips: >-
Expand Down
7 changes: 5 additions & 2 deletions Doc/library/getpass.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ The :mod:`getpass` module provides two functions:
:envvar:`USER`, :envvar:`!LNAME` and :envvar:`USERNAME`, in order, and
returns the value of the first one which is set to a non-empty string. If
none are set, the login name from the password database is returned on
systems which support the :mod:`pwd` module, otherwise, an exception is
raised.
systems which support the :mod:`pwd` module, otherwise, an :exc:`OSError`
is raised.

In general, this function should be preferred over :func:`os.getlogin()`.

.. versionchanged:: 3.13
Previously, various exceptions beyond just :exc:`OSError` were raised.
2 changes: 1 addition & 1 deletion Doc/library/importlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ find and load modules.
.. versionadded:: 3.4


.. class:: NamespaceLoader(name, path, path_finder):
.. class:: NamespaceLoader(name, path, path_finder)

A concrete implementation of :class:`importlib.abc.InspectLoader` for
namespace packages. This is an alias for a private class and is only made
Expand Down
27 changes: 13 additions & 14 deletions Doc/library/socket.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ all modern Unix systems, Windows, MacOS, and probably additional platforms.

The Python interface is a straightforward transliteration of the Unix system
call and library interface for sockets to Python's object-oriented style: the
:func:`.socket` function returns a :dfn:`socket object` whose methods implement
:func:`~socket.socket` function returns a :dfn:`socket object` whose methods implement
the various socket system calls. Parameter types are somewhat higher-level than
in the C interface: as with :meth:`read` and :meth:`write` operations on Python
files, buffer allocation on receive operations is automatic, and buffer length
Expand Down Expand Up @@ -185,15 +185,14 @@ created. Socket addresses are represented as follows:
.. versionadded:: 3.7

- :const:`AF_PACKET` is a low-level interface directly to network devices.
The packets are represented by the tuple
The addresses are represented by the tuple
``(ifname, proto[, pkttype[, hatype[, addr]]])`` where:

- *ifname* - String specifying the device name.
- *proto* - The Ethernet protocol number.
May be :data:`ETH_P_ALL` to capture all protocols,
one of the :ref:`ETHERTYPE_* constants <socket-ethernet-types>`
or any other Ethernet protocol number.
Value must be in network-byte-order.
- *pkttype* - Optional integer specifying the packet type:

- ``PACKET_HOST`` (the default) - Packet addressed to the local host.
Expand Down Expand Up @@ -348,7 +347,7 @@ Constants
AF_INET6

These constants represent the address (and protocol) families, used for the
first argument to :func:`.socket`. If the :const:`AF_UNIX` constant is not
first argument to :func:`~socket.socket`. If the :const:`AF_UNIX` constant is not
defined then this protocol is unsupported. More constants may be available
depending on the system.

Expand All @@ -365,7 +364,7 @@ Constants
SOCK_SEQPACKET

These constants represent the socket types, used for the second argument to
:func:`.socket`. More constants may be available depending on the system.
:func:`~socket.socket`. More constants may be available depending on the system.
(Only :const:`SOCK_STREAM` and :const:`SOCK_DGRAM` appear to be generally
useful.)

Expand Down Expand Up @@ -404,7 +403,7 @@ Constants

Many constants of these forms, documented in the Unix documentation on sockets
and/or the IP protocol, are also defined in the socket module. They are
generally used in arguments to the :meth:`setsockopt` and :meth:`getsockopt`
generally used in arguments to the :meth:`~socket.setsockopt` and :meth:`~socket.getsockopt`
methods of socket objects. In most cases, only those symbols that are defined
in the Unix header files are defined; for a few symbols, default values are
provided.
Expand Down Expand Up @@ -770,7 +769,7 @@ The following functions all create :ref:`socket objects <socket-objects>`.

Build a pair of connected socket objects using the given address family, socket
type, and protocol number. Address family, socket type, and protocol number are
as for the :func:`.socket` function above. The default family is :const:`AF_UNIX`
as for the :func:`~socket.socket` function above. The default family is :const:`AF_UNIX`
if defined on the platform; otherwise, the default is :const:`AF_INET`.

The newly created sockets are :ref:`non-inheritable <fd_inheritance>`.
Expand Down Expand Up @@ -866,7 +865,7 @@ The following functions all create :ref:`socket objects <socket-objects>`.

Duplicate the file descriptor *fd* (an integer as returned by a file object's
:meth:`~io.IOBase.fileno` method) and build a socket object from the result. Address
family, socket type and protocol number are as for the :func:`.socket` function
family, socket type and protocol number are as for the :func:`~socket.socket` function
above. The file descriptor should refer to a socket, but this is not checked ---
subsequent operations on the object may fail if the file descriptor is invalid.
This function is rarely needed, but can be used to get or set socket options on
Expand Down Expand Up @@ -931,7 +930,7 @@ The :mod:`socket` module also offers various network-related services:
``(family, type, proto, canonname, sockaddr)``

In these tuples, *family*, *type*, *proto* are all integers and are
meant to be passed to the :func:`.socket` function. *canonname* will be
meant to be passed to the :func:`~socket.socket` function. *canonname* will be
a string representing the canonical name of the *host* if
:const:`AI_CANONNAME` is part of the *flags* argument; else *canonname*
will be empty. *sockaddr* is a tuple describing a socket address, whose
Expand Down Expand Up @@ -1047,7 +1046,7 @@ The :mod:`socket` module also offers various network-related services:
.. function:: getprotobyname(protocolname)

Translate an internet protocol name (for example, ``'icmp'``) to a constant
suitable for passing as the (optional) third argument to the :func:`.socket`
suitable for passing as the (optional) third argument to the :func:`~socket.socket`
function. This is usually only needed for sockets opened in "raw" mode
(:const:`SOCK_RAW`); for the normal socket modes, the correct protocol is chosen
automatically if the protocol is omitted or zero.
Expand Down Expand Up @@ -1331,7 +1330,7 @@ The :mod:`socket` module also offers various network-related services:

Send the list of file descriptors *fds* over an :const:`AF_UNIX` socket *sock*.
The *fds* parameter is a sequence of file descriptors.
Consult :meth:`sendmsg` for the documentation of these parameters.
Consult :meth:`~socket.sendmsg` for the documentation of these parameters.

.. availability:: Unix, Windows, not Emscripten, not WASI.

Expand All @@ -1345,7 +1344,7 @@ The :mod:`socket` module also offers various network-related services:

Receive up to *maxfds* file descriptors from an :const:`AF_UNIX` socket *sock*.
Return ``(msg, list(fds), flags, addr)``.
Consult :meth:`recvmsg` for the documentation of these parameters.
Consult :meth:`~socket.recvmsg` for the documentation of these parameters.

.. availability:: Unix, Windows, not Emscripten, not WASI.

Expand Down Expand Up @@ -2064,10 +2063,10 @@ Example

Here are four minimal example programs using the TCP/IP protocol: a server that
echoes all data that it receives back (servicing only one client), and a client
using it. Note that a server must perform the sequence :func:`.socket`,
using it. Note that a server must perform the sequence :func:`~socket.socket`,
:meth:`~socket.bind`, :meth:`~socket.listen`, :meth:`~socket.accept` (possibly
repeating the :meth:`~socket.accept` to service more than one client), while a
client only needs the sequence :func:`.socket`, :meth:`~socket.connect`. Also
client only needs the sequence :func:`~socket.socket`, :meth:`~socket.connect`. Also
note that the server does not :meth:`~socket.sendall`/:meth:`~socket.recv` on
the socket it is listening on but on the new socket returned by
:meth:`~socket.accept`.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/sqlite3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ Cursor objects

.. method:: execute(sql, parameters=(), /)

Execute SQL a single SQL statement,
Execute a single SQL statement,
optionally binding Python values using
:ref:`placeholders <sqlite3-placeholders>`.

Expand Down
100 changes: 100 additions & 0 deletions Doc/library/ssl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,12 @@ Constants

.. versionadded:: 3.7

.. data:: HAS_PSK

Whether the OpenSSL library has built-in support for TLS-PSK.

.. versionadded:: 3.13

.. data:: CHANNEL_BINDING_TYPES

List of supported TLS channel binding types. Strings in this list
Expand Down Expand Up @@ -2006,6 +2012,100 @@ to speed up repeated connections from the same clients.
>>> ssl.create_default_context().verify_mode # doctest: +SKIP
<VerifyMode.CERT_REQUIRED: 2>

.. method:: SSLContext.set_psk_client_callback(callback)

Enables TLS-PSK (pre-shared key) authentication on a client-side connection.

In general, certificate based authentication should be preferred over this method.

The parameter ``callback`` is a callable object with the signature:
``def callback(hint: str | None) -> tuple[str | None, bytes]``.
The ``hint`` parameter is an optional identity hint sent by the server.
The return value is a tuple in the form (client-identity, psk).
Client-identity is an optional string which may be used by the server to
select a corresponding PSK for the client. The string must be less than or
equal to ``256`` octets when UTF-8 encoded. PSK is a
:term:`bytes-like object` representing the pre-shared key. Return a zero
length PSK to reject the connection.

Setting ``callback`` to :const:`None` removes any existing callback.

.. note::
When using TLS 1.3:

- the ``hint`` parameter is always :const:`None`.
- client-identity must be a non-empty string.

Example usage::

context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
context.maximum_version = ssl.TLSVersion.TLSv1_2
context.set_ciphers('PSK')

# A simple lambda:
psk = bytes.fromhex('c0ffee')
context.set_psk_client_callback(lambda hint: (None, psk))

# A table using the hint from the server:
psk_table = { 'ServerId_1': bytes.fromhex('c0ffee'),
'ServerId_2': bytes.fromhex('facade')
}
def callback(hint):
return 'ClientId_1', psk_table.get(hint, b'')
context.set_psk_client_callback(callback)

This method will raise :exc:`NotImplementedError` if :data:`HAS_PSK` is
``False``.

.. versionadded:: 3.13

.. method:: SSLContext.set_psk_server_callback(callback, identity_hint=None)

Enables TLS-PSK (pre-shared key) authentication on a server-side connection.

In general, certificate based authentication should be preferred over this method.

The parameter ``callback`` is a callable object with the signature:
``def callback(identity: str | None) -> bytes``.
The ``identity`` parameter is an optional identity sent by the client which can
be used to select a corresponding PSK.
The return value is a :term:`bytes-like object` representing the pre-shared key.
Return a zero length PSK to reject the connection.

Setting ``callback`` to :const:`None` removes any existing callback.

The parameter ``identity_hint`` is an optional identity hint string sent to
the client. The string must be less than or equal to ``256`` octets when
UTF-8 encoded.

.. note::
When using TLS 1.3 the ``identity_hint`` parameter is not sent to the client.

Example usage::

context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.maximum_version = ssl.TLSVersion.TLSv1_2
context.set_ciphers('PSK')

# A simple lambda:
psk = bytes.fromhex('c0ffee')
context.set_psk_server_callback(lambda identity: psk)

# A table using the identity of the client:
psk_table = { 'ClientId_1': bytes.fromhex('c0ffee'),
'ClientId_2': bytes.fromhex('facade')
}
def callback(identity):
return psk_table.get(identity, b'')
context.set_psk_server_callback(callback, 'ServerId_1')

This method will raise :exc:`NotImplementedError` if :data:`HAS_PSK` is
``False``.

.. versionadded:: 3.13

.. index:: single: certificates

.. index:: single: X509 certificate
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/tkinter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ details that are unchanged.
* `Modern Tkinter for Busy Python Developers <https://tkdocs.com/book.html>`_
By Mark Roseman. (ISBN 978-1999149567)

* `Python and Tkinter Programming <https://www.packtpub.com/product/python-gui-programming-with-tkinter/9781788835886>`_
By Alan Moore. (ISBN 978-1788835886)
* `Python GUI programming with Tkinter <https://www.packtpub.com/product/python-gui-programming-with-tkinter/9781788835886>`_
By Alan D. Moore. (ISBN 978-1788835886)

* `Programming Python <https://learning-python.com/about-pp4e.html>`_
By Mark Lutz; has excellent coverage of Tkinter. (ISBN 978-0596158101)
Expand Down
60 changes: 59 additions & 1 deletion Doc/library/tkinter.ttk.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,8 @@ option. If you don't know the class name of a widget, use the method
.. method:: element_create(elementname, etype, *args, **kw)

Create a new element in the current theme, of the given *etype* which is
expected to be either "image" or "from".
expected to be either "image", "from" or "vsapi".
The latter is only available in Tk 8.6 on Windows.

If "image" is used, *args* should contain the default image name followed
by statespec/value pairs (this is the imagespec), and *kw* may have the
Expand Down Expand Up @@ -1439,6 +1440,63 @@ option. If you don't know the class name of a widget, use the method
style = ttk.Style(root)
style.element_create('plain.background', 'from', 'default')

If "vsapi" is used as the value of *etype*, :meth:`element_create`
will create a new element in the current theme whose visual appearance
is drawn using the Microsoft Visual Styles API which is responsible
for the themed styles on Windows XP and Vista.
*args* is expected to contain the Visual Styles class and part as
given in the Microsoft documentation followed by an optional sequence
of tuples of ttk states and the corresponding Visual Styles API state
value.
*kw* may have the following options:

padding=padding
Specify the element's interior padding.
*padding* is a list of up to four integers specifying the left,
top, right and bottom padding quantities respectively.
If fewer than four elements are specified, bottom defaults to top,
right defaults to left, and top defaults to left.
In other words, a list of three numbers specify the left, vertical,
and right padding; a list of two numbers specify the horizontal
and the vertical padding; a single number specifies the same
padding all the way around the widget.
This option may not be mixed with any other options.

margins=padding
Specifies the elements exterior padding.
*padding* is a list of up to four integers specifying the left, top,
right and bottom padding quantities respectively.
This option may not be mixed with any other options.

width=width
Specifies the width for the element.
If this option is set then the Visual Styles API will not be queried
for the recommended size or the part.
If this option is set then *height* should also be set.
The *width* and *height* options cannot be mixed with the *padding*
or *margins* options.

height=height
Specifies the height of the element.
See the comments for *width*.

Example::

style = ttk.Style(root)
style.element_create('pin', 'vsapi', 'EXPLORERBAR', 3, [
('pressed', '!selected', 3),
('active', '!selected', 2),
('pressed', 'selected', 6),
('active', 'selected', 5),
('selected', 4),
('', 1)])
style.layout('Explorer.Pin',
[('Explorer.Pin.pin', {'sticky': 'news'})])
pin = ttk.Checkbutton(style='Explorer.Pin')
pin.pack(expand=True, fill='both')

.. versionchanged:: 3.13
Added support of the "vsapi" element factory.

.. method:: element_names()

Expand Down
Loading

0 comments on commit e60ad5c

Please sign in to comment.