Skip to content

Commit 561e343

Browse files
authored
Merge branch 'main' into lint/ruff/tools-build-fix-132390
2 parents ff185a4 + f69b344 commit 561e343

33 files changed

+544
-177
lines changed

Doc/c-api/gcsupport.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ the garbage collector.
277277
278278
Type of the visitor function to be passed to :c:func:`PyUnstable_GC_VisitObjects`.
279279
*arg* is the same as the *arg* passed to ``PyUnstable_GC_VisitObjects``.
280-
Return ``0`` to continue iteration, return ``1`` to stop iteration. Other return
280+
Return ``1`` to continue iteration, return ``0`` to stop iteration. Other return
281281
values are reserved for now so behavior on returning anything else is undefined.
282282
283283
.. versionadded:: 3.12

Doc/c-api/typeobj.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
611611
Note that the :c:member:`~PyVarObject.ob_size` field may later be used for
612612
other purposes. For example, :py:type:`int` instances use the bits of
613613
:c:member:`~PyVarObject.ob_size` in an implementation-defined
614-
way; the underlying storage and its size should be acessed using
614+
way; the underlying storage and its size should be accessed using
615615
:c:func:`PyLong_Export`.
616616

617617
.. note::

Doc/c-api/unicode.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ APIs:
622622
623623
On error, set *\*p_left* to ``NULL`` and set an exception.
624624
625-
On sucess, set *\*p_left* to a new strong reference to the result.
625+
On success, set *\*p_left* to a new strong reference to the result.
626626
627627
628628
.. c:function:: void PyUnicode_AppendAndDel(PyObject **p_left, PyObject *right)

Doc/howto/logging-cookbook.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,19 @@ which, when run, will produce:
626626
of each message with the handler's level, and only passes a message to a
627627
handler if it's appropriate to do so.
628628

629+
.. versionchanged:: next
630+
The :class:`QueueListener` can be started (and stopped) via the
631+
:keyword:`with` statement. For example:
632+
633+
.. code-block:: python
634+
635+
with QueueListener(que, handler) as listener:
636+
# The queue listener automatically starts
637+
# when the 'with' block is entered.
638+
pass
639+
# The queue listener automatically stops once
640+
# the 'with' block is exited.
641+
629642
.. _network-logging:
630643

631644
Sending and receiving logging events across a network

Doc/library/codecs.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ particular, the following variants typically exist:
11071107
+-----------------+--------------------------------+--------------------------------+
11081108
| cp852 | 852, IBM852 | Central and Eastern Europe |
11091109
+-----------------+--------------------------------+--------------------------------+
1110-
| cp855 | 855, IBM855 | Bulgarian, Byelorussian, |
1110+
| cp855 | 855, IBM855 | Belarusian, Bulgarian, |
11111111
| | | Macedonian, Russian, Serbian |
11121112
+-----------------+--------------------------------+--------------------------------+
11131113
| cp856 | | Hebrew |
@@ -1155,7 +1155,7 @@ particular, the following variants typically exist:
11551155
+-----------------+--------------------------------+--------------------------------+
11561156
| cp1250 | windows-1250 | Central and Eastern Europe |
11571157
+-----------------+--------------------------------+--------------------------------+
1158-
| cp1251 | windows-1251 | Bulgarian, Byelorussian, |
1158+
| cp1251 | windows-1251 | Belarusian, Bulgarian, |
11591159
| | | Macedonian, Russian, Serbian |
11601160
+-----------------+--------------------------------+--------------------------------+
11611161
| cp1252 | windows-1252 | Western Europe |
@@ -1220,7 +1220,7 @@ particular, the following variants typically exist:
12201220
+-----------------+--------------------------------+--------------------------------+
12211221
| iso8859_4 | iso-8859-4, latin4, L4 | Baltic languages |
12221222
+-----------------+--------------------------------+--------------------------------+
1223-
| iso8859_5 | iso-8859-5, cyrillic | Bulgarian, Byelorussian, |
1223+
| iso8859_5 | iso-8859-5, cyrillic | Belarusian, Bulgarian, |
12241224
| | | Macedonian, Russian, Serbian |
12251225
+-----------------+--------------------------------+--------------------------------+
12261226
| iso8859_6 | iso-8859-6, arabic | Arabic |
@@ -1257,7 +1257,7 @@ particular, the following variants typically exist:
12571257
| | | |
12581258
| | | .. versionadded:: 3.5 |
12591259
+-----------------+--------------------------------+--------------------------------+
1260-
| mac_cyrillic | maccyrillic | Bulgarian, Byelorussian, |
1260+
| mac_cyrillic | maccyrillic | Belarusian, Bulgarian, |
12611261
| | | Macedonian, Russian, Serbian |
12621262
+-----------------+--------------------------------+--------------------------------+
12631263
| mac_greek | macgreek | Greek |

