Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 37ec841

Browse filesBrowse files
committed
Merge branch 'master' into long_export-decimal
2 parents 5a00ee2 + 8d15058 commit 37ec841
Copy full SHA for 37ec841

File tree

Expand file treeCollapse file tree

163 files changed

+8538
-5075
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

163 files changed

+8538
-5075
lines changed

‎.github/workflows/build.yml

Copy file name to clipboardExpand all lines: .github/workflows/build.yml
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
# reproducible: to get the same tools versions (autoconf, aclocal, ...)
4747
runs-on: ubuntu-24.04
4848
container:
49-
image: ghcr.io/python/autoconf:2024.11.11.11786316759
49+
image: ghcr.io/python/autoconf:2025.01.02.12581854023
5050
timeout-minutes: 60
5151
needs: check_source
5252
if: needs.check_source.outputs.run_tests == 'true'
@@ -63,7 +63,7 @@ jobs:
6363
run: echo "IMAGE_VERSION=${ImageVersion}" >> "$GITHUB_ENV"
6464
- name: Check Autoconf and aclocal versions
6565
run: |
66-
grep "Generated by GNU Autoconf 2.71" configure
66+
grep "Generated by GNU Autoconf 2.72" configure
6767
grep "aclocal 1.16.5" aclocal.m4
6868
grep -q "runstatedir" configure
6969
grep -q "PKG_PROG_PKG_CONFIG" aclocal.m4

‎.github/workflows/reusable-docs.yml

Copy file name to clipboardExpand all lines: .github/workflows/reusable-docs.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
100100
doctest:
101101
name: 'Doctest'
102-
runs-on: ubuntu-22.04
102+
runs-on: ubuntu-24.04
103103
timeout-minutes: 60
104104
steps:
105105
- uses: actions/checkout@v4

‎.pre-commit-config.yaml

Copy file name to clipboardExpand all lines: .pre-commit-config.yaml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ repos:
5555
hooks:
5656
- id: check-dependabot
5757
- id: check-github-workflows
58+
- id: check-readthedocs
5859

5960
- repo: https://github.com/rhysd/actionlint
6061
rev: v1.7.4

‎Doc/about.rst

Copy file name to clipboardExpand all lines: Doc/about.rst
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
=====================
2-
About these documents
3-
=====================
1+
========================
2+
About this documentation
3+
========================
44

55

6-
These documents are generated from `reStructuredText`_ sources by `Sphinx`_, a
7-
document processor specifically written for the Python documentation.
6+
Python's documentation is generated from `reStructuredText`_ sources
7+
using `Sphinx`_, a documentation generator originally created for Python
8+
and now maintained as an independent project.
89

910
.. _reStructuredText: https://docutils.sourceforge.io/rst.html
1011
.. _Sphinx: https://www.sphinx-doc.org/
@@ -20,14 +21,14 @@ volunteers are always welcome!
2021
Many thanks go to:
2122

2223
* Fred L. Drake, Jr., the creator of the original Python documentation toolset
23-
and writer of much of the content;
24+
and author of much of the content;
2425
* the `Docutils <https://docutils.sourceforge.io/>`_ project for creating
2526
reStructuredText and the Docutils suite;
2627
* Fredrik Lundh for his Alternative Python Reference project from which Sphinx
2728
got many good ideas.
2829

2930

30-
Contributors to the Python Documentation
31+
Contributors to the Python documentation
3132
----------------------------------------
3233

3334
Many people have contributed to the Python language, the Python standard

‎Doc/c-api/arg.rst

Copy file name to clipboardExpand all lines: Doc/c-api/arg.rst
+14-8Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,24 @@ There are three ways strings and buffers can be converted to C:
229229
Numbers
230230
-------
231231

