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

Skip to content

Commit 0ea0d59

Browse files
committed
Merge branch 'master' into long_export-decimal
2 parents cb169f7 + 48c70b8 commit 0ea0d59

226 files changed

Lines changed: 2152 additions & 812 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/c-api/long.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
657657
Export API
658658
^^^^^^^^^^
659659
660-
.. versionadded:: next
660+
.. versionadded:: 3.14
661661
662662
.. c:struct:: PyLongLayout
663663
@@ -769,7 +769,7 @@ PyLongWriter API
769769
770770
The :c:type:`PyLongWriter` API can be used to import an integer.
771771
772-
.. versionadded:: next
772+
.. versionadded:: 3.14
773773
774774
.. c:struct:: PyLongWriter
775775

Doc/c-api/sequence.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ Sequence Protocol
105105
equivalent to the Python expression ``value in o``.
106106
107107
108+
.. c:function:: int PySequence_In(PyObject *o, PyObject *value)
109+
110+
Alias for :c:func:`PySequence_Contains`.
111+
112+
.. deprecated:: 3.14
113+
The function is :term:`soft deprecated` and should no longer be used to
114+
write new code.
115+
116+
108117
.. c:function:: Py_ssize_t PySequence_Index(PyObject *o, PyObject *value)
109118
110119
Return the first index *i* for which ``o[i] == value``. On error, return

Doc/library/asyncio-policy.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,20 @@ for the current process:
4040

4141
Return the current process-wide policy.
4242

43+
.. deprecated:: next
44+
The :func:`get_event_loop_policy` function is deprecated and
45+
will be removed in Python 3.16.
46+
4347
.. function:: set_event_loop_policy(policy)
4448

4549
Set the current process-wide policy to *policy*.
4650

4751
If *policy* is set to ``None``, the default policy is restored.
4852

53+
.. deprecated:: next
54+
The :func:`set_event_loop_policy` function is deprecated and
55+
will be removed in Python 3.16.
56+
4957

5058
.. _asyncio-policy-objects:
5159

Doc/library/ctypes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,7 +1964,7 @@ Utility functions
19641964

19651965
.. availability:: Windows
19661966

1967-
.. versionadded:: next
1967+
.. versionadded:: 3.14
19681968

19691969

19701970
.. function:: cast(obj, type)
@@ -2825,4 +2825,4 @@ Exceptions
28252825

28262826
.. availability:: Windows
28272827

2828-
.. versionadded:: next
2828+
.. versionadded:: 3.14

Doc/library/errno.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ defined by the module. The specific list of defined symbols is available as
617617

618618
Memory page has hardware error.
619619

620-
.. versionadded:: next
620+
.. versionadded:: 3.14
621621

622622

623623
.. data:: EALREADY

