Skip to content

Commit

Permalink
Merge branch 'main' into num-areidentical-mixin-121039
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev authored Jun 28, 2024
2 parents 2a2f9af + 1a2e7a7 commit 0a1901d
Show file tree
Hide file tree
Showing 63 changed files with 713 additions and 294 deletions.
4 changes: 2 additions & 2 deletions Doc/howto/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ Logging Flow
The flow of log event information in loggers and handlers is illustrated in the
following diagram.

.. image:: logging_flow.png
:class: invert-in-dark-mode
.. raw:: html
:file: logging_flow.svg

Loggers
^^^^^^^
Expand Down
Binary file modified Doc/howto/logging_flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
281 changes: 281 additions & 0 deletions Doc/howto/logging_flow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
180 changes: 89 additions & 91 deletions Doc/library/pprint.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,52 +35,85 @@ Dictionaries are sorted by key before the display is computed.
Functions
---------

.. function:: pp(object, *args, sort_dicts=False, **kwargs)

Prints the formatted representation of *object* followed by a newline.
If *sort_dicts* is false (the default), dictionaries will be displayed with
their keys in insertion order, otherwise the dict keys will be sorted.
*args* and *kwargs* will be passed to :func:`~pprint.pprint` as formatting
parameters.

>>> import pprint
>>> stuff = ['spam', 'eggs', 'lumberjack', 'knights', 'ni']
>>> stuff.insert(0, stuff)
>>> pprint.pp(stuff)
[<Recursion on list with id=...>,
'spam',
'eggs',
'lumberjack',
'knights',
'ni']
.. function:: pp(object, stream=None, indent=1, width=80, depth=None, *, \
compact=False, sort_dicts=False, underscore_numbers=False)

Prints the formatted representation of *object*, followed by a newline.
This function may be used in the interactive interpreter
instead of the :func:`print` function for inspecting values.
Tip: you can reassign ``print = pprint.pp`` for use within a scope.

:param object:
The object to be printed.

:param stream:
A file-like object to which the output will be written
by calling its :meth:`!write` method.
If ``None`` (the default), :data:`sys.stdout` is used.
:type stream: :term:`file-like object` | None

:param int indent:
The amount of indentation added for each nesting level.

:param int width:
The desired maximum number of characters per line in the output.
If a structure cannot be formatted within the width constraint,
a best effort will be made.

:param depth:
The number of nesting levels which may be printed.
If the data structure being printed is too deep,
the next contained level is replaced by ``...``.
If ``None`` (the default), there is no constraint
on the depth of the objects being formatted.
:type depth: int | None

:param bool compact:
Control the way long :term:`sequences <sequence>` are formatted.
If ``False`` (the default),
each item of a sequence will be formatted on a separate line,
otherwise as many items as will fit within the *width*
will be formatted on each output line.

:param bool sort_dicts:
If ``True``, dictionaries will be formatted with
their keys sorted, otherwise
they will be displayed in insertion order (the default).

:param bool underscore_numbers:
If ``True``,
integers will be formatted with the ``_`` character for a thousands separator,
otherwise underscores are not displayed (the default).

>>> import pprint
>>> stuff = ['spam', 'eggs', 'lumberjack', 'knights', 'ni']
>>> stuff.insert(0, stuff)
>>> pprint.pp(stuff)
[<Recursion on list with id=...>,
'spam',
'eggs',
'lumberjack',
'knights',
'ni']

.. versionadded:: 3.8


.. function:: pprint(object, stream=None, indent=1, width=80, depth=None, *, \
compact=False, sort_dicts=True, underscore_numbers=False)

Prints the formatted representation of *object* on *stream*, followed by a
newline. If *stream* is ``None``, :data:`sys.stdout` is used. This may be used
in the interactive interpreter instead of the :func:`print` function for
inspecting values (you can even reassign ``print = pprint.pprint`` for use
within a scope).

The configuration parameters *stream*, *indent*, *width*, *depth*,
*compact*, *sort_dicts* and *underscore_numbers* are passed to the
:class:`PrettyPrinter` constructor and their meanings are as
described in its documentation below.
Alias for :func:`~pprint.pp` with *sort_dicts* set to ``True`` by default,
which would automatically sort the dictionaries' keys,
you might want to use :func:`~pprint.pp` instead where it is ``False`` by default.

Note that *sort_dicts* is ``True`` by default and you might want to use
:func:`~pprint.pp` instead where it is ``False`` by default.

.. function:: pformat(object, indent=1, width=80, depth=None, *, \
compact=False, sort_dicts=True, underscore_numbers=False)

Return the formatted representation of *object* as a string. *indent*,
*width*, *depth*, *compact*, *sort_dicts* and *underscore_numbers* are
passed to the :class:`PrettyPrinter` constructor as formatting parameters
and their meanings are as described in its documentation below.
and their meanings are as described in the documentation above.