232+
These formats allow representing Python numbers or single characters as C numbers.
233+
Formats that require :class:`int`, :class:`float` or :class:`complex` can
234+
also use the corresponding special methods :meth:`~object.__index__`,
235+
:meth:`~object.__float__` or :meth:`~object.__complex__` to convert
236+
the Python object to the required type.
237+
238+
For signed integer formats, :exc:`OverflowError` is raised if the value
239+
is out of range for the C type.
240+
For unsigned integer formats, no range checking is done --- the
241+
most significant bits are silently truncated when the receiving field is too
242+
small to receive the value.
243+
232244
``b`` (:class:`int`) [unsigned char]
233-
Convert a nonnegative Python integer to an unsigned tiny int, stored in a C
245+
Convert a nonnegative Python integer to an unsigned tiny integer, stored in a C
234246
:c:expr:`unsigned char`.
235247

236248
``B`` (:class:`int`) [unsigned char]
237-
Convert a Python integer to a tiny int without overflow checking, stored in a C
249+
Convert a Python integer to a tiny integer without overflow checking, stored in a C
238250
:c:expr:`unsigned char`.
239251

240252
``h`` (:class:`int`) [short int]
@@ -344,12 +356,6 @@ Other objects
344356
in *items*. The C arguments must correspond to the individual format units in
345357
*items*. Format units for sequences may be nested.
346358

