8000 Merge branch 'master' into speedup_type_creation · python/cpython@89963ea · GitHub
[go: up one dir, main page]

Skip to content

Commit 89963ea

Browse files
committed
Merge branch 'master' into speedup_type_creation
2 parents ab17d15 + ffcb4c0 commit 89963ea

File tree

89 files changed

+4568
-1977
lines changed

Some content is hidden

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

89 files changed

+4568
-1977
lines changed

Doc/library/asyncio-eventloop.rst

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ Tasks
261261
Creating connections
262262
--------------------
263263

264-
.. coroutinemethod:: AbstractEventLoop.create_connection(protocol_factory, host=None, port=None, \*, ssl=None, family=0, proto=0, flags=0, sock=None, local_addr=None, server_hostname=None, ssl_handshake_timeout=10.0)
264+
.. coroutinemethod:: AbstractEventLoop.create_connection(protocol_factory, host=None, port=None, \*, ssl=None, family=0, proto=0, flags=0, sock=None, local_addr=None, server_hostname=None, ssl_handshake_timeout=None)
265265

266266
Create a streaming transport connection to a given Internet *host* and
267267
*port*: socket family :py:data:`~socket.AF_INET` or
@@ -327,6 +327,7 @@ Creating connections
327327

328328
* *ssl_handshake_timeout* is (for an SSL connection) the time in seconds
329329
to wait for the SSL handshake to complete before aborting the connection.
330+
``10.0`` seconds if ``None`` (default).
330331

331332
.. versionadded:: 3.7
332333

@@ -393,7 +394,7 @@ Creating connections
393394
:ref:`UDP echo server protocol <asyncio-udp-echo-server-protocol>` examples.
394395

395396

396-
.. coroutinemethod:: AbstractEventLoop.create_unix_connection(protocol_factory, path=None, \*, ssl=None, sock=None, server_hostname=None, ssl_handshake_timeout=10.0)
397+
.. coroutinemethod:: AbstractEventLoop.create_unix_connection(protocol_factory, path=None, \*, ssl=None, sock=None, server_hostname=None, ssl_handshake_timeout=None)
397398

398399
Create UNIX connection: socket family :py:data:`~socket.AF_UNIX`, socket
399400
type :py:data:`~socket.SOCK_STREAM`. The :py:data:`~socket.AF_UNIX` socket
@@ -423,7 +424,7 @@ Creating connections
423424
Creating listening connections
424425
------------------------------
425426

426-
.. coroutinemethod:: AbstractEventLoop.create_server(protocol_factory, host=None, port=None, \*, family=socket.AF_UNSPEC, flags=socket.AI_PASSIVE, sock=None, backlog=100, ssl=None, reuse_address=None, reuse_port=None, ssl_handshake_timeout=10.0)
427+
.. coroutinemethod:: AbstractEventLoop.create_server(protocol_factory, host=None, port=None, \*, family=socket.AF_UNSPEC, flags=socket.AI_PASSIVE, sock=None, backlog=100, ssl=None, reuse_address=None, reuse_port=None, ssl_handshake_timeout=None)
427428

428429
Create a TCP server (socket type :data:`~socket.SOCK_STREAM`) bound to
429430
*host* and *port*.
@@ -469,6 +470,7 @@ Creating listening connections
469470

470471
* *ssl_handshake_timeout* is (for an SSL server) the time in seconds to wait
471472
for the SSL handshake to complete before aborting the connection.
473+
``10.0`` seconds if ``None`` (default).
472474

473475
.. versionadded:: 3.7
474476

@@ -488,7 +490,7 @@ Creating listening connections
488490
The *host* parameter can now be a sequence of strings.
489491

490492

491-
.. coroutinemethod:: AbstractEventLoop.create_unix_server(protocol_factory, path=None, \*, sock=None, backlog=100, ssl=None, ssl_handshake_timeout=10.0)
493+
.. coroutinemethod:: AbstractEventLoop.create_unix_server(protocol_factory, path=None, \*, sock=None, backlog=100, ssl=None, ssl_handshake_timeout=None)
492494

