From: DongHun Kwak Date: Tue, 25 Jan 2022 23:27:52 +0000 (+0900) Subject: Imported Upstream version 3.9.8 X-Git-Tag: upstream/3.9.8^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0e8f56af9d63082f66d36b09c70f52e23a44ebd2;p=platform%2Fupstream%2Fpython3.git Imported Upstream version 3.9.8 --- diff --git a/Doc/c-api/call.rst b/Doc/c-api/call.rst index 31dc9c80..739b5e97 100644 --- a/Doc/c-api/call.rst +++ b/Doc/c-api/call.rst @@ -185,7 +185,7 @@ Object Calling API Various functions are available for calling a Python object. Each converts its arguments to a convention supported by the called object – either *tp_call* or vectorcall. -In order to do as litle conversion as possible, pick one that best fits +In order to do as little conversion as possible, pick one that best fits the format of data you have available. The following table summarizes the available functions; diff --git a/Doc/c-api/gcsupport.rst b/Doc/c-api/gcsupport.rst index f821b450..b0d62d8c 100644 --- a/Doc/c-api/gcsupport.rst +++ b/Doc/c-api/gcsupport.rst @@ -33,6 +33,14 @@ Constructors for container types must conform to two rules: #. Once all the fields which may contain references to other containers are initialized, it must call :c:func:`PyObject_GC_Track`. +Similarly, the deallocator for the object must conform to a similar pair of +rules: + +#. Before fields which refer to other containers are invalidated, + :c:func:`PyObject_GC_UnTrack` must be called. + +#. The object's memory must be deallocated using :c:func:`PyObject_GC_Del`. + .. warning:: If a type adds the Py_TPFLAGS_HAVE_GC, then it *must* implement at least a :c:member:`~PyTypeObject.tp_traverse` handler or explicitly use one @@ -100,14 +108,6 @@ Constructors for container types must conform to two rules: .. versionadded:: 3.9 -Similarly, the deallocator for the object must conform to a similar pair of -rules: - -#. Before fields which refer to other containers are invalidated, - :c:func:`PyObject_GC_UnTrack` must be called. - -#. The object's memory must be deallocated using :c:func:`PyObject_GC_Del`. - .. c:function:: void PyObject_GC_Del(void *op) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index eb0bd145..9d7876e0 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -448,7 +448,7 @@ Process-wide parameters (set by :c:func:`Py_SetProgramName` above) and some environment variables. The returned string consists of a series of directory names separated by a platform dependent delimiter character. The delimiter character is ``':'`` - on Unix and Mac OS X, ``';'`` on Windows. The returned string points into + on Unix and macOS, ``';'`` on Windows. The returned string points into static storage; the caller should not modify its value. The list :data:`sys.path` is initialized with this value on interpreter startup; it can be (and usually is) modified later to change the search path for loading @@ -469,7 +469,7 @@ Process-wide parameters default search path but uses the one provided instead. This is useful if Python is embedded by an application that has full knowledge of the location of all modules. The path components should be separated by the platform - dependent delimiter character, which is ``':'`` on Unix and Mac OS X, ``';'`` + dependent delimiter character, which is ``':'`` on Unix and macOS, ``';'`` on Windows. This also causes :data:`sys.executable` to be set to the program @@ -510,7 +510,7 @@ Process-wide parameters Return the platform identifier for the current platform. On Unix, this is formed from the "official" name of the operating system, converted to lower case, followed by the major revision number; e.g., for Solaris 2.x, which is - also known as SunOS 5.x, the value is ``'sunos5'``. On Mac OS X, it is + also known as SunOS 5.x, the value is ``'sunos5'``. On macOS, it is ``'darwin'``. On Windows, it is ``'win'``. The returned string points into static storage; the caller should not modify its value. The value is available to Python code as ``sys.platform``. diff --git a/Doc/c-api/type.rst b/Doc/c-api/type.rst index 69894cae..cc2d8fda 100644 --- a/Doc/c-api/type.rst +++ b/Doc/c-api/type.rst @@ -173,7 +173,7 @@ The following functions and structs are used to create The *module* argument can be used to record the module in which the new class is defined. It must be a module object or ``NULL``. If not ``NULL``, the module is associated with the new type and can later be - retreived with :c:func:`PyType_GetModule`. + retrieved with :c:func:`PyType_GetModule`. The associated module is not inherited by subclasses; it must be specified for each class individually. diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst index 5a1f5f99..a8006167 100644 --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -189,136 +189,136 @@ sub-slots .. table:: :widths: 26,17,12 - +---------------------------------------------------------+-----------------------------------+--------------+ - | Slot | :ref:`Type ` | special | - | | | methods | - +=========================================================+===================================+==============+ - | :c:member:`~PyAsyncMethods.am_await` | :c:type:`unaryfunc` | __await__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyAsyncMethods.am_aiter` | :c:type:`unaryfunc` | __aiter__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyAsyncMethods.am_anext` | :c:type:`unaryfunc` | __anext__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_add` | :c:type:`binaryfunc` | __add__ | - | | | __radd__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_inplace_add` | :c:type:`binaryfunc` | __iadd__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_subtract` | :c:type:`binaryfunc` | __sub__ | - | | | __rsub__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_inplace_subtract` | :c:type:`binaryfunc` | __sub__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_multiply` | :c:type:`binaryfunc` | __mul__ | - | | | __rmul__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_inplace_multiply` | :c:type:`binaryfunc` | __mul__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_remainder` | :c:type:`binaryfunc` | __mod__ | - | | | __rmod__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_inplace_remainder` | :c:type:`binaryfunc` | __mod__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_divmod` | :c:type:`binaryfunc` | __divmod__ | - | | | __rdivmod__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_power` | :c:type:`ternaryfunc` | __pow__ | - | | | __rpow__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_inplace_power` | :c:type:`ternaryfunc` | __pow__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_negative` | :c:type:`unaryfunc` | __neg__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_positive` | :c:type:`unaryfunc` | __pos__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_absolute` | :c:type:`unaryfunc` | __abs__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_bool` | :c:type:`inquiry` | __bool__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_invert` | :c:type:`unaryfunc` | __invert__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_lshift` | :c:type:`binaryfunc` | __lshift__ | - | | | __rlshift__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_inplace_lshift` | :c:type:`binaryfunc` | __lshift__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_rshift` | :c:type:`binaryfunc` | __rshift__ | - | | | __rrshift__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_inplace_rshift` | :c:type:`binaryfunc` | __rshift__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_and` | :c:type:`binaryfunc` | __and__ | - | | | __rand__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_inplace_and` | :c:type:`binaryfunc` | __and__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_xor` | :c:type:`binaryfunc` | __xor__ | - | | | __rxor__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_inplace_xor` | :c:type:`binaryfunc` | __xor__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_or` | :c:type:`binaryfunc` | __or__ | - | | | __ror__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_inplace_or` | :c:type:`binaryfunc` | __or__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_int` | :c:type:`unaryfunc` | __int__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_reserved` | void * | | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_float` | :c:type:`unaryfunc` | __float__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_floor_divide` | :c:type:`binaryfunc` | __floordiv__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_inplace_floor_divide` | :c:type:`binaryfunc` | __floordiv__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_true_divide` | :c:type:`binaryfunc` | __truediv__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_inplace_true_divide` | :c:type:`binaryfunc` | __truediv__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_index` | :c:type:`unaryfunc` | __index__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_matrix_multiply` | :c:type:`binaryfunc` | __matmul__ | - | | | __rmatmul__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyNumberMethods.nb_inplace_matrix_multiply` | :c:type:`binaryfunc` | __matmul__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyMappingMethods.mp_length` | :c:type:`lenfunc` | __len__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyMappingMethods.mp_subscript` | :c:type:`binaryfunc` | __getitem__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyMappingMethods.mp_ass_subscript` | :c:type:`objobjargproc` | __setitem__, | - | | | __delitem__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PySequenceMethods.sq_length` | :c:type:`lenfunc` | __len__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PySequenceMethods.sq_concat` | :c:type:`binaryfunc` | __add__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PySequenceMethods.sq_repeat` | :c:type:`ssizeargfunc` | __mul__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PySequenceMethods.sq_item` | :c:type:`ssizeargfunc` | __getitem__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PySequenceMethods.sq_ass_item` | :c:type:`ssizeobjargproc` | __setitem__ | - | | | __delitem__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PySequenceMethods.sq_contains` | :c:type:`objobjproc` | __contains__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PySequenceMethods.sq_inplace_concat` | :c:type:`binaryfunc` | __iadd__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PySequenceMethods.sq_inplace_repeat` | :c:type:`ssizeargfunc` | __imul__ | - +---------------------------------------------------------+-----------------------------------+--------------+ - | | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyBufferProcs.bf_getbuffer` | :c:func:`getbufferproc` | | - +---------------------------------------------------------+-----------------------------------+--------------+ - | :c:member:`~PyBufferProcs.bf_releasebuffer` | :c:func:`releasebufferproc` | | - +---------------------------------------------------------+-----------------------------------+--------------+ + +---------------------------------------------------------+-----------------------------------+---------------+ + | Slot | :ref:`Type ` | special | + | | | methods | + +=========================================================+===================================+===============+ + | :c:member:`~PyAsyncMethods.am_await` | :c:type:`unaryfunc` | __await__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyAsyncMethods.am_aiter` | :c:type:`unaryfunc` | __aiter__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyAsyncMethods.am_anext` | :c:type:`unaryfunc` | __anext__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_add` | :c:type:`binaryfunc` | __add__ | + | | | __radd__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_inplace_add` | :c:type:`binaryfunc` | __iadd__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_subtract` | :c:type:`binaryfunc` | __sub__ | + | | | __rsub__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_inplace_subtract` | :c:type:`binaryfunc` | __isub__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_multiply` | :c:type:`binaryfunc` | __mul__ | + | | | __rmul__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_inplace_multiply` | :c:type:`binaryfunc` | __imul__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_remainder` | :c:type:`binaryfunc` | __mod__ | + | | | __rmod__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_inplace_remainder` | :c:type:`binaryfunc` | __imod__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_divmod` | :c:type:`binaryfunc` | __divmod__ | + | | | __rdivmod__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_power` | :c:type:`ternaryfunc` | __pow__ | + | | | __rpow__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_inplace_power` | :c:type:`ternaryfunc` | __ipow__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_negative` | :c:type:`unaryfunc` | __neg__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_positive` | :c:type:`unaryfunc` | __pos__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_absolute` | :c:type:`unaryfunc` | __abs__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_bool` | :c:type:`inquiry` | __bool__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_invert` | :c:type:`unaryfunc` | __invert__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_lshift` | :c:type:`binaryfunc` | __lshift__ | + | | | __rlshift__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_inplace_lshift` | :c:type:`binaryfunc` | __ilshift__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_rshift` | :c:type:`binaryfunc` | __rshift__ | + | | | __rrshift__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_inplace_rshift` | :c:type:`binaryfunc` | __irshift__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_and` | :c:type:`binaryfunc` | __and__ | + | | | __rand__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_inplace_and` | :c:type:`binaryfunc` | __iand__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_xor` | :c:type:`binaryfunc` | __xor__ | + | | | __rxor__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_inplace_xor` | :c:type:`binaryfunc` | __ixor__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_or` | :c:type:`binaryfunc` | __or__ | + | | | __ror__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_inplace_or` | :c:type:`binaryfunc` | __ior__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_int` | :c:type:`unaryfunc` | __int__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_reserved` | void * | | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_float` | :c:type:`unaryfunc` | __float__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_floor_divide` | :c:type:`binaryfunc` | __floordiv__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_inplace_floor_divide` | :c:type:`binaryfunc` | __ifloordiv__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_true_divide` | :c:type:`binaryfunc` | __truediv__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_inplace_true_divide` | :c:type:`binaryfunc` | __itruediv__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_index` | :c:type:`unaryfunc` | __index__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_matrix_multiply` | :c:type:`binaryfunc` | __matmul__ | + | | | __rmatmul__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyNumberMethods.nb_inplace_matrix_multiply` | :c:type:`binaryfunc` | __imatmul__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyMappingMethods.mp_length` | :c:type:`lenfunc` | __len__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyMappingMethods.mp_subscript` | :c:type:`binaryfunc` | __getitem__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyMappingMethods.mp_ass_subscript` | :c:type:`objobjargproc` | __setitem__, | + | | | __delitem__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PySequenceMethods.sq_length` | :c:type:`lenfunc` | __len__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PySequenceMethods.sq_concat` | :c:type:`binaryfunc` | __add__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PySequenceMethods.sq_repeat` | :c:type:`ssizeargfunc` | __mul__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PySequenceMethods.sq_item` | :c:type:`ssizeargfunc` | __getitem__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PySequenceMethods.sq_ass_item` | :c:type:`ssizeobjargproc` | __setitem__ | + | | | __delitem__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PySequenceMethods.sq_contains` | :c:type:`objobjproc` | __contains__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PySequenceMethods.sq_inplace_concat` | :c:type:`binaryfunc` | __iadd__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PySequenceMethods.sq_inplace_repeat` | :c:type:`ssizeargfunc` | __imul__ | + +---------------------------------------------------------+-----------------------------------+---------------+ + | | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyBufferProcs.bf_getbuffer` | :c:func:`getbufferproc` | | + +---------------------------------------------------------+-----------------------------------+---------------+ + | :c:member:`~PyBufferProcs.bf_releasebuffer` | :c:func:`releasebufferproc` | | + +---------------------------------------------------------+-----------------------------------+---------------+ .. _slot-typedefs-table: @@ -657,6 +657,18 @@ and :c:type:`PyType_Type` effectively act as defaults.) :c:func:`PyObject_GC_Del` if the instance was allocated using :c:func:`PyObject_GC_New` or :c:func:`PyObject_GC_NewVar`. + If the type supports garbage collection (has the :const:`Py_TPFLAGS_HAVE_GC` + flag bit set), the destructor should call :c:func:`PyObject_GC_UnTrack` + before clearing any member fields. + + .. code-block:: c + + static void foo_dealloc(foo_object *self) { + PyObject_GC_UnTrack(self); + Py_CLEAR(self->ref); + Py_TYPE(self)->tp_free((PyObject *)self); + } + Finally, if the type is heap allocated (:const:`Py_TPFLAGS_HEAPTYPE`), the deallocator should decrement the reference count for its type object after calling the type deallocator. In order to avoid dangling pointers, the diff --git a/Doc/data/python3.9.abi b/Doc/data/python3.9.abi index 228fefcd..e2037436 100644 --- a/Doc/data/python3.9.abi +++ b/Doc/data/python3.9.abi @@ -1290,7 +1290,9 @@ - + + + @@ -1691,9 +1693,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - @@ -1741,7 +1774,7 @@ - + @@ -1758,6 +1791,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1784,11727 +1846,16151 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + - + + + + - - - + + + + + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + + + + - + - + + + + + + + + + + - + + + + + + + + + + + + + + + + + + - + - + - + - - - - - - - - - - + - + + + + + - + - + - - - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + + + - - + + - - + + + + - - + + + + - - + + - - + + + + - - + + - - + + - - + + + + - - + + + + - - + + - - + + - - + + + + - - + + - - + + + + + + + + + + + - - + + - - + + - - + + + + - - + + - - + + - - + + + + - - + + + + - - + + - - + + + + + - - + + - - + + - - + + + + + + + + + + + - - + + - - + + - - + + + + - - + + - - + + + + - - + + - - + + + + - - + + - + - + + + + - + - - - - - - - - - - + - + - - - - + - - - - - - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - + + - - + + - - + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + + + + - + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - + + - - + + - - - - - - - - - - - + + - - + + - - + + - - - - + + - - + + - - + + - - - - + + - - - - + + - - + + - - - - - + + - - + + - - + + - - - - - - - - - - - + + - - + + - - + + - - - - + + - - + + + + + - + + + + + + + + + + - + - + - - - - + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - - - + + - - + + - - - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - + - - + + + + - - + + - - + + - - + + - - + + - - + + - - + + + + - - + + - - + + + + + + + + + + + + + - - + + - - + + + + - - + + - - + + + + + + + + + + + - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + - - - - - - - + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + - - - - - - + + + + - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - - + + + + - - - - + + + + - - - + + + - - - - + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + - - - - - + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + - - - - - + + + + + - - - - - + + + + + + - - - - + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + - - - - - - - + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - + + - - - - - - - - - - - + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + - - - - - - - - + + - - - - - - - - + + - - - - - - - + + - - - - - - + + - - - - - - + - - - + + - - - + + - - - + + - - + + + + + + + + + + + + + - - - - - - - - + + + - - - - + + + - - - - + + + - - + + + - - + + - - - + + - - - - + + - - - - + + - - - - - + + - - - - + + - - - + + - - - + + - - - + + - - - - + + - - - - + + - - - - + + - - - - + + - - - - - + + - - - - + + - - - + + - - - + + - - - - - + + - - - - - - + + - - - - + + - - - - - + + - - - - - + + - - - - + + - - - - + + - - - - + + - - - - + + - - - - + + - - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + - - - - + + - - - + + - - - + + - - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - - - + + - - - - + + - - - - + + - - - - + + - - - - + + - - - - + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - + + + + - - - - + + + + + - - - - + + + - - - - + + + - - - - + + + + + - - - - - + + + + - - - + + + - + - - - + + + - - - - + + + + + + - - - + + + + + + + + + + + + + + - - - + + + + + - - - + + + + + - - - + + + - - - + + + + + + + + + + + + + + + + + + - - - + + - - - + + + - - - - + + + + - - - + + + + + + + + - - - + + - - - - + + - - + - - - - - - - - + + - - - - - - + - - - - + + - - - - - - + + - - - + + - - - - - - + - - - - + - - - - + + - - - - - - + + - - - - - + + - - - - - - + + - - - - - + + - - - - - - + + - - - + + + + + + - - - + + + + - - - - + + + + + + + + + + + + + + + + + - - - - + + + + + - - - - - + + + + + + - - - + + + + + + - - - - + + + + + + - - - + + + + + + - - - + + + + + + - - - + + + + + + - - + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + - - - + + + + + + - - + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + - + + + + - + - + - - - - + - + - + - + + + + - + - + - + - + - + - - - - + - + - - + + + + + - + + + + - + + + + - + + + + - + + + + - + + + + - + + + + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + - + + + + - + + + + - + - + - + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + + + - - + + + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + + + - - + + + + - - + + - - + + - - + + + + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - - - - - - - - - - - - - + - - - - + + - - + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + - + - + - + - - - - - - - - - - - - - - - + + - - + + - - - - + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - - - - + - + - - - - + + - - + + - - - - - + + - - + + - - - - - - - - - - - - - - - - + + - - + + - - + + - - - - + + - - + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - + + - - + + - - - - - - - - - - - - + + - - + + - - + + - - + + - - - - + + - - + + - - - - - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - - + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + - - - - + - - - - - - + - - + + - - + + - - + + - - + + - - + + - - - - + + - - + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - - + + - - - - - - - - - - - - - - + - - - - + - - - - + - - - - + - + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + - - - - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + + + - - + + - - + + - - + + - - + + + + + + - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + - + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - - - - - - - + - - - - + - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + - + - - - - - - + - + - + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + - - - - - + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - + + + + + - - - - + + + + - - - - - - + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + - - - + + + - - + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - + + + - - - - + + + + + + + + - - - - - - - + + + - - + + + - - + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + - - + + - - - + + + - - + + + + - - + + + + + - - - - - - - - + + + + + - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - - - + + + + - - + + + + + + + + + - - - - - + + + + - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + - - - + + + - - - + + + + - - - + + - - - - + + + - - - - + + + + + - - - - + + + + - - - + + + + - - - - + + + + - - - - + + + + + - - - - - - - - - - - - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - + + + - - - - - + + + + - - - - - + + + + - - - + + + + + + + + - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + - - - - - - - - + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + - - - + + - - - + + - - - + + + + - - - + + + + - - - + + + + - - - + + + - - - + + + + + + + + + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + + - - - + + + + - - + + + + + + + + + + + + + + + - - + + + - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + - - - + + - - - + - - - + + - - - - + + - - - + + - - - - - - - + + - - - - - - - - - - - - - - + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + - - - - - + + - - - + + - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + - - - - - - - - + + - - - + + + + + + + + - - - + + + + + + + + - - - - - - + + + + + + + + - - + + + + - - - + + + + + - - - - + + + + + - - - - + + - - - - - - - - - - + + - - - - - - - - - + + - - - - + + - - - - + + - - - - - + + - - - - - + + - - - - - + + - - + - - - + + - - - + + - - - + + - + + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - - - + + + - - + - - - + + + + + + + - - - - + + - - - - - + - - - - - - + + - - - + + - - - - - - - - + + - - - + + - - - - + + - - - + + - - - - + + - - - + + - - - - + + - - - + + - - - - + + - - - + + - - - + + - - - + + - - - + + - - - - + + - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - + + - - - + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - - - - - - - + + - - - + + - - - + + - - - - - - - - - - - - - - - - + - - - - - + + - - - - + - - - + + - - - - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + - - - + + + + + - - - - - - - - - - - - + + + - - - + + - - - + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + - - - + + - - - - + + - - - - + + - - - - - - + + - - - - - + + - - - - - + + - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - + + - - - - + + - - - - + + - - - - + + - - - - + + - - - - + + - - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - - - - - + + - - - - - - + + - - - + + - - - + + - - - + + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - + + + + + - - + + + + - - + + + - - + + + + - - + + + + - - + + + + - - + + + + - - - + + + + - - + + + - - + + - - - - - - - - - - - - - - - + + - - - + + + - - - + + + - - - + + - - - - + + - - - - + + + + + + - - - - + + + - - - + + - - - - + + - - - - - + + - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - - - + + - - - - - + + - - - + + + + + + + + + + + + + + - - - - + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - - - - - + + - - - - + + + + + + + + - - - + + + + - - - - - - + + + + - - - - + + - - - - + + + - - - + - - - + + - - - - + - - - + - - + + + - - + - - - - - - + + - - - - + + - - + - - - - - - - - - - - - - - - - - - + + - - - - - + + - - + + - - - - - - - - - - + + - - - - - + + - - - + + - - - + + - - - - - + + - - - - - - - - - + + + + - - - - - - - - - + + + - - - - - + + + + + - - - - - - - + + + + + - - + + + - - + + - - - + + + + - + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + - + + + + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - - - + + - - + + - - + + - - + + - - - - - - + + - - + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + - - + + + + - - - - + + - - - - + + + + - - - - + + + + + - - - - + + + + + - - - + + - - - + + + - - + + + + - - + + + - - + - + + + + + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - + + + - - + + + + - - - - - - - + + + + - - + + + + - - - - + + + + + + - + + - + + + + - - + + + + + - - + + + + - - + + + + + - - + + - - + + + + + + + + + + + - - + + + + - - - + + + - - - + + + + - - - + + + - - - + + + + - - - - - + + + - - - - - + + + + + - - - - - + + + + + + + + + + - - - - + + + + + - - - - - + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + - - - + + - - - + + + + + + + + + + + - - - - - + + - - - - + + - - - - - + + - - - - - + + - - - - + + - - - - - + + - - - - + + - - - - + + - - - + + - - - - - + + - - - - + + - - - - + + + + + + + + + + + + + + + + - - - + + + + - - - + + - - - - + + + + + - - - - - - - - - + + + + - - - + + + + - - - + + + + + + + + - - - + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - + + + + + - - + + + + + + - - - - + + + + + + - - + + + + + + - - - + + + + + + - - - - - + + + + + + - - - + + + + + + + - - - - - + + + + + + + - - - - + + + + + + + - - - + + + + + + + - - + + + + + - - - + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - + + + + + + - - + + + + + + - - - + + + + + - - - - + + + + + - - - - + + + + + - - - + + + + + - - - + + + + + + - - - + + - - - - - + + - - + - - - - + + - - - - + + - - - + + + + - - - + + + + - - - - + + + + - - - - + + + + - - - + + - + + + + + + + + + + + + + + + + + + - + - + - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + - + - + - + - - + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + - - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + - - - - - - - - - - - - - + + + - - - - - + + + - - - - + + - + + - - + - + + - - - - - - + - + - - - - - + + + + + + - - - - + + + + + + + + + + + + + + - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + - - + + - - - - - + + - - - + + - - - - + + + - - - - + + + + + + - - - + + + + + + - - - + + + + + - - + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - + + + + + - - - - - - + + - - - - - + + + + + + - - - - - - + + + - - - + + - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - + - - - - + + - - - - + + - - - - + + + + + + + + + + + + + + + + + + + + + + - - - + + - - - - - - - - + + - - - - - + + - - - - + + - - + - - - - - + + - - - - + + - - - + + - - - + + - - + - - - - - - - + + + - - - - + + - - - - + + - - - + + - - - + + - - - - + + + + + + + + + + + + + + + + + + + + - + - + - - - - + - + - - - - - - - - - + - - - - - - - + + + + + + + + + + + - - - - - + + + + + + + - - - - + + + + + + + - - - - + + + + + - - - + + + + + - - - - + + + - - - - + + + - - - - - + + + - - - - + + + - - - + + + + + - - + - - + + - - - - + + + + - - - + + + + - - - + + + + - - - - - - - - - - - - - + + + + - - - + + + + + - - - - + + + + - - - - + + + - - - - + + - - - + + - - - - + + + - - - - - + + + - - - - + + - - - + + + - - - + + + + + + + + - - + - - + - - - - + + - - - - - - + + - - + - - - + + - - - - - + + - - - - - + + - - - - - - + + - - - - + + - - - - + + - - - - + + - - - - - + + - - + - - - - - + + - - - - + + - - - - + + - - - - - + + - - - - - - + + - - - - - + + - - - - - + + - - - + + - - - + + + + + + + + - - - + - - - + - - - + + + - - - - + + + + - - - - + + + + - - - - + + - - - - + + + - - - - + + + - - - + + - - - - + + + + + - - - - + + + + + - - - - - - + + - - - - - + - - - - - + + - - - - + + - - - - - - - + + - - - - - - - + + - - - - - - - + + - - - - - - + + - - - - - - - - - - - - + + - - - - - - + + - - - - + + - - - + + + + + + + - - - - - + + + + + - - - - - - + + + + + - - - - + + + + + - - - - - - + + + + + + + - - - - - + + + + + + + - - + + + - - - - - + + + - - + + + - - - + + + - - - - - + + + + - - - - - + + - - - + + + + + + + + - - - - + + + + + + - - - - - + + - - - - - + + + + + + + - - - - + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + - - - - + + - - - + + - - - - - + + - - - - - - + + - - - + + + - - - - - - + + + - - - - - + + + - - - - - - - + + + - - - - - - + + - - - + + - - - - - - + + - - - - - + + - - - - - - - + + - - - - - - + + - - - + + - - - - - + + - - - - + + - - - - - - - - - - - - - - - + + - - - - - - - - + + - - - - - + + + + + + + - - - - - + + + + + + + + + - - - - - - - + + + + + + + + + + - - - - - - + + + + - - - - - - + + + + - - - - - + + + - - + + + - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - + + - - - + + - - - + + - - - + + - - - + + - - - - + + - - - + + - - - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - + + + - - - + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + - - - - - + + + - - - - - + + + - - - + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + - - - - - - + + + + - - - - - + + - - - - - + + + - - - - - - + + + - - - - - + + + + - - - + + + - - - + + + + - - - - + + + - - - - - + + + - - - - + + - - - - + + + - - - + + - - - - - - + + - - - + + + - - - - - + + - - - - - + + + + + - - - - + + + + + - - - + + + + + - - - + + + - - - - + + + - - - - + + + - - - - + + + - - - + - - + - - - - - - - + + - - - - - - + - - - - + + - - - - + + + + - - + + + + + + - - - + + + - - - - + - - - + + - - - + + - - - - + + - - - - + + - - - - + + - - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - - - + + - - - + + - - - + + - - - - - - - + - - - + + - - - - + + - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - - + + - - - - - - - - - + + - - - - - - - - + + + + + + + + - - - - - - - - + + - - - - - + + - - - - - - + + - - - - - - + + - - - - + + - - - - - + + - - - - - - - - + + - - - - - - + + - - - + + - - - - - - - - - - - - - - - - - + + - - - - - - - - - + - - - + + - - - + + - - - - + + - - - - + + - - - + + - - - + + - - - + + - - + + - - + + - - - + + - - + + - - + + - - + + - - - + + - - + + - - - + + - - + + - - - + - - - + - - - - - + + - - - + - - - - - + + - - - - + + - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - + + - - - - - + + - - - - + + - - - + + - - - - - + + - - - - + + - - + - - + + - - + + - - - - + + - - - - - + + - - + - - + - - + + - - + - - + - - + - + - + - + - - + + - - + - - + + - - + + + + + + + + - - - - - + + + + + + + + + + + + + + + + - - - + + + - - - + + + + - - - + + + - - - + + + - - - + + + + - - + + + + - - - + + + + + + + - - - - - + + + - - - - - + + + + + + + + + - - - - + + - - - - - + + - - - - - + + - - - - - + + + + + - - - - - + + - - - + - - - - + + + - - - + + + - - - + + + - - - - + + - - - - + + - - + + + - - - + + + - - - + + + - - - + + + - - - - - - + + - - - - - + + + - - - - + + + - - - - - - - + + + + + - - - - - - - + + - - - - + + - - - - - - - - - + + + + - - - - + + - - - - - + + + - - - - + + + - - + + + + + + + - - + + + - + + - - - + + + - - + + + - - + + + - - - - - + + - - - + + - - - - - - - - - - + + + - - - - + + + - - + + - - - + + - - - - - - - - - - - - + + + - - - - - + + + - - - - - - + + - - - - - + + + - + + - - - + + - - - - - + + - - - - - - + + + - - - + + + - - - - + + + - - - - - + + + - - - - + + + - - + + + + + - - - + + - - + + - - - - - + + - - - - - - + + - - + - - - - + - - - - + - - - - + - - - - - + - + - - + - - - - + - - - - - + - - - - + - - - - - + - - + + + + + - - - + + + - - - + + + + + + + + + + + + + + + - + + + + + - - - - + + + + + - - - - - + + + + - - - + + + + + + + + - - - - + + + + + + + + - - - + + + + + + + - - - - + + + + + - - - - - + + + + + - - - + + + + - - - - - + + + + - - - - - - + + + + + - - - - - - + + + - - - - - - - - - - - - - - - - + + + - - - - + + + + + + - - - - - - + + + + + - - - - + + + + + + - - - - + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - + + + + + + - - - - - - + + + + + - - - - - - + + + + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + - - - - - + + + + + - - - - - + + + + - - - - - - + + + + - - - - - - + + + + - - - - - - + + + + + - - - - - - + + - - - - - + + + + - - - - - + + - - - - - + + - - - - - - + + - - - - - - + + - - - - - + + - - - - - + + - - - - - + + - - - - - + + - - - - + + - - - - + + - - - - + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + - - - - - - - - - + + - + + + + - + + + + - + - - - - - - - - - - - - - - - - + + - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - + + + - - - - - - - - - - - - - - + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - + + + + + + + - - - - - + + + + + - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - + + + + - - - + + - - + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + - - - - - - + + + + + - - - - - - + + + + - - - - - + + + + - - - - + + + - - - + + + + + - - - + + + + + - - - - + + + + - - - - + + + - - - - - + + + - - + + + - - + + + - - - + + + + + + - - - + + + + + - - - - - - + + + + - - - - - + + + + + - - + + + - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - + + - - - - - + + - - - - - + + - - - - - + + + + + + - - - + + + + - - + - - + - - + - - - - + - + - + - - - + + + + + + - - - - + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + - - + + + + + + + - - - + + + + + - - - + + + + + - - - + + - - - + + - - + + + + + + - - - + + + + - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + + - - - + + + - - + - - - + + + - - + - - - - + + - - - - + + - - - - - - - + + - - - - - + + + - - - - + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - + + + + - - - - + + + + - - - + + - - - + + - - - - + + - - - - - - - - + + - - - - - - + + - - - - - - - + + - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - + + - - + + - - + + - - + + - - + - - + - - + - - + - - - - - - - - + + - - - - - - - - - + + - - - - + - - - - + + - - - - + + - - - + - - + - - + - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - + + - - + - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - + + + + - - - + + + - - - + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + - - - + + + - - - + + + + + + + + + + - + + - - + + - - + - - - + + + + + + + + + + + + - - + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + - - - + - - + - - + - - + + - - - + + - + - - + + - + - - + - - - - - + + - - + + - - - - + + - - - - - + + - - - - - + + - - - - - + + - - - - + + - - - + + - - - + + - - - + + - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + - + + + + + - + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + - - + + - - - - + + - - - + + - - - + - - - + + - - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + - - - + + + - - - + + - - + + + + + + + + - - - - - - - - - + + + - - + + + + + - + + + + - - + + + + + - - - - - + + + + + - - + + + + + - - + + + + - - - + + + + - - - + + + + - - - + + + + - - + + + + - - + + + + + - - - + + + + - - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + - - + + + + - - - + + + + + + + + - - - + + + + - - - - - + + + + - - + + + + - - + + + + + + + + - - - - + + - - + + + - - + - - + - - + - - - - - - - - - - - - - - - + + - - - + + - - + - - - + + - - - + + - - - + + - - - + + - - - + - - - + + - - + - - + - - - + + - - - + + - - - + + - - + + + + + + + + + + - - + - - + - - + + + - - + + - - - + + - - + - - + - - - + + - - - - + + + + - - - + + + - - - - - - - - - - - - - - - + - - - - - - + + - - - - - + + - - - - + + - - - - - - - - + + - - - - - - - - + + - - - - - - - + + - - - - - + + - - - - - + + - - - - + + - - - - + + - - - - - + + - - + - - + - - - - - - + + + + + - - - - - + + + - - - - - - + + + - - - - - - - - - - - + + + + - - - - - - - - - - - + + + + - - - - - - - + + + - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + - - - - - - - + + + - - - - - - - + + - - - - - - - - - + + + + + - - - - - - + - - - - + + + + - - - - - + - + - - + - - + - - - + + - - - - + + - - - - - - + + - - - - - + + - - - - - + + - - - - - + + - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + - - - + + + + + - + + + + + - - - + + - - - - - - - - - - - - - - - - - - - - - + + - - - - + + - - + + - - - - + + + - - + + + - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - + + - - - - - + + - - - - + + - - - - + + - - - + + - - - + + - - - - - + + - - - - - + + - - - - + + - - - - + + - - - - + + - - - + + - - - + + - - - - - - - + + - - - - - - + + - - - - - + + - - - + + - - - + + - - - - - + + - - - - - - + + - - - - + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + - - - - - - - - - + + - - - - + + - - + - - - - - + + - - - - - + + - - - - - + - - - + - - - + - - - + - - - + - - - - + - - + - - + + - - + - - + + - - + - - + - + - - - + + - - - - + + - - - - - + + - - - - + + - - - - + + - - - + + - - - + + - - - - + + - - - - + + - - + - - + + - - - + + - - + + - - - + + - - - - + + - - + - - - + + - + - - - + + - - - - + + - - + - - + - - + + - - - - + + - - - - + + - - + - - - - - - - - - - - - + + - - + - - + + - + - - + + - - + + - - - - + + - + - - - - - - - + + - - - - - - + + - - - - + - - - + + - - - - - - - - - - - + + - - - - - + + - - - - - - - - - + + - - - - - - - - - + + - - - - - + + - - - - + + - - - - - - - - - - - - - - - - + + - - - - - - + + - - - - + + - - - - + + - - - - - - - - - - + + + + + + + + - - + - - - - + + - - - + + - - - + + - - - - - - - - - + + - - - - - - - + + - - - - - - - + + - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - + + - - - + + - - - + + - - - - + + - - - - + + - - - + + - - - - - + + - - - - - + + - - - - - + + - - - - - + + - - - - - + + - - - - + + - - - - + + - - - - + + - - - - + + - - - - + + - - - - - + + - - - - - + + - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - + + - - - - + + - - - - - - - - + + - - - - + + - - - - + + - - - - + + - - - - - - - - + + - + - - + + - - - + + - - - - - - - - - - - - - - + + - - - - + + - - + + - - - - - + + - - - + + - - + - - - - + + - - - - + + - - - + + - - - + + + + + + + + + + + + + + - - - + + - - - + + - - + - - + - - + + - - + + - - + + - - + + - - - - + - - - - + + - - - + + - - - - + + - - - - - - + + - - - - - - + + - - - + + - - - + + + + + - + - + - + - + @@ -13517,167 +18003,210 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + - - - - + + - - + + - - - - + + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -13689,16 +18218,95 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -13709,16 +18317,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -13752,17 +18480,38 @@ + + + + + + + + + + + + + + + + + + + + + @@ -13770,19 +18519,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -13808,16 +18635,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Doc/distributing/index.rst b/Doc/distributing/index.rst index 56a0a2ea..136cf4e7 100644 --- a/Doc/distributing/index.rst +++ b/Doc/distributing/index.rst @@ -31,7 +31,7 @@ installing other Python projects, refer to the Key terms ========= -* the `Python Packaging Index `__ is a public +* the `Python Package Index `__ is a public repository of open source licensed packages made available for use by other Python users * the `Python Packaging Authority @@ -101,7 +101,7 @@ by invoking the ``pip`` module at the command line:: .. note:: - For POSIX users (including Mac OS X and Linux users), these instructions + For POSIX users (including macOS and Linux users), these instructions assume the use of a :term:`virtual environment`. For Windows users, these instructions assume that the option to @@ -127,14 +127,14 @@ involved in creating and publishing a project: * `Project structure`_ * `Building and packaging the project`_ -* `Uploading the project to the Python Packaging Index`_ +* `Uploading the project to the Python Package Index`_ * `The .pypirc file`_ .. _Project structure: \ https://packaging.python.org/tutorials/packaging-projects/#packaging-python-projects .. _Building and packaging the project: \ https://packaging.python.org/tutorials/packaging-projects/#creating-the-package-files -.. _Uploading the project to the Python Packaging Index: \ +.. _Uploading the project to the Python Package Index: \ https://packaging.python.org/tutorials/packaging-projects/#uploading-the-distribution-archives .. _The .pypirc file: \ https://packaging.python.org/specifications/pypirc/ @@ -150,7 +150,7 @@ These are quick answers or links for some common tasks. This isn't an easy topic, but here are a few tips: -* check the Python Packaging Index to see if the name is already in use +* check the Python Package Index to see if the name is already in use * check popular hosting sites like GitHub, Bitbucket, etc to see if there is already a project with that name * check what comes up in a web search for the name you're considering diff --git a/Doc/distutils/apiref.rst b/Doc/distutils/apiref.rst index b14197c2..fadce738 100644 --- a/Doc/distutils/apiref.rst +++ b/Doc/distutils/apiref.rst @@ -373,7 +373,7 @@ This module provides the following functions. compiler object under Unix---if you supply a value for *compiler*, *plat* is ignored. - .. % Is the posix/nt only thing still true? Mac OS X seems to work, and + .. % Is the posix/nt only thing still true? macOS seems to work, and .. % returns a UnixCCompiler instance. How to document this... hmm. @@ -1119,11 +1119,11 @@ other utility module. For non-POSIX platforms, currently just returns ``sys.platform``. - For Mac OS X systems the OS version reflects the minimal version on which + For macOS systems the OS version reflects the minimal version on which binaries will run (that is, the value of ``MACOSX_DEPLOYMENT_TARGET`` during the build of Python), not the OS version of the current system. - For universal binary builds on Mac OS X the architecture value reflects + For universal binary builds on macOS the architecture value reflects the universal binary status instead of the architecture of the current processor. For 32-bit universal binaries the architecture is ``fat``, for 64-bit universal binaries the architecture is ``fat64``, and @@ -1132,7 +1132,7 @@ other utility module. a 3-way universal build (ppc, i386, x86_64) and ``intel`` is used for a universal build with the i386 and x86_64 architectures - Examples of returned values on Mac OS X: + Examples of returned values on macOS: * ``macosx-10.3-ppc`` diff --git a/Doc/extending/newtypes.rst b/Doc/extending/newtypes.rst index d9023709..7c51d8e2 100644 --- a/Doc/extending/newtypes.rst +++ b/Doc/extending/newtypes.rst @@ -73,7 +73,19 @@ function:: newdatatype_dealloc(newdatatypeobject *obj) { free(obj->obj_UnderlyingDatatypePtr); - Py_TYPE(obj)->tp_free(obj); + Py_TYPE(obj)->tp_free((PyObject *)obj); + } + +If your type supports garbage collection, the destructor should call +:c:func:`PyObject_GC_UnTrack` before clearing any member fields:: + + static void + newdatatype_dealloc(newdatatypeobject *obj) + { + PyObject_GC_UnTrack(obj); + Py_CLEAR(obj->other_obj); + ... + Py_TYPE(obj)->tp_free((PyObject *)obj); } .. index:: @@ -376,7 +388,7 @@ analogous to the :ref:`rich comparison methods `, like :c:func:`PyObject_RichCompareBool`. This function is called with two Python objects and the operator as arguments, -where the operator is one of ``Py_EQ``, ``Py_NE``, ``Py_LE``, ``Py_GT``, +where the operator is one of ``Py_EQ``, ``Py_NE``, ``Py_LE``, ``Py_GE``, ``Py_LT`` or ``Py_GT``. It should compare the two objects with respect to the specified operator and return ``Py_True`` or ``Py_False`` if the comparison is successful, ``Py_NotImplemented`` to indicate that comparison is not diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst index d2b868eb..d0aee4e6 100644 --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -715,7 +715,7 @@ Why don't generators support the with statement? For technical reasons, a generator used directly as a context manager would not work correctly. When, as is most common, a generator is used as an iterator run to completion, no closing is needed. When it is, wrap -it as "contextlib.closing(generator)" in the 'with' statment. +it as "contextlib.closing(generator)" in the 'with' statement. Why are colons required for the if/while/def/class statements? diff --git a/Doc/faq/gui.rst b/Doc/faq/gui.rst index 145283d0..86c56d95 100644 --- a/Doc/faq/gui.rst +++ b/Doc/faq/gui.rst @@ -23,7 +23,7 @@ install (since it comes included with most `binary distributions `_ of Python) and use. For more info about Tk, including pointers to the source, see the `Tcl/Tk home page `_. Tcl/Tk is fully portable to the -Mac OS X, Windows, and Unix platforms. +macOS, Windows, and Unix platforms. Depending on what platform(s) you are aiming at, there are also several alternatives. A `list of cross-platform diff --git a/Doc/faq/installed.rst b/Doc/faq/installed.rst index 42296533..16c9a74d 100644 --- a/Doc/faq/installed.rst +++ b/Doc/faq/installed.rst @@ -29,7 +29,7 @@ there are several possible ways it could have gotten there. * Some Windows machines also have Python installed. At this writing we're aware of computers from Hewlett-Packard and Compaq that include Python. Apparently some of HP/Compaq's administrative tools are written in Python. -* Many Unix-compatible operating systems, such as Mac OS X and some Linux +* Many Unix-compatible operating systems, such as macOS and some Linux distributions, have Python installed by default; it's included in the base installation. diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index 04d6592a..5286bbbc 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -836,6 +836,27 @@ ago? ``-190 % 12 == 2`` is useful; ``-190 % 12 == -10`` is a bug waiting to bite. +How do I get int literal attribute instead of SyntaxError? +---------------------------------------------------------- + +Trying to lookup an ``int`` literal attribute in the normal manner gives +a syntax error because the period is seen as a decimal point:: + + >>> 1.__class__ + File "", line 1 + 1.__class__ + ^ + SyntaxError: invalid decimal literal + +The solution is to separate the literal from the period +with either a space or parentheses. + + >>> 1 .__class__ + + >>> (1).__class__ + + + How do I convert a string to a number? -------------------------------------- @@ -1184,7 +1205,7 @@ difference is that a Python list can contain objects of many different types. The ``array`` module also provides methods for creating arrays of fixed types with compact representations, but they are slower to index than lists. Also -note that the Numeric extensions and others define array-like structures with +note that NumPy and other third party packages define array-like structures with various characteristics as well. To get Lisp-style linked lists, you can emulate cons cells using tuples:: diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst index 74e86148..c7f8bc8f 100644 --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -65,11 +65,10 @@ output must only depend on its input. Some languages are very strict about purity and don't even have assignment statements such as ``a=3`` or ``c = a + b``, but it's difficult to avoid all -side effects. Printing to the screen or writing to a disk file are side -effects, for example. For example, in Python a call to the :func:`print` or -:func:`time.sleep` function both return no useful value; they're only called for -their side effects of sending some text to the screen or pausing execution for a -second. +side effects, such as printing to the screen or writing to a disk file. Another +example is a call to the :func:`print` or :func:`time.sleep` function, neither +of which returns a useful value. Both are called only for their side effects +of sending some text to the screen or pausing execution for a second. Python programs written in functional style usually won't go to the extreme of avoiding all I/O or all assignments; instead, they'll provide a diff --git a/Doc/includes/sqlite3/text_factory.py b/Doc/includes/sqlite3/text_factory.py index a857a155..c0d87cd5 100644 --- a/Doc/includes/sqlite3/text_factory.py +++ b/Doc/includes/sqlite3/text_factory.py @@ -3,9 +3,9 @@ import sqlite3 con = sqlite3.connect(":memory:") cur = con.cursor() -AUSTRIA = "\xd6sterreich" +AUSTRIA = "Österreich" -# by default, rows are returned as Unicode +# by default, rows are returned as str cur.execute("select ?", (AUSTRIA,)) row = cur.fetchone() assert row[0] == AUSTRIA diff --git a/Doc/install/index.rst b/Doc/install/index.rst index ae0d0294..eb4de247 100644 --- a/Doc/install/index.rst +++ b/Doc/install/index.rst @@ -199,7 +199,7 @@ directory. If you don't choose an installation directory---i.e., if you just run ``setup.py install``\ ---then the :command:`install` command installs to the standard location for third-party Python modules. This location varies by platform and -by how you built/installed Python itself. On Unix (and Mac OS X, which is also +by how you built/installed Python itself. On Unix (and macOS, which is also Unix-based), it also depends on whether the module distribution being installed is pure Python or contains extensions ("non-pure"): @@ -229,7 +229,7 @@ Notes: :file:`{prefix}` and :file:`{exec-prefix}` stand for the directories that Python is installed to, and where it finds its libraries at run-time. They are always -the same under Windows, and very often the same under Unix and Mac OS X. You +the same under Windows, and very often the same under Unix and macOS. You can find out what your Python installation uses for :file:`{prefix}` and :file:`{exec-prefix}` by running Python in interactive mode and typing a few simple commands. Under Unix, just type ``python`` at the shell prompt. Under @@ -305,7 +305,7 @@ install into it. It is enabled with a simple option:: Files will be installed into subdirectories of :data:`site.USER_BASE` (written as :file:`{userbase}` hereafter). This scheme installs pure Python modules and extension modules in the same location (also known as :data:`site.USER_SITE`). -Here are the values for UNIX, including Mac OS X: +Here are the values for UNIX, including macOS: =============== =========================================================== Type of file Installation directory @@ -728,7 +728,7 @@ Location and names of config files ---------------------------------- The names and locations of the configuration files vary slightly across -platforms. On Unix and Mac OS X, the three configuration files (in the order +platforms. On Unix and macOS, the three configuration files (in the order they are processed) are: +--------------+----------------------------------------------------------+-------+ diff --git a/Doc/installing/index.rst b/Doc/installing/index.rst index 31e9b0bd..4bacc7ba 100644 --- a/Doc/installing/index.rst +++ b/Doc/installing/index.rst @@ -44,7 +44,7 @@ Key terms ``venv``. It allows virtual environments to be used on versions of Python prior to 3.4, which either don't provide ``venv`` at all, or aren't able to automatically install ``pip`` into created environments. -* The `Python Packaging Index `__ is a public +* The `Python Package Index `__ is a public repository of open source licensed packages made available for use by other Python users. * the `Python Packaging Authority @@ -78,13 +78,13 @@ The standard packaging tools are all designed to be used from the command line. The following command will install the latest version of a module and its -dependencies from the Python Packaging Index:: +dependencies from the Python Package Index:: python -m pip install SomePackage .. note:: - For POSIX users (including Mac OS X and Linux users), the examples in + For POSIX users (including macOS and Linux users), the examples in this guide assume the use of a :term:`virtual environment`. For Windows users, the examples in this guide assume that the option to @@ -163,7 +163,7 @@ rather than attempting to install them with ``pip``. ... work with multiple versions of Python installed in parallel? ---------------------------------------------------------------- -On Linux, Mac OS X, and other POSIX systems, use the versioned Python commands +On Linux, macOS, and other POSIX systems, use the versioned Python commands in combination with the ``-m`` switch to run the appropriate copy of ``pip``:: @@ -225,8 +225,8 @@ users being expected to compile extension modules from source as part of the installation process. With the introduction of support for the binary ``wheel`` format, and the -ability to publish wheels for at least Windows and Mac OS X through the -Python Packaging Index, this problem is expected to diminish over time, +ability to publish wheels for at least Windows and macOS through the +Python Package Index, this problem is expected to diminish over time, as users are more regularly able to install pre-built extensions rather than needing to build them themselves. diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 6c01667b..fa731fec 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1104,7 +1104,7 @@ Anything with more interesting error-handling or resource management should be done downstream after the arguments are parsed. For example, JSON or YAML conversions have complex error cases that require -better reporting than can be given by the ``type`` keyword. An +better reporting than can be given by the ``type`` keyword. A :exc:`~json.JSONDecodeError` would not be well formatted and a :exc:`FileNotFound` exception would not be handled at all. diff --git a/Doc/library/array.rst b/Doc/library/array.rst index f2f7894e..f892d098 100644 --- a/Doc/library/array.rst +++ b/Doc/library/array.rst @@ -256,7 +256,6 @@ Examples:: Packing and unpacking of External Data Representation (XDR) data as used in some remote procedure call systems. - `The Numerical Python Documentation `_ - The Numeric Python extension (NumPy) defines another array type; see - http://www.numpy.org/ for further information about Numerical Python. + `NumPy `_ + The NumPy package defines another array type. diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst index b8eecbda..149179d5 100644 --- a/Doc/library/ast.rst +++ b/Doc/library/ast.rst @@ -1549,6 +1549,19 @@ and classes for traversing abstract syntax trees: ``await`` as variable names. The lowest supported version is ``(3, 4)``; the highest is ``sys.version_info[0:2]``. + If source contains a null character ('\0'), :exc:`ValueError` is raised. + + .. warning:: + Note that successfully parsing source code into an AST object doesn't + guarantee that the source code provided is valid Python code that can + be executed as the compilation step can raise further :exc:`SyntaxError` + exceptions. For instance, the source ``return 42`` generates a valid + AST node for a return statement, but it cannot be compiled alone (it needs + to be inside a function node). + + In particular, :func:`ast.parse` won't do any scoping checks, which the + compilation step does. + .. warning:: It is possible to crash the Python interpreter with a sufficiently large/complex string due to stack depth limitations diff --git a/Doc/library/asyncio-stream.rst b/Doc/library/asyncio-stream.rst index 714de8d4..bf431cfb 100644 --- a/Doc/library/asyncio-stream.rst +++ b/Doc/library/asyncio-stream.rst @@ -373,8 +373,8 @@ TCP echo server using the :func:`asyncio.start_server` function:: server = await asyncio.start_server( handle_echo, '127.0.0.1', 8888) - addr = server.sockets[0].getsockname() - print(f'Serving on {addr}') + addrs = ', '.join(str(sock.getsockname()) for sock in server.sockets) + print(f'Serving on {addrs}') async with server: await server.serve_forever() diff --git a/Doc/library/cgi.rst b/Doc/library/cgi.rst index 0c985c07..3ec919e9 100644 --- a/Doc/library/cgi.rst +++ b/Doc/library/cgi.rst @@ -89,7 +89,7 @@ To get at submitted form data, use the :class:`FieldStorage` class. If the form contains non-ASCII characters, use the *encoding* keyword parameter set to the value of the encoding defined for the document. It is usually contained in the META tag in the HEAD section of the HTML document or by the -:mailheader:`Content-Type` header). This reads the form contents from the +:mailheader:`Content-Type` header. This reads the form contents from the standard input or the environment (depending on the value of various environment variables set according to the CGI standard). Since it may consume standard input, it should be instantiated only once. diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index 3338545e..2f7497c0 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -920,7 +920,7 @@ it's a device to determine the storage layout of the encoded bytes, and vanishes once the byte sequence has been decoded into a string; as a ``ZERO WIDTH NO-BREAK SPACE`` it's a normal character that will be decoded like any other. -There's another encoding that is able to encoding the full range of Unicode +There's another encoding that is able to encode the full range of Unicode characters: UTF-8. UTF-8 is an 8-bit encoding, which means there are no issues with byte order in UTF-8. Each byte in a UTF-8 byte sequence consists of two parts: marker bits (the most significant bits) and payload bits. The marker bits diff --git a/Doc/library/collections.abc.rst b/Doc/library/collections.abc.rst index 2345e78a..cb4f7670 100644 --- a/Doc/library/collections.abc.rst +++ b/Doc/library/collections.abc.rst @@ -24,6 +24,9 @@ This module provides :term:`abstract base classes ` that can be used to test whether a class provides a particular interface; for example, whether it is hashable or whether it is a mapping. +.. versionadded:: 3.9 + These abstract classes now support ``[]``. See :ref:`types-genericalias` + and :pep:`585`. .. _collections-abstract-base-classes: diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst index 3de59183..60d33f59 100644 --- a/Doc/library/configparser.rst +++ b/Doc/library/configparser.rst @@ -237,7 +237,8 @@ A configuration file consists of sections, each led by a ``[section]`` header, followed by key/value entries separated by a specific string (``=`` or ``:`` by default [1]_). By default, section names are case sensitive but keys are not [1]_. Leading and trailing whitespace is removed from keys and values. -Values can be omitted, in which case the key/value delimiter may also be left +Values can be omitted if the parser is configured to allow it [1]_, +in which case the key/value delimiter may also be left out. Values can also span multiple lines, as long as they are indented deeper than the first line of the value. Depending on the parser's mode, blank lines may be treated as parts of multiline values or ignored. diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index fd6422cc..b186f1d5 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -20,7 +20,7 @@ ctypes tutorial Note: The code samples in this tutorial use :mod:`doctest` to make sure that they actually work. Since some code samples behave differently under Linux, -Windows, or Mac OS X, they contain doctest directives in comments. +Windows, or macOS, they contain doctest directives in comments. Note: Some code samples reference the ctypes :class:`c_int` type. On platforms where ``sizeof(long) == sizeof(int)`` it is an alias to :class:`c_long`. @@ -80,7 +80,7 @@ the library by creating an instance of CDLL by calling the constructor:: >>> -.. XXX Add section for Mac OS X. +.. XXX Add section for macOS. .. _ctypes-accessing-functions-from-loaded-dlls: @@ -1288,7 +1288,7 @@ Here are some examples:: 'libbz2.so.1.0' >>> -On OS X, :func:`find_library` tries several predefined naming schemes and paths +On macOS, :func:`find_library` tries several predefined naming schemes and paths to locate the library, and returns a full pathname if successful:: >>> from ctypes.util import find_library diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index dae0dd7a..0f8b70cd 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -27,6 +27,9 @@ on efficient attribute extraction for output formatting and manipulation. Module :mod:`time` Time access and conversions. + Module :mod:`zoneinfo` + Concrete time zones representing the IANA time zone database. + Package `dateutil `_ Third-party library with expanded time zone and parsing support. @@ -2174,14 +2177,13 @@ only EST (fixed offset -5 hours), or only EDT (fixed offset -4 hours)). .. seealso:: - `dateutil.tz `_ + :mod:`zoneinfo` The :mod:`datetime` module has a basic :class:`timezone` class (for handling arbitrary fixed offsets from UTC) and its :attr:`timezone.utc` attribute (a UTC timezone instance). - *dateutil.tz* library brings the *IANA timezone database* - (also known as the Olson database) to Python, and its usage is - recommended. + ``zoneinfo`` brings the *IANA timezone database* (also known as the Olson + database) to Python, and its usage is recommended. `IANA timezone database `_ The Time Zone Database (often called tz, tzdata or zoneinfo) contains code @@ -2431,7 +2433,8 @@ incomplete or ambiguous ISO 8601 directives will raise a :exc:`ValueError`. The full set of format codes supported varies across platforms, because Python calls the platform C library's :func:`strftime` function, and platform variations are common. To see the full set of format codes supported on your -platform, consult the :manpage:`strftime(3)` documentation. +platform, consult the :manpage:`strftime(3)` documentation. There are also +differences between platforms in handling of unsupported format specifiers. .. versionadded:: 3.6 ``%G``, ``%u`` and ``%V`` were added. diff --git a/Doc/library/dbm.rst b/Doc/library/dbm.rst index 57ae547b..ff01ae90 100644 --- a/Doc/library/dbm.rst +++ b/Doc/library/dbm.rst @@ -216,7 +216,7 @@ supported. contains them all:: k = db.firstkey() - while k != None: + while k is not None: print(k) k = db.nextkey(k) diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst index bbe8bdc8..4e15901c 100644 --- a/Doc/library/enum.rst +++ b/Doc/library/enum.rst @@ -1125,9 +1125,9 @@ and raise an error if the two do not match:: _Private__names """"""""""""""" -Private names will be normal attributes in Python 3.10 instead of either an error +:ref:`Private names ` will be normal attributes in Python 3.11 instead of either an error or a member (depending on if the name ends with an underscore). Using these names -in 3.9 will issue a :exc:`DeprecationWarning`. +in 3.9 and 3.10 will issue a :exc:`DeprecationWarning`. ``Enum`` member type @@ -1150,6 +1150,10 @@ all-uppercase names for members):: >>> FieldTypes.size.value 2 +.. note:: + + This behavior is deprecated and will be removed in 3.12. + .. versionchanged:: 3.5 @@ -1200,3 +1204,8 @@ all named flags and all named combinations of flags that are in the value:: >>> Color(7) # not named combination +.. note:: + + In 3.11 unnamed combinations of flags will only produce the canonical flag + members (aka single-value flags). So ``Color(7)`` would produce something + like ````. diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index 85cd193f..6c21c6b9 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -34,6 +34,10 @@ class or one of its subclasses, and not from :exc:`BaseException`. More information on defining exceptions is available in the Python Tutorial under :ref:`tut-userexceptions`. + +Exception context +----------------- + When raising (or re-raising) an exception in an :keyword:`except` or :keyword:`finally` clause :attr:`__context__` is automatically set to the last exception caught; if the @@ -67,6 +71,25 @@ exceptions so that the final line of the traceback always shows the last exception that was raised. +Inheriting from built-in exceptions +----------------------------------- + +User code can create subclasses that inherit from an exception type. +It's recommended to only subclass one exception type at a time to avoid +any possible conflicts between how the bases handle the ``args`` +attribute, as well as due to possible memory layout incompatibilities. + +.. impl-detail:: + + Most built-in exceptions are implemented in C for efficiency, see: + :source:`Objects/exceptions.c`. Some have custom memory layouts + which makes it impossible to create a subclass that inherits from + multiple exception types. The memory layout of a type is an implementation + detail and might change between Python versions, leading to new + conflicts in the future. Therefore, it's recommended to avoid + subclassing multiple exception types altogether. + + Base classes ------------ @@ -717,6 +740,8 @@ The following exceptions are used as warning categories; see the (:pep:`565`). Enabling the :ref:`Python Development Mode ` shows this warning. + The deprecation policy is described in :pep:`387`. + .. exception:: PendingDeprecationWarning @@ -731,6 +756,8 @@ The following exceptions are used as warning categories; see the Ignored by the default warning filters. Enabling the :ref:`Python Development Mode ` shows this warning. + The deprecation policy is described in :pep:`387`. + .. exception:: SyntaxWarning diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index c5c1c161..4acbc67b 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -507,7 +507,7 @@ are always available. They are listed here in alphabetical order. a suite of Python statements which is then executed (unless a syntax error occurs). [#]_ If it is a code object, it is simply executed. In all cases, the code that's executed is expected to be valid as file input (see the - section "File input" in the Reference Manual). Be aware that the + section :ref:`file-input` in the Reference Manual). Be aware that the :keyword:`nonlocal`, :keyword:`yield`, and :keyword:`return` statements may not be used outside of function definitions even within the context of code passed to the @@ -862,8 +862,8 @@ are always available. They are listed here in alphabetical order. Return ``True`` if *class* is a subclass (direct, indirect or :term:`virtual `) of *classinfo*. A class is considered a subclass of itself. *classinfo* may be a tuple of class - objects, in which case every entry in *classinfo* will be checked. In any other - case, a :exc:`TypeError` exception is raised. + objects, in which case return ``True`` if *class* is a subclass of any entry + in *classinfo*. In any other case, a :exc:`TypeError` exception is raised. .. function:: iter(object[, sentinel]) @@ -1298,8 +1298,11 @@ are always available. They are listed here in alphabetical order. coercion rules for binary arithmetic operators apply. For :class:`int` operands, the result has the same type as the operands (after coercion) unless the second argument is negative; in that case, all arguments are - converted to float and a float result is delivered. For example, ``10**2`` - returns ``100``, but ``10**-2`` returns ``0.01``. + converted to float and a float result is delivered. For example, ``pow(10, 2)`` + returns ``100``, but ``pow(10, -2)`` returns ``0.01``. For a negative base of + type :class:`int` or :class:`float` and a non-integral exponent, a complex + result is delivered. For example, ``pow(-9, 0.5)`` returns a value close + to ``3j``. For :class:`int` operands *base* and *exp*, if *mod* is present, *mod* must also be of integer type and *mod* must be nonzero. If *mod* is present and @@ -1513,14 +1516,12 @@ are always available. They are listed here in alphabetical order. .. class:: slice(stop) slice(start, stop[, step]) - .. index:: single: Numerical Python - Return a :term:`slice` object representing the set of indices specified by ``range(start, stop, step)``. The *start* and *step* arguments default to ``None``. Slice objects have read-only data attributes :attr:`~slice.start`, :attr:`~slice.stop` and :attr:`~slice.step` which merely return the argument values (or their default). They have no other explicit functionality; - however they are used by Numerical Python and other third party extensions. + however they are used by NumPy and other third party packages. Slice objects are also generated when extended indexing syntax is used. For example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See :func:`itertools.islice` for an alternate version that returns an iterator. @@ -1547,6 +1548,15 @@ are always available. They are listed here in alphabetical order. compare equal --- this is helpful for sorting in multiple passes (for example, sort by department, then by salary grade). + The sort algorithm uses only ``<`` comparisons between items. While + defining an :meth:`~object.__lt__` method will suffice for sorting, + :PEP:`8` recommends that all six :ref:`rich comparisons + ` be implemented. This will help avoid bugs when using + the same data with other ordering tools such as :func:`max` that rely + on a different underlying method. Implementing all six comparisons + also helps avoid confusion for mixed type comparisons which can call + reflected the :meth:`~object.__gt__` method. + For sorting examples and a brief sorting tutorial, see :ref:`sortinghowto`. .. decorator:: staticmethod diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst index b2901e43..1e408482 100644 --- a/Doc/library/functools.rst +++ b/Doc/library/functools.rst @@ -392,8 +392,8 @@ The :mod:`functools` module defines the following functions: dispatch>` :term:`generic function`. To define a generic function, decorate it with the ``@singledispatch`` - decorator. Note that the dispatch happens on the type of the first argument, - create your function accordingly:: + decorator. When defining a function using ``@singledispatch``, note that the + dispatch happens on the type of the first argument:: >>> from functools import singledispatch >>> @singledispatch @@ -403,9 +403,9 @@ The :mod:`functools` module defines the following functions: ... print(arg) To add overloaded implementations to the function, use the :func:`register` - attribute of the generic function. It is a decorator. For functions - annotated with types, the decorator will infer the type of the first - argument automatically:: + attribute of the generic function, which can be used as a decorator. For + functions annotated with types, the decorator will infer the type of the + first argument automatically:: >>> @fun.register ... def _(arg: int, verbose=False): @@ -431,17 +431,17 @@ The :mod:`functools` module defines the following functions: ... - To enable registering lambdas and pre-existing functions, the - :func:`register` attribute can be used in a functional form:: + To enable registering :term:`lambdas` and pre-existing functions, + the :func:`register` attribute can also be used in a functional form:: >>> def nothing(arg, verbose=False): ... print("Nothing.") ... >>> fun.register(type(None), nothing) - The :func:`register` attribute returns the undecorated function which - enables decorator stacking, pickling, as well as creating unit tests for - each variant independently:: + The :func:`register` attribute returns the undecorated function. This + enables decorator stacking, :mod:`pickling`, and the creation + of unit tests for each variant independently:: >>> @fun.register(float) ... @fun.register(Decimal) @@ -476,11 +476,12 @@ The :mod:`functools` module defines the following functions: Where there is no registered implementation for a specific type, its method resolution order is used to find a more generic implementation. The original function decorated with ``@singledispatch`` is registered - for the base ``object`` type, which means it is used if no better + for the base :class:`object` type, which means it is used if no better implementation is found. - If an implementation registered to :term:`abstract base class`, virtual - subclasses will be dispatched to that implementation:: + If an implementation is registered to an :term:`abstract base class`, + virtual subclasses of the base class will be dispatched to that + implementation:: >>> from collections.abc import Mapping >>> @fun.register @@ -493,7 +494,7 @@ The :mod:`functools` module defines the following functions: >>> fun({"a": "b"}) a => b - To check which implementation will the generic function choose for + To check which implementation the generic function will choose for a given type, use the ``dispatch()`` attribute:: >>> fun.dispatch(float) @@ -516,7 +517,7 @@ The :mod:`functools` module defines the following functions: .. versionadded:: 3.4 .. versionchanged:: 3.7 - The :func:`register` attribute supports using type annotations. + The :func:`register` attribute now supports using type annotations. .. class:: singledispatchmethod(func) @@ -525,8 +526,9 @@ The :mod:`functools` module defines the following functions: dispatch>` :term:`generic function`. To define a generic method, decorate it with the ``@singledispatchmethod`` - decorator. Note that the dispatch happens on the type of the first non-self - or non-cls argument, create your function accordingly:: + decorator. When defining a function using ``@singledispatchmethod``, note + that the dispatch happens on the type of the first non-*self* or non-*cls* + argument:: class Negator: @singledispatchmethod @@ -542,9 +544,10 @@ The :mod:`functools` module defines the following functions: return not arg ``@singledispatchmethod`` supports nesting with other decorators such as - ``@classmethod``. Note that to allow for ``dispatcher.register``, - ``singledispatchmethod`` must be the *outer most* decorator. Here is the - ``Negator`` class with the ``neg`` methods being class bound:: + :func:`@classmethod`. Note that to allow for + ``dispatcher.register``, ``singledispatchmethod`` must be the *outer most* + decorator. Here is the ``Negator`` class with the ``neg`` methods bound to + the class, rather than an instance of the class:: class Negator: @singledispatchmethod @@ -562,8 +565,9 @@ The :mod:`functools` module defines the following functions: def _(cls, arg: bool): return not arg - The same pattern can be used for other similar decorators: ``staticmethod``, - ``abstractmethod``, and others. + The same pattern can be used for other similar decorators: + :func:`@staticmethod`, + :func:`@abstractmethod`, and others. .. versionadded:: 3.8 diff --git a/Doc/library/hashlib.rst b/Doc/library/hashlib.rst index 615ee116..58ccbbed 100644 --- a/Doc/library/hashlib.rst +++ b/Doc/library/hashlib.rst @@ -372,10 +372,10 @@ Constructor functions also accept the following tree hashing parameters: * *depth*: maximal depth of tree (1 to 255, 255 if unlimited, 1 in sequential mode). -* *leaf_size*: maximal byte length of leaf (0 to 2**32-1, 0 if unlimited or in +* *leaf_size*: maximal byte length of leaf (0 to ``2**32-1``, 0 if unlimited or in sequential mode). -* *node_offset*: node offset (0 to 2**64-1 for BLAKE2b, 0 to 2**48-1 for +* *node_offset*: node offset (0 to ``2**64-1`` for BLAKE2b, 0 to ``2**48-1`` for BLAKE2s, 0 for the first, leftmost, leaf, or in sequential mode). * *node_depth*: node depth (0 to 255, 0 for leaves, or in sequential mode). @@ -496,7 +496,7 @@ Keyed hashing Keyed hashing can be used for authentication as a faster and simpler replacement for `Hash-based message authentication code -`_ (HMAC). +`_ (HMAC). BLAKE2 can be securely used in prefix-MAC mode thanks to the indifferentiability property inherited from BLAKE. diff --git a/Doc/library/html.entities.rst b/Doc/library/html.entities.rst index 067e1b1e..7d836fe7 100644 --- a/Doc/library/html.entities.rst +++ b/Doc/library/html.entities.rst @@ -44,4 +44,4 @@ This module defines four dictionaries, :data:`html5`, .. rubric:: Footnotes -.. [#] See https://www.w3.org/TR/html5/syntax.html#named-character-references +.. [#] See https://html.spec.whatwg.org/multipage/syntax.html#named-character-references diff --git a/Doc/library/http.cookiejar.rst b/Doc/library/http.cookiejar.rst index 9ac5d52a..fb113d89 100644 --- a/Doc/library/http.cookiejar.rst +++ b/Doc/library/http.cookiejar.rst @@ -122,7 +122,7 @@ The following classes are provided: :mod:`http.cookiejar` and :mod:`http.cookies` modules do not depend on each other. - https://curl.haxx.se/rfc/cookie_spec.html + https://curl.se/rfc/cookie_spec.html The specification of the original Netscape cookie protocol. Though this is still the dominant protocol, the 'Netscape cookie protocol' implemented by all the major browsers (and :mod:`http.cookiejar`) only bears a passing resemblance to diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index 69e31129..c7fbcb21 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -805,6 +805,46 @@ ABC hierarchy:: .. versionadded:: 3.9 + .. abstractmethod:: name() + + The base name of this object without any parent references. + + .. abstractmethod:: iterdir() + + Yield Traversable objects in self. + + .. abstractmethod:: is_dir() + + Return True if self is a directory. + + .. abstractmethod:: is_file() + + Return True if self is a file. + + .. abstractmethod:: joinpath(child) + + Return Traversable child in self. + + .. abstractmethod:: __truediv__(child) + + Return Traversable child in self. + + .. abstractmethod:: open(mode='r', *args, **kwargs) + + *mode* may be 'r' or 'rb' to open as text or binary. Return a handle + suitable for reading (same as :attr:`pathlib.Path.open`). + + When opening as text, accepts encoding parameters such as those + accepted by :attr:`io.TextIOWrapper`. + + .. method:: read_bytes() + + Read contents of self as bytes. + + .. method:: read_text(encoding=None) + + Read contents of self as text. + .. class:: TraversableResources diff --git a/Doc/library/intro.rst b/Doc/library/intro.rst index 8567e4d1..5bb33b9c 100644 --- a/Doc/library/intro.rst +++ b/Doc/library/intro.rst @@ -58,5 +58,5 @@ Notes on availability operating system. * If not separately noted, all functions that claim "Availability: Unix" are - supported on Mac OS X, which builds on a Unix core. + supported on macOS, which builds on a Unix core. diff --git a/Doc/library/ipaddress.rst b/Doc/library/ipaddress.rst index 2ab4dd83..9c2dff55 100644 --- a/Doc/library/ipaddress.rst +++ b/Doc/library/ipaddress.rst @@ -41,7 +41,7 @@ IP addresses, networks and interfaces: Return an :class:`IPv4Address` or :class:`IPv6Address` object depending on the IP address passed as argument. Either IPv4 or IPv6 addresses may be - supplied; integers less than 2**32 will be considered to be IPv4 by default. + supplied; integers less than ``2**32`` will be considered to be IPv4 by default. A :exc:`ValueError` is raised if *address* does not represent a valid IPv4 or IPv6 address. @@ -56,7 +56,7 @@ IP addresses, networks and interfaces: Return an :class:`IPv4Network` or :class:`IPv6Network` object depending on the IP address passed as argument. *address* is a string or integer representing the IP network. Either IPv4 or IPv6 networks may be supplied; - integers less than 2**32 will be considered to be IPv4 by default. *strict* + integers less than ``2**32`` will be considered to be IPv4 by default. *strict* is passed to :class:`IPv4Network` or :class:`IPv6Network` constructor. A :exc:`ValueError` is raised if *address* does not represent a valid IPv4 or IPv6 address, or if the network has host bits set. @@ -70,7 +70,7 @@ IP addresses, networks and interfaces: Return an :class:`IPv4Interface` or :class:`IPv6Interface` object depending on the IP address passed as argument. *address* is a string or integer representing the IP address. Either IPv4 or IPv6 addresses may be supplied; - integers less than 2**32 will be considered to be IPv4 by default. A + integers less than ``2**32`` will be considered to be IPv4 by default. A :exc:`ValueError` is raised if *address* does not represent a valid IPv4 or IPv6 address. @@ -682,7 +682,7 @@ dictionaries. Note that currently expanded netmasks are not supported. That means ``2001:db00::0/24`` is a valid argument while ``2001:db00::0/ffff:ff00::`` - not. + is not. 2. An integer that fits into 128 bits. This is equivalent to a single-address network, with the network address being *address* and diff --git a/Doc/library/json.rst b/Doc/library/json.rst index c8184da8..6fa89f57 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -11,9 +11,9 @@ -------------- -`JSON (JavaScript Object Notation) `_, specified by +`JSON (JavaScript Object Notation) `_, specified by :rfc:`7159` (which obsoletes :rfc:`4627`) and by -`ECMA-404 `_, +`ECMA-404 `_, is a lightweight data interchange format inspired by `JavaScript `_ object literal syntax (although it is not a strict subset of JavaScript [#rfc-errata]_ ). @@ -544,7 +544,7 @@ Standard Compliance and Interoperability ---------------------------------------- The JSON format is specified by :rfc:`7159` and by -`ECMA-404 `_. +`ECMA-404 `_. This section details this module's level of compliance with the RFC. For simplicity, :class:`JSONEncoder` and :class:`JSONDecoder` subclasses, and parameters other than those explicitly mentioned, are not considered. diff --git a/Doc/library/logging.config.rst b/Doc/library/logging.config.rst index ab448505..d4dc5853 100644 --- a/Doc/library/logging.config.rst +++ b/Doc/library/logging.config.rst @@ -163,7 +163,7 @@ in :mod:`logging` itself) and defining handlers which are declared either in :func:`listen` socket and sending a configuration which runs whatever code the attacker wants to have executed in the victim's process. This is especially easy to do if the default port is used, but not hard even if a - different port is used). To avoid the risk of this happening, use the + different port is used. To avoid the risk of this happening, use the ``verify`` argument to :func:`listen` to prevent unrecognised configurations from being applied. diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst index 6233a2a6..e72a898a 100644 --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -203,7 +203,7 @@ is the module's name in the Python package namespace. attributes can then be used as you like. For example, they could be incorporated into logged messages. For example:: - FORMAT = '%(asctime)-15s %(clientip)s %(user)-8s %(message)s' + FORMAT = '%(asctime)s %(clientip)-15s %(user)-8s %(message)s' logging.basicConfig(format=FORMAT) d = {'clientip': '192.168.0.1', 'user': 'fbloggs'} logger = logging.getLogger('tcpserver') @@ -993,7 +993,7 @@ functions. be used as you like. For example, they could be incorporated into logged messages. For example:: - FORMAT = '%(asctime)-15s %(clientip)s %(user)-8s %(message)s' + FORMAT = '%(asctime)s %(clientip)-15s %(user)-8s %(message)s' logging.basicConfig(format=FORMAT) d = {'clientip': '192.168.0.1', 'user': 'fbloggs'} logging.warning('Protocol problem: %s', 'connection reset', extra=d) @@ -1348,7 +1348,7 @@ with the :mod:`warnings` module. The proposal which described this feature for inclusion in the Python standard library. - `Original Python logging package `_ + `Original Python logging package `_ This is the original source for the :mod:`logging` package. The version of the package available from this site is suitable for use with Python 1.5.2, 2.1.x and 2.2.x, which do not include the :mod:`logging` package in the standard diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst index 1f3fbc34..959f81fe 100644 --- a/Doc/library/mmap.rst +++ b/Doc/library/mmap.rst @@ -100,7 +100,7 @@ To map anonymous memory, -1 should be passed as the fileno along with the length To ensure validity of the created memory mapping the file specified by the descriptor *fileno* is internally automatically synchronized - with physical backing store on Mac OS X and OpenVMS. + with physical backing store on macOS and OpenVMS. This example shows a simple way of using :class:`~mmap.mmap`:: diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst index 952a5b40..2c7d7d8c 100644 --- a/Doc/library/multiprocessing.rst +++ b/Doc/library/multiprocessing.rst @@ -783,7 +783,7 @@ For an example of the usage of queues for interprocess communication see multithreading/multiprocessing semantics, this number is not reliable. Note that this may raise :exc:`NotImplementedError` on Unix platforms like - Mac OS X where ``sem_getvalue()`` is not implemented. + macOS where ``sem_getvalue()`` is not implemented. .. method:: empty() @@ -951,7 +951,8 @@ Miscellaneous use. The number of usable CPUs can be obtained with ``len(os.sched_getaffinity(0))`` - May raise :exc:`NotImplementedError`. + When the number of CPUs cannot be determined a :exc:`NotImplementedError` + is raised. .. seealso:: :func:`os.cpu_count` @@ -1029,7 +1030,13 @@ Miscellaneous The return value can be ``'fork'``, ``'spawn'``, ``'forkserver'`` or ``None``. ``'fork'`` is the default on Unix, while ``'spawn'`` is - the default on Windows. + the default on Windows and macOS. + +.. versionchanged:: 3.8 + + On macOS, the *spawn* start method is now the default. The *fork* start + method should be considered unsafe as it can lead to crashes of the + subprocess. See :issue:`33725`. .. versionadded:: 3.4 @@ -1234,7 +1241,7 @@ object -- see :ref:`multiprocessing-managers`. first argument is named *block*, as is consistent with :meth:`Lock.acquire`. .. note:: - On Mac OS X, this is indistinguishable from :class:`Semaphore` because + On macOS, this is indistinguishable from :class:`Semaphore` because ``sem_getvalue()`` is not implemented on that platform. .. class:: Condition([lock]) @@ -1373,7 +1380,7 @@ object -- see :ref:`multiprocessing-managers`. .. note:: - On Mac OS X, ``sem_timedwait`` is unsupported, so calling ``acquire()`` with + On macOS, ``sem_timedwait`` is unsupported, so calling ``acquire()`` with a timeout will emulate that function's behavior using a sleeping loop. .. note:: @@ -2628,12 +2635,13 @@ handler type) for messages from different processes to get mixed up. inherited. .. currentmodule:: multiprocessing -.. function:: log_to_stderr() +.. function:: log_to_stderr(level=None) This function performs a call to :func:`get_logger` but in addition to returning the logger created by get_logger, it adds a handler which sends output to :data:`sys.stderr` using format ``'[%(levelname)s/%(processName)s] %(message)s'``. + You can modify ``levelname`` of the logger by passing a ``level`` argument. Below is an example session with logging turned on:: diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 0ad44d1a..d4cc296f 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -102,9 +102,10 @@ process and user. .. data:: environ - A :term:`mapping` object representing the string environment. For example, - ``environ['HOME']`` is the pathname of your home directory (on some platforms), - and is equivalent to ``getenv("HOME")`` in C. + A :term:`mapping` object where keys and values are strings that represent + the process environment. For example, ``environ['HOME']`` is the pathname + of your home directory (on some platforms), and is equivalent to + ``getenv("HOME")`` in C. This mapping is captured the first time the :mod:`os` module is imported, typically during Python startup as part of processing :file:`site.py`. Changes @@ -141,10 +142,10 @@ process and user. .. data:: environb - Bytes version of :data:`environ`: a :term:`mapping` object representing the - environment as byte strings. :data:`environ` and :data:`environb` are - synchronized (modify :data:`environb` updates :data:`environ`, and vice - versa). + Bytes version of :data:`environ`: a :term:`mapping` object where both keys + and values are :class:`bytes` objects representing the process environment. + :data:`environ` and :data:`environb` are synchronized (modifying + :data:`environb` updates :data:`environ`, and vice versa). :data:`environb` is only available if :data:`supports_bytes_environ` is ``True``. @@ -2657,7 +2658,7 @@ features: String that uniquely identifies the type of the filesystem that contains the file. - On Mac OS systems, the following attributes may also be available: + On macOS systems, the following attributes may also be available: .. attribute:: st_rsize diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst index c31ff654..88e8756c 100644 --- a/Doc/library/pathlib.rst +++ b/Doc/library/pathlib.rst @@ -708,6 +708,10 @@ call fails (for example because the path doesn't exist). >>> Path.home() PosixPath('/home/antoine') + Note that unlike :func:`os.path.expanduser`, on POSIX systems a + :exc:`KeyError` or :exc:`RuntimeError` will be raised, and on Windows systems a + :exc:`RuntimeError` will be raised if home directory can't be resolved. + .. versionadded:: 3.5 @@ -764,6 +768,10 @@ call fails (for example because the path doesn't exist). >>> p.expanduser() PosixPath('/home/eric/films/Monty Python') + Note that unlike :func:`os.path.expanduser`, on POSIX systems a + :exc:`KeyError` or :exc:`RuntimeError` will be raised, and on Windows systems a + :exc:`RuntimeError` will be raised if home directory can't be resolved. + .. versionadded:: 3.5 diff --git a/Doc/library/platform.rst b/Doc/library/platform.rst index 49186ce3..d87205c3 100644 --- a/Doc/library/platform.rst +++ b/Doc/library/platform.rst @@ -225,13 +225,13 @@ Windows Platform .. versionadded:: 3.8 -Mac OS Platform ---------------- +macOS Platform +-------------- .. function:: mac_ver(release='', versioninfo=('','',''), machine='') - Get Mac OS version information and return it as tuple ``(release, versioninfo, + Get macOS version information and return it as tuple ``(release, versioninfo, machine)`` with *versioninfo* being a tuple ``(version, dev_stage, non_release_version)``. diff --git a/Doc/library/plistlib.rst b/Doc/library/plistlib.rst index ce6d4a85..5ded9661 100644 --- a/Doc/library/plistlib.rst +++ b/Doc/library/plistlib.rst @@ -133,7 +133,7 @@ The following classes are available: encoded data, which contains UID (see PList manual). It has one attribute, :attr:`data`, which can be used to retrieve the int value - of the UID. :attr:`data` must be in the range `0 <= data < 2**64`. + of the UID. :attr:`data` must be in the range ``0 <= data < 2**64``. .. versionadded:: 3.8 diff --git a/Doc/library/profile.rst b/Doc/library/profile.rst index 774d46d0..cf324a57 100644 --- a/Doc/library/profile.rst +++ b/Doc/library/profile.rst @@ -622,7 +622,7 @@ procedure can be used to obtain a better constant for a given platform (see The method executes the number of Python calls given by the argument, directly and again under the profiler, measuring the time for both. It then computes the hidden overhead per profiler event, and returns that as a float. For example, -on a 1.8Ghz Intel Core i5 running Mac OS X, and using Python's time.process_time() as +on a 1.8Ghz Intel Core i5 running macOS, and using Python's time.process_time() as the timer, the magical number is about 4.04e-6. The object of this exercise is to get a fairly consistent result. If your diff --git a/Doc/library/random.rst b/Doc/library/random.rst index f2d67494..758d1292 100644 --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -502,7 +502,7 @@ between the effects of a drug versus a placebo:: Simulation of arrival times and service deliveries for a multiserver queue:: - from heapq import heappush, heappop + from heapq import heapify, heapreplace from random import expovariate, gauss from statistics import mean, median, stdev @@ -514,14 +514,15 @@ Simulation of arrival times and service deliveries for a multiserver queue:: waits = [] arrival_time = 0.0 servers = [0.0] * num_servers # time when each server becomes available - for i in range(100_000): + heapify(servers) + for i in range(1_000_000): arrival_time += expovariate(1.0 / average_arrival_interval) - next_server_available = heappop(servers) + next_server_available = servers[0] wait = max(0.0, next_server_available - arrival_time) waits.append(wait) - service_duration = gauss(average_service_time, stdev_service_time) + service_duration = max(0.0, gauss(average_service_time, stdev_service_time)) service_completed = arrival_time + wait + service_duration - heappush(servers, service_completed) + heapreplace(servers, service_completed) print(f'Mean wait: {mean(waits):.1f}. Stdev wait: {stdev(waits):.1f}.') print(f'Median wait: {median(waits):.1f}. Max wait: {max(waits):.1f}.') diff --git a/Doc/library/re.rst b/Doc/library/re.rst index ff7687cc..b12ce4b9 100644 --- a/Doc/library/re.rst +++ b/Doc/library/re.rst @@ -1572,7 +1572,7 @@ find all of the adverbs in some text, they might use :func:`findall` in the following manner:: >>> text = "He was carefully disguised but captured quickly by police." - >>> re.findall(r"\w+ly", text) + >>> re.findall(r"\w+ly\b", text) ['carefully', 'quickly'] @@ -1586,7 +1586,7 @@ a writer wanted to find all of the adverbs *and their positions* in some text, they would use :func:`finditer` in the following manner:: >>> text = "He was carefully disguised but captured quickly by police." - >>> for m in re.finditer(r"\w+ly", text): + >>> for m in re.finditer(r"\w+ly\b", text): ... print('%02d-%02d: %s' % (m.start(), m.end(), m.group(0))) 07-16: carefully 40-47: quickly diff --git a/Doc/library/select.rst b/Doc/library/select.rst index a354187c..46b5ff8b 100644 --- a/Doc/library/select.rst +++ b/Doc/library/select.rst @@ -534,7 +534,7 @@ https://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2 | :const:`KQ_FILTER_PROC` | Watch for events on a process id | +---------------------------+---------------------------------------------+ | :const:`KQ_FILTER_NETDEV` | Watch for events on a network device | - | | [not available on Mac OS X] | + | | [not available on macOS] | +---------------------------+---------------------------------------------+ | :const:`KQ_FILTER_SIGNAL` | Returns whenever the watched signal is | | | delivered to the process | @@ -626,7 +626,7 @@ https://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2 | :const:`KQ_NOTE_TRACKERR` | unable to attach to a child | +----------------------------+--------------------------------------------+ - :const:`KQ_FILTER_NETDEV` filter flags (not available on Mac OS X): + :const:`KQ_FILTER_NETDEV` filter flags (not available on macOS): +----------------------------+--------------------------------------------+ | Constant | Meaning | diff --git a/Doc/library/site.rst b/Doc/library/site.rst index 2e3646f6..e2ad3c48 100644 --- a/Doc/library/site.rst +++ b/Doc/library/site.rst @@ -32,7 +32,7 @@ It starts by constructing up to four directories from a head and a tail part. For the head part, it uses ``sys.prefix`` and ``sys.exec_prefix``; empty heads are skipped. For the tail part, it uses the empty string and then :file:`lib/site-packages` (on Windows) or -:file:`lib/python{X.Y}/site-packages` (on Unix and Macintosh). For each +:file:`lib/python{X.Y}/site-packages` (on Unix and macOS). For each of the distinct head-tail combinations, it sees if it refers to an existing directory, and if so, adds it to ``sys.path`` and also inspects the newly added path for configuration files. @@ -176,8 +176,8 @@ Module contents Path to the user site-packages for the running Python. Can be ``None`` if :func:`getusersitepackages` hasn't been called yet. Default value is - :file:`~/.local/lib/python{X.Y}/site-packages` for UNIX and non-framework Mac - OS X builds, :file:`~/Library/Python/{X.Y}/lib/python/site-packages` for Mac + :file:`~/.local/lib/python{X.Y}/site-packages` for UNIX and non-framework + macOS builds, :file:`~/Library/Python/{X.Y}/lib/python/site-packages` for macOS framework builds, and :file:`{%APPDATA%}\\Python\\Python{XY}\\site-packages` on Windows. This directory is a site directory, which means that :file:`.pth` files in it will be processed. @@ -187,8 +187,8 @@ Module contents Path to the base directory for the user site-packages. Can be ``None`` if :func:`getuserbase` hasn't been called yet. Default value is - :file:`~/.local` for UNIX and Mac OS X non-framework builds, - :file:`~/Library/Python/{X.Y}` for Mac framework builds, and + :file:`~/.local` for UNIX and macOS non-framework builds, + :file:`~/Library/Python/{X.Y}` for macOS framework builds, and :file:`{%APPDATA%}\\Python` for Windows. This value is used by Distutils to compute the installation directories for scripts, data files, Python modules, etc. for the :ref:`user installation scheme `. diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 609fbe86..db94a2a1 100755 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -197,11 +197,15 @@ created. Socket addresses are represented as follows: - *addr* - Optional bytes-like object specifying the hardware physical address, whose interpretation depends on the device. + .. availability:: Linux >= 2.2. + - :const:`AF_QIPCRTR` is a Linux-only socket based interface for communicating with services running on co-processors in Qualcomm platforms. The address family is represented as a ``(node, port)`` tuple where the *node* and *port* are non-negative integers. + .. availability:: Linux >= 4.7. + .. versionadded:: 3.8 - :const:`IPPROTO_UDPLITE` is a variant of UDP which allows you to specify @@ -506,7 +510,7 @@ Constants .. data:: AF_LINK - .. availability:: BSD, OSX. + .. availability:: BSD, macOS. .. versionadded:: 3.4 @@ -814,8 +818,8 @@ The :mod:`socket` module also offers various network-related services: .. function:: gethostbyname_ex(hostname) Translate a host name to IPv4 address format, extended interface. Return a - triple ``(hostname, aliaslist, ipaddrlist)`` where *hostname* is the primary - host name responding to the given *ip_address*, *aliaslist* is a (possibly + triple ``(hostname, aliaslist, ipaddrlist)`` where *hostname* is the host's + primary host name, *aliaslist* is a (possibly empty) list of alternative host names for the same address, and *ipaddrlist* is a list of IPv4 addresses for the same interface on the same host (often but not always a single address). :func:`gethostbyname_ex` does not support IPv6 name diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index c0b6ab07..b24a2f09 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -116,6 +116,24 @@ Module functions and constants ------------------------------ +.. data:: apilevel + + String constant stating the supported DB-API level. Required by the DB-API. + Hard-coded to ``"2.0"``. + +.. data:: paramstyle + + String constant stating the type of parameter marker formatting expected by + the :mod:`sqlite3` module. Required by the DB-API. Hard-coded to + ``"qmark"``. + + .. note:: + + The :mod:`sqlite3` module supports both ``qmark`` and ``numeric`` DB-API + parameter styles, because that is what the underlying SQLite library + supports. However, the DB-API does not allow multiple values for + the ``paramstyle`` attribute. + .. data:: version The version number of this module, as a string. This is not the version of @@ -138,6 +156,26 @@ Module functions and constants The version number of the run-time SQLite library, as a tuple of integers. +.. data:: threadsafety + + Integer constant required by the DB-API, stating the level of thread safety + the :mod:`sqlite3` module supports. Currently hard-coded to ``1``, meaning + *"Threads may share the module, but not connections."* However, this may not + always be true. You can check the underlying SQLite library's compile-time + threaded mode using the following query:: + + import sqlite3 + con = sqlite3.connect(":memory:") + con.execute(""" + select * from pragma_compile_options + where compile_options like 'THREADSAFE=%' + """).fetchall() + + Note that the `SQLITE_THREADSAFE levels + `_ do not match the DB-API 2.0 + ``threadsafety`` levels. + + .. data:: PARSE_DECLTYPES This constant is meant to be used with the *detect_types* parameter of the @@ -446,14 +484,22 @@ Connection Objects Registers *trace_callback* to be called for each SQL statement that is actually executed by the SQLite backend. - The only argument passed to the callback is the statement (as string) that - is being executed. The return value of the callback is ignored. Note that - the backend does not only run statements passed to the :meth:`Cursor.execute` - methods. Other sources include the transaction management of the Python - module and the execution of triggers defined in the current database. + The only argument passed to the callback is the statement (as + :class:`str`) that is being executed. The return value of the callback is + ignored. Note that the backend does not only run statements passed to the + :meth:`Cursor.execute` methods. Other sources include the + :ref:`transaction management ` of the + sqlite3 module and the execution of triggers defined in the current + database. Passing :const:`None` as *trace_callback* will disable the trace callback. + .. note:: + Exceptions raised in the trace callback are not propagated. As a + development and debugging aid, use + :meth:`~sqlite3.enable_callback_tracebacks` to enable printing + tracebacks from exceptions raised in the trace callback. + .. versionadded:: 3.3 @@ -505,8 +551,8 @@ Connection Objects Using this attribute you can control what objects are returned for the ``TEXT`` data type. By default, this attribute is set to :class:`str` and the - :mod:`sqlite3` module will return Unicode objects for ``TEXT``. If you want to - return bytestrings instead, you can set it to :class:`bytes`. + :mod:`sqlite3` module will return :class:`str` objects for ``TEXT``. + If you want to return :class:`bytes` instead, you can set it to :class:`bytes`. You can also set it to any other callable that accepts a single bytestring parameter and returns the resulting object. @@ -680,6 +726,14 @@ Cursor Objects The cursor will be unusable from this point forward; a :exc:`ProgrammingError` exception will be raised if any operation is attempted with the cursor. + .. method:: setinputsizes(sizes) + + Required by the DB-API. Is a no-op in :mod:`sqlite3`. + + .. method:: setoutputsize(size [, column]) + + Required by the DB-API. Is a no-op in :mod:`sqlite3`. + .. attribute:: rowcount Although the :class:`Cursor` class of the :mod:`sqlite3` module implements this @@ -1008,6 +1062,12 @@ If a timestamp stored in SQLite has a fractional part longer than 6 numbers, its value will be truncated to microsecond precision by the timestamp converter. +.. note:: + + The default "timestamp" converter ignores UTC offsets in the database and + always returns a naive :class:`datetime.datetime` object. To preserve UTC + offsets in timestamps, either leave converters disabled, or register an + offset-aware converter with :func:`register_converter`. .. _sqlite3-controlling-transactions: @@ -1091,7 +1151,7 @@ committed: .. rubric:: Footnotes .. [#f1] The sqlite3 module is not built with loadable extension support by - default, because some platforms (notably Mac OS X) have SQLite + default, because some platforms (notably macOS) have SQLite libraries which are compiled without this feature. To get loadable extension support, you must pass ``--enable-loadable-sqlite-extensions`` to configure. diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst index d673effc..0b231f17 100644 --- a/Doc/library/ssl.rst +++ b/Doc/library/ssl.rst @@ -18,7 +18,7 @@ This module provides access to Transport Layer Security (often known as "Secure Sockets Layer") encryption and peer authentication facilities for network sockets, both client-side and server-side. This module uses the OpenSSL -library. It is available on all modern Unix systems, Windows, Mac OS X, and +library. It is available on all modern Unix systems, Windows, macOS, and probably additional platforms, as long as OpenSSL is installed on that platform. .. note:: @@ -1522,7 +1522,7 @@ to speed up repeated connections from the same clients. Load a set of default "certification authority" (CA) certificates from default locations. On Windows it loads CA certs from the ``CA`` and - ``ROOT`` system stores. On other systems it calls + ``ROOT`` system stores. On all systems it calls :meth:`SSLContext.set_default_verify_paths`. In the future the method may load CA certificates from other locations, too. diff --git a/Doc/library/stat.rst b/Doc/library/stat.rst index f48a0a9f..98219eae 100644 --- a/Doc/library/stat.rst +++ b/Doc/library/stat.rst @@ -372,11 +372,11 @@ The following flags can be used in the *flags* argument of :func:`os.chflags`: .. data:: UF_COMPRESSED - The file is stored compressed (Mac OS X 10.6+). + The file is stored compressed (macOS 10.6+). .. data:: UF_HIDDEN - The file should not be displayed in a GUI (Mac OS X 10.5+). + The file should not be displayed in a GUI (macOS 10.5+). .. data:: SF_ARCHIVED @@ -398,7 +398,7 @@ The following flags can be used in the *flags* argument of :func:`os.chflags`: The file is a snapshot file. -See the \*BSD or Mac OS systems man page :manpage:`chflags(2)` for more information. +See the \*BSD or macOS systems man page :manpage:`chflags(2)` for more information. On Windows, the following file attribute constants are available for use when testing bits in the ``st_file_attributes`` member returned by :func:`os.stat`. diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst index 57a3285f..55dcc172 100644 --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -1125,6 +1125,8 @@ calls these functions. code was zero then return, otherwise raise :exc:`CalledProcessError`. The :exc:`CalledProcessError` object will have the return code in the :attr:`~CalledProcessError.returncode` attribute. + If :func:`check_call` was unable to start the process it will propagate the exception + that was raised. Code needing to capture stdout or stderr should use :func:`run` instead:: diff --git a/Doc/library/sysconfig.rst b/Doc/library/sysconfig.rst index 641abf43..ee27efd8 100644 --- a/Doc/library/sysconfig.rst +++ b/Doc/library/sysconfig.rst @@ -74,7 +74,7 @@ places. Python currently supports seven schemes: -- *posix_prefix*: scheme for POSIX platforms like Linux or Mac OS X. This is +- *posix_prefix*: scheme for POSIX platforms like Linux or macOS. This is the default scheme used when Python or a component is installed. - *posix_home*: scheme for POSIX platforms used when a *home* option is used upon installation. This scheme is used when a component is installed through @@ -188,7 +188,7 @@ Other functions - win-amd64 (64bit Windows on AMD64, aka x86_64, Intel64, and EM64T) - win32 (all others - specifically, sys.platform is returned) - Mac OS X can return: + macOS can return: - macosx-10.6-ppc - macosx-10.4-ppc64 diff --git a/Doc/library/test.rst b/Doc/library/test.rst index bb1bd29b..16f908c8 100644 --- a/Doc/library/test.rst +++ b/Doc/library/test.rst @@ -457,7 +457,7 @@ The :mod:`test.support` module defines the following functions: .. function:: unlink(filename) Call :func:`os.unlink` on *filename*. On Windows platforms, this is - wrapped with a wait loop that checks for the existence fo the file. + wrapped with a wait loop that checks for the existence of the file. .. function:: rmdir(filename) @@ -925,8 +925,8 @@ The :mod:`test.support` module defines the following functions: .. decorator:: requires_mac_version(*min_version) - Decorator for the minimum version when running test on Mac OS X. If the - MAC OS X version is less than the minimum, raise :exc:`unittest.SkipTest`. + Decorator for the minimum version when running test on macOS. If the + macOS version is less than the minimum, raise :exc:`unittest.SkipTest`. .. decorator:: requires_IEEE_754 @@ -1145,7 +1145,7 @@ The :mod:`test.support` module defines the following functions: Context manager catching :class:`threading.Thread` exception using :func:`threading.excepthook`. - Attributes set when an exception is catched: + Attributes set when an exception is caught: * ``exc_type`` * ``exc_value`` diff --git a/Doc/library/tkinter.ttk.rst b/Doc/library/tkinter.ttk.rst index 6967d750..2db4c0f9 100644 --- a/Doc/library/tkinter.ttk.rst +++ b/Doc/library/tkinter.ttk.rst @@ -759,7 +759,7 @@ ones inherited from :class:`ttk.Widget`. Platform-specific notes ^^^^^^^^^^^^^^^^^^^^^^^ -* On MacOS X, toplevel windows automatically include a built-in size grip +* On macOS, toplevel windows automatically include a built-in size grip by default. Adding a :class:`Sizegrip` is harmless, since the built-in grip will just mask the widget. diff --git a/Doc/library/tracemalloc.rst b/Doc/library/tracemalloc.rst index 20f668c7..68432aea 100644 --- a/Doc/library/tracemalloc.rst +++ b/Doc/library/tracemalloc.rst @@ -740,12 +740,12 @@ Traceback .. method:: format(limit=None, most_recent_first=False) - Format the traceback as a list of lines with newlines. Use the - :mod:`linecache` module to retrieve lines from the source code. - If *limit* is set, format the *limit* most recent frames if *limit* - is positive. Otherwise, format the ``abs(limit)`` oldest frames. - If *most_recent_first* is ``True``, the order of the formatted frames - is reversed, returning the most recent frame first instead of last. + Format the traceback as a list of lines. Use the :mod:`linecache` module to + retrieve lines from the source code. If *limit* is set, format the *limit* + most recent frames if *limit* is positive. Otherwise, format the + ``abs(limit)`` oldest frames. If *most_recent_first* is ``True``, the order + of the formatted frames is reversed, returning the most recent frame first + instead of last. Similar to the :func:`traceback.format_tb` function, except that :meth:`.format` does not include newlines. diff --git a/Doc/library/types.rst b/Doc/library/types.rst index 81a2b7b9..b6df3925 100644 --- a/Doc/library/types.rst +++ b/Doc/library/types.rst @@ -229,7 +229,7 @@ Standard names are defined for the following types: .. note:: A future version of Python may stop setting this attribute by default. - To guard against this potential change, preferrably read from the + To guard against this potential change, preferably read from the :attr:`__spec__` attribute instead or use ``getattr(module, "__loader__", None)`` if you explicitly need to use this attribute. @@ -254,7 +254,7 @@ Standard names are defined for the following types: .. note:: A future version of Python may stop setting this attribute by default. - To guard against this potential change, preferrably read from the + To guard against this potential change, preferably read from the :attr:`__spec__` attribute instead or use ``getattr(module, "__package__", None)`` if you explicitly need to use this attribute. diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 78ab760d..3b50d76c 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -17,12 +17,10 @@ -------------- -This module provides runtime support for type hints as specified by -:pep:`484`, :pep:`526`, :pep:`544`, :pep:`586`, :pep:`589`, and :pep:`591`. -The most fundamental support consists of the types :data:`Any`, :data:`Union`, -:data:`Tuple`, :data:`Callable`, :class:`TypeVar`, and -:class:`Generic`. For full specification please see :pep:`484`. For -a simplified introduction to type hints see :pep:`483`. +This module provides runtime support for type hints. The most fundamental +support consists of the types :data:`Any`, :data:`Union`, :data:`Callable`, +:class:`TypeVar`, and :class:`Generic`. For a full specification, please see +:pep:`484`. For a simplified introduction to type hints, see :pep:`483`. The function below takes and returns a string and is annotated as follows:: @@ -34,6 +32,33 @@ In the function ``greeting``, the argument ``name`` is expected to be of type :class:`str` and the return type :class:`str`. Subtypes are accepted as arguments. +.. _relevant-peps: + +Relevant PEPs +============= + +Since the initial introduction of type hints in :pep:`484` and :pep:`483`, a +number of PEPs have modified and enhanced Python's framework for type +annotations. These include: + +* :pep:`526`: Syntax for Variable Annotations + *Introducing* syntax for annotating variables outside of function + definitions, and :data:`ClassVar` +* :pep:`544`: Protocols: Structural subtyping (static duck typing) + *Introducing* :class:`Protocol` and the + :func:`@runtime_checkable` decorator +* :pep:`585`: Type Hinting Generics In Standard Collections + *Introducing* :class:`types.GenericAlias` and the ability to use standard + library classes as :ref:`generic types` +* :pep:`586`: Literal Types + *Introducing* :class:`Literal` +* :pep:`589`: TypedDict: Type Hints for Dictionaries with a Fixed Set of Keys + *Introducing* :class:`TypedDict` +* :pep:`591`: Adding a final qualifier to typing + *Introducing* :data:`Final` and the :func:`@final` decorator +* :pep:`593`: Flexible function and variable annotations + *Introducing* :class:`Annotated` + Type aliases ============ @@ -232,8 +257,8 @@ A user-defined class can be defined as a generic class. single type parameter ``T`` . This also makes ``T`` valid as a type within the class body. -The :class:`Generic` base class defines :meth:`__class_getitem__` so that -``LoggedVar[t]`` is valid as a type:: +The :class:`Generic` base class defines :meth:`~object.__class_getitem__` so +that ``LoggedVar[t]`` is valid as a type:: from collections.abc import Iterable diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst index 785ecf8f..bfb994e3 100644 --- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -164,8 +164,8 @@ The :mod:`urllib.request` module defines the following functions: This helper function returns a dictionary of scheme to proxy server URL mappings. It scans the environment for variables named ``_proxy``, in a case insensitive approach, for all operating systems first, and when it - cannot find it, looks for proxy information from Mac OSX System - Configuration for Mac OS X and Windows Systems Registry for Windows. + cannot find it, looks for proxy information from System + Configuration for macOS and Windows Systems Registry for Windows. If both lowercase and uppercase environment variables exist (and disagree), lowercase is preferred. @@ -298,8 +298,8 @@ The following classes are provided: the list of proxies from the environment variables ``_proxy``. If no proxy environment variables are set, then in a Windows environment proxy settings are obtained from the registry's - Internet Settings section, and in a Mac OS X environment proxy information - is retrieved from the OS X System Configuration Framework. + Internet Settings section, and in a macOS environment proxy information + is retrieved from the System Configuration Framework. To disable autodetected proxy pass an empty dictionary. @@ -650,7 +650,7 @@ OpenerDirector Objects optional *timeout* parameter specifies a timeout in seconds for blocking operations like the connection attempt (if not specified, the global default timeout setting will be used). The timeout feature actually works only for - HTTP, HTTPS and FTP connections). + HTTP, HTTPS and FTP connections. .. method:: OpenerDirector.error(proto, *args) diff --git a/Doc/library/venv.rst b/Doc/library/venv.rst index e0205708..1ad75d5a 100644 --- a/Doc/library/venv.rst +++ b/Doc/library/venv.rst @@ -421,7 +421,7 @@ subclass which installs setuptools and pip into a created virtual environment:: 'more target ' 'directories.') parser.add_argument('dirs', metavar='ENV_DIR', nargs='+', - help='A directory in which to create the + help='A directory in which to create the ' 'virtual environment.') parser.add_argument('--no-setuptools', default=False, action='store_true', dest='nodist', diff --git a/Doc/library/weakref.rst b/Doc/library/weakref.rst index b88543e4..4b0945c0 100644 --- a/Doc/library/weakref.rst +++ b/Doc/library/weakref.rst @@ -88,6 +88,10 @@ support weak references but can add support through subclassing:: Extension types can easily be made to support weak references; see :ref:`weakref-support`. +When ``__slots__`` are defined for a given type, weak reference support is +disabled unless a ``'__weakref__'`` string is also present in the sequence of +strings in the ``__slots__`` declaration. +See :ref:`__slots__ documentation ` for details. .. class:: ref(object[, callback]) diff --git a/Doc/library/webbrowser.rst b/Doc/library/webbrowser.rst index 5980ff5b..0ddba0de 100644 --- a/Doc/library/webbrowser.rst +++ b/Doc/library/webbrowser.rst @@ -143,9 +143,9 @@ for the controller classes, all defined in this module. +------------------------+-----------------------------------------+-------+ | ``'windows-default'`` | :class:`WindowsDefault` | \(2) | +------------------------+-----------------------------------------+-------+ -| ``'macosx'`` | :class:`MacOSX('default')` | \(3) | +| ``'macosx'`` | :class:`MacOSXOSAScript('default')` | \(3) | +------------------------+-----------------------------------------+-------+ -| ``'safari'`` | :class:`MacOSX('safari')` | \(3) | +| ``'safari'`` | :class:`MacOSXOSAScript('safari')` | \(3) | +------------------------+-----------------------------------------+-------+ | ``'google-chrome'`` | :class:`Chrome('google-chrome')` | | +------------------------+-----------------------------------------+-------+ @@ -169,7 +169,7 @@ Notes: Only on Windows platforms. (3) - Only on Mac OS X platform. + Only on macOS platform. .. versionadded:: 3.3 Support for Chrome/Chromium has been added. diff --git a/Doc/library/xml.dom.minidom.rst b/Doc/library/xml.dom.minidom.rst index d3a5f872..20984b98 100644 --- a/Doc/library/xml.dom.minidom.rst +++ b/Doc/library/xml.dom.minidom.rst @@ -156,6 +156,9 @@ module documentation. This section lists the differences between the API and The :meth:`writexml` method now preserves the attribute order specified by the user. + .. versionchanged:: 3.9 + The *standalone* parameter was added. + .. method:: Node.toxml(encoding=None, standalone=None) Return a string or byte string containing the XML represented by @@ -174,6 +177,9 @@ module documentation. This section lists the differences between the API and The :meth:`toxml` method now preserves the attribute order specified by the user. + .. versionchanged:: 3.9 + The *standalone* parameter was added. + .. method:: Node.toprettyxml(indent="\\t", newl="\\n", encoding=None, \ standalone=None) @@ -190,6 +196,8 @@ module documentation. This section lists the differences between the API and The :meth:`toprettyxml` method now preserves the attribute order specified by the user. + .. versionchanged:: 3.9 + The *standalone* parameter was added. .. _dom-example: diff --git a/Doc/license.rst b/Doc/license.rst index d459ff66..4ab04f34 100644 --- a/Doc/license.rst +++ b/Doc/license.rst @@ -655,7 +655,7 @@ OpenSSL The modules :mod:`hashlib`, :mod:`posix`, :mod:`ssl`, :mod:`crypt` use the OpenSSL library for added performance if made available by the -operating system. Additionally, the Windows and Mac OS X installers for +operating system. Additionally, the Windows and macOS installers for Python may include a copy of the OpenSSL libraries, so we include a copy of the OpenSSL license here:: diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 75424162..0bc1e244 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -479,7 +479,6 @@ is semantically equivalent to:: The specification, background, and examples for the Python :keyword:`with` statement. - .. index:: single: parameter; function definition diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 40301230..29a69870 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1205,7 +1205,7 @@ Basic customization as necessary before returning it. If :meth:`__new__` is invoked during object construction and it returns an - instance or subclass of *cls*, then the new instance’s :meth:`__init__` method + instance of *cls*, then the new instance’s :meth:`__init__` method will be invoked like ``__init__(self[, ...])``, where *self* is the new instance and the remaining arguments are the same as were passed to the object constructor. @@ -1492,7 +1492,7 @@ Basic customization This is intended to provide protection against a denial-of-service caused by carefully-chosen inputs that exploit the worst case performance of a - dict insertion, O(n^2) complexity. See + dict insertion, O(n\ :sup:`2`) complexity. See http://www.ocert.org/advisories/ocert-2011-003.html for details. Changing hash values affects the iteration order of sets. @@ -2512,8 +2512,8 @@ left undefined. return the value of the object truncated to an :class:`~numbers.Integral` (typically an :class:`int`). - If :meth:`__int__` is not defined then the built-in function :func:`int` - falls back to :meth:`__trunc__`. + The built-in function :func:`int` falls back to :meth:`__trunc__` if neither + :meth:`__int__` nor :meth:`__index__` is defined. .. _context-managers: diff --git a/Doc/reference/executionmodel.rst b/Doc/reference/executionmodel.rst index 55ac01b6..5c85dd70 100644 --- a/Doc/reference/executionmodel.rst +++ b/Doc/reference/executionmodel.rst @@ -119,14 +119,14 @@ is subtle. Python lacks declarations and allows name binding operations to occur anywhere within a code block. The local variables of a code block can be determined by scanning the entire text of the block for name binding operations. -If the :keyword:`global` statement occurs within a block, all uses of the name -specified in the statement refer to the binding of that name in the top-level +If the :keyword:`global` statement occurs within a block, all uses of the names +specified in the statement refer to the bindings of those names in the top-level namespace. Names are resolved in the top-level namespace by searching the global namespace, i.e. the namespace of the module containing the code block, and the builtins namespace, the namespace of the module :mod:`builtins`. The -global namespace is searched first. If the name is not found there, the +global namespace is searched first. If the names are not found there, the builtins namespace is searched. The :keyword:`!global` statement must precede -all uses of the name. +all uses of the listed names. The :keyword:`global` statement has the same scope as a name binding operation in the same block. If the nearest enclosing scope for a free variable contains diff --git a/Doc/requirements.txt b/Doc/requirements.txt index 47b78eea..cb21ed20 100644 --- a/Doc/requirements.txt +++ b/Doc/requirements.txt @@ -4,6 +4,10 @@ # won't suddenly cause build failures. Updating the version is fine as long # as no warnings are raised by doing so. sphinx==2.4.4 +# Docutils version is pinned to a version compatible with Sphinx +# version 2.4.4. It can be removed after bumping Sphinx version to at +# least 3.5.4. +docutils==0.17.1 blurb diff --git a/Doc/tutorial/appetite.rst b/Doc/tutorial/appetite.rst index 26e5168a..3fa68097 100644 --- a/Doc/tutorial/appetite.rst +++ b/Doc/tutorial/appetite.rst @@ -23,7 +23,7 @@ You could write a Unix shell script or Windows batch files for some of these tasks, but shell scripts are best at moving around files and changing text data, not well-suited for GUI applications or games. You could write a C/C++/Java program, but it can take a lot of development time to get even a first-draft -program. Python is simpler to use, available on Windows, Mac OS X, and Unix +program. Python is simpler to use, available on Windows, macOS, and Unix operating systems, and will help you get the job done more quickly. Python is simple to use, but it is a real programming language, offering much diff --git a/Doc/tutorial/floatingpoint.rst b/Doc/tutorial/floatingpoint.rst index 0c0eb526..b98de6e5 100644 --- a/Doc/tutorial/floatingpoint.rst +++ b/Doc/tutorial/floatingpoint.rst @@ -158,7 +158,7 @@ which implements arithmetic based on rational numbers (so the numbers like 1/3 can be represented exactly). If you are a heavy user of floating point operations you should take a look -at the Numerical Python package and many other packages for mathematical and +at the NumPy package and many other packages for mathematical and statistical operations supplied by the SciPy project. See . Python provides tools that may help on those rare occasions when you really diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index 8763626e..33678f5a 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -11,6 +11,13 @@ with a prompt are output from the interpreter. Note that a secondary prompt on a line by itself in an example means you must type a blank line; this is used to end a multi-line command. +.. only:: html + + You can toggle the display of prompts and output by clicking on ``>>>`` + in the upper-right corner of an example box. If you hide the prompts + and output for an example, then you can easily copy and paste the input + lines into your interpreter. + .. index:: single: # (hash); comment Many of the examples in this manual, even those entered at the interactive diff --git a/Doc/tutorial/modules.rst b/Doc/tutorial/modules.rst index af595e5c..f6250291 100644 --- a/Doc/tutorial/modules.rst +++ b/Doc/tutorial/modules.rst @@ -191,7 +191,8 @@ named :file:`spam.py` in a list of directories given by the variable file is specified). * :envvar:`PYTHONPATH` (a list of directory names, with the same syntax as the shell variable :envvar:`PATH`). -* The installation-dependent default. +* The installation-dependent default (by convention including a + ``site-packages`` directory, handled by the :mod:`site` module). .. note:: On file systems which support symlinks, the directory containing the input diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index 95342f3a..5739388e 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -322,7 +322,7 @@ Miscellaneous options Hash randomization is intended to provide protection against a denial-of-service caused by carefully-chosen inputs that exploit the worst - case performance of a dict construction, O(n^2) complexity. See + case performance of a dict construction, O(n\ :sup:`2`) complexity. See http://www.ocert.org/advisories/ocert-2011-003.html for details. :envvar:`PYTHONHASHSEED` allows you to set a fixed value for the hash @@ -621,7 +621,7 @@ conflict. .. envvar:: PYTHONCASEOK If this is set, Python ignores case in :keyword:`import` statements. This - only works on Windows and OS X. + only works on Windows and macOS. .. envvar:: PYTHONDONTWRITEBYTECODE @@ -704,7 +704,7 @@ conflict. If this environment variable is set, ``sys.argv[0]`` will be set to its value instead of the value got through the C runtime. Only works on - Mac OS X. + macOS. .. envvar:: PYTHONWARNINGS diff --git a/Doc/using/mac.rst b/Doc/using/mac.rst index ead71e1b..2f132a96 100644 --- a/Doc/using/mac.rst +++ b/Doc/using/mac.rst @@ -1,14 +1,14 @@ .. _using-on-mac: -*************************** -Using Python on a Macintosh -*************************** +********************* +Using Python on a Mac +********************* :Author: Bob Savage -Python on a Macintosh running Mac OS X is in principle very similar to Python on +Python on a Mac running macOS is in principle very similar to Python on any other Unix platform, but there are a number of additional features such as the IDE and the Package Manager that are worth pointing out. @@ -17,7 +17,7 @@ the IDE and the Package Manager that are worth pointing out. Getting and Installing MacPython ================================ -Mac OS X 10.8 comes with Python 2.7 pre-installed by Apple. If you wish, you +macOS since version 10.8 comes with Python 2.7 pre-installed by Apple. If you wish, you are invited to install the most recent version of Python 3 from the Python website (https://www.python.org). A current "universal binary" build of Python, which runs natively on the Mac's new Intel and legacy PPC CPU's, is available @@ -54,12 +54,12 @@ section on running Python scripts from the Unix shell. How to run a Python script -------------------------- -Your best way to get started with Python on Mac OS X is through the IDLE +Your best way to get started with Python on macOS is through the IDLE integrated development environment, see section :ref:`ide` and use the Help menu when the IDE is running. If you want to run Python scripts from the Terminal window command line or from -the Finder you first need an editor to create your script. Mac OS X comes with a +the Finder you first need an editor to create your script. macOS comes with a number of standard Unix command line editors, :program:`vim` and :program:`emacs` among them. If you want a more Mac-like editor, :program:`BBEdit` or :program:`TextWrangler` from Bare Bones Software (see @@ -87,7 +87,7 @@ To run your script from the Finder you have two options: Running scripts with a GUI -------------------------- -With older versions of Python, there is one Mac OS X quirk that you need to be +With older versions of Python, there is one macOS quirk that you need to be aware of: programs that talk to the Aqua window manager (in other words, anything that has a GUI) need to be run in a special way. Use :program:`pythonw` instead of :program:`python` to start such scripts. @@ -98,7 +98,7 @@ With Python 3.9, you can use either :program:`python` or :program:`pythonw`. Configuration ------------- -Python on OS X honors all standard Unix environment variables such as +Python on macOS honors all standard Unix environment variables such as :envvar:`PYTHONPATH`, but setting these variables for programs started from the Finder is non-standard as the Finder does not read your :file:`.profile` or :file:`.cshrc` at startup. You need to create a file @@ -148,10 +148,10 @@ X by Apple, and the latest version can be downloaded and installed from https://www.activestate.com; it can also be built from source. *wxPython* is another popular cross-platform GUI toolkit that runs natively on -Mac OS X. Packages and documentation are available from https://www.wxpython.org. +macOS. Packages and documentation are available from https://www.wxpython.org. -*PyQt* is another popular cross-platform GUI toolkit that runs natively on Mac -OS X. More information can be found at +*PyQt* is another popular cross-platform GUI toolkit that runs natively on +macOS. More information can be found at https://riverbankcomputing.com/software/pyqt/intro. diff --git a/Doc/whatsnew/2.0.rst b/Doc/whatsnew/2.0.rst index ace396b9..dd49da8f 100644 --- a/Doc/whatsnew/2.0.rst +++ b/Doc/whatsnew/2.0.rst @@ -791,7 +791,7 @@ Previously the Python virtual machine used 16-bit numbers in its bytecode, limiting the size of source files. In particular, this affected the maximum size of literal lists and dictionaries in Python source; occasionally people who are generating Python code would run into this limit. A patch by Charles G. -Waldman raises the limit from ``2^16`` to ``2^{32}``. +Waldman raises the limit from ``2**16`` to ``2**32``. Three new convenience functions intended for adding constants to a module's dictionary at module initialization time were added: :func:`PyModule_AddObject`, diff --git a/Doc/whatsnew/2.7.rst b/Doc/whatsnew/2.7.rst index d19c8e01..abb65222 100644 --- a/Doc/whatsnew/2.7.rst +++ b/Doc/whatsnew/2.7.rst @@ -953,12 +953,12 @@ Several performance enhancements have been added: considered and traversed by the collector. (Contributed by Antoine Pitrou; :issue:`4688`.) -* Long integers are now stored internally either in base 2**15 or in base - 2**30, the base being determined at build time. Previously, they - were always stored in base 2**15. Using base 2**30 gives +* Long integers are now stored internally either in base ``2**15`` or in base + ``2**30``, the base being determined at build time. Previously, they + were always stored in base ``2**15``. Using base ``2**30`` gives significant performance improvements on 64-bit machines, but benchmark results on 32-bit machines have been mixed. Therefore, - the default is to use base 2**30 on 64-bit machines and base 2**15 + the default is to use base ``2**30`` on 64-bit machines and base ``2**15`` on 32-bit machines; on Unix, there's a new configure option :option:`!--enable-big-digits` that can be used to override this default. diff --git a/Doc/whatsnew/3.1.rst b/Doc/whatsnew/3.1.rst index 919fbeeb..f1e6d0c4 100644 --- a/Doc/whatsnew/3.1.rst +++ b/Doc/whatsnew/3.1.rst @@ -474,12 +474,12 @@ Build and C API Changes Changes to Python's build process and to the C API include: -* Integers are now stored internally either in base 2**15 or in base - 2**30, the base being determined at build time. Previously, they - were always stored in base 2**15. Using base 2**30 gives +* Integers are now stored internally either in base ``2**15`` or in base + ``2**30``, the base being determined at build time. Previously, they + were always stored in base ``2**15``. Using base ``2**30`` gives significant performance improvements on 64-bit machines, but benchmark results on 32-bit machines have been mixed. Therefore, - the default is to use base 2**30 on 64-bit machines and base 2**15 + the default is to use base ``2**30`` on 64-bit machines and base ``2**15`` on 32-bit machines; on Unix, there's a new configure option ``--enable-big-digits`` that can be used to override this default. diff --git a/Include/Python.h b/Include/Python.h index acee38c4..6ee52e74 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -35,19 +35,6 @@ #ifndef MS_WINDOWS #include #endif -#ifdef HAVE_CRYPT_H -#if defined(HAVE_CRYPT_R) && !defined(_GNU_SOURCE) -/* Required for glibc to expose the crypt_r() function prototype. */ -# define _GNU_SOURCE -# define _Py_GNU_SOURCE_FOR_CRYPT -#endif -#include -#ifdef _Py_GNU_SOURCE_FOR_CRYPT -/* Don't leak the _GNU_SOURCE define to other headers. */ -# undef _GNU_SOURCE -# undef _Py_GNU_SOURCE_FOR_CRYPT -#endif -#endif /* For size_t? */ #ifdef HAVE_STDDEF_H diff --git a/Include/abstract.h b/Include/abstract.h index bb51c668..d31d66e6 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -318,7 +318,7 @@ PyAPI_FUNC(int) PyObject_DelItem(PyObject *o, PyObject *key); /* Takes an arbitrary object which must support the (character, single segment) buffer interface and returns a pointer to a read-only memory location - useable as character based input for subsequent processing. + usable as character based input for subsequent processing. Return 0 on success. buffer and buffer_len are only set in case no error occurs. Otherwise, -1 is returned and an exception set. */ diff --git a/Include/cpython/dictobject.h b/Include/cpython/dictobject.h index e33a0d15..50f4c4a9 100644 --- a/Include/cpython/dictobject.h +++ b/Include/cpython/dictobject.h @@ -26,7 +26,7 @@ typedef struct { /* If ma_values is NULL, the table is "combined": keys and values are stored in ma_keys. - If ma_values is not NULL, the table is splitted: + If ma_values is not NULL, the table is split: keys are stored in ma_keys and values are stored in ma_values */ PyObject **ma_values; } PyDictObject; diff --git a/Include/cpython/unicodeobject.h b/Include/cpython/unicodeobject.h index 17db79cf..1b460c9f 100644 --- a/Include/cpython/unicodeobject.h +++ b/Include/cpython/unicodeobject.h @@ -416,7 +416,7 @@ enum PyUnicode_Kind { /* Fast check to determine whether an object is ready. Equivalent to - PyUnicode_IS_COMPACT(op) || ((PyUnicodeObject*)(op))->data.any) */ + PyUnicode_IS_COMPACT(op) || ((PyUnicodeObject*)(op))->data.any */ #define PyUnicode_IS_READY(op) (((PyASCIIObject*)op)->state.ready) @@ -857,12 +857,20 @@ PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF16( /* --- Unicode-Escape Codecs ---------------------------------------------- */ +/* Variant of PyUnicode_DecodeUnicodeEscape that supports partial decoding. */ +PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeStateful( + const char *string, /* Unicode-Escape encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed /* bytes consumed */ +); /* Helper for PyUnicode_DecodeUnicodeEscape that detects invalid escape chars. */ -PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscape( +PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeInternal( const char *string, /* Unicode-Escape encoded string */ Py_ssize_t length, /* size of string */ const char *errors, /* error handling */ + Py_ssize_t *consumed, /* bytes consumed */ const char **first_invalid_escape /* on return, points to first invalid escaped char in string. */ @@ -880,6 +888,14 @@ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape( Py_ssize_t length /* Number of Py_UNICODE chars to encode */ ); +/* Variant of PyUnicode_DecodeRawUnicodeEscape that supports partial decoding. */ +PyAPI_FUNC(PyObject*) _PyUnicode_DecodeRawUnicodeEscapeStateful( + const char *string, /* Unicode-Escape encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed /* bytes consumed */ +); + /* --- Latin-1 Codecs ----------------------------------------------------- */ PyAPI_FUNC(PyObject*) _PyUnicode_AsLatin1String( diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h index 88956f10..a1bd6a0b 100644 --- a/Include/internal/pycore_code.h +++ b/Include/internal/pycore_code.h @@ -3,7 +3,7 @@ #ifdef __cplusplus extern "C" { #endif - + typedef struct { PyObject *ptr; /* Cached pointer (borrowed reference) */ uint64_t globals_ver; /* ma_version of global dict */ diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h index 32e86d06..c66ff12d 100644 --- a/Include/internal/pycore_object.h +++ b/Include/internal/pycore_object.h @@ -15,6 +15,9 @@ extern "C" { PyAPI_FUNC(int) _PyType_CheckConsistency(PyTypeObject *type); PyAPI_FUNC(int) _PyDict_CheckConsistency(PyObject *mp, int check_content); +/* Only private in Python 3.10 and 3.9.8+; public in 3.11 */ +extern PyObject *_PyType_GetQualName(PyTypeObject *type); + /* Tell the GC to track this object. * * NB: While the object is tracked by the collector, it must be safe to call the diff --git a/Include/internal/pycore_traceback.h b/Include/internal/pycore_traceback.h index 1f092411..c23290eb 100644 --- a/Include/internal/pycore_traceback.h +++ b/Include/internal/pycore_traceback.h @@ -51,7 +51,7 @@ PyAPI_FUNC(void) _Py_DumpTraceback( _PyGILState_GetInterpreterStateUnsafe() in last resort. It is better to pass NULL to interp and current_tstate, the function tries - different options to retrieve these informations. + different options to retrieve this information. This function is signal safe. */ diff --git a/Include/patchlevel.h b/Include/patchlevel.h index af883f23..8057ab92 100644 --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -18,12 +18,12 @@ /*--start constants--*/ #define PY_MAJOR_VERSION 3 #define PY_MINOR_VERSION 9 -#define PY_MICRO_VERSION 7 +#define PY_MICRO_VERSION 8 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL #define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "3.9.7" +#define PY_VERSION "3.9.8" /*--end constants--*/ /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. diff --git a/Include/pytime.h b/Include/pytime.h index bdda1da2..c79eba2f 100644 --- a/Include/pytime.h +++ b/Include/pytime.h @@ -91,13 +91,13 @@ PyAPI_FUNC(_PyTime_t) _PyTime_FromNanoseconds(_PyTime_t ns); PyAPI_FUNC(int) _PyTime_FromNanosecondsObject(_PyTime_t *t, PyObject *obj); -/* Convert a number of seconds (Python float or int) to a timetamp. +/* Convert a number of seconds (Python float or int) to a timestamp. Raise an exception and return -1 on error, return 0 on success. */ PyAPI_FUNC(int) _PyTime_FromSecondsObject(_PyTime_t *t, PyObject *obj, _PyTime_round_t round); -/* Convert a number of milliseconds (Python float or int, 10^-3) to a timetamp. +/* Convert a number of milliseconds (Python float or int, 10^-3) to a timestamp. Raise an exception and return -1 on error, return 0 on success. */ PyAPI_FUNC(int) _PyTime_FromMillisecondsObject(_PyTime_t *t, PyObject *obj, diff --git a/Lib/_osx_support.py b/Lib/_osx_support.py index 37975fe8..2fc324a1 100644 --- a/Lib/_osx_support.py +++ b/Lib/_osx_support.py @@ -156,9 +156,9 @@ def _default_sysroot(cc): if _cache_default_sysroot is not None: return _cache_default_sysroot - + contents = _read_output('%s -c -E -v - "): in_incdirs = True @@ -482,7 +482,7 @@ def customize_compiler(_config_vars): This customization is performed when the first extension module build is requested - in distutils.sysconfig.customize_compiler). + in distutils.sysconfig.customize_compiler. """ # Find a compiler to use for extension module builds diff --git a/Lib/argparse.py b/Lib/argparse.py index f45a2ed4..cb5345d5 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -526,12 +526,13 @@ class HelpFormatter(object): parts = [action_header] # if there was help for the action, add lines of help text - if action.help: + if action.help and action.help.strip(): help_text = self._expand_help(action) - help_lines = self._split_lines(help_text, help_width) - parts.append('%*s%s\n' % (indent_first, '', help_lines[0])) - for line in help_lines[1:]: - parts.append('%*s%s\n' % (help_position, '', line)) + if help_text: + help_lines = self._split_lines(help_text, help_width) + parts.append('%*s%s\n' % (indent_first, '', help_lines[0])) + for line in help_lines[1:]: + parts.append('%*s%s\n' % (help_position, '', line)) # or add a newline if the description doesn't end with one elif not action_header.endswith('\n'): @@ -1208,7 +1209,8 @@ class _SubParsersAction(Action): # namespace for the relevant parts. subnamespace, arg_strings = parser.parse_known_args(arg_strings, None) for key, value in vars(subnamespace).items(): - setattr(namespace, key, value) + if not hasattr(namespace, key): + setattr(namespace, key, value) if arg_strings: vars(namespace).setdefault(_UNRECOGNIZED_ARGS_ATTR, []) @@ -1842,11 +1844,6 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): if action.default is not SUPPRESS: setattr(namespace, action.dest, action.default) - # add any parser defaults that aren't present - for dest in self._defaults: - if not hasattr(namespace, dest): - setattr(namespace, dest, self._defaults[dest]) - # parse the arguments and exit if there are any errors if self.exit_on_error: try: @@ -1857,6 +1854,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): else: namespace, args = self._parse_known_args(args, namespace) + # add any parser defaults that aren't present + for dest in self._defaults: + if not hasattr(namespace, dest): + setattr(namespace, dest, self._defaults[dest]) + if hasattr(namespace, _UNRECOGNIZED_ARGS_ATTR): args.extend(getattr(namespace, _UNRECOGNIZED_ARGS_ATTR)) delattr(namespace, _UNRECOGNIZED_ARGS_ATTR) diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index b2d446a5..bb2f9915 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -350,7 +350,7 @@ class Server(events.AbstractServer): self._start_serving() # Skip one loop iteration so that all 'loop.add_reader' # go through. - await tasks.sleep(0, loop=self._loop) + await tasks.sleep(0) async def serve_forever(self): if self._serving_forever_fut is not None: @@ -539,7 +539,7 @@ class BaseEventLoop(events.AbstractEventLoop): closing_agens = list(self._asyncgens) self._asyncgens.clear() - results = await tasks.gather( + results = await tasks._gather( *[ag.aclose() for ag in closing_agens], return_exceptions=True, loop=self) @@ -1457,7 +1457,7 @@ class BaseEventLoop(events.AbstractEventLoop): fs = [self._create_server_getaddrinfo(host, port, family=family, flags=flags) for host in hosts] - infos = await tasks.gather(*fs, loop=self) + infos = await tasks._gather(*fs, loop=self) infos = set(itertools.chain.from_iterable(infos)) completed = False @@ -1515,7 +1515,7 @@ class BaseEventLoop(events.AbstractEventLoop): server._start_serving() # Skip one loop iteration so that all 'loop.add_reader' # go through. - await tasks.sleep(0, loop=self) + await tasks.sleep(0) if self._debug: logger.info("%r is serving", server) diff --git a/Lib/asyncio/events.py b/Lib/asyncio/events.py index 0dce87b8..c8e4b407 100644 --- a/Lib/asyncio/events.py +++ b/Lib/asyncio/events.py @@ -465,7 +465,7 @@ class AbstractEventLoop: # The reason to accept file-like object instead of just file descriptor # is: we need to own pipe and close it at transport finishing # Can got complicated errors if pass f.fileno(), - # close fd in pipe transport then close f and vise versa. + # close fd in pipe transport then close f and vice versa. raise NotImplementedError async def connect_write_pipe(self, protocol_factory, pipe): @@ -478,7 +478,7 @@ class AbstractEventLoop: # The reason to accept file-like object instead of just file descriptor # is: we need to own pipe and close it at transport finishing # Can got complicated errors if pass f.fileno(), - # close fd in pipe transport then close f and vise versa. + # close fd in pipe transport then close f and vice versa. raise NotImplementedError async def subprocess_shell(self, protocol_factory, cmd, *, diff --git a/Lib/asyncio/runners.py b/Lib/asyncio/runners.py index 268635d6..6920acba 100644 --- a/Lib/asyncio/runners.py +++ b/Lib/asyncio/runners.py @@ -61,7 +61,7 @@ def _cancel_all_tasks(loop): task.cancel() loop.run_until_complete( - tasks.gather(*to_cancel, loop=loop, return_exceptions=True)) + tasks._gather(*to_cancel, loop=loop, return_exceptions=True)) for task in to_cancel: if task.cancelled(): diff --git a/Lib/asyncio/subprocess.py b/Lib/asyncio/subprocess.py index c9506b15..820304ec 100644 --- a/Lib/asyncio/subprocess.py +++ b/Lib/asyncio/subprocess.py @@ -193,8 +193,8 @@ class Process: stderr = self._read_stream(2) else: stderr = self._noop() - stdin, stdout, stderr = await tasks.gather(stdin, stdout, stderr, - loop=self._loop) + stdin, stdout, stderr = await tasks._gather(stdin, stdout, stderr, + loop=self._loop) await self.wait() return (stdout, stderr) diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py index d7e0575e..22ed3289 100644 --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -580,15 +580,16 @@ def as_completed(fs, *, loop=None, timeout=None): if futures.isfuture(fs) or coroutines.iscoroutine(fs): raise TypeError(f"expect an iterable of futures, not {type(fs).__name__}") + if loop is not None: + warnings.warn("The loop argument is deprecated since Python 3.8, " + "and scheduled for removal in Python 3.10.", + DeprecationWarning, stacklevel=2) + from .queues import Queue # Import here to avoid circular import problem. done = Queue(loop=loop) if loop is None: loop = events.get_event_loop() - else: - warnings.warn("The loop argument is deprecated since Python 3.8, " - "and scheduled for removal in Python 3.10.", - DeprecationWarning, stacklevel=2) todo = {ensure_future(f, loop=loop) for f in set(fs)} timeout_handle = None @@ -756,6 +757,10 @@ def gather(*coros_or_futures, loop=None, return_exceptions=False): "and scheduled for removal in Python 3.10.", DeprecationWarning, stacklevel=2) + return _gather(*coros_or_futures, loop=loop, return_exceptions=return_exceptions) + + +def _gather(*coros_or_futures, loop=None, return_exceptions=False): if not coros_or_futures: if loop is None: loop = events.get_event_loop() diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py index 3efa6698..eecbc101 100644 --- a/Lib/asyncio/unix_events.py +++ b/Lib/asyncio/unix_events.py @@ -323,7 +323,7 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop): server._start_serving() # Skip one loop iteration so that all 'loop.add_reader' # go through. - await tasks.sleep(0, loop=self) + await tasks.sleep(0) return server @@ -1383,7 +1383,7 @@ class ThreadedChildWatcher(AbstractChildWatcher): def remove_child_handler(self, pid): # asyncio never calls remove_child_handler() !!! # The method is no-op but is implemented because - # abstract base classe requires it + # abstract base classes require it. return True def attach_loop(self, loop): diff --git a/Lib/compileall.py b/Lib/compileall.py index 39f4bb39..25ad83c2 100644 --- a/Lib/compileall.py +++ b/Lib/compileall.py @@ -365,9 +365,9 @@ def main(): 'environment variable is set, and ' '"timestamp" otherwise.')) parser.add_argument('-o', action='append', type=int, dest='opt_levels', - help=('Optimization levels to run compilation with.' - 'Default is -1 which uses optimization level of' - 'Python interpreter itself (specified by -O).')) + help=('Optimization levels to run compilation with. ' + 'Default is -1 which uses the optimization level ' + 'of the Python interpreter itself (see -O).')) parser.add_argument('-e', metavar='DIR', dest='limit_sl_dest', help='Ignore symlinks pointing outsite of the DIR') parser.add_argument('--hardlink-dupes', action='store_true', diff --git a/Lib/concurrent/futures/thread.py b/Lib/concurrent/futures/thread.py index b7a2cac7..51c942f5 100644 --- a/Lib/concurrent/futures/thread.py +++ b/Lib/concurrent/futures/thread.py @@ -36,6 +36,12 @@ def _python_exit(): # See bpo-39812 for context. threading._register_atexit(_python_exit) +# At fork, reinitialize the `_global_shutdown_lock` lock in the child process +if hasattr(os, 'register_at_fork'): + os.register_at_fork(before=_global_shutdown_lock.acquire, + after_in_child=_global_shutdown_lock._at_fork_reinit, + after_in_parent=_global_shutdown_lock.release) + class _WorkItem(object): def __init__(self, future, fn, args, kwargs): diff --git a/Lib/contextlib.py b/Lib/contextlib.py index f60f0c27..4e8f5f75 100644 --- a/Lib/contextlib.py +++ b/Lib/contextlib.py @@ -496,10 +496,10 @@ class ExitStack(_BaseExitStack, AbstractContextManager): # Context may not be correct, so find the end of the chain while 1: exc_context = new_exc.__context__ - if exc_context is old_exc: + if exc_context is None or exc_context is old_exc: # Context is already set correctly (see issue 20317) return - if exc_context is None or exc_context is frame_exc: + if exc_context is frame_exc: break new_exc = exc_context # Change the end of the chain to point to the exception @@ -630,10 +630,10 @@ class AsyncExitStack(_BaseExitStack, AbstractAsyncContextManager): # Context may not be correct, so find the end of the chain while 1: exc_context = new_exc.__context__ - if exc_context is old_exc: + if exc_context is None or exc_context is old_exc: # Context is already set correctly (see issue 20317) return - if exc_context is None or exc_context is frame_exc: + if exc_context is frame_exc: break new_exc = exc_context # Change the end of the chain to point to the exception diff --git a/Lib/ctypes/_aix.py b/Lib/ctypes/_aix.py index 190cac65..fc3e95cb 100644 --- a/Lib/ctypes/_aix.py +++ b/Lib/ctypes/_aix.py @@ -163,7 +163,7 @@ def get_legacy(members): return member else: # 32-bit legacy names - both shr.o and shr4.o exist. - # shr.o is the preffered name so we look for shr.o first + # shr.o is the preferred name so we look for shr.o first # i.e., shr4.o is returned only when shr.o does not exist for name in ['shr.o', 'shr4.o']: member = get_one_match(re.escape(name), members) @@ -282,7 +282,7 @@ def find_shared(paths, name): if path.exists(archive): members = get_shared(get_ld_headers(archive)) member = get_member(re.escape(name), members) - if member != None: + if member is not None: return (base, member) else: return (None, None) @@ -307,7 +307,7 @@ def find_library(name): libpaths = get_libpaths() (base, member) = find_shared(libpaths, name) - if base != None: + if base is not None: return f"{base}({member})" # To get here, a member in an archive has not been found diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py index 245cd94c..97ad2b8e 100644 --- a/Lib/ctypes/test/test_structures.py +++ b/Lib/ctypes/test/test_structures.py @@ -443,7 +443,7 @@ class StructureTestCase(unittest.TestCase): s = Test(1, 2, 3) # Test the StructUnionType_paramfunc() code path which copies the - # structure: if the stucture is larger than sizeof(void*). + # structure: if the structure is larger than sizeof(void*). self.assertGreater(sizeof(s), sizeof(c_void_p)) dll = CDLL(_ctypes_test.__file__) @@ -451,7 +451,7 @@ class StructureTestCase(unittest.TestCase): func.argtypes = (Test,) func.restype = None func(s) - # bpo-37140: Passing the structure by refrence must not call + # bpo-37140: Passing the structure by reference must not call # its finalizer! self.assertEqual(finalizer_calls, []) self.assertEqual(s.first, 1) diff --git a/Lib/difflib.py b/Lib/difflib.py index 0dda80d3..afd8a0c7 100644 --- a/Lib/difflib.py +++ b/Lib/difflib.py @@ -62,7 +62,7 @@ class SequenceMatcher: notion, pairing up elements that appear uniquely in each sequence. That, and the method here, appear to yield more intuitive difference reports than does diff. This method appears to be the least vulnerable - to synching up on blocks of "junk lines", though (like blank lines in + to syncing up on blocks of "junk lines", though (like blank lines in ordinary text files, or maybe "

