Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
c88d972
Build print output before writing to the stream
methane Nov 6, 2026
649822b
Optimize print() with TextIOWrapper string list writes
methane Nov 13, 2026
d5def80
gh-161934: Document batched print writes
methane Nov 13, 2026
f0fa0a2
gh-161934: Preallocate print output parts
methane Nov 14, 2026
2410f05
Merge remote-tracking branch 'upstream/main' into codex/textio-print2
methane Nov 16, 2026
ea678b2
gh-162034: Quote the utils.sh path in the Apple testbed build phase (…
fametrano Nov 16, 2026
91ab655
Add a documentation URL field to the docs issue template (#162086)
deadlovelll Nov 16, 2026
585755d
gh-149584: _remote_debugging: Simplify asyncio result construction (G…
maurycy Nov 16, 2026
6f049d3
gh-149584: _remote_debugging: Deduplicate AwaitedInfo construction (G…
maurycy Nov 16, 2026
812bd87
gh-149584: _remote_debugging: Simplify page cache state (GH-162094)
maurycy Nov 16, 2026
bd1e9af
gh-149584: _remote_debugging: Deduplicate frame parsing (GH-162105)
maurycy Nov 16, 2026
be3dfe5
_remote_debugging: Use PyBytesWriter in read_py_bytes() (GH-162110)
maurycy Nov 16, 2026
f4c13c8
gh-162092: Fix test_check_interned() of test_capi (#162099)
vstinner Nov 16, 2026
5e18bfc
gh-162028: Fix the pure Python JSON decoder error position for invali…
thejesh23 Nov 16, 2026
910a92b
gh-110891: Document `PyType_GetDict` as returning a new reference (GH…
kirtiagwl1595 Nov 16, 2026
6903425
Add a `this` module doc, with an In Memoriam links (#161925)
warsaw Nov 17, 2026
b90572a
gh-161996: Fix crash in `Interpreter.exec` when the uncaught exceptio…
aisk Nov 17, 2026
4497fe9
gh-161792: Fix crashes in the callable iterator on free-threading (#1…
nascheme Nov 17, 2026
c7fef83
Docs: update OpenSSL cipher list format URL (#162155)
romuald Nov 17, 2026
aedb2c1
gh-158414: Fix hang when writing incomplete UTF-8 sequence to Windows…
aisk Nov 17, 2026
c885978
gh-116245: Document `getentropy()` use in `os.urandom()` (#162108)
kirtiagwl1595 Nov 17, 2026
e28063e
gh-162144: Skip `@nomemtest` tests when using a thread sanitizer (TSa…
vstinner Nov 17, 2026
715d34f
gh-162170: Makefile: have "install" depend on pgo (#95287)
kmod Nov 17, 2026
3ad9316
gh-162034: Quote paths in the Apple testbed's utils.sh (#162161)
fametrano Nov 17, 2026
9427640
Improve PyManager documentation around tag matching (GH-161940)
zooba Nov 18, 2026
f5ec90d
gh-103484: Remove an outdated footnote in the `unittest.mock` example…
farisbasha Nov 18, 2026
b219e55
Correct `DynamicClassAttribute` from function to class in types docs …
tanloong Nov 18, 2026
0d5e2ed
gh-161767: Fix crash in `PyDict_AsFrozenDictAndClear` on `embedded` v…
sobolevn Nov 18, 2026
117ff5a
gh-159207: Store Tachyon samples in bounded columnar blocks (GH-160313)
ivonastojanovic Nov 18, 2026
4b8e534
gh-157695: Rename HAVE_GETDENTS64 to _Py_HAVE_GETDENTS64 (#162184)
vstinner Nov 18, 2026
aa17c68
gh-157579: Fix TemporaryDirectory cleanup fallbacks with bytes paths …
encukou Nov 18, 2026
b107dc2
gh-161660: Fix `test_json` with `PYTHON_LAZY_IMPORTS=all` (#161866)
sobolevn Nov 18, 2026
355486e
gh-149584: Read remote stack chunks without the page cache (GH-160888)
maurycy Nov 18, 2026
e59260b
gh-100687: Reduce frequency of overallocation in `x_add()` (#158002)
eendebakpt Nov 18, 2026
ddd88c7
Replace stale signature lines in `getopt` docstrings with summaries (…
farisbasha Nov 18, 2026
59a7a46
gh-162214: Test Py_GIL_DISABLED macro using #ifdef (#162223)
vstinner Nov 18, 2026
fce90ca
gh-162214: Test Py_STATS macro using #ifdef (#162225)
vstinner Nov 18, 2026
d7d41e2
gh-162214: Use #ifdef to test USING_APPLE_OS_LIBFFI macro in ctypes.h…
vstinner Nov 18, 2026
fb9330b
gh-136267: Use the target configuration in build-details.json (#161529)
itamaro Nov 18, 2026
32197d8
gh-162214: Define TARGET_OS_OSX macro in Modules/_testcapi/mem.c (#16…
vstinner Nov 18, 2026
f3c11aa
gh-162214: Define STRINGLIB_IS_UNICODE macro in bytes_methods.c (#162…
vstinner Nov 18, 2026
abbfbce
gh-162182: Fix c-analyzer on static_assert containing a comma (#162186)
cmaloney Nov 18, 2026
94250a7
gh-157695: Make HAVE_RL_CHANGE_ENVIRONMENT macro private (#162213)
vstinner Nov 18, 2026
391c7d7
Update Emscripten libffi to 3.8.1 (#162188)
agriyakhetarpal Nov 19, 2026
9e181c4
gh-160873: Remove obsolete Emscripten workarounds (#162192)
lpyu001 Nov 19, 2026
aced381
gh-161767: Fix refleak in PyDict_AsFrozenDictAndClear() (#162250)
vstinner Nov 19, 2026
6c9f2b6
gh-149584: Stop rereading the base frame sentinel in _remote_debuggin…
maurycy Nov 19, 2026
441c010
gh-162230: Relay `BufferedRWPair.readline()` to the reader (#162231)
maurycy Nov 19, 2026
9f205da
gh-129813: Use `PyBytesWriter` for strided mmap slices (#162257)
maurycy Nov 19, 2026
3edcc34
gh-129813: Use `PyBytesWriter` in `ctypes` (#162260)
maurycy Nov 19, 2026
03e7a88
gh-129813: Use `PyBytesWriter` in `binascii` (#162259)
maurycy Nov 19, 2026
4cfa012
gh-157227: Remove dead integer-location handling from sampling collec…
maurycy Nov 19, 2026
484bc16
gh-161751: Fix race in mimalloc abandoned segment visit (gh-162003)
corona10 Nov 19, 2026
b9f1d8a
Centralize print string joining
methane Nov 19, 2026
052deb5
Clarify that print does not guarantee atomic writes
methane Nov 19, 2026
2434c39
Untrack print parts
methane Nov 19, 2026
b0ccebc
Doc: Correct logging HOWTO and cookbook (GH-162198)
methane Nov 19, 2026
0b5e26c
gh-157695: Make HAVE_CURSES_xxx macros private (#162212)
vstinner Nov 19, 2026
53f4cad
Display test header when running python -m test --tsan (#162249)
vstinner Nov 19, 2026
562f08d
gh-143663: Perform path normalization in TarFile.extractall() (GH-143…
0xd6cb6d73 Nov 19, 2026
ec912e7
gh-162031: Return None from readinto() on non-blocking streams with n…
cmaloney Nov 19, 2026
f15999d
gh-161875: Push NULL and None in GET_AWAITABLE (#161876)
asvetlov Nov 19, 2026
d456158
Docs: fix typo in `TracebackException.__notes__` description (#162290)
simonnelse Nov 19, 2026
865d8d8
gh-161875: Push NULL and None in GET_ANEXT (#161877)
asvetlov Nov 19, 2026
6957e70
gh-129813: Use PyBytesWriter in _testbuffer (#162297)
vstinner Nov 19, 2026
f84083b
Fix regrtest rerun: reset worker_bug (#162293)
vstinner Nov 19, 2026
b09a7e9
gh-136267: Read the target version from patchlevel.h in build-details…
itamaro Nov 20, 2026
c0f3fcf
gh-160978: Return the same ctypes array type when created concurrentl…
thalesmourabh Nov 20, 2026
6f34060
gh-161184: Use a managed dict and weakref list for the io types (#161…
eendebakpt Nov 20, 2026
8dbf4cf
gh-159580: Improve performance of isinstance() for misses and improve…
eendebakpt Nov 20, 2026
609599d
gh-161934: Simplify tests for single-write print()
methane Nov 20, 2026
a9758d1
Merge remote-tracking branch 'upstream/main' into codex/textio-print2
methane Nov 20, 2026
a519cb7
gh-161934: Check for TextIOWrapper.write overrides with managed dicts
methane Nov 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/ISSUE_TEMPLATE/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ body:
value: |
> [!NOTE]
> Trivial changes (for example typos) don’t require an issue before opening a PR.
- type: input
id: url
attributes:
label: "Documentation URL"
description: "A link to the relevant documentation page, if applicable."
placeholder: "https://docs.python.org/3/..."
- type: textarea
id: description
attributes:
label: "Documentation"
description: "A clear and concise description of the issue. Include a link to the page."
description: "A clear and concise description of the issue."
validations:
required: true
9 changes: 9 additions & 0 deletions Doc/builtins/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,11 @@ are always available. They are listed here in alphabetical order.
a :exc:`TypeError` exception is raised. :exc:`TypeError` may not be
raised for an invalid type if an earlier check succeeds.

If *object* has a ``__class__`` attribute that differs from
:func:`type(object) <type>` (for example a proxy, or a :mod:`unittest.mock`
object created with a *spec*), ``True`` is also returned when that class
is a subclass of *classinfo*.

.. versionchanged:: 3.10
*classinfo* can be a :ref:`types-union`.

Expand Down Expand Up @@ -1742,6 +1747,10 @@ are always available. They are listed here in alphabetical order.
.. versionchanged:: 3.3
Added the *flush* keyword argument.

.. versionchanged:: 3.16
The output is now written in a single ``write()`` call whenever possible,
instead of writing each argument, separator, and terminator separately.


.. class:: property(fget=None, fset=None, fdel=None, doc=None)

Expand Down
2 changes: 2 additions & 0 deletions Doc/c-api/dict.rst
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,8 @@ Dictionary objects
as an argument, prefer :c:func:`PyFrozenDict_New` to leave the source
intact.

Does not work for dicts with embedded values.

.. impl-detail::

Works with O(1) complexity.
Expand Down
3 changes: 3 additions & 0 deletions Doc/data/refcounts.dat
Original file line number Diff line number Diff line change
Expand Up @@ -2417,6 +2417,9 @@ PyType_GenericNew:PyObject*:type:0:
PyType_GenericNew:PyObject*:args:0:
PyType_GenericNew:PyObject*:kwds:0:

PyType_GetDict:PyObject*::+1:
PyType_GetDict:PyTypeObject*:type:0:

PyType_GetFlags:unsigned long:::
PyType_GetFlags:PyTypeObject*:type:0:

Expand Down
71 changes: 25 additions & 46 deletions Doc/howto/logging-cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,10 @@ Suppose you configure logging with the following JSON:
}
}

This configuration does *almost* what we want, except that ``sys.stdout`` would show messages
of severity ``ERROR`` and only events of this severity and higher will be tracked
as well as ``INFO`` and ``WARNING`` messages. To prevent this, we can set up a filter which
excludes those messages and add it to the relevant handler. This can be configured by
adding a ``filters`` section parallel to ``formatters`` and ``handlers``:
This configuration does *almost* what we want, except that ``sys.stdout`` would
also show messages of severity ``ERROR`` and above. To exclude those messages,
we can add a filter to the stdout handler. This can be configured by adding a
``filters`` section parallel to ``formatters`` and ``handlers``:

.. code-block:: json

Expand Down Expand Up @@ -562,9 +561,9 @@ One solution is to use a two-part approach. For the first part, attach only a
:class:`QueueHandler` to those loggers which are accessed from
performance-critical threads. They simply write to their queue, which can be
sized to a large enough capacity or initialized with no upper bound to their
size. The write to the queue will typically be accepted quickly, though you
will probably need to catch the :exc:`queue.Full` exception as a precaution
in your code. If you are a library developer who has performance-critical
size. The write to the queue will typically be accepted quickly. If a bounded
queue is full, :class:`QueueHandler` calls :meth:`~logging.Handler.handleError`
with the record. If you are a library developer who has performance-critical
threads in their code, be sure to document this (together with a suggestion to
attach only ``QueueHandlers`` to your loggers) for the benefit of other
developers who will use your code.
Expand Down Expand Up @@ -1608,8 +1607,8 @@ application:

The most current file is always :file:`logging_rotatingfile_example.out`,
and each time it reaches the size limit it is renamed with the suffix
``.1``. Each of the existing backup files is renamed to increment the suffix
(``.1`` becomes ``.2``, etc.) and the ``.6`` file is erased.
``.1``. Before this happens, the oldest backup (``.5``), if present, is
deleted and the remaining backups are renamed (``.4`` becomes ``.5``, etc.).

Obviously this example sets the log length much too small as an extreme
example. You would want to set *maxBytes* to an appropriate value.
Expand Down Expand Up @@ -1801,7 +1800,7 @@ Before Python 3.2, there were only two places where this creation was done:
* :func:`makeLogRecord`, which is called with a dictionary containing
attributes to be added to the LogRecord. This is typically invoked when a
suitable dictionary has been received over the network (e.g. in pickle form
via a :class:`~handlers.SocketHandler`, or in JSON form via an
via a :class:`~handlers.SocketHandler`, or as URL-encoded data via an
:class:`~handlers.HTTPHandler`).

This has usually meant that if you need to do anything special with a
Expand All @@ -1827,11 +1826,7 @@ do simply by adding new packages or modules and doing ::

logger = logging.getLogger(__name__)

at module level). It's probably one too many things to think about. Developers
could also add the filter to a :class:`~logging.NullHandler` attached to their
top-level logger, but this would not be invoked if an application developer
attached a handler to a lower-level library logger --- so output from that
handler would not reflect the intentions of the library developer.
at module level). It's probably one too many things to think about.

In Python 3.2 and later, :class:`~logging.LogRecord` creation is done through a
factory, which you can specify. The factory is just a callable you can set with
Expand Down Expand Up @@ -1913,15 +1908,15 @@ You can also subclass :class:`QueueListener` to get messages from other kinds
of queues, for example a ZeroMQ 'subscribe' socket. Here's an example::

class ZeroMQSocketListener(QueueListener):
def __init__(self, uri, /, *handlers, **kwargs):
self.ctx = kwargs.get('ctx') or zmq.Context()
def __init__(self, uri, /, *handlers, ctx=None, **kwargs):
self.ctx = ctx or zmq.Context()
socket = zmq.Socket(self.ctx, zmq.SUB)
socket.setsockopt_string(zmq.SUBSCRIBE, '') # subscribe to everything
socket.connect(uri)
super().__init__(socket, *handlers, **kwargs)

def dequeue(self):
msg = self.queue.recv_json()
def dequeue(self, block):
msg = self.queue.recv_json(flags=0 if block else zmq.NOBLOCK)
return logging.makeLogRecord(msg)

.. _pynng-handlers:
Expand Down Expand Up @@ -2245,7 +2240,7 @@ works::
import logging.config
import logging.handlers
from multiprocessing import Process, Queue, Event, current_process
import os
from multiprocessing import get_start_method
import random
import time

Expand Down Expand Up @@ -2281,13 +2276,8 @@ works::
logging.config.dictConfig(config)
listener = logging.handlers.QueueListener(q, MyHandler())
listener.start()
if os.name == 'posix':
# On POSIX, the setup logger will have been configured in the
# parent process, but should have been disabled following the
# dictConfig call.
# On Windows, since fork isn't used, the setup logger won't
# exist in the child, so it would be created and the message
# would appear - hence the "if posix" clause.
if get_start_method() == 'fork':
# dictConfig disables the setup logger inherited from the parent.
logger = logging.getLogger('setup')
logger.critical('Should not appear, because of disabled logger ...')
stop_event.wait()
Expand All @@ -2312,13 +2302,8 @@ works::
logging.CRITICAL]
loggers = ['foo', 'foo.bar', 'foo.bar.baz',
'spam', 'spam.ham', 'spam.ham.eggs']
if os.name == 'posix':
# On POSIX, the setup logger will have been configured in the
# parent process, but should have been disabled following the
# dictConfig call.
# On Windows, since fork isn't used, the setup logger won't
# exist in the child, so it would be created and the message
# would appear - hence the "if posix" clause.
if get_start_method() == 'fork':
# dictConfig disables the setup logger inherited from the parent.
logger = logging.getLogger('setup')
logger.critical('Should not appear, because of disabled logger ...')
for i in range(100):
Expand All @@ -2345,9 +2330,7 @@ works::
}
# The worker process configuration is just a QueueHandler attached to the
# root logger, which allows all messages to be sent to the queue.
# We disable existing loggers to disable the "setup" logger used in the
# parent process. This is needed on POSIX because the logger will
# be there in the child following a fork().
# Disable the parent's "setup" logger if it was inherited via fork.
config_worker = {
'version': 1,
'disable_existing_loggers': True,
Expand All @@ -2365,9 +2348,7 @@ works::
# The listener process configuration shows that the full flexibility of
# logging configuration is available to dispatch events to handlers however
# you want.
# We disable existing loggers to disable the "setup" logger used in the
# parent process. This is needed on POSIX because the logger will
# be there in the child following a fork().
# Disable the parent's "setup" logger if it was inherited via fork.
config_listener = {
'version': 1,
'disable_existing_loggers': True,
Expand Down Expand Up @@ -4077,11 +4058,9 @@ How to uniformly handle newlines in logging output

Usually, messages that are logged (say to console or file) consist of a single
line of text. However, sometimes there is a need to handle messages with
multiple lines - whether because a logging format string contains newlines, or
logged data contains newlines. If you want to handle such messages uniformly, so
that each line in the logged message appears uniformly formatted as if it was
logged separately, you can do this using a handler mixin, as in the following
snippet:
multiple lines because the message or its arguments contain newlines.
To format each line as if it were logged separately, you can use a handler
mixin, as in the following snippet:

.. code-block:: python

Expand Down
25 changes: 7 additions & 18 deletions Doc/howto/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,6 @@ interpreter, and don't just continue from the session described above::
logger.warning('And this, too')
logger.error('And non-ASCII stuff, too, like Øresund and Malmö')

.. versionchanged:: 3.9
The *encoding* argument was added. In earlier Python versions, or if not
specified, the encoding used is the default value used by :func:`open`. While
not shown in the above example, an *errors* argument can also now be passed,
which determines how encoding errors are handled. For available values and
the default, see the documentation for :func:`open`.

And now if we open the file and look at what we have, we should find the log
messages:

Expand Down Expand Up @@ -465,10 +458,9 @@ With the logger object configured, the following methods create log messages:
a message and a level that corresponds to their respective method names. The
message is actually a format string, which may contain the standard string
substitution syntax of ``%s``, ``%d``, ``%f``, and so on. The
rest of their arguments is a list of objects that correspond with the
substitution fields in the message. With regard to ``**kwargs``, the
logging methods care only about a keyword of ``exc_info`` and use it to
determine whether to log exception information.
remaining positional arguments correspond to the substitution fields in the
message. These methods also accept the keyword arguments *exc_info*, *extra*,
*stack_info*, and *stacklevel*, described in :meth:`Logger.debug`.

* :meth:`Logger.exception` creates a log message similar to
:meth:`Logger.error`. The difference is that :meth:`Logger.exception` dumps a
Expand Down Expand Up @@ -1006,9 +998,9 @@ Logged messages are formatted for presentation through instances of the
use with the % operator and a dictionary.

For formatting multiple messages in a batch, instances of
:class:`BufferingFormatter` can be used. In addition to the format
string (which is applied to each message in the batch), there is provision for
header and trailer format strings.
:class:`BufferingFormatter` can be used. A line formatter formats each record
in the batch. To add a header or footer, override
:meth:`~BufferingFormatter.formatHeader` or :meth:`~BufferingFormatter.formatFooter`.

When filtering based on logger level and/or handler level is not enough,
instances of :class:`Filter` can be added to both :class:`Logger` and
Expand Down Expand Up @@ -1059,10 +1051,7 @@ In the preceding sections and examples, it has been assumed that the message
passed when logging the event is a string. However, this is not the only
possibility. You can pass an arbitrary object as a message, and its
:meth:`~object.__str__` method will be called when the logging system needs to
convert it to a string representation. In fact, if you want to, you can avoid
computing a string representation altogether - for example, the
:class:`~handlers.SocketHandler` emits an event by pickling it and sending it
over the wire.
convert it to a string representation.


Optimization
Expand Down
14 changes: 12 additions & 2 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,8 @@ not have to be) the original ``STACK[-2]``.

.. opcode:: GET_AWAITABLE (where)

Implements ``STACK[-1] = get_awaitable(STACK[-1])``, where ``get_awaitable(o)``
Replaces ``STACK[-1]`` with ``get_awaitable(STACK[-1])``, ``NULL`` and
``None``, ready for :opcode:`SEND`. ``get_awaitable(o)``
returns ``o`` if ``o`` is a coroutine object or a generator object with
the :data:`~inspect.CO_ITERABLE_COROUTINE` flag, or resolves
``o.__await__``.
Expand All @@ -833,6 +834,10 @@ not have to be) the original ``STACK[-2]``.
.. versionchanged:: 3.11
Previously, this instruction did not have an oparg.

.. versionchanged:: next
Also pushes ``NULL`` and ``None``, which were previously pushed by
separate instructions.


.. opcode:: GET_AITER

Expand All @@ -846,11 +851,16 @@ not have to be) the original ``STACK[-2]``.

.. opcode:: GET_ANEXT

Implement ``STACK.append(get_awaitable(STACK[-1].__anext__()))`` to the stack.
Implement ``STACK.append(get_awaitable(STACK[-1].__anext__()))`` to the stack,
then push ``NULL`` and ``None``, ready for :opcode:`SEND`.
See ``GET_AWAITABLE`` for details about ``get_awaitable``.

.. versionadded:: 3.5

.. versionchanged:: next
Also pushes ``NULL`` and ``None``, which were previously pushed by
separate instructions.


.. opcode:: END_ASYNC_FOR

Expand Down
9 changes: 6 additions & 3 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6466,9 +6466,12 @@ Random numbers
random bytes in non-blocking mode (using the :data:`GRND_NONBLOCK` flag) or
to poll until the system urandom entropy pool is initialized.

On a Unix-like system, random bytes are read from the ``/dev/urandom``
device. If the ``/dev/urandom`` device is not available or not readable, the
:exc:`NotImplementedError` exception is raised.
On other Unix-like systems, the C ``getrandom()`` function is used if it is
available, otherwise the C ``getentropy()`` function.

If none of these functions can be used, random bytes are read from the
``/dev/urandom`` device. If the ``/dev/urandom`` device is not available or
not readable, the :exc:`NotImplementedError` exception is raised.

On Windows, it will use ``BCryptGenRandom()``.

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/ssl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1965,7 +1965,7 @@ to speed up repeated connections from the same clients.
Set the allowed ciphers for sockets created with this context when
connecting using TLS 1.2 and earlier. The *ciphers* argument should
be a string in the `OpenSSL cipher list format
<https://docs.openssl.org/master/man1/ciphers/>`_.
<https://docs.openssl.org/master/man1/openssl-ciphers/#cipher-list-format>`_.
To set allowed TLS 1.3 ciphers, use :meth:`SSLContext.set_ciphersuites`.

If no cipher can be selected (because compile-time options or other
Expand Down
42 changes: 42 additions & 0 deletions Doc/library/this.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
:orphan:

:mod:`!this` --- The Zen of Python
==================================

.. module:: this
:synopsis: The Zen of Python

..
This easter egg module is deliberately missing from the table of contents.

:pep:`20` -- The Zen of Python, by Tim Peters (RIP).

| Beautiful is better than ugly.
| Explicit is better than implicit.
| Simple is better than complex.
| Complex is better than complicated.
| Flat is better than nested.
| Sparse is better than dense.
| Readability counts.
| Special cases aren't special enough to break the rules.
| Although practicality beats purity.
| Errors should never pass silently.
| Unless explicitly silenced.
| In the face of ambiguity, refuse the temptation to guess.
| There should be one-\- and preferably only one -\-obvious way to do it.
| Although that way may not be obvious at first unless you're Dutch.
| Now is better than never.
| Although never is often better than *right* now.
| If the implementation is hard to explain, it's a bad idea.
| If the implementation is easy to explain, it may be a good idea.
| Namespaces are one honking great idea -\- let's do more of those!

`In Memoriam: Tim Peters 1952-2026 <https://discuss.python.org/t/in-memoriam-tim-peters-1952-2026/110028>`__.


Usage
-----

.. code-block:: shell-session

$ python3 -m this
4 changes: 2 additions & 2 deletions Doc/library/traceback.rst
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ the module-level functions described above.

The :attr:`~BaseException.__notes__` value from the original exception,
or ``None``
if the exception does not have any notes. If it is not ``None``
is it formatted in the traceback after the exception string.
if the exception does not have any notes. If it is not ``None``,
it is formatted in the traceback after the exception string.

.. versionadded:: 3.11

Expand Down
Loading
Loading