.. function:: isreadable(object)
Expand Down Expand Up @@ -119,51 +152,39 @@ Functions
PrettyPrinter Objects
---------------------

This module defines one class:

.. First the implementation class:
.. index:: single: ...; placeholder

.. class:: PrettyPrinter(indent=1, width=80, depth=None, stream=None, *, \
compact=False, sort_dicts=True, underscore_numbers=False)

Construct a :class:`PrettyPrinter` instance. This constructor understands
several keyword parameters.

*stream* (default :data:`!sys.stdout`) is a :term:`file-like object` to
which the output will be written by calling its :meth:`!write` method.
If both *stream* and :data:`!sys.stdout` are ``None``, then
:meth:`~PrettyPrinter.pprint` silently returns.
Construct a :class:`PrettyPrinter` instance.

Other values configure the manner in which nesting of complex data
structures is displayed.
Arguments have the same meaning as for :func:`~pprint.pp`.
Note that they are in a different order, and that *sort_dicts* defaults to ``True``.

*indent* (default 1) specifies the amount of indentation added for
each nesting level.

*depth* controls the number of nesting levels which may be printed; if
the data structure being printed is too deep, the next contained level
is replaced by ``...``. By default, there is no constraint on the
depth of the objects being formatted.

*width* (default 80) specifies the desired maximum number of characters per
line in the output. If a structure cannot be formatted within the width
constraint, a best effort will be made.

*compact* impacts the way that long sequences (lists, tuples, sets, etc)
are formatted. If *compact* is false (the default) then each item of a
sequence will be formatted on a separate line. If *compact* is true, as
many items as will fit within the *width* will be formatted on each output
line.

If *sort_dicts* is true (the default), dictionaries will be formatted with
their keys sorted, otherwise they will display in insertion order.
>>> import pprint
>>> stuff = ['spam', 'eggs', 'lumberjack', 'knights', 'ni']
>>> stuff.insert(0, stuff[:])
>>> pp = pprint.PrettyPrinter(indent=4)
>>> pp.pprint(stuff)
[ ['spam', 'eggs', 'lumberjack', 'knights', 'ni'],
'spam',
'eggs',
'lumberjack',
'knights',
'ni']
>>> pp = pprint.PrettyPrinter(width=41, compact=True)
>>> pp.pprint(stuff)
[['spam', 'eggs', 'lumberjack',
'knights', 'ni'],
'spam', 'eggs', 'lumberjack', 'knights',
'ni']
>>> tup = ('spam', ('eggs', ('lumberjack', ('knights', ('ni', ('dead',
... ('parrot', ('fresh fruit',))))))))
>>> pp = pprint.PrettyPrinter(depth=6)
>>> pp.pprint(tup)
('spam', ('eggs', ('lumberjack', ('knights', ('ni', ('dead', (...)))))))

If *underscore_numbers* is true, integers will be formatted with the
``_`` character for a thousands separator, otherwise underscores are not
displayed (the default).

.. versionchanged:: 3.4
Added the *compact* parameter.
Expand All @@ -177,29 +198,6 @@ This module defines one class:
.. versionchanged:: 3.11
No longer attempts to write to :data:`!sys.stdout` if it is ``None``.

>>> import pprint
>>> stuff = ['spam', 'eggs', 'lumberjack', 'knights', 'ni']
>>> stuff.insert(0, stuff[:])
>>> pp = pprint.PrettyPrinter(indent=4)
>>> pp.pprint(stuff)
[ ['spam', 'eggs', 'lumberjack', 'knights', 'ni'],
'spam',
'eggs',
'lumberjack',
'knights',
'ni']
>>> pp = pprint.PrettyPrinter(width=41, compact=True)
>>> pp.pprint(stuff)
[['spam', 'eggs', 'lumberjack',
'knights', 'ni'],
'spam', 'eggs', 'lumberjack', 'knights',
'ni']
>>> tup = ('spam', ('eggs', ('lumberjack', ('knights', ('ni', ('dead',
... ('parrot', ('fresh fruit',))))))))
>>> pp = pprint.PrettyPrinter(depth=6)
>>> pp.pprint(tup)
('spam', ('eggs', ('lumberjack', ('knights', ('ni', ('dead', (...)))))))


:class:`PrettyPrinter` instances have the following methods:

Expand Down
6 changes: 6 additions & 0 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2262,6 +2262,12 @@ Changes in the Python API
returned by :meth:`zipfile.ZipFile.open` was changed from ``'r'`` to ``'rb'``.
(Contributed by Serhiy Storchaka in :gh:`115961`.)