493495
Similar to :meth:`AbstractEventLoop.create_server`, but specific to the
494496
socket family :py:data:`~socket.AF_UNIX`.
@@ -507,7 +509,7 @@ Creating listening connections
507509

508510
The *path* parameter can now be a :class:`~pathlib.Path` object.
509511

510-
.. coroutinemethod:: BaseEventLoop.connect_accepted_socket(protocol_factory, sock, \*, ssl=None, ssl_handshake_timeout=10.0)
512+
.. coroutinemethod:: BaseEventLoop.connect_accepted_socket(protocol_factory, sock, \*, ssl=None, ssl_handshake_timeout=None)
511513

512514
Handle an accepted connection.
513515

@@ -524,6 +526,7 @@ Creating listening connections
524526

525527
* *ssl_handshake_timeout* is (for an SSL connection) the time in seconds to
526528
wait for the SSL handshake to complete before aborting the connection.
529+
``10.0`` seconds if ``None`` (default).
527530

528531
When completed it returns a ``(transport, protocol)`` pair.
529532

@@ -534,6 +537,38 @@ Creating listening connections
534537
.. versionadded:: 3.5.3
535538

536539

540+
TLS Upgrade
541+
-----------
542+
543+
.. coroutinemethod:: AbstractEventLoop.start_tls(transport, protocol, sslcontext, \*, server_side=False, server_hostname=None, ssl_handshake_timeout=None)
544+
545+
Upgrades an existing connection to TLS.
546+
547+
Returns a new transport instance, that the *protocol* must start using
548+
immediately after the *await*. The *transport* instance passed to
549+
the *start_tls* method should never be used again.
550+
551+
Parameters:
552+
553+
* *transport* and *protocol* instances that methods like
554+
:meth:`~AbstractEventLoop.create_server` and
555+
:meth:`~AbstractEventLoop.create_connection` return.
556+
557+
* *sslcontext*: a configured instance of :class:`~ssl.SSLContext`.
558+
559+
* *server_side* pass ``True`` when a server-side connection is being
560+
upgraded (like the one created by :meth:`~AbstractEventLoop.create_server`).
561+
562+
* *server_hostname*: sets or overrides the host name that the target
563+
server's certificate will be matched against.
564+
565+
* *ssl_handshake_timeout* is (for an SSL connection) the time in seconds to
566+
wait for the SSL handshake to complete before aborting the connection.
567+
``10.0`` seconds if ``None`` (default).
568+
569+
.. versionadded:: 3.7
570+
571+
537572
Watch file descriptors
538573
----------------------
539574

@@ -878,6 +913,12 @@ Server
878913
The server is closed asynchronously, use the :meth:`wait_closed`
879914
coroutine to wait until the server is closed.
880915

916+
.. method:: get_loop()
917+
918+
Gives the event loop associated with the server object.
919+
920+
.. versionadded:: 3.7
921+
881922
.. coroutinemethod:: wait_closed()
882923

883924
Wait until the :meth:`close` method completes.

Doc/library/asyncio-task.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@ Future
306306
If the future is already done when this method is called, raises
307307
:exc:`InvalidStateError`.
308308

309+
.. method:: get_loop()
310+
311+
Return the event loop the future object is bound to.
312+
313+
.. versionadded:: 3.7
314+
309315

310316
Example: Future with run_until_complete()
311317
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Doc/library/concurrent.futures.rst

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,29 @@ Executor Objects
4040

4141
.. method:: map(func, *iterables, timeout=None, chunksize=1)
4242

