Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc0f724

Browse files
committed
Merge remote-tracking branch 'origin/main' into call-family
2 parents c1d2475 + 0d3d500 commit fc0f724

101 files changed

Lines changed: 3318 additions & 697 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Doc/bugs.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ If you find a bug in this documentation or would like to propose an improvement,
1919
please submit a bug report on the :ref:`tracker <using-the-tracker>`. If you
2020
have a suggestion on how to fix it, include that as well.
2121

22+
You can also open a discussion item on our
23+
`Documentation Discourse forum <https://discuss.python.org/c/documentation/26>`_.
24+
2225
If you're short on time, you can also email documentation bug reports to
2326
[email protected] (behavioral bugs can be sent to [email protected]).
2427
'docs@' is a mailing list run by volunteers; your request will be noticed,

Doc/library/asyncio-eventloop.rst

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -186,19 +186,24 @@ Running and stopping the loop
186186
.. coroutinemethod:: loop.shutdown_default_executor(timeout=None)
187187

188188
Schedule the closure of the default executor and wait for it to join all of
189-
the threads in the :class:`ThreadPoolExecutor`. After calling this method, a
190-
:exc:`RuntimeError` will be raised if :meth:`loop.run_in_executor` is called
191-
while using the default executor.
189+
the threads in the :class:`~concurrent.futures.ThreadPoolExecutor`.
190+
Once this method has been called,
191+
using the default executor with :meth:`loop.run_in_executor`
192+
will raise a :exc:`RuntimeError`.
192193

193-
The *timeout* parameter specifies the amount of time the executor will
194-
be given to finish joining. The default value is ``None``, which means the
195-
executor will be given an unlimited amount of time.
194+
The *timeout* parameter specifies the amount of time
195+
(in :class:`float` seconds) the executor will be given to finish joining.
196+
With the default, ``None``,
197+
the executor is allowed an unlimited amount of time.
196198

197-
If the timeout duration is reached, a warning is emitted and executor is
198-
terminated without waiting for its threads to finish joining.
199+
If the *timeout* is reached, a :exc:`RuntimeWarning` is emitted
200+
and the default executor is terminated
201+
without waiting for its threads to finish joining.
199202

200-
Note that there is no need to call this function when
201-
:func:`asyncio.run` is used.
203+
.. note::
204+
205+
Do not call this method when using :func:`asyncio.run`,
206+
as the latter handles default executor shutdown automatically.
202207

203208
.. versionadded:: 3.9
204209

@@ -213,22 +218,23 @@ Scheduling callbacks
213218
Schedule the *callback* :term:`callback` to be called with
214219
*args* arguments at the next iteration of the event loop.
215220

221+
Return an instance of :class:`asyncio.Handle`,
222+
which can be used later to cancel the callback.
223+
216224
Callbacks are called in the order in which they are registered.
217225
Each callback will be called exactly once.
218226

219-
An optional keyword-only *context* argument allows specifying a
227+
The optional keyword-only *context* argument specifies a
220228
custom :class:`contextvars.Context` for the *callback* to run in.
221-
The current context is used when no *context* is provided.
222-
223-
An instance of :class:`asyncio.Handle` is returned, which can be
224-
used later to cancel the callback.
229+
Callbacks use the current context when no *context* is provided.
225230

226-
This method is not thread-safe.
231+
Unlike :meth:`call_soon_threadsafe`, this method is not thread-safe.
227232

228233
.. method:: loop.call_soon_threadsafe(callback, *args, context=None)
229234

230-
A thread-safe variant of :meth:`call_soon`. Must be used to
231-
schedule callbacks *from another thread*.
235+
A thread-safe variant of :meth:`call_soon`. When scheduling callbacks from
236+
another thread, this function *must* be used, since :meth:`call_soon` is not
237+
thread-safe.
232238

233239
Raises :exc:`RuntimeError` if called on a loop that's been closed.
234240
This can happen on a secondary thread when the main application is

Doc/library/asyncio-task.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ Task Object
10971097
The *limit* argument is passed to :meth:`get_stack` directly.
10981098

10991099
The *file* argument is an I/O stream to which the output
1100-
is written; by default output is written to :data:`sys.stderr`.
1100+
is written; by default output is written to :data:`sys.stdout`.
11011101

11021102
.. method:: get_coro()
11031103

Doc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sphinx==4.5.0
88
blurb
99

1010
sphinx-lint==0.6.7
11-
sphinxext-opengraph>=0.7.1
11+
sphinxext-opengraph==0.7.5
1212

1313
# The theme used by the documentation is stored separately, so we need
1414
# to install that as well.

Doc/whatsnew/3.12.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ APIs:
479479
* :class:`webbrowser.MacOSX` (:gh:`86421`)
480480

481481
Pending Removal in Python 3.14
482-
==============================
482+
------------------------------
483483

484484
* Deprecated the following :mod:`importlib.abc` classes, scheduled for removal in
485485
Python 3.14:

Include/patchlevel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
#define PY_MINOR_VERSION 12
2121
#define PY_MICRO_VERSION 0
2222
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA
23-
#define PY_RELEASE_SERIAL 4
23+
#define PY_RELEASE_SERIAL 5
2424