* :class:`functools.partial` now emits a :exc:`FutureWarning` when it is
used as a method.
Its behavior will be changed in future Python versions.
Wrap it in :func:`staticmethod` if you want to preserve the old behavior.
(Contributed by Serhiy Storchaka in :gh:`121027`.)

.. _pep667-porting-notes-py:

* Calling :func:`locals` in an :term:`optimized scope` now produces an
Expand Down
5 changes: 1 addition & 4 deletions Include/exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@
* we may still need to support gcc >= 4, as some Ubuntu LTS and Centos versions
* have 4 < gcc < 5.
*/
#ifndef __has_attribute
#define __has_attribute(x) 0 // Compatibility with non-clang compilers.
#endif
#if (defined(__GNUC__) && (__GNUC__ >= 4)) ||\
(defined(__clang__) && __has_attribute(visibility))
(defined(__clang__) && _Py__has_attribute(visibility))
#define Py_IMPORTED_SYMBOL __attribute__ ((visibility ("default")))
#define Py_EXPORTED_SYMBOL __attribute__ ((visibility ("default")))
#define Py_LOCAL_SYMBOL __attribute__ ((visibility ("hidden")))
Expand Down
1 change: 0 additions & 1 deletion Include/internal/pycore_call.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ extern "C" {
# error "this header requires Py_BUILD_CORE define"
#endif

#include "pycore_identifier.h" // _Py_Identifier
#include "pycore_pystate.h" // _PyThreadState_GET()

/* Suggested size (number of positional arguments) for arrays of PyObject*
Expand Down
1 change: 0 additions & 1 deletion Include/internal/pycore_dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ extern "C" {
#endif

#include "pycore_freelist.h" // _PyFreeListState
#include "pycore_identifier.h" // _Py_Identifier
#include "pycore_object.h" // PyManagedDictPointer
#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_LOAD_SSIZE_ACQUIRE

Expand Down
20 changes: 0 additions & 20 deletions Include/internal/pycore_identifier.h

This file was deleted.

1 change: 0 additions & 1 deletion Include/internal/pycore_unicodeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ extern "C" {

#include "pycore_lock.h" // PyMutex
#include "pycore_fileutils.h" // _Py_error_handler
#include "pycore_identifier.h" // _Py_Identifier
#include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI
#include "pycore_global_objects.h" // _Py_SINGLETON

Expand Down
45 changes: 35 additions & 10 deletions Include/pyport.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@
#endif


// Preprocessor check for a builtin preprocessor function. Always return 0
// if __has_builtin() macro is not defined.
//
// __has_builtin() is available on clang and GCC 10.
#ifdef __has_builtin
# define _Py__has_builtin(x) __has_builtin(x)
#else
# define _Py__has_builtin(x) 0
#endif

// Preprocessor check for a compiler __attribute__. Always return 0
// if __has_attribute() macro is not defined.
#ifdef __has_attribute
# define _Py__has_attribute(x) __has_attribute(x)
#else
# define _Py__has_attribute(x) 0
#endif

// Macro to use C++ static_cast<> in the Python C API.
#ifdef __cplusplus
# define _Py_STATIC_CAST(type, expr) static_cast<type>(expr)
Expand Down Expand Up @@ -532,16 +550,6 @@ extern "C" {
#endif


// Preprocessor check for a builtin preprocessor function. Always return 0
// if __has_builtin() macro is not defined.
//
// __has_builtin() is available on clang and GCC 10.
#ifdef __has_builtin
# define _Py__has_builtin(x) __has_builtin(x)
#else
# define _Py__has_builtin(x) 0
#endif

// _Py_TYPEOF(expr) gets the type of an expression.
//
// Example: _Py_TYPEOF(x) x_copy = (x);
Expand Down Expand Up @@ -607,4 +615,21 @@ extern "C" {
# define _SGI_MP_SOURCE
#endif

// Explicit fallthrough in switch case to avoid warnings
// with compiler flag -Wimplicit-fallthrough.
//
// Usage example:
//
// switch (value) {
// case 1: _Py_FALLTHROUGH;
// case 2: code; break;
// }
//
// __attribute__((fallthrough)) was introduced in GCC 7.
#if _Py__has_attribute(fallthrough)
# define _Py_FALLTHROUGH __attribute__((fallthrough))
#else
# define _Py_FALLTHROUGH do { } while (0)
#endif

#endif /* Py_PYPORT_H */
2 changes: 1 addition & 1 deletion Lib/ensurepip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


__all__ = ["version", "bootstrap"]
_PIP_VERSION = "24.0"
_PIP_VERSION = "24.1.1"

# Directory of system wheel packages. Some Linux distribution packaging
# policies recommend against bundling dependencies. For example, Fedora
Expand Down
Binary file removed Lib/ensurepip/_bundled/pip-24.0-py3-none-any.whl
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 0a1901d

Please sign in to comment.