[Python-checkins] gh-138072: Fix typos and grammatical errors and improve clarity in asyncio howto document (#138895)
https://github.com/python/cpython/commit/362fd59dc8c6cd23a5cfd4b5a8300902565a2f58 commit: 362fd59dc8c6cd23a5cfd4b5a8300902565a2f58 branch: main author: Morteza24 committer: hugovk <[email protected]> date: 2025-10-14T11:19:35+03:00 summary: gh-138072: Fix typos and grammatical errors and improve clarity in asyncio howto document (#138895) files: M Doc/howto/a-conceptual-overview-of-asyncio.rst diff --git a/Doc/howto/a-conceptual-overview-of-asyncio.rst b/Doc/howto/a-conceptual-overview-of-asyncio.rst index d68f7cc6921fc9..af1e39480cc1f6 100644 --- a/Doc/howto/a-conceptual-overview-of-asyncio.rst +++ b/Doc/howto/a-conceptual-overview-of-asyncio.rst @@ -9,12 +9,11 @@ model of how :mod:`asyncio` fundamentally works, helping you understand the how and why behind the recommended patterns. You might be curious about some key :mod:`!asyncio` concepts. -You'll be comfortably able to answer these questions by the end of this -article: +By the end of this article, you'll be able to comfortably answer these questions: - What's happening behind the scenes when an object is awaited? - How does :mod:`!asyncio` differentiate between a task which doesn't need - CPU-time (such as a network request or file read) as opposed to a task that + CPU time (such as a network request or file read) as opposed to a task that does (such as computing n-factorial)? - How to write an asynchronous variant of an operation, such as an async sleep or database request. @@ -35,7 +34,7 @@ A conceptual overview part 1: the high-level In part 1, we'll cover the main, high-level building blocks of :mod:`!asyncio`: -the event loop, coroutine functions, coroutine objects, tasks and ``await``. +the event loop, coroutine functions, coroutine objects, tasks, and ``await``. == Event Loop @@ -56,7 +55,7 @@ Once it pauses or completes, it returns control to the event loop. The event loop will then select another job from its pool and invoke it. You can *roughly* think of the collection of jobs as a queue: jobs are added and then processed one at a time, generally (but not always) in order. -This process repeats indefinitely with the event loop cycling endlessly +This process repeats indefinitely, with the event loop cycling endlessly onwards. If there are no more jobs pending execution, the event loop is smart enough to rest and avoid needlessly wasting CPU cycles, and will come back when there's @@ -276,7 +275,7 @@ in this case, a call to resume ``plant_a_tree()``. Generally speaking, when the awaited task finishes (``dig_the_hole_task``), the original task or coroutine (``plant_a_tree()``) is added back to the event -loops to-do list to be resumed. +loop's to-do list to be resumed. This is a basic, yet reliable mental model. In practice, the control handoffs are slightly more complex, but not by much. @@ -310,7 +309,7 @@ Consider this program:: The first statement in the coroutine ``main()`` creates ``task_b`` and schedules it for execution via the event loop. Then, ``coro_a()`` is repeatedly awaited. Control never cedes to the -event loop which is why we see the output of all three ``coro_a()`` +event loop, which is why we see the output of all three ``coro_a()`` invocations before ``coro_b()``'s output: .. code-block:: none @@ -338,8 +337,8 @@ This behavior of ``await coroutine`` can trip a lot of people up! That example highlights how using only ``await coroutine`` could unintentionally hog control from other tasks and effectively stall the event loop. -:func:`asyncio.run` can help you detect such occurences via the -``debug=True`` flag which accordingly enables +:func:`asyncio.run` can help you detect such occurrences via the +``debug=True`` flag, which enables :ref:`debug mode `. Among other things, it will log any coroutines that monopolize execution for 100ms or longer. @@ -348,8 +347,8 @@ The design intentionally trades off some conceptual clarity around usage of ``await`` for improved performance. Each time a task is awaited, control needs to be passed all the way up the call stack to the event loop. -That might sound minor, but in a large program with many ``await``'s and a deep -callstack that overhead can add up to a meaningful performance drag. +That might sound minor, but in a large program with many ``await`` statements and a deep +call stack, that overhead can add up to a meaningful performance drag. A conceptual overview part 2: the nuts and bolts @@ -372,7 +371,7 @@ resume a coroutine. If the coroutine was paused and is now being resumed, the argument ``arg`` will be sent in as the return value of the ``yield`` statement which originally paused it. -If the coroutine is being used for the first time (as opposed to being resumed) +If the coroutine is being used for the first time (as opposed to being resumed), ``arg`` must be ``None``. .
[Python-checkins] gh-138993: Dedent `credits` text (#138994)
https://github.com/python/cpython/commit/207f977bc7ced2bb97bfc205fbba1128ab57ceca commit: 207f977bc7ced2bb97bfc205fbba1128ab57ceca branch: main author: Stan Ulbrych <[email protected]> committer: hugovk <[email protected]> date: 2025-10-14T11:15:17+03:00 summary: gh-138993: Dedent `credits` text (#138994) files: A Misc/NEWS.d/next/Library/2025-09-16-16-46-58.gh-issue-138993.-8s8_T.rst M Lib/site.py diff --git a/Lib/site.py b/Lib/site.py index f0e742f2e2..7c6810792cfa7e 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -449,9 +449,9 @@ def setcopyright(): """Set 'copyright' and 'credits' in builtins""" builtins.copyright = _sitebuiltins._Printer("copyright", sys.copyright) builtins.credits = _sitebuiltins._Printer("credits", """\ -Thanks to CWI, CNRI, BeOpen, Zope Corporation, the Python Software -Foundation, and a cast of thousands for supporting Python -development. See www.python.org for more information.""") +Thanks to CWI, CNRI, BeOpen, Zope Corporation, the Python Software +Foundation, and a cast of thousands for supporting Python +development. See www.python.org for more information.""") files, dirs = [], [] # Not all modules are required to have a __file__ attribute. See # PEP 420 for more details. diff --git a/Misc/NEWS.d/next/Library/2025-09-16-16-46-58.gh-issue-138993.-8s8_T.rst b/Misc/NEWS.d/next/Library/2025-09-16-16-46-58.gh-issue-138993.-8s8_T.rst new file mode 100644 index 00..1be588f2ba568c --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-09-16-16-46-58.gh-issue-138993.-8s8_T.rst @@ -0,0 +1 @@ +Dedent :data:`credits` text. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] gh-101100: Fix sphinx warnings in `library/smtplib.rst` (GH-139991) (#140085)
https://github.com/python/cpython/commit/13562e186648374c959d6103a6b57fcb83ea79f2 commit: 13562e186648374c959d6103a6b57fcb83ea79f2 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: hugovk <[email protected]> date: 2025-10-14T08:18:53Z summary: [3.13] gh-101100: Fix sphinx warnings in `library/smtplib.rst` (GH-139991) (#140085) Co-authored-by: Weilin Du <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]> files: M Doc/library/smtplib.rst M Doc/tools/.nitignore diff --git a/Doc/library/smtplib.rst b/Doc/library/smtplib.rst index c5f8516f768a68..c5a3de52090cee 100644 --- a/Doc/library/smtplib.rst +++ b/Doc/library/smtplib.rst @@ -80,8 +80,8 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions). An :class:`SMTP_SSL` instance behaves exactly the same as instances of :class:`SMTP`. :class:`SMTP_SSL` should be used for situations where SSL is - required from the beginning of the connection and using :meth:`starttls` is - not appropriate. If *host* is not specified, the local host is used. If + required from the beginning of the connection and using :meth:`~SMTP.starttls` + is not appropriate. If *host* is not specified, the local host is used. If *port* is zero, the standard SMTP-over-SSL port (465) is used. The optional arguments *local_hostname*, *timeout* and *source_address* have the same meaning as they do in the :class:`SMTP` class. *context*, also optional, @@ -112,7 +112,7 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions). The LMTP protocol, which is very similar to ESMTP, is heavily based on the standard SMTP client. It's common to use Unix sockets for LMTP, so our - :meth:`connect` method must support that as well as a regular host:port + :meth:`~SMTP.connect` method must support that as well as a regular host:port server. The optional arguments *local_hostname* and *source_address* have the same meaning as they do in the :class:`SMTP` class. To specify a Unix socket, you must use an absolute path for *host*, starting with a '/'. @@ -147,9 +147,15 @@ A nice selection of exceptions is defined as well: .. exception:: SMTPResponseException Base class for all exceptions that include an SMTP error code. These exceptions - are generated in some instances when the SMTP server returns an error code. The - error code is stored in the :attr:`smtp_code` attribute of the error, and the - :attr:`smtp_error` attribute is set to the error message. + are generated in some instances when the SMTP server returns an error code. + + .. attribute:: smtp_code + + The error code. + + .. attribute:: smtp_error + + The error message. .. exception:: SMTPSenderRefused @@ -161,9 +167,13 @@ A nice selection of exceptions is defined as well: .. exception:: SMTPRecipientsRefused - All recipient addresses refused. The errors for each recipient are accessible - through the attribute :attr:`recipients`, which is a dictionary of exactly the - same sort as :meth:`SMTP.sendmail` returns. + All recipient addresses refused. + + .. attribute:: recipients + + A dictionary of exactly the same sort as returned + by :meth:`SMTP.sendmail` containing the errors for + each recipient. .. exception:: SMTPDataError @@ -213,7 +223,6 @@ SMTP Objects An :class:`SMTP` instance has the following methods: - .. method:: SMTP.set_debuglevel(level) Set the debug output level. A value of 1 or ``True`` for *level* results in @@ -417,7 +426,7 @@ An :class:`SMTP` instance has the following methods: .. versionchanged:: 3.4 The method now supports hostname check with - :attr:`SSLContext.check_hostname` and *Server Name Indicator* (see + :attr:`ssl.SSLContext.check_hostname` and *Server Name Indicator* (see :const:`~ssl.HAS_SNI`). .. versionchanged:: 3.5 @@ -435,7 +444,7 @@ An :class:`SMTP` instance has the following methods: ESMTP options (such as ``DSN`` commands) that should be used with all ``RCPT`` commands can be passed as *rcpt_options*. (If you need to use different ESMTP options to different recipients you have to use the low-level methods such as - :meth:`mail`, :meth:`rcpt` and :meth:`data` to send the message.) + :meth:`!mail`, :meth:`!rcpt` and :meth:`!data` to send the message.) .. note:: @@ -467,10 +476,7 @@ An :class:`SMTP` instance has the following methods: This method may raise the following exceptions: :exc:`SMTPRecipientsRefused` - All recipients were refused. Nobody got the mail. The :attr:`recipients` - attribute of the exception object is a dictionary with information about the - refused recipients (like the one returned when at least one recipient was - accepted). + All recipients were refused. Nobody got the mail. :exc:`SMTPHeloError
[Python-checkins] [3.13] gh-102247: Improve documentation of http.HTTPStatus members update (GH-133190) (#140090)
https://github.com/python/cpython/commit/5bead87f8368198c390d61bb46020f4db8dbaa29 commit: 5bead87f8368198c390d61bb46020f4db8dbaa29 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: hugovk <[email protected]> date: 2025-10-14T08:24:31Z summary: [3.13] gh-102247: Improve documentation of http.HTTPStatus members update (GH-133190) (#140090) Co-authored-by: Loïc Simon files: M Doc/library/http.rst diff --git a/Doc/library/http.rst b/Doc/library/http.rst index ce3fb9f8120502..b0bdfc65e4508d 100644 --- a/Doc/library/http.rst +++ b/Doc/library/http.rst @@ -139,7 +139,8 @@ equal to the constant name (i.e. ``http.HTTPStatus.OK`` is also available as .. versionchanged:: 3.13 Implemented RFC9110 naming for status constants. Old constant names are preserved for - backwards compatibility. + backwards compatibility: ``413 REQUEST_ENTITY_TOO_LARGE``, ``414 REQUEST_URI_TOO_LONG``, + ``416 REQUESTED_RANGE_NOT_SATISFIABLE`` and ``422 UNPROCESSABLE_ENTITY``. HTTP status category ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] gh-102247: Improve documentation of http.HTTPStatus members update (GH-133190) (#140089)
https://github.com/python/cpython/commit/e1caa1e6fa1a9d842e91cc040ccfdebc78018293 commit: e1caa1e6fa1a9d842e91cc040ccfdebc78018293 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: hugovk <[email protected]> date: 2025-10-14T08:26:00Z summary: [3.14] gh-102247: Improve documentation of http.HTTPStatus members update (GH-133190) (#140089) Co-authored-by: Loïc Simon files: M Doc/library/http.rst diff --git a/Doc/library/http.rst b/Doc/library/http.rst index ce3fb9f8120502..b0bdfc65e4508d 100644 --- a/Doc/library/http.rst +++ b/Doc/library/http.rst @@ -139,7 +139,8 @@ equal to the constant name (i.e. ``http.HTTPStatus.OK`` is also available as .. versionchanged:: 3.13 Implemented RFC9110 naming for status constants. Old constant names are preserved for - backwards compatibility. + backwards compatibility: ``413 REQUEST_ENTITY_TOO_LARGE``, ``414 REQUEST_URI_TOO_LONG``, + ``416 REQUESTED_RANGE_NOT_SATISFIABLE`` and ``422 UNPROCESSABLE_ENTITY``. HTTP status category ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-137871: Clarify cmath.nan documentation by linking to math module (#137876)
https://github.com/python/cpython/commit/025b4034d6c80900aedea3b397cb730dc4910ef0 commit: 025b4034d6c80900aedea3b397cb730dc4910ef0 branch: main author: Aziz committer: hugovk <[email protected]> date: 2025-10-14T11:24:43+03:00 summary: gh-137871: Clarify cmath.nan documentation by linking to math module (#137876) Co-authored-by: Sergey B Kirpichev files: M Doc/library/cmath.rst diff --git a/Doc/library/cmath.rst b/Doc/library/cmath.rst index 26518a0458fd81..b6d5dbee21dcd5 100644 --- a/Doc/library/cmath.rst +++ b/Doc/library/cmath.rst @@ -338,7 +338,7 @@ Constants .. data:: nan A floating-point "not a number" (NaN) value. Equivalent to - ``float('nan')``. + ``float('nan')``. See also :data:`math.nan`. .. versionadded:: 3.6 ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] gh-97914: Reword misleading sentence on conditional expressions (GH-139064) (#140094)
https://github.com/python/cpython/commit/63ba8018a17e0c324a96bfc0977e00b76f7491b5 commit: 63ba8018a17e0c324a96bfc0977e00b76f7491b5 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: hugovk <[email protected]> date: 2025-10-14T08:29:16Z summary: [3.13] gh-97914: Reword misleading sentence on conditional expressions (GH-139064) (#140094) Co-authored-by: Irit Katriel <[email protected]> Co-authored-by: Gilles Peiffer Co-authored-by: Adam Turner <[email protected]> files: M Doc/reference/expressions.rst diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index d88134b0edbcad..24962c68578cef 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -1871,8 +1871,9 @@ Conditional expressions conditional_expression: `or_test` ["if" `or_test` "else" `expression`] expression: `conditional_expression` | `lambda_expr` -Conditional expressions (sometimes called a "ternary operator") have the lowest -priority of all Python operations. +A conditional expression (sometimes called a "ternary operator") is an +alternative to the if-else statement. As it is an expression, it returns a value +and can appear as a sub-expression. The expression ``x if C else y`` first evaluates the condition, *C* rather than *x*. If *C* is true, *x* is evaluated and its value is returned; otherwise, *y* is ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] gh-139590: Stricter `ruff` rules for `Tools/wasm` (GH-139752) (#139811)
https://github.com/python/cpython/commit/5848d805366c6a1c681a0cc863992ad7ae705e8d commit: 5848d805366c6a1c681a0cc863992ad7ae705e8d branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: hugovk <[email protected]> date: 2025-10-14T10:29:32+03:00 summary: [3.14] gh-139590: Stricter `ruff` rules for `Tools/wasm` (GH-139752) (#139811) Co-authored-by: sobolevn Co-authored-by: Hugo van Kemenade <[email protected]> files: D Tools/wasm/mypy.ini M .github/workflows/mypy.yml M .pre-commit-config.yaml M Tools/wasm/.ruff.toml M Tools/wasm/emscripten/__main__.py M Tools/wasm/emscripten/wasm_assets.py M Tools/wasm/wasi/__main__.py M Tools/wasm/wasm_build.py diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index 498a7d0a844110..5d5d77f29f6eb1 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -29,7 +29,6 @@ on: - "Tools/jit/**" - "Tools/peg_generator/**" - "Tools/requirements-dev.txt" - - "Tools/wasm/**" workflow_dispatch: permissions: @@ -61,7 +60,6 @@ jobs: "Tools/clinic", "Tools/jit", "Tools/peg_generator", - "Tools/wasm", ] steps: - uses: actions/checkout@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0e00ffb3bd2d66..b0311f052798ad 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,6 +26,10 @@ repos: name: Run Ruff (lint) on Tools/peg_generator/ args: [--exit-non-zero-on-fix, --config=Tools/peg_generator/.ruff.toml] files: ^Tools/peg_generator/ + - id: ruff-check +name: Run Ruff (lint) on Tools/wasm/ +args: [--exit-non-zero-on-fix, --config=Tools/wasm/.ruff.toml] +files: ^Tools/wasm/ - id: ruff-format name: Run Ruff (format) on Doc/ args: [--check] diff --git a/Tools/wasm/.ruff.toml b/Tools/wasm/.ruff.toml index aabcf8dc4f502e..3d8e59fa3f22c4 100644 --- a/Tools/wasm/.ruff.toml +++ b/Tools/wasm/.ruff.toml @@ -22,7 +22,4 @@ select = [ ] ignore = [ "E501",# Line too long -"F541",# f-string without any placeholders -"PYI024", # Use `typing.NamedTuple` instead of `collections.namedtuple` -"PYI025", # Use `from collections.abc import Set as AbstractSet` ] diff --git a/Tools/wasm/emscripten/__main__.py b/Tools/wasm/emscripten/__main__.py index fdf3142c0a3b1a..c88e9edba6d230 100644 --- a/Tools/wasm/emscripten/__main__.py +++ b/Tools/wasm/emscripten/__main__.py @@ -3,16 +3,16 @@ import argparse import contextlib import functools +import hashlib import os import shutil import subprocess import sys import sysconfig -import hashlib import tempfile -from urllib.request import urlopen from pathlib import Path from textwrap import dedent +from urllib.request import urlopen try: from os import process_cpu_count as cpu_count @@ -33,9 +33,7 @@ PREFIX_DIR = CROSS_BUILD_DIR / HOST_TRIPLE / "prefix" LOCAL_SETUP = CHECKOUT / "Modules" / "Setup.local" -LOCAL_SETUP_MARKER = "# Generated by Tools/wasm/emscripten.py\n".encode( -"utf-8" -) +LOCAL_SETUP_MARKER = b"# Generated by Tools/wasm/emscripten.py\n" def updated_env(updates={}): @@ -432,6 +430,7 @@ def main(): make_build, configure_host, make_host, +clean, ): subcommand.add_argument( "--quiet", diff --git a/Tools/wasm/emscripten/wasm_assets.py b/Tools/wasm/emscripten/wasm_assets.py index 90f318f319a9f1..384790872353b2 100755 --- a/Tools/wasm/emscripten/wasm_assets.py +++ b/Tools/wasm/emscripten/wasm_assets.py @@ -15,7 +15,6 @@ import sys import sysconfig import zipfile -from typing import Dict # source directory SRCDIR = pathlib.Path(__file__).parents[3].absolute() @@ -134,7 +133,7 @@ def filterfunc(filename: str) -> bool: pzf.writepy(entry, filterfunc=filterfunc) -def detect_extension_modules(args: argparse.Namespace) -> Dict[str, bool]: +def detect_extension_modules(args: argparse.Namespace) -> dict[str, bool]: modules = {} # disabled by Modules/Setup.local ? @@ -149,7 +148,7 @@ def detect_extension_modules(args: argparse.Namespace) -> Dict[str, bool]: # disabled by configure? with open(args.sysconfig_data) as f: data = f.read() -loc: Dict[str, Dict[str, str]] = {} +loc: dict[str, dict[str, str]] = {} exec(data, globals(), loc) for key, value in loc["build_time_vars"].items(): diff --git a/Tools/wasm/mypy.ini b/Tools/wasm/mypy.ini deleted file mode 100644 index 4de0a30c260f5f..00 --- a/Tools/wasm/mypy.ini +++ /dev/null @@ -1,11 +0,0 @@ -[mypy] -files = Tools/wasm/wasm_*.py -pretty = True -show_traceback = True - -# Make sure the wasm can be run using Python 3.8: -python_version = 3.8 - -# Be strict... -strict = True -enable_error_code = truthy-bool,ignore-without-code diff --git a/Tools/wasm/wasi/__main__.py b/To
[Python-checkins] [3.14] gh-102431: Clarify constraints on operands of Decimal logical operations (GH-102836) (#140105)
https://github.com/python/cpython/commit/1c55b9163bd048f14db4f3c7e55df801ee760ac8
commit: 1c55b9163bd048f14db4f3c7e55df801ee760ac8
branch: 3.14
author: Sergey B Kirpichev
committer: vstinner
date: 2025-10-14T15:44:30+02:00
summary:
[3.14] gh-102431: Clarify constraints on operands of Decimal logical operations
(GH-102836) (#140105)
* [3.14] gh-102431: Clarify constraints on operands of Decimal logical
operations (GH-102836)
Sync C/Python implementation of the decimal: logical_ops for contexts.
(cherry picked from commit 6ecf77dbdec7838e9ce2298cb8d16e8c2250da81)
Co-authored-by: Sergey B Kirpichev
files:
A Misc/NEWS.d/next/Library/2023-03-21-10-59-40.gh-issue-102431.eUDnf4.rst
M Lib/_pydecimal.py
M Modules/_decimal/docstrings.h
diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py
index 9b8e42a2342536..97a629fe92ccec 100644
--- a/Lib/_pydecimal.py
+++ b/Lib/_pydecimal.py
@@ -3340,7 +3340,10 @@ def _fill_logical(self, context, opa, opb):
return opa, opb
def logical_and(self, other, context=None):
-"""Applies an 'and' operation between self and other's digits."""
+"""Applies an 'and' operation between self and other's digits.
+
+Both self and other must be logical numbers.
+"""
if context is None:
context = getcontext()
@@ -3357,14 +3360,20 @@ def logical_and(self, other, context=None):
return _dec_from_triple(0, result.lstrip('0') or '0', 0)
def logical_invert(self, context=None):
-"""Invert all its digits."""
+"""Invert all its digits.
+
+The self must be logical number.
+"""
if context is None:
context = getcontext()
return self.logical_xor(_dec_from_triple(0,'1'*context.prec,0),
context)
def logical_or(self, other, context=None):
-"""Applies an 'or' operation between self and other's digits."""
+"""Applies an 'or' operation between self and other's digits.
+
+Both self and other must be logical numbers.
+"""
if context is None:
context = getcontext()
@@ -3381,7 +3390,10 @@ def logical_or(self, other, context=None):
return _dec_from_triple(0, result.lstrip('0') or '0', 0)
def logical_xor(self, other, context=None):
-"""Applies an 'xor' operation between self and other's digits."""
+"""Applies an 'xor' operation between self and other's digits.
+
+Both self and other must be logical numbers.
+"""
if context is None:
context = getcontext()
diff --git
a/Misc/NEWS.d/next/Library/2023-03-21-10-59-40.gh-issue-102431.eUDnf4.rst
b/Misc/NEWS.d/next/Library/2023-03-21-10-59-40.gh-issue-102431.eUDnf4.rst
new file mode 100644
index 00..e82ddb6e1011ad
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2023-03-21-10-59-40.gh-issue-102431.eUDnf4.rst
@@ -0,0 +1,2 @@
+Clarify constraints for "logical" arguments in methods of
+:class:`decimal.Context`.
diff --git a/Modules/_decimal/docstrings.h b/Modules/_decimal/docstrings.h
index 77017a92252cb8..9c2da5e35f919a 100644
--- a/Modules/_decimal/docstrings.h
+++ b/Modules/_decimal/docstrings.h
@@ -292,22 +292,26 @@ an infinity then Decimal('Infinity') is returned.\n\
PyDoc_STRVAR(doc_logical_and,
"logical_and($self, /, other, context=None)\n--\n\n\
-Return the digit-wise 'and' of the two (logical) operands.\n\
+Applies an 'and' operation between self and other's digits.\n\n\
+Both self and other must be logical numbers.\n\
\n");
PyDoc_STRVAR(doc_logical_invert,
"logical_invert($self, /, context=None)\n--\n\n\
-Return the digit-wise inversion of the (logical) operand.\n\
+Invert all its digits.\n\n\
+The self must be logical number.\n\
\n");
PyDoc_STRVAR(doc_logical_or,
"logical_or($self, /, other, context=None)\n--\n\n\
-Return the digit-wise 'or' of the two (logical) operands.\n\
+Applies an 'or' operation between self and other's digits.\n\n\
+Both self and other must be logical numbers. \n\
\n");
PyDoc_STRVAR(doc_logical_xor,
"logical_xor($self, /, other, context=None)\n--\n\n\
-Return the digit-wise 'exclusive or' of the two (logical) operands.\n\
+Applies an 'xor' operation between self and other's digits.\n\n\
+Both self and other must be logical numbers.\n\
\n");
PyDoc_STRVAR(doc_max,
@@ -712,22 +716,90 @@ Return the exponent of the magnitude of the operand's
MSD.\n\
PyDoc_STRVAR(doc_ctx_logical_and,
"logical_and($self, x, y, /)\n--\n\n\
-Digit-wise and of x and y.\n\
+Applies the logical operation 'and' between each operand's digits.\n\n\
+The operands must be both logical numbers.\n\n\
+>>> ExtendedContext.logical_and(Decimal('0'), Decimal('0'))\n\
+Decimal('0')\n\
+>>> ExtendedContext.logical_and(Decimal('0'), Decimal('1'))\n\
+Decimal('0')\n\
+>>> ExtendedContext.logical_and(Decimal('1'), Decimal('0'))\n\
+Decimal('0')\n\
+>>> ExtendedContext.logical_and(Decimal('1'), Decimal('1'))\n\
[Python-checkins] [3.13] gh-70765: Remove unnecessary extra backtick from Changelog entry (GH-140071) (#140101)
https://github.com/python/cpython/commit/7e40d9472595d4e7bc0c22c2e0fcbc7a447159d6 commit: 7e40d9472595d4e7bc0c22c2e0fcbc7a447159d6 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: picnixz <[email protected]> date: 2025-10-14T11:16:02Z summary: [3.13] gh-70765: Remove unnecessary extra backtick from Changelog entry (GH-140071) (#140101) gh-70765: Remove unnecessary extra backtick from Changelog entry (GH-140071) (cherry picked from commit f70082b4777804b69e98192121a61c2048669a16) Co-authored-by: Rafael Fontenelle files: M Misc/NEWS.d/next/Library/2025-10-02-17-40-10.gh-issue-70765.zVlLZn.rst diff --git a/Misc/NEWS.d/next/Library/2025-10-02-17-40-10.gh-issue-70765.zVlLZn.rst b/Misc/NEWS.d/next/Library/2025-10-02-17-40-10.gh-issue-70765.zVlLZn.rst index e1a9bbe9afe4d1..d20f881eb09d55 100644 --- a/Misc/NEWS.d/next/Library/2025-10-02-17-40-10.gh-issue-70765.zVlLZn.rst +++ b/Misc/NEWS.d/next/Library/2025-10-02-17-40-10.gh-issue-70765.zVlLZn.rst @@ -1,5 +1,5 @@ :mod:`http.server`: fix default handling of HTTP/0.9 requests in :class:`~http.server.BaseHTTPRequestHandler`. Previously, -:meth:`!BaseHTTPRequestHandler.parse_request`` incorrectly +:meth:`!BaseHTTPRequestHandler.parse_request` incorrectly waited for headers in the request although those are not supported in HTTP/0.9. Patch by Bénédikt Tran. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-140126: Fix compile error if --with-assertions is enabled (#140133)
https://github.com/python/cpython/commit/1e1f43519605b7c54a96aa44d0feed09d2bb1a67 commit: 1e1f43519605b7c54a96aa44d0feed09d2bb1a67 branch: main author: Neil Schemenauer committer: vstinner date: 2025-10-14T23:34:30Z summary: gh-140126: Fix compile error if --with-assertions is enabled (#140133) The `types_world_is_stopped()` function needs to be defined if NDEBUG is not defined. files: M Objects/typeobject.c diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 9398bcb29c83e4..29233c1959c4d0 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -81,7 +81,7 @@ class object "PyObject *" "&PyBaseObject_Type" #define END_TYPE_DICT_LOCK() Py_END_CRITICAL_SECTION2() -#ifdef Py_DEBUG +#ifndef NDEBUG // Return true if the world is currently stopped. static bool types_world_is_stopped(void) ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-97914: Reword misleading sentence on conditional expressions (#139064)
https://github.com/python/cpython/commit/fb25d6b35c7bf9267fd21c809ea095c4ce60b763 commit: fb25d6b35c7bf9267fd21c809ea095c4ce60b763 branch: main author: Irit Katriel <[email protected]> committer: hugovk <[email protected]> date: 2025-10-14T11:21:13+03:00 summary: gh-97914: Reword misleading sentence on conditional expressions (#139064) Co-authored-by: Gilles Peiffer Co-authored-by: Adam Turner <[email protected]> files: M Doc/reference/expressions.rst diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 9aca25e3214a16..c655d6c52ecc16 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -1938,8 +1938,9 @@ Conditional expressions conditional_expression: `or_test` ["if" `or_test` "else" `expression`] expression: `conditional_expression` | `lambda_expr` -Conditional expressions (sometimes called a "ternary operator") have the lowest -priority of all Python operations. +A conditional expression (sometimes called a "ternary operator") is an +alternative to the if-else statement. As it is an expression, it returns a value +and can appear as a sub-expression. The expression ``x if C else y`` first evaluates the condition, *C* rather than *x*. If *C* is true, *x* is evaluated and its value is returned; otherwise, *y* is ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