43-
Equivalent to :func:`map(func, *iterables) <map>` except *func* is executed
44-
asynchronously and several calls to *func* may be made concurrently. The
45-
returned iterator raises a :exc:`concurrent.futures.TimeoutError` if
46-
:meth:`~iterator.__next__` is called and the result isn't available
43+
Similar to :func:`map(func, *iterables) <map>` except:
44+
45+
* the *iterables* are collected immediately rather than lazily;
46+
47+
* *func* is executed asynchronously and several calls to
48+
*func* may be made concurrently.
49+
50+
The returned iterator raises a :exc:`concurrent.futures.TimeoutError`
51+
if :meth:`~iterator.__next__` is called and the result isn't available
4752
after *timeout* seconds from the original call to :meth:`Executor.map`.
4853
*timeout* can be an int or a float. If *timeout* is not specified or
49-
``None``, there is no limit to the wait time. If a call raises an
50-
exception, then that exception will be raised when its value is
51-
retrieved from the iterator. When using :class:`ProcessPoolExecutor`, this
52-
method chops *iterables* into a number of chunks which it submits to the
53-
pool as separate tasks. The (approximate) size of these chunks can be
54-
specified by setting *chunksize* to a positive integer. For very long
55-
iterables, using a large value for *chunksize* can significantly improve
56-
performance compared to the default size of 1. With :class:`ThreadPoolExecutor`,
57-
*chunksize* has no effect.
54+
``None``, there is no limit to the wait time.
55+
56+
If a *func* call raises an exception, then that exception will be
57+
raised when its value is retrieved from the iterator.
58+
59+
When using :class:`ProcessPoolExecutor`, this method chops *iterables*
60+
into a number of chunks which it submits to the pool as separate
61+
tasks. The (approximate) size of these chunks can be specified by
62+
setting *chunksize* to a positive integer. For very long iterables,
63+
using a large value for *chunksize* can significantly improve
64+
performance compared to the default size of 1. With
65+
:class:`ThreadPoolExecutor`, *chunksize* has no effect.
5866

5967
.. versionchanged:: 3.5
6068
Added the *chunksize* argument.

Doc/library/datetime.rst

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,21 @@ Other constructors, all class methods:
436436
d``.
437437

438438

439+
.. classmethod:: date.fromisoformat(date_string)
440+
441+
Return a :class:`date` corresponding to a *date_string* in the format emitted
442+
by :meth:`date.isoformat`. Specifically, this function supports strings in
443+
the format(s) ``YYYY-MM-DD``.
444+
445+
.. caution::
446+
447+
This does not support parsing arbitrary ISO 8601 strings - it is only intended
448+
as the inverse operation of :meth:`date.isoformat`.
449+
450+
.. versionadded:: 3.7
451+
452+
453+
439454
Class attributes:
440455

441456
.. attribute:: date.min
@@ -819,6 +834,21 @@ Other constructors, all class methods:
819834
Added the *tzinfo* argument.
820835

821836

837+
.. classmethod:: datetime.fromisoformat(date_string)
838+
839+
Return a :class:`datetime` corresponding to a *date_string* in one of the
840+
formats emitted by :meth:`date.isoformat` and :meth:`datetime.isoformat`.
841+
Specifically, this function supports strings in the format(s)
842+
``YYYY-MM-DD[*HH[:MM[:SS[.mmm[mmm]]]][+HH:MM[:SS[.ffffff]]]]``,
843+
where ``*`` can match any single character.
844+
845+
.. caution::
846+
847+
This does not support parsing arbitrary ISO 8601 strings - it is only intended
848+
as the inverse operation of :meth:`datetime.isoformat`.
849+
850+
.. versionadded:: 3.7
851+
822852
.. classmethod:: datetime.strptime(date_string, format)
823853

824854
Return a :class:`.datetime` corresponding to *date_string*, parsed according to
@@ -1486,6 +1516,23 @@ In boolean contexts, a :class:`.time` object is always considered to be true.
14861516
error-prone and has been removed in Python 3.5. See :issue:`13936` for full
14871517
details.
14881518