" lines in HTML files). That may be because this is the only method of the 3 that has a *concept* of "junk" . @@ -115,38 +115,6 @@ class SequenceMatcher: case. SequenceMatcher is quadratic time for the worst case and has expected-case behavior dependent in a complicated way on how many elements the sequences have in common; best case time is linear. - - Methods: - - __init__(isjunk=None, a='', b='') - Construct a SequenceMatcher. - - set_seqs(a, b) - Set the two sequences to be compared. - - set_seq1(a) - Set the first sequence to be compared. - - set_seq2(b) - Set the second sequence to be compared. - - find_longest_match(alo=0, ahi=None, blo=0, bhi=None) - Find longest matching block in a[alo:ahi] and b[blo:bhi]. - - get_matching_blocks() - Return list of triples describing matching subsequences. - - get_opcodes() - Return list of 5-tuples describing how to turn a into b. - - ratio() - Return a measure of the sequences' similarity (float in [0,1]). - - quick_ratio() - Return an upper bound on .ratio() relatively quickly. - - real_quick_ratio() - Return an upper bound on ratio() very quickly. """ def __init__(self, isjunk=None, a='', b='', autojunk=True): @@ -837,14 +805,6 @@ class Differ: + 4. Complicated is better than complex. ? ++++ ^ ^ + 5. Flat is better than nested. - - Methods: - - __init__(linejunk=None, charjunk=None) - Construct a text differencer, with optional filters. - - compare(a, b) - Compare two sequences of lines; generate the resulting delta. """ def __init__(self, linejunk=None, charjunk=None): diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py index b5ef143e..4c47f2ed 100644 --- a/Lib/distutils/ccompiler.py +++ b/Lib/distutils/ccompiler.py @@ -392,7 +392,7 @@ class CCompiler: return output_dir, macros, include_dirs def _prep_compile(self, sources, output_dir, depends=None): - """Decide which souce files must be recompiled. + """Decide which source files must be recompiled. Determine the list of object files corresponding to 'sources', and figure out which ones really need to be recompiled. diff --git a/Lib/distutils/command/check.py b/Lib/distutils/command/check.py index ada25006..73a30f3a 100644 --- a/Lib/distutils/command/check.py +++ b/Lib/distutils/command/check.py @@ -83,7 +83,7 @@ class check(Command): name, version, URL Recommended fields: - (author and author_email) or (maintainer and maintainer_email)) + (author and author_email) or (maintainer and maintainer_email) Warns if any are missing. """ diff --git a/Lib/distutils/msvc9compiler.py b/Lib/distutils/msvc9compiler.py index 6934e964..a7976fbe 100644 --- a/Lib/distutils/msvc9compiler.py +++ b/Lib/distutils/msvc9compiler.py @@ -673,7 +673,7 @@ class MSVCCompiler(CCompiler) : # If a manifest should be embedded, return a tuple of # (manifest_filename, resource_id). Returns None if no manifest # should be embedded. See http://bugs.python.org/issue7833 for why - # we want to avoid any manifest for extension modules if we can) + # we want to avoid any manifest for extension modules if we can. for arg in ld_args: if arg.startswith("/MANIFESTFILE:"): temp_manifest = arg.split(":", 1)[1] diff --git a/Lib/distutils/tests/test_bdist_rpm.py b/Lib/distutils/tests/test_bdist_rpm.py index 6453a02b..ba4382fb 100644 --- a/Lib/distutils/tests/test_bdist_rpm.py +++ b/Lib/distutils/tests/test_bdist_rpm.py @@ -44,7 +44,7 @@ class BuildRpmTestCase(support.TempdirManager, # spurious sdtout/stderr output under Mac OS X @unittest.skipUnless(sys.platform.startswith('linux'), 'spurious sdtout/stderr output under Mac OS X') - @requires_zlib + @requires_zlib() @unittest.skipIf(find_executable('rpm') is None, 'the rpm command is not found') @unittest.skipIf(find_executable('rpmbuild') is None, @@ -87,7 +87,7 @@ class BuildRpmTestCase(support.TempdirManager, # spurious sdtout/stderr output under Mac OS X @unittest.skipUnless(sys.platform.startswith('linux'), 'spurious sdtout/stderr output under Mac OS X') - @requires_zlib + @requires_zlib() # http://bugs.python.org/issue1533164 @unittest.skipIf(find_executable('rpm') is None, 'the rpm command is not found') diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py index f0792de7..d00c4898 100644 --- a/Lib/distutils/unixccompiler.py +++ b/Lib/distutils/unixccompiler.py @@ -215,7 +215,8 @@ class UnixCCompiler(CCompiler): return "-L" + dir def _is_gcc(self, compiler_name): - return "gcc" in compiler_name or "g++" in compiler_name + # clang uses same syntax for rpath as gcc + return any(name in compiler_name for name in ("gcc", "g++", "clang")) def runtime_library_dir_option(self, dir): # XXX Hackish, at the very least. See Python bug #445902: diff --git a/Lib/doctest.py b/Lib/doctest.py index baa503c8..d2c8828e 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -1022,10 +1022,8 @@ class DocTestFinder: if inspect.isclass(obj) and self._recurse: for valname, val in obj.__dict__.items(): # Special handling for staticmethod/classmethod. - if isinstance(val, staticmethod): - val = getattr(obj, valname) - if isinstance(val, classmethod): - val = getattr(obj, valname).__func__ + if isinstance(val, (staticmethod, classmethod)): + val = val.__func__ # Recurse to methods, properties, and nested classes. if ((inspect.isroutine(val) or inspect.isclass(val) or diff --git a/Lib/email/_parseaddr.py b/Lib/email/_parseaddr.py index 178329fb..c5a7b231 100644 --- a/Lib/email/_parseaddr.py +++ b/Lib/email/_parseaddr.py @@ -128,6 +128,8 @@ def _parsedate_tz(data): tss = 0 elif len(tm) == 3: [thh, tmm, tss] = tm + else: + return None else: return None try: diff --git a/Lib/email/contentmanager.py b/Lib/email/contentmanager.py index 3cf62dc8..fcf278db 100644 --- a/Lib/email/contentmanager.py +++ b/Lib/email/contentmanager.py @@ -144,7 +144,7 @@ def _encode_text(string, charset, cte, policy): linesep = policy.linesep.encode('ascii') def embedded_body(lines): return linesep.join(lines) + linesep def normal_body(lines): return b'\n'.join(lines) + b'\n' - if cte==None: + if cte is None: # Use heuristics to decide on the "best" encoding. if max((len(x) for x in lines), default=0) <= policy.max_line_length: try: diff --git a/Lib/encodings/raw_unicode_escape.py b/Lib/encodings/raw_unicode_escape.py index 2b919b40..46c8e070 100644 --- a/Lib/encodings/raw_unicode_escape.py +++ b/Lib/encodings/raw_unicode_escape.py @@ -21,15 +21,16 @@ class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input, final=False): return codecs.raw_unicode_escape_encode(input, self.errors)[0] -class IncrementalDecoder(codecs.IncrementalDecoder): - def decode(self, input, final=False): - return codecs.raw_unicode_escape_decode(input, self.errors)[0] +class IncrementalDecoder(codecs.BufferedIncrementalDecoder): + def _buffer_decode(self, input, errors, final): + return codecs.raw_unicode_escape_decode(input, errors, final) class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): - pass + def decode(self, input, errors='strict'): + return codecs.raw_unicode_escape_decode(input, errors, False) ### encodings module API diff --git a/Lib/encodings/unicode_escape.py b/Lib/encodings/unicode_escape.py index 817f9326..9b1ce99b 100644 --- a/Lib/encodings/unicode_escape.py +++ b/Lib/encodings/unicode_escape.py @@ -21,15 +21,16 @@ class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input, final=False): return codecs.unicode_escape_encode(input, self.errors)[0] -class IncrementalDecoder(codecs.IncrementalDecoder): - def decode(self, input, final=False): - return codecs.unicode_escape_decode(input, self.errors)[0] +class IncrementalDecoder(codecs.BufferedIncrementalDecoder): + def _buffer_decode(self, input, errors, final): + return codecs.unicode_escape_decode(input, errors, final) class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): - pass + def decode(self, input, errors='strict'): + return codecs.unicode_escape_decode(input, errors, False) ### encodings module API diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py index 7b03970c..2a140a26 100644 --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -11,12 +11,8 @@ from . import _bundled __all__ = ["version", "bootstrap"] - - -_SETUPTOOLS_VERSION = "57.4.0" - -_PIP_VERSION = "21.2.3" - +_SETUPTOOLS_VERSION = "58.1.0" +_PIP_VERSION = "21.2.4" _PROJECTS = [ ("setuptools", _SETUPTOOLS_VERSION, "py3"), ("pip", _PIP_VERSION, "py3"), diff --git a/Lib/ensurepip/_bundled/pip-21.2.3-py3-none-any.whl b/Lib/ensurepip/_bundled/pip-21.2.3-py3-none-any.whl deleted file mode 100644 index d417df63..00000000 Binary files a/Lib/ensurepip/_bundled/pip-21.2.3-py3-none-any.whl and /dev/null differ diff --git a/Lib/ensurepip/_bundled/pip-21.2.4-py3-none-any.whl b/Lib/ensurepip/_bundled/pip-21.2.4-py3-none-any.whl new file mode 100644 index 00000000..46d3012c Binary files /dev/null and b/Lib/ensurepip/_bundled/pip-21.2.4-py3-none-any.whl differ diff --git a/Lib/ensurepip/_bundled/setuptools-57.4.0-py3-none-any.whl b/Lib/ensurepip/_bundled/setuptools-57.4.0-py3-none-any.whl deleted file mode 100644 index af8f8ba2..00000000 Binary files a/Lib/ensurepip/_bundled/setuptools-57.4.0-py3-none-any.whl and /dev/null differ diff --git a/Lib/ensurepip/_bundled/setuptools-58.1.0-py3-none-any.whl b/Lib/ensurepip/_bundled/setuptools-58.1.0-py3-none-any.whl new file mode 100644 index 00000000..18c8c229 Binary files /dev/null and b/Lib/ensurepip/_bundled/setuptools-58.1.0-py3-none-any.whl differ diff --git a/Lib/functools.py b/Lib/functools.py index 97744a86..1a290e1c 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -901,11 +901,24 @@ class singledispatchmethod: self.dispatcher = singledispatch(func) self.func = func + # bpo-45678: special-casing for classmethod/staticmethod in Python <=3.9, + # as functools.update_wrapper doesn't work properly in singledispatchmethod.__get__ + # if it is applied to an unbound classmethod/staticmethod + if isinstance(func, (staticmethod, classmethod)): + self._wrapped_func = func.__func__ + else: + self._wrapped_func = func def register(self, cls, method=None): """generic_method.register(cls, func) -> func Registers a new implementation for the given *cls* on a *generic_method*. """ + # bpo-39679: in Python <= 3.9, classmethods and staticmethods don't + # inherit __annotations__ of the wrapped function (fixed in 3.10+ as + # a side-effect of bpo-43682) but we need that for annotation-derived + # singledispatches. So we add that just-in-time here. + if isinstance(cls, (staticmethod, classmethod)): + cls.__annotations__ = getattr(cls.__func__, '__annotations__', {}) return self.dispatcher.register(cls, func=method) def __get__(self, obj, cls=None): @@ -915,7 +928,7 @@ class singledispatchmethod: _method.__isabstractmethod__ = self.__isabstractmethod__ _method.register = self.register - update_wrapper(_method, self.func) + update_wrapper(_method, self._wrapped_func) return _method @property diff --git a/Lib/graphlib.py b/Lib/graphlib.py index d0e7a481..1c5d9a41 100644 --- a/Lib/graphlib.py +++ b/Lib/graphlib.py @@ -17,7 +17,7 @@ class _NodeInfo: self.npredecessors = 0 # List of successor nodes. The list can contain duplicated elements as - # long as they're all reflected in the successor's npredecessors attribute). + # long as they're all reflected in the successor's npredecessors attribute. self.successors = [] diff --git a/Lib/html/parser.py b/Lib/html/parser.py index 9e49effc..58f6bb3b 100644 --- a/Lib/html/parser.py +++ b/Lib/html/parser.py @@ -405,7 +405,7 @@ class HTMLParser(_markupbase.ParserBase): tagname = namematch.group(1).lower() # consume and ignore other stuff between the name and the > # Note: this is not 100% correct, since we might have things like - # , but looking for > after tha name should cover + # , but looking for > after the name should cover # most of the cases and is much simpler gtpos = rawdata.find('>', namematch.end()) self.handle_endtag(tagname) diff --git a/Lib/http/client.py b/Lib/http/client.py index 0fd9021b..a98432e5 100644 --- a/Lib/http/client.py +++ b/Lib/http/client.py @@ -70,6 +70,7 @@ Req-sent-unread-response _CS_REQ_SENT import email.parser import email.message +import errno import http import io import re @@ -944,7 +945,12 @@ class HTTPConnection: """Connect to the host and port specified in __init__.""" self.sock = self._create_connection( (self.host,self.port), self.timeout, self.source_address) - self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) + # Might fail in OSs that don't implement TCP_NODELAY + try: + self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) + except OSError as e: + if e.errno != errno.ENOPROTOOPT: + raise if self._tunnel_host: self._tunnel() diff --git a/Lib/idlelib/ChangeLog b/Lib/idlelib/ChangeLog index d7d7e1ef..c8960cfa 100644 --- a/Lib/idlelib/ChangeLog +++ b/Lib/idlelib/ChangeLog @@ -1175,7 +1175,7 @@ Wed Mar 10 05:18:02 1999 Guido van Rossum classes in selected module methods of selected class - Sinlge clicking in a directory, module or class item updates the next + Single clicking in a directory, module or class item updates the next column with info about the selected item. Double clicking in a module, class or method item opens the file (and selects the clicked item if it is a class or method). diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html index 3f87e89f..edc539cd 100644 --- a/Lib/idlelib/help.html +++ b/Lib/idlelib/help.html @@ -24,7 +24,7 @@ - + @@ -59,7 +59,7 @@ modules |

  • - next |
  • -

    Completion boxes intially exclude names beginning with ‘_’ or, for +

    Completion boxes initially exclude names beginning with ‘_’ or, for modules, not included in ‘__all__’. The hidden names can be accessed by typing ‘_’ after ‘.’, either before or after the box is opened.

    @@ -932,8 +932,8 @@ also used for testing.

    tkinter.tix — Extension widgets for Tk

    Next topic

    -

    Other Graphical User Interface Packages

    +

    Development Tools

    This Page

      @@ -959,7 +959,7 @@ also used for testing.

      modules |
    • - next |