Skip to content

Commit 8c3ec53

Browse files
committed
Merge 3.4.3 release engineering changes back into 3.4.
2 parents e287746 + 7b2c3c6 commit 8c3ec53

89 files changed

Lines changed: 1275 additions & 1170 deletions

Some content is hidden

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

Doc/extending/newtypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ Here is an example::
12051205
{
12061206
if (strcmp(name, "data") == 0)
12071207
{
1208-
return PyInt_FromLong(obj->data);
1208+
return PyLong_FromLong(obj->data);
12091209
}
12101210

12111211
PyErr_Format(PyExc_AttributeError,

Doc/includes/email-headers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Import the email modules we'll need
22
from email.parser import Parser
33

4-
# If the e-mail headers are in a file, uncomment this line:
5-
#headers = Parser().parse(open(messagefile, 'r'))
4+
# If the e-mail headers are in a file, uncomment these two lines:
5+
# with open(messagefile) as fp:
6+
# headers = Parser().parse(fp)
67

78
# Or for parsing headers in a string, use:
89
headers = Parser().parsestr('From: <[email protected]>\n'

Doc/includes/email-mime.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
for file in pngfiles:
2121
# Open the files in binary mode. Let the MIMEImage class automatically
2222
# guess the specific image type.
23-
fp = open(file, 'rb')
24-
img = MIMEImage(fp.read())
25-
fp.close()
23+
with open(file, 'rb') as fp:
24+
img = MIMEImage(fp.read())
2625
msg.attach(img)
2726

2827
# Send the email via our own SMTP server.

Doc/includes/email-read-alternative-new-api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
from imaginary import magic_html_parser
1313

1414
# In a real program you'd get the filename from the arguments.
15-
msg = BytesParser(policy=policy.default).parse(open('outgoing.msg', 'rb'))
15+
with open('outgoing.msg', 'rb') as fp:
16+
msg = BytesParser(policy=policy.default).parse(fp)
1617

1718
# Now the header items can be accessed as a dictionary, and any non-ASCII will
1819
# be converted to unicode:

Doc/includes/email-simple.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66

77
# Open a plain text file for reading. For this example, assume that
88
# the text file contains only ASCII characters.
9-
fp = open(textfile, 'rb')
10-
# Create a text/plain message
11-
msg = MIMEText(fp.read())
12-
fp.close()
9+
with open(textfile) as fp:
10+
# Create a text/plain message
11+
msg = MIMEText(fp.read())
1312

1413
# me == the sender's email address
1514
# you == the recipient's email address

Doc/library/asyncio-dev.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ Example of unhandled exception::
212212
loop = asyncio.get_event_loop()
213213
asyncio.async(bug())
214214
loop.run_forever()
215+
loop.close()
215216

216217
Output::
217218

@@ -258,6 +259,7 @@ coroutine in another coroutine and use classic try/except::
258259
loop = asyncio.get_event_loop()
259260
asyncio.async(handle_exception())
260261
loop.run_forever()
262+
loop.close()
261263

262264
Another option is to use the :meth:`BaseEventLoop.run_until_complete`
263265
function::

Doc/library/asyncio-eventloop.rst

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ It provides multiple facilities, amongst which:
2222

2323
Base class of event loops.
2424

25+
This class is :ref:`not thread safe <asyncio-multithreading>`.
26+
2527
Run an event loop
2628
-----------------
2729

@@ -104,6 +106,9 @@ keywords to your callback, use :func:`functools.partial`. For example,
104106

105107
Like :meth:`call_soon`, but thread safe.
106108

109+
See the :ref:`concurrency and multithreading <asyncio-multithreading>`
110+
section of the documentation.
111+
107112

108113
.. _asyncio-delayed-calls:
109114

@@ -180,7 +185,7 @@ Coroutines
180185
Creating connections
181186
--------------------
182187

183-
.. method:: BaseEventLoop.create_connection(protocol_factory, host=None, port=None, \*, ssl=None, family=0, proto=0, flags=0, sock=None, local_addr=None, server_hostname=None)
188+
.. coroutinemethod:: BaseEventLoop.create_connection(protocol_factory, host=None, port=None, \*, ssl=None, family=0, proto=0, flags=0, sock=None, local_addr=None, server_hostname=None)
184189

185190
Create a streaming transport connection to a given Internet *host* and
186191
*port*: socket family :py:data:`~socket.AF_INET` or
@@ -253,7 +258,7 @@ Creating connections
253258
(:class:`StreamReader`, :class:`StreamWriter`) instead of a protocol.
254259

255260

256-
.. method:: BaseEventLoop.create_datagram_endpoint(protocol_factory, local_addr=None, remote_addr=None, \*, family=0, proto=0, flags=0)
261+
.. coroutinemethod:: BaseEventLoop.create_datagram_endpoint(protocol_factory, local_addr=None, remote_addr=None, \*, family=0, proto=0, flags=0)
257262

258263
Create datagram connection: socket family :py:data:`~socket.AF_INET` or
259264
:py:data:`~socket.AF_INET6` depending on *host* (or *family* if specified),
@@ -271,7 +276,7 @@ Creating connections
271276
:ref:`UDP echo server protocol <asyncio-udp-echo-server-protocol>` examples.
272277

273278

274-
.. method:: BaseEventLoop.create_unix_connection(protocol_factory, path, \*, ssl=None, sock=None, server_hostname=None)
279+
.. coroutinemethod:: BaseEventLoop.create_unix_connection(protocol_factory, path, \*, ssl=None, sock=None, server_hostname=None)
275280

276281
Create UNIX connection: socket family :py:data:`~socket.AF_UNIX`, socket
277282
type :py:data:`~socket.SOCK_STREAM`. The :py:data:`~socket.AF_UNIX` socket
@@ -290,7 +295,7 @@ Creating connections
290295
Creating listening connections
291296
------------------------------
292297

293-
.. method:: BaseEventLoop.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)
298+
.. coroutinemethod:: BaseEventLoop.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)
294299

295300
Create a TCP server (socket type :data:`~socket.SOCK_STREAM`) bound to
296301
*host* and *port*.
@@ -336,11 +341,13 @@ Creating listening connections
336341
:class:`StreamWriter`) pair and calls back a function with this pair.
337342