Doc/library/logging.handlers.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,13 @@ possible, while any potentially slow operations (such as sending an email via
11481148
.. versionchanged:: 3.5
11491149
The ``respect_handler_level`` argument was added.
11501150

1151+
.. versionchanged:: next
1152+
:class:`QueueListener` can now be used as a context manager via
1153+
:keyword:`with`. When entering the context, the listener is started. When
1154+
exiting the context, the listener is stopped.
1155+
:meth:`~contextmanager.__enter__` returns the
1156+
:class:`QueueListener` object.
1157+
11511158
.. method:: dequeue(block)
11521159

11531160
Dequeues a record and return it, optionally blocking.

Doc/whatsnew/3.14.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,14 @@ linecache
812812
(Contributed by Tian Gao in :gh:`131638`.)
813813

814814

815+
logging.handlers
816+
----------------
817+
818+
* :class:`logging.handlers.QueueListener` now implements the context
819+
manager protocol, allowing it to be used in a :keyword:`with` statement.
820+
(Contributed by Charles Machalow in :gh:`132106`.)
821+
822+
815823
mimetypes
816824
---------
817825

Include/cpython/warnings.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ PyAPI_FUNC(int) PyErr_WarnExplicitFormat(
1818

1919
// DEPRECATED: Use PyErr_WarnEx() instead.
2020
#define PyErr_Warn(category, msg) PyErr_WarnEx((category), (msg), 1)
21+
22+
int _PyErr_WarnExplicitObjectWithContext(
23+
PyObject *category,
24+
PyObject *message,
25+
PyObject *filename,
26+
int lineno);

Lib/hmac.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ def __init(self, key, msg, digestmod):
8181
try:
8282
self._init_openssl_hmac(key, msg, digestmod)
8383
return
84-
except _hashopenssl.UnsupportedDigestmodError:
84+
except _hashopenssl.UnsupportedDigestmodError: # pragma: no cover
8585
pass
8686
if _hmac and isinstance(digestmod, str):
8787
try:
8888
self._init_builtin_hmac(key, msg, digestmod)
8989
return
90-
except _hmac.UnknownHashError:
90+
except _hmac.UnknownHashError: # pragma: no cover
9191
pass
9292
self._init_old(key, msg, digestmod)
9393

@@ -121,12 +121,12 @@ def _init_old(self, key, msg, digestmod):
121121
warnings.warn(f"block_size of {blocksize} seems too small; "
122122
f"using our default of {self.blocksize}.",
123123
RuntimeWarning, 2)
124-
blocksize = self.blocksize
124+
blocksize = self.blocksize # pragma: no cover
125125
else:
126126
warnings.warn("No block_size attribute on given digest object; "
127127
f"Assuming {self.blocksize}.",
128128
RuntimeWarning, 2)
129-
blocksize = self.blocksize
129+
blocksize = self.blocksize # pragma: no cover
130130

131131
if len(key) > blocksize:
132132
key = digest_cons(key).digest()

Lib/logging/handlers.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,19 @@ def __init__(self, queue, *handlers, respect_handler_level=False):
15321532
self._thread = None
15331533
self.respect_handler_level = respect_handler_level
15341534

1535+
def __enter__(self):
1536+
"""
1537+
For use as a context manager. Starts the listener.
1538+
"""
1539+
self.start()
1540+
return self
1541+
1542+
def __exit__(self, *args):
1543+
"""
1544+
For use as a context manager. Stops the listener.
1545+
"""
1546+
self.stop()
1547+
15351548
def dequeue(self, block):
15361549
"""
15371550
Dequeue a record and return it, optionally blocking.

0 commit comments

Comments
 (0)