1519+
1520+
Other constructor:
1521+
1522+
.. classmethod:: time.fromisoformat(time_string)
1523+
1524+
Return a :class:`time` corresponding to a *time_string* in one of the
1525+
formats emitted by :meth:`time.isoformat`. Specifically, this function supports
1526+
strings in the format(s) ``HH[:MM[:SS[.mmm[mmm]]]][+HH:MM[:SS[.ffffff]]]``.
1527+
1528+
.. caution::
1529+
1530+
This does not support parsing arbitrary ISO 8601 strings - it is only intended
1531+
as the inverse operation of :meth:`time.isoformat`.
1532+
1533+
.. versionadded:: 3.7
1534+
1535+
14891536
Instance methods:
14901537

14911538
.. method:: time.replace(hour=self.hour, minute=self.minute, second=self.second, \
@@ -1587,7 +1634,6 @@ Instance methods:
15871634
``self.tzinfo.tzname(None)``, or raises an exception if the latter doesn't
15881635
return ``None`` or a string object.
15891636

1590-
15911637
Example:
15921638

15931639
>>> from datetime import time, tzinfo, timedelta

Doc/library/io.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ Text I/O
904904
locale encoding using :func:`locale.setlocale`, use the current locale
905905
encoding instead of the user preferred encoding.
906906

907-
:class:`TextIOWrapper` provides one attribute in addition to those of
907+
:class:`TextIOWrapper` provides these members in addition to those of
908908
:class:`TextIOBase` and its parents:
909909

910910
.. attribute:: line_buffering
@@ -918,11 +918,19 @@ Text I/O
918918

919919
.. versionadded:: 3.7
920920

921-
.. method:: reconfigure(*, line_buffering=None, write_through=None)
921+
.. method:: reconfigure(*[, encoding][, errors][, newline][, \
922+
line_buffering][, write_through])
922923

923-
Reconfigure this text stream using new settings for *line_buffering*
924-
and *write_through*. Passing ``None`` as an argument will retain
925-
the current setting for that parameter.
924+
Reconfigure this text stream using new settings for *encoding*,
925+
*errors*, *newline*, *line_buffering* and *write_through*.
926+
927+
Parameters not specified keep current settings, except
928+
``errors='strict`` is used when *encoding* is specified but
929+
*errors* is not specified.
930+
931+
It is not possible to change the encoding or newline if some data
932+
has already been read from the stream. On the other hand, changing
933+
encoding after write is possible.
926934

927935
This method does an implicit stream flush before setting the
928936
new parameters.

Doc/library/os.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,13 +735,17 @@ as internal buffering of data.
735735

736736
.. function:: dup2(fd, fd2, inheritable=True)
737737

738-
Duplicate file descriptor *fd* to *fd2*, closing the latter first if necessary.
739-
The file descriptor *fd2* is :ref:`inheritable <fd_inheritance>` by default,
740-
or non-inheritable if *inheritable* is ``False``.
738+
Duplicate file descriptor *fd* to *fd2*, closing the latter first if
739+
necessary. Return *fd2*. The new file descriptor is :ref:`inheritable
740+
<fd_inheritance>` by default or non-inheritable if *inheritable*
741+
is ``False``.
741742

742743
.. versionchanged:: 3.4
743744
Add the optional *inheritable* parameter.
744745

746+
.. versionchanged:: 3.7
747+
Return *fd2* on success. Previously, ``None`` was always returned.
748+
745749

746750
.. function:: fchmod(fd, mode)
747751

Doc/library/pickle.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ The :mod:`pickle` module exports two classes, :class:`Pickler` and
370370
Python 2 names to the new names used in Python 3. The *encoding* and
371371
*errors* tell pickle how to decode 8-bit string instances pickled by Python
372372
2; these default to 'ASCII' and 'strict', respectively. The *encoding* can
373-
be 'bytes' to read these ß8-bit string instances as bytes objects.
373+
be 'bytes' to read these 8-bit string instances as bytes objects.
374374

375375
.. method:: load()
376376

Include/compile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
7575
#define PY_INVALID_STACK_EFFECT INT_MAX
7676
PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg);
7777