338343

339-
.. method:: BaseEventLoop.create_unix_server(protocol_factory, path=None, \*, sock=None, backlog=100, ssl=None)
344+
.. coroutinemethod:: BaseEventLoop.create_unix_server(protocol_factory, path=None, \*, sock=None, backlog=100, ssl=None)
340345

341346
Similar to :meth:`BaseEventLoop.create_server`, but specific to the
342347
socket family :py:data:`~socket.AF_UNIX`.
343348

349+
This method is a :ref:`coroutine <coroutine>`.
350+
344351
Availability: UNIX.
345352

346353

@@ -384,7 +391,7 @@ the file descriptor of a socket.
384391
Low-level socket operations
385392
---------------------------
386393

387-
.. method:: BaseEventLoop.sock_recv(sock, nbytes)
394+
.. coroutinemethod:: BaseEventLoop.sock_recv(sock, nbytes)
388395

389396
Receive data from the socket. The return value is a bytes object
390397
representing the data received. The maximum amount of data to be received
@@ -399,7 +406,7 @@ Low-level socket operations
399406

400407
The :meth:`socket.socket.recv` method.
401408

402-
.. method:: BaseEventLoop.sock_sendall(sock, data)
409+
.. coroutinemethod:: BaseEventLoop.sock_sendall(sock, data)
403410

404411
Send data to the socket. The socket must be connected to a remote socket.
405412
This method continues to send data from *data* until either all data has
@@ -416,7 +423,7 @@ Low-level socket operations
416423

417424
The :meth:`socket.socket.sendall` method.
418425

419-
.. method:: BaseEventLoop.sock_connect(sock, address)
426+
.. coroutinemethod:: BaseEventLoop.sock_connect(sock, address)
420427

421428
Connect to a remote socket at *address*.
422429

@@ -438,7 +445,7 @@ Low-level socket operations
438445
method.
439446

440447

441-
.. method:: BaseEventLoop.sock_accept(sock)
448+
.. coroutinemethod:: BaseEventLoop.sock_accept(sock)
442449

443450
Accept a connection. The socket must be bound to an address and listening
444451
for connections. The return value is a pair ``(conn, address)`` where *conn*
@@ -459,12 +466,12 @@ Low-level socket operations
459466
Resolve host name
460467
-----------------
461468

462-
.. method:: BaseEventLoop.getaddrinfo(host, port, \*, family=0, type=0, proto=0, flags=0)
469+
.. coroutinemethod:: BaseEventLoop.getaddrinfo(host, port, \*, family=0, type=0, proto=0, flags=0)
463470

464471
This method is a :ref:`coroutine <coroutine>`, similar to
465472
:meth:`socket.getaddrinfo` function but non-blocking.
466473

467-
.. method:: BaseEventLoop.getnameinfo(sockaddr, flags=0)
474+
.. coroutinemethod:: BaseEventLoop.getnameinfo(sockaddr, flags=0)
468475

469476
This method is a :ref:`coroutine <coroutine>`, similar to
470477
:meth:`socket.getnameinfo` function but non-blocking.
@@ -476,7 +483,7 @@ Connect pipes
476483
On Windows with :class:`SelectorEventLoop`, these methods are not supported.
477484
Use :class:`ProactorEventLoop` to support pipes on Windows.
478485

479-
.. method:: BaseEventLoop.connect_read_pipe(protocol_factory, pipe)
486+
.. coroutinemethod:: BaseEventLoop.connect_read_pipe(protocol_factory, pipe)
480487

481488
Register read pipe in eventloop.
482489

@@ -490,7 +497,7 @@ Use :class:`ProactorEventLoop` to support pipes on Windows.
490497

491498
This method is a :ref:`coroutine <coroutine>`.
492499

493-
.. method:: BaseEventLoop.connect_write_pipe(protocol_factory, pipe)
500+
.. coroutinemethod:: BaseEventLoop.connect_write_pipe(protocol_factory, pipe)
494501

495502
Register write pipe in eventloop.
496503

@@ -543,7 +550,7 @@ Call a function in an :class:`~concurrent.futures.Executor` (pool of threads or
543550
pool of processes). By default, an event loop uses a thread pool executor
544551
(:class:`~concurrent.futures.ThreadPoolExecutor`).
545552

546-
.. method:: BaseEventLoop.run_in_executor(executor, callback, \*args)
553+
.. coroutinemethod:: BaseEventLoop.run_in_executor(executor, callback, \*args)
547554

548555
Arrange for a callback to be called in the specified executor.
549556

@@ -654,7 +661,7 @@ Server
654661
The server is closed asynchonously, use the :meth:`wait_closed` coroutine
655662
to wait until the server is closed.
656663

657-
.. method:: wait_closed()
664+
.. coroutinemethod:: wait_closed()
658665

659666
Wait until the :meth:`close` method completes.
660667

Doc/library/asyncio-protocol.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ then call the transport's methods for various purposes.
2323
subprocess pipes. The methods available on a transport depend on
2424
the transport's kind.
2525

26+
The transport classes are :ref:`not thread safe <asyncio-multithreading>`.
27+
2628

2729
BaseTransport
2830
-------------

0 commit comments

Comments
 (0)