347-
It is possible to pass "long" integers (integers whose value exceeds the
348-
platform's :c:macro:`LONG_MAX`) however no proper range checking is done --- the
349-
most significant bits are silently truncated when the receiving field is too
350-
small to receive the value (actually, the semantics are inherited from downcasts
351-
in C --- your mileage may vary).
352-
353359
A few other characters have a meaning in a format string. These may not occur
354360
inside nested parentheses. They are:
355361

‎Doc/c-api/object.rst

Copy file name to clipboardExpand all lines: Doc/c-api/object.rst
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ Object Protocol
111111
.. note::
112112
113113
Exceptions that occur when this calls :meth:`~object.__getattr__` and
114-
:meth:`~object.__getattribute__` methods are silently ignored.
114+
:meth:`~object.__getattribute__` methods aren't propagated,
115+
but instead given to :func:`sys.unraisablehook`.
115116
For proper error handling, use :c:func:`PyObject_HasAttrWithError`,
116117
:c:func:`PyObject_GetOptionalAttr` or :c:func:`PyObject_GetAttr` instead.
117118
@@ -492,6 +493,13 @@ Object Protocol
492493
on failure. This is equivalent to the Python statement ``del o[key]``.
493494
494495
496+
.. c:function:: int PyObject_DelItemString(PyObject *o, const char *key)
497+
498+
This is the same as :c:func:`PyObject_DelItem`, but *key* is
499+
specified as a :c:expr:`const char*` UTF-8 encoded bytes string,
500+
rather than a :c:expr:`PyObject*`.
501+
502+
495503
.. c:function:: PyObject* PyObject_Dir(PyObject *o)
496504
497505
This is equivalent to the Python expression ``dir(o)``, returning a (possibly

‎Doc/c-api/typeobj.rst

Copy file name to clipboardExpand all lines: Doc/c-api/typeobj.rst
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
10231023
:c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is clear in the subtype and the
10241024
:c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` fields in the subtype exist and have
10251025
``NULL`` values.
1026+
10261027
.. XXX are most flag bits *really* inherited individually?
10271028
10281029
**Default:**

‎Doc/conf.py

Copy file name to clipboardExpand all lines: Doc/conf.py
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@
101101

102102
# Create table of contents entries for domain objects (e.g. functions, classes,
103103
# attributes, etc.). Default is True.
104-
toc_object_entries = True
105-
# Hide parents to tidy up long entries in sidebar
106-
toc_object_entries_show_parents = 'hide'
104+
toc_object_entries = False
107105

108106
# Ignore any .rst files in the includes/ directory;
109107
# they're embedded in pages but not rendered as individual pages.

‎Doc/deprecations/pending-removal-in-3.16.rst

Copy file name to clipboardExpand all lines: Doc/deprecations/pending-removal-in-3.16.rst
+31-1Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,35 @@ Pending removal in Python 3.16
1919
* :mod:`asyncio`:
2020

2121
* :func:`!asyncio.iscoroutinefunction` is deprecated
22-
and will be removed in Python 3.16,
22+
and will be removed in Python 3.16;
2323
use :func:`inspect.iscoroutinefunction` instead.
2424
(Contributed by Jiahao Li and Kumar Aditya in :gh:`122875`.)
2525

26+
* :mod:`asyncio` policy system is deprecated and will be removed in Python 3.16.
27+
In particular, the following classes and functions are deprecated:
28+
29+
* :class:`asyncio.AbstractEventLoopPolicy`
30+
* :class:`asyncio.DefaultEventLoopPolicy`
31+
* :class:`asyncio.WindowsSelectorEventLoopPolicy`
32+
* :class:`asyncio.WindowsProactorEventLoopPolicy`
33+
* :func:`asyncio.get_event_loop_policy`
34+
* :func:`asyncio.set_event_loop_policy`
35+
* :func:`asyncio.set_event_loop`
36+
37+
Users should use :func:`asyncio.run` or :class:`asyncio.Runner` with
38+
*loop_factory* to use the desired event loop implementation.
39+
40+
For example, to use :class:`asyncio.SelectorEventLoop` on Windows::
41+
42+
import asyncio
43+
44+
async def main():
45+
...
46+
47+
asyncio.run(main(), loop_factory=asyncio.SelectorEventLoop)
48+
49+
(Contributed by Kumar Aditya in :gh:`127949`.)
50+
2651
* :mod:`builtins`:
2752

2853
* Bitwise inversion on boolean types, ``~True`` or ``~False``
@@ -54,3 +79,8 @@ Pending removal in Python 3.16
5479

5580
* The undocumented and unused :attr:`!TarFile.tarfile` attribute
5681
has been deprecated since Python 3.13.
82+
83+
* :mod:`functools`:
84+
85+
* Calling the Python implementation of :func:`functools.reduce` with *function*
86+
or *sequence* as keyword arguments has been deprecated since Python 3.14.

‎Doc/howto/free-threading-extensions.rst

Copy file name to clipboardExpand all lines: Doc/howto/free-threading-extensions.rst
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ Most of the C API is thread-safe, but there are some exceptions.
9696

9797
* **Struct Fields**: Accessing fields in Python C API objects or structs
9898
directly is not thread-safe if the field may be concurrently modified.
99-
* **Macros**: Accessor macros like :c:macro:`PyList_GET_ITEM` and
100-
:c:macro:`PyList_SET_ITEM` do not perform any error checking or locking.
99+
* **Macros**: Accessor macros like :c:macro:`PyList_GET_ITEM`,
100+
:c:macro:`PyList_SET_ITEM`, and macros like
101+
:c:macro:`PySequence_Fast_GET_SIZE` that use the object returned by
102+
:c:func:`PySequence_Fast` do not perform any error checking or locking.
101103
These macros are not thread-safe if the container object may be modified
102104
concurrently.
103105
* **Borrowed References**: C API functions that return

‎Doc/library/asyncio-eventloop.rst

Copy file name to clipboardExpand all lines: Doc/library/asyncio-eventloop.rst
+11-5Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ an event loop:
6262
.. versionchanged:: 3.14
6363
Raises a :exc:`RuntimeError` if there is no current event loop.
6464

65+
.. note::
66+
67+
The :mod:`!asyncio` policy system is deprecated and will be removed
68+
in Python 3.16; from there on, this function will always return the
69+
running event loop.
70+
71+
6572
.. function:: set_event_loop(loop)
6673

6774
Set *loop* as the current event loop for the current OS thread.
@@ -1781,12 +1788,11 @@ By default asyncio is configured to use :class:`EventLoop`.
17811788
import asyncio
17821789
import selectors
17831790

1784-
class MyPolicy(asyncio.DefaultEventLoopPolicy):
1785-
def new_event_loop(self):
1786-
selector = selectors.SelectSelector()
1787-
return asyncio.SelectorEventLoop(selector)
1791+
async def main():
1792+
...
17881793

1789-
asyncio.set_event_loop_policy(MyPolicy())
1794+
loop_factory = lambda: asyncio.SelectorEventLoop(selectors.SelectSelector())
1795+
asyncio.run(main(), loop_factory=loop_factory)
17901796

17911797

17921798
.. availability:: Unix, Windows.

‎Doc/library/asyncio-policy.rst

Copy file name to clipboardExpand all lines: Doc/library/asyncio-policy.rst
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
Policies
88
========
99

10+
.. warning::
11+
12+
Policies are deprecated and will be removed in Python 3.16.
13+
Users are encouraged to use the :func:`asyncio.run` function
14+
or the :class:`asyncio.Runner` with *loop_factory* to use
15+
the desired loop implementation.
16+
17+
1018
An event loop policy is a global object
1119
used to get and set the current :ref:`event loop <asyncio-event-loop>`,
1220
as well as create new event loops.

‎Doc/library/asyncio-runner.rst

Copy file name to clipboardExpand all lines: Doc/library/asyncio-runner.rst
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ Running an asyncio Program
7676

7777
*coro* can be any awaitable object.
7878

79+
.. note::
80+
81+
The :mod:`!asyncio` policy system is deprecated and will be removed
82+
in Python 3.16; from there on, an explicit *loop_factory* is needed
83+
to configure the event loop.
84+
7985

8086
Runner context manager
8187
======================

‎Doc/library/asyncio-task.rst

Copy file name to clipboardExpand all lines: Doc/library/asyncio-task.rst
+53-8Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,14 +1067,59 @@ Scheduling From Other Threads
10671067
This function is meant to be called from a different OS thread
10681068
than the one where the event loop is running. Example::
10691069

1070-
# Create a coroutine
1071-
coro = asyncio.sleep(1, result=3)
1072-
1073-
# Submit the coroutine to a given loop
1074-
future = asyncio.run_coroutine_threadsafe(coro, loop)
1075-
1076-
# Wait for the result with an optional timeout argument
1077-
assert future.result(timeout) == 3
1070+
def in_thread(loop: asyncio.AbstractEventLoop) -> None:
1071+
# Run some blocking IO
1072+
pathlib.Path("example.txt").write_text("hello world", encoding="utf8")
1073+
1074+
# Create a coroutine
1075+
coro = asyncio.sleep(1, result=3)
1076+
1077+
# Submit the coroutine to a given loop
1078+
future = asyncio.run_coroutine_threadsafe(coro, loop)
1079+
1080+
# Wait for the result with an optional timeout argument
1081+
assert future.result(timeout=2) == 3
1082+
1083+
async def amain() -> None:
1084+
# Get the running loop
1085+
loop = asyncio.get_running_loop()
1086+
1087+
# Run something in a thread
1088+
await asyncio.to_thread(in_thread, loop)
1089+
1090+
It's also possible to run the other way around. Example::
1091+
1092+
@contextlib.contextmanager
1093+
def loop_in_thread() -> Generator[asyncio.AbstractEventLoop]:
1094+
loop_fut = concurrent.futures.Future[asyncio.AbstractEventLoop]()
1095+
stop_event = asyncio.Event()
1096+
1097+
async def main() -> None:
1098+
loop_fut.set_result(asyncio.get_running_loop())
1099+
await stop_event.wait()
1100+
1101+
with concurrent.futures.ThreadPoolExecutor(1) as tpe:
1102+
complete_fut = tpe.submit(asyncio.run, main())
1103+
for fut in concurrent.futures.as_completed((loop_fut, complete_fut)):
1104+
if fut is loop_fut:
1105+
loop = loop_fut.result()
1106+
try:
1107+
yield loop
1108+
finally:
1109+
loop.call_soon_threadsafe(stop_event.set)
1110+
else:
1111+
fut.result()
1112+
1113+
# Create a loop in another thread
1114+
with loop_in_thread() as loop:
1115+
# Create a coroutine
1116+
coro = asyncio.sleep(1, result=3)
1117+
1118+
# Submit the coroutine to a given loop
1119+
future = asyncio.run_coroutine_threadsafe(coro, loop)
1120+
1121+
# Wait for the result with an optional timeout argument
1122+
assert future.result(timeout=2) == 3
10781123

10791124
If an exception is raised in the coroutine, the returned Future
10801125
will be notified. It can also be used to cancel the task in

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.