78-
PyAPI_FUNC(int) _PyAST_Optimize(struct _mod *, PyArena *arena);
78+
PyAPI_FUNC(int) _PyAST_Optimize(struct _mod *, PyArena *arena, int optimize);
7979

8080
#ifdef __cplusplus
8181
}

Include/fileutils.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,20 @@ PyAPI_FUNC(wchar_t *) Py_DecodeLocale(
1313
PyAPI_FUNC(char*) Py_EncodeLocale(
1414
const wchar_t *text,
1515
size_t *error_pos);
16+
17+
PyAPI_FUNC(char*) _Py_EncodeLocaleRaw(
18+
const wchar_t *text,
19+
size_t *error_pos);
1620
#endif
1721

18-
#ifndef Py_LIMITED_API
22+
#ifdef Py_BUILD_CORE
23+
PyAPI_FUNC(wchar_t*) _Py_DecodeUTF8_surrogateescape(
24+
const char *s,
25+
Py_ssize_t size,
26+
size_t *p_wlen);
27+
#endif
1928

29+
#ifndef Py_LIMITED_API
2030
PyAPI_FUNC(PyObject *) _Py_device_encoding(int);
2131

2232
#ifdef MS_WINDOWS

Include/odictobject.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ extern "C" {
66

77

88
/* OrderedDict */
9+
/* This API is optional and mostly redundant. */
910

1011
#ifndef Py_LIMITED_API
1112

@@ -21,10 +22,6 @@ PyAPI_DATA(PyTypeObject) PyODictValues_Type;
2122
#define PyODict_CheckExact(op) (Py_TYPE(op) == &PyODict_Type)
2223
#define PyODict_SIZE(op) PyDict_GET_SIZE((op))
2324

24-
#endif /* Py_LIMITED_API */
25-
26-
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
27-
2825
PyAPI_FUNC(PyObject *) PyODict_New(void);
2926
PyAPI_FUNC(int) PyODict_SetItem(PyObject *od, PyObject *key, PyObject *item);
3027
PyAPI_FUNC(int) PyODict_DelItem(PyObject *od, PyObject *key);

Include/pylifecycle.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ PyAPI_FUNC(int) Py_SetStandardStreamEncoding(const char *encoding,
5454
PyAPI_FUNC(_PyInitError) _Py_InitializeCore(const _PyCoreConfig *);
5555
PyAPI_FUNC(int) _Py_IsCoreInitialized(void);
5656

57-
PyAPI_FUNC(_PyInitError) _PyCoreConfig_ReadEnv(_PyCoreConfig *);
5857
PyAPI_FUNC(_PyInitError) _PyCoreConfig_Read(_PyCoreConfig *);
5958
PyAPI_FUNC(void) _PyCoreConfig_Clear(_PyCoreConfig *);
6059
PyAPI_FUNC(int) _PyCoreConfig_Copy(
@@ -119,6 +118,11 @@ PyAPI_FUNC(wchar_t *) Py_GetPath(void);
119118
#ifdef Py_BUILD_CORE
120119
PyAPI_FUNC(_PyInitError) _PyPathConfig_Init(const _PyCoreConfig *core_config);
121120
PyAPI_FUNC(PyObject*) _PyPathConfig_ComputeArgv0(int argc, wchar_t **argv);
121+
PyAPI_FUNC(int) _Py_FindEnvConfigValue(
122+
FILE *env_file,
123+
const wchar_t *key,
124+
wchar_t *value,
125+
size_t value_size);
122126
#endif
123127
PyAPI_FUNC(void) Py_SetPath(const wchar_t *);
124128
#ifdef MS_WINDOWS

0 commit comments

Comments
 (0)
0