2525
/* Version as a string */
26-
#define PY_VERSION "3.12.0a4+"
26+
#define PY_VERSION "3.12.0a5+"
2727
/*--end constants--*/
2828

2929
/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.

Lib/pydoc_data/topics.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Autogenerated by Sphinx on Tue Jan 10 13:08:32 2023
2+
# Autogenerated by Sphinx on Tue Feb 7 13:18:04 2023
33
topics = {'assert': 'The "assert" statement\n'
44
'**********************\n'
55
'\n'
@@ -4647,6 +4647,18 @@
46474647
'the source. The extension interface uses the modules "bdb" and '
46484648
'"cmd".\n'
46494649
'\n'
4650+
'See also:\n'
4651+
'\n'
4652+
' Module "faulthandler"\n'
4653+
' Used to dump Python tracebacks explicitly, on a fault, '
4654+
'after a\n'
4655+
' timeout, or on a user signal.\n'
4656+
'\n'
4657+
' Module "traceback"\n'
4658+
' Standard interface to extract, format and print stack '
4659+
'traces of\n'
4660+
' Python programs.\n'
4661+
'\n'
46504662
'The debugger’s prompt is "(Pdb)". Typical usage to run a program '
46514663
'under\n'
46524664
'control of the debugger is:\n'
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import unittest
2+
3+
from test.support import import_helper
4+
5+
6+
# Skip this test if the _testcapi module isn't available.
7+
_testcapi = import_helper.import_module('_testcapi')
8+
9+
10+
class PyEval_EvalCodeExTests(unittest.TestCase):
11+
12+
def test_simple(self):
13+
def f():
14+
return a
15+
16+
self.assertEqual(_testcapi.eval_code_ex(f.__code__, dict(a=1)), 1)
17+
18+
# Need to force the compiler to use LOAD_NAME
19+
# def test_custom_locals(self):
20+
# def f():
21+
# return
22+
23+
def test_with_args(self):
24+
def f(a, b, c):
25+
return a
26+
27+
self.assertEqual(_testcapi.eval_code_ex(f.__code__, {}, {}, (1, 2, 3)), 1)
28+
29+
def test_with_kwargs(self):
30+
def f(a, b, c):
31+
return a
32+
33+
self.assertEqual(_testcapi.eval_code_ex(f.__code__, {}, {}, (), dict(a=1, b=2, c=3)), 1)
34+
35+
def test_with_default(self):
36+
def f(a):
37+
return a
38+
39+
self.assertEqual(_testcapi.eval_code_ex(f.__code__, {}, {}, (), {}, (1,)), 1)
40+
41+
def test_with_kwarg_default(self):
42+
def f(*, a):
43+
return a
44+
45+
self.assertEqual(_testcapi.eval_code_ex(f.__code__, {}, {}, (), {}, (), dict(a=1)), 1)
46+
47+
def test_with_closure(self):
48+
a = 1
49+
def f():
50+
return a
51+
52+
self.assertEqual(_testcapi.eval_code_ex(f.__code__, {}, {}, (), {}, (), {}, f.__closure__), 1)
53+
54+
55+
if __name__ == "__main__":
56+
unittest.main()

Lib/test/test_capi/test_misc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,9 @@ def callback():
14131413
ret = assert_python_ok('-X', 'tracemalloc', '-c', code)
14141414
self.assertIn(b'callback called', ret.out)
14151415

1416+
def test_gilstate_matches_current(self):
1417+
_testcapi.test_current_tstate_matches()
1418+
14161419

14171420
class Test_testcapi(unittest.TestCase):
14181421
locals().update((name, getattr(_testcapi, name))

Lib/test/test_fileio.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
from test.support import (
1313
cpython_only, swap_attr, gc_collect, is_emscripten, is_wasi
1414
)
15-
from test.support.os_helper import (TESTFN, TESTFN_UNICODE, make_bad_fd)
15+
from test.support.os_helper import (
16+
TESTFN, TESTFN_ASCII, TESTFN_UNICODE, make_bad_fd,
17+
)
1618
from test.support.warnings_helper import check_warnings
1719
from collections import UserList
1820

@@ -431,18 +433,15 @@ def testUnicodeOpen(self):
431433

432434
def testBytesOpen(self):
433435
# Opening a bytes filename
434-
try:
435-
fn = TESTFN.encode("ascii")
436-
except UnicodeEncodeError:
437-
self.skipTest('could not encode %r to ascii' % TESTFN)
436+
fn = TESTFN_ASCII.encode("ascii")
438437
f = self.FileIO(fn, "w")
439438
try:
440439
f.write(b"abc")
441440
f.close()
442-
with open(TESTFN, "rb") as f:
441+
with open(TESTFN_ASCII, "rb") as f:
443442
self.assertEqual(f.read(), b"abc")
444443
finally:
445-
os.unlink(TESTFN)
444+
os.unlink(TESTFN_ASCII)
446445

447446
@unittest.skipIf(sys.getfilesystemencoding() != 'utf-8',
448447
"test only works for utf-8 filesystems")

0 commit comments

Comments
 (0)