Doc/library/itertools.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ loops that truncate the stream.
681681
consumed from the input iterator and there is no way to access it.
682682
This could be an issue if an application wants to further consume the
683683
input iterator after *takewhile* has been run to exhaustion. To work
684-
around this problem, consider using `more-iterools before_and_after()
684+
around this problem, consider using `more-itertools before_and_after()
685685
<https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.before_and_after>`_
686686
instead.
687687

Doc/library/select.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ Edge and Level Trigger Polling (epoll) Objects
324324
:const:`EPOLLEXCLUSIVE` was added. It's only supported by Linux Kernel 4.5
325325
or later.
326326

327-
.. versionadded:: next
327+
.. versionadded:: 3.14
328328
:const:`EPOLLWAKEUP` was added. It's only supported by Linux Kernel 3.5
329329
or later.
330330

Doc/library/stdtypes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4153,7 +4153,7 @@ copying.
41534153

41544154
Count the number of occurrences of *value*.
41554155

4156-
.. versionadded:: next
4156+
.. versionadded:: 3.14
41574157

41584158
.. method:: index(value, start=0, stop=sys.maxsize, /)
41594159

@@ -4162,7 +4162,7 @@ copying.
41624162

41634163
Raises a :exc:`ValueError` if *value* cannot be found.
41644164

4165-
.. versionadded:: next
4165+
.. versionadded:: 3.14
41664166

41674167
There are also several readonly attributes available:
41684168

Doc/whatsnew/3.14.rst

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,96 @@ asyncio
780780
It now raises a :exc:`RuntimeError` if there is no current event loop.
781781
(Contributed by Kumar Aditya in :gh:`126353`.)
782782

783+
There's a few patterns that use :func:`asyncio.get_event_loop`, most
784+
of them can be replaced with :func:`asyncio.run`.
785+
786+
If you're running an async function, simply use :func:`asyncio.run`.
787+
788+
Before::
789+
790+
async def main():
791+
...
792+
793+
794+
loop = asyncio.get_event_loop()
795+
try:
796+
loop.run_until_complete(main())
797+
finally:
798+
loop.close()
799+
800+
After::
801+
802+
async def main():
803+
...
804+
805+
asyncio.run(main())
806+
807+
If you need to start something, e.g. a server listening on a socket
808+
and then run forever, use :func:`asyncio.run` and an
809+
:class:`asyncio.Event`.
810+
811+
Before::
812+
813+
def start_server(loop):
814+
...
815+
816+
loop = asyncio.get_event_loop()
817+
try:
818+
start_server(loop)
819+
loop.run_forever()
820+
finally:
821+
loop.close()
822+
823+
After::
824+
825+
def start_server(loop):
826+
...
827+
828+
async def main():
829+
start_server(asyncio.get_running_loop())
830+
await asyncio.Event().wait()
831+
832+
asyncio.run(main())
833+
834+
If you need to run something in an event loop, then run some blocking
835+
code around it, use :class:`asyncio.Runner`.
836+
837+
Before::
838+
839+
async def operation_one():
840+
...
841+
842+
def blocking_code():
843+
...
844+
845+
async def operation_two():
846+
...
847+
848+
loop = asyncio.get_event_loop()
849+
try:
850+
loop.run_until_complete(operation_one())
851+
blocking_code()
852+
loop.run_until_complete(operation_two())
853+
finally:
854+
loop.close()
855+
856+
After::
857+
858+
async def operation_one():
859+
...
860+
861+
def blocking_code():
862+
...
863+
864+
async def operation_two():
865+
...
866+
867+
with asyncio.Runner() as runner:
868+
runner.run(operation_one())
869+
blocking_code()
870+
runner.run(operation_two())
871+
872+
783873

784874
collections.abc
785875
---------------
@@ -1073,6 +1163,10 @@ Deprecated
10731163
:c:macro:`!isfinite` available from :file:`math.h`
10741164
since C99. (Contributed by Sergey B Kirpichev in :gh:`119613`.)
10751165

1166+
* The previously undocumented function :c:func:`PySequence_In` is :term:`soft deprecated`.
1167+
Use :c:func:`PySequence_Contains` instead.
1168+
(Contributed by Yuki Kobayashi in :gh:`127896`.)
1169+
10761170
.. Add C API deprecations above alphabetically, not here at the end.
10771171
10781172
.. include:: ../deprecations/c-api-pending-removal-in-3.15.rst

Include/internal/pycore_atexit.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,29 @@ typedef struct atexit_callback {
3636
struct atexit_callback *next;
3737
} atexit_callback;
3838

39-
typedef struct {
40-
PyObject *func;
41-
PyObject *args;
42-
PyObject *kwargs;
43-
} atexit_py_callback;
44-
4539
struct atexit_state {
40+
#ifdef Py_GIL_DISABLED
41+
PyMutex ll_callbacks_lock;
42+
#endif
4643
atexit_callback *ll_callbacks;
4744

4845
// XXX The rest of the state could be moved to the atexit module state
4946
// and a low-level callback added for it during module exec.
5047
// For the moment we leave it here.
51-
atexit_py_callback **callbacks;
52-
int ncallbacks;
53-
int callback_len;
48+
49+
// List containing tuples with callback information.
50+
// e.g. [(func, args, kwargs), ...]
51+
PyObject *callbacks;
5452
};
5553

54+
#ifdef Py_GIL_DISABLED
55+
# define _PyAtExit_LockCallbacks(state) PyMutex_Lock(&state->ll_callbacks_lock);
56+
# define _PyAtExit_UnlockCallbacks(state) PyMutex_Unlock(&state->ll_callbacks_lock);
57+
#else
58+
# define _PyAtExit_LockCallbacks(state)
59+
# define _PyAtExit_UnlockCallbacks(state)
60+
#endif
61+
5662
// Export for '_interpchannels' shared extension
5763
PyAPI_FUNC(int) _Py_AtExit(
5864
PyInterpreterState *interp,

0 commit comments

Comments
 (0)