Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit a5d0466

Browse files
author
Anselm Kruis
committed
merge branch 3.5
2 parents 6a9a82d + 9b566c3 commit a5d0466

File tree

222 files changed

+1774
-1130
lines changed

Some content is hidden

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

222 files changed

+1774
-1130
lines changed

Doc/c-api/buffer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protocol <bufferobjects>`. This protocol has two sides:
4040

4141
Simple objects such as :class:`bytes` and :class:`bytearray` expose their
4242
underlying buffer in byte-oriented form. Other forms are possible; for example,
43-
the elements exposed by a :class:`array.array` can be multi-byte values.
43+
the elements exposed by an :class:`array.array` can be multi-byte values.
4444

4545
An example consumer of the buffer interface is the :meth:`~io.BufferedIOBase.write`
4646
method of file objects: any object that can export a series of bytes through

Doc/distutils/index.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ very little overhead for build/release/install mechanics.
1515
.. note::
1616

1717
This guide only covers the basic tools for building and distributing
18-
extensions that are provided as part of this version of Python. Third
19-
party tools offer easier to use and more secure alternatives. Refer to the
20-
`quick recommendations section
21-
<https://python-packaging-user-guide.readthedocs.org/en/latest/current.html>`__
18+
extensions that are provided as part of this version of Python. Third party
19+
tools offer easier to use and more secure alternatives. Refer to the `quick
20+
recommendations section <https://packaging.python.org/en/latest/current/>`__
2221
in the Python Packaging User Guide for more information.
2322

2423

Doc/distutils/packageindex.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ follows::
167167
username: <username>
168168
password: <password>
169169

170-
The *distutils* section defines a *index-servers* variable that lists the
170+
The *distutils* section defines an *index-servers* variable that lists the
171171
name of all sections describing a repository.
172172

173173
Each section describing a repository defines three variables:

Doc/faq/general.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ after a final minor release is made, the Subversion trunk is incremented to the
151151
next minor version, which becomes the "a0" version,
152152
e.g. "2.4a0".
153153

154-
See also the documentation for ``sys.version``, ``sys.hexversion``, and
155-
``sys.version_info``.
154+
See also the documentation for :data:`sys.version`, :data:`sys.hexversion`, and
155+
:data:`sys.version_info`.
156156

157157

158158
How do I obtain a copy of the Python source?

Doc/faq/programming.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ How do I modify a string in place?
849849
You can't, because strings are immutable. In most situations, you should
850850
simply construct a new string from the various parts you want to assemble
851851
it from. However, if you need an object with the ability to modify in-place
852-
unicode data, try using a :class:`io.StringIO` object or the :mod:`array`
852+
unicode data, try using an :class:`io.StringIO` object or the :mod:`array`
853853
module::
854854

855855
>>> import io

Doc/howto/descriptor.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ Non-data descriptors provide a simple mechanism for variations on the usual
319319
patterns of binding functions into methods.
320320

321321
To recap, functions have a :meth:`__get__` method so that they can be converted
322-
to a method when accessed as attributes. The non-data descriptor transforms a
322+
to a method when accessed as attributes. The non-data descriptor transforms an
323323
``obj.f(*args)`` call into ``f(obj, *args)``. Calling ``klass.f(*args)``
324324
becomes ``f(*args)``.
325325

Doc/howto/logging-cookbook.rst

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,3 +2288,69 @@ You can of course use the conventional means of decoration::
22882288
@log_if_errors(logger)
22892289
def foo(fail=False):
22902290
...
2291+
2292+
2293+
.. _utc-formatting:
2294+
2295+
Formatting times using UTC (GMT) via configuration
2296+
--------------------------------------------------
2297+
2298+
Sometimes you want to format times using UTC, which can be done using a class
2299+
such as `UTCFormatter`, shown below::
2300+
2301+
import logging
2302+
import time
2303+
2304+
class UTCFormatter(logging.Formatter):
2305+
converter = time.gmtime
2306+
2307+
and you can then use the ``UTCFormatter`` in your code instead of
2308+
:class:`~logging.Formatter`. If you want to do that via configuration, you can
2309+
use the :func:`~logging.config.dictConfig` API with an approach illustrated by
2310+
the following complete example::
2311+
2312+
import logging
2313+
import logging.config
2314+
import time
2315+
2316+
class UTCFormatter(logging.Formatter):
2317+
converter = time.gmtime
2318+
2319+
LOGGING = {
2320+
'version': 1,
2321+
'disable_existing_loggers': False,
2322+
'formatters': {
2323+
'utc': {
2324+
'()': UTCFormatter,
2325+
'format': '%(asctime)s %(message)s',
2326+
},
2327+
'local': {
2328+
'format': '%(asctime)s %(message)s',
2329+
}
2330+
},
2331+
'handlers': {
2332+
'console1': {
2333+
'class': 'logging.StreamHandler',
2334+
'formatter': 'utc',
2335+
},
2336+
'console2': {
2337+
'class': 'logging.StreamHandler',
2338+
'formatter': 'local',
2339+
},
2340+
},
2341+
'root': {
2342+
'handlers': ['console1', 'console2'],
2343+
}
2344+
}
2345+
2346+
if __name__ == '__main__':
2347+
logging.config.dictConfig(LOGGING)
2348+
logging.warning('The local time is %s', time.asctime())
2349+
2350+
When this script is run, it should print something like::
2351+
2352+
2015-10-17 12:53:29,501 The local time is Sat Oct 17 13:53:29 2015
2353+
2015-10-17 13:53:29,501 The local time is Sat Oct 17 13:53:29 2015
2354+
2355+
showing how the time is formatted both as local time and UTC, one for each
2356+
handler.

Doc/install/index.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ modules and extensions.
2828

2929
.. note::
3030

31-
This guide only covers the basic tools for installing extensions that are
32-
provided as part of this version of Python. Third party tools offer easier
33-
to use and more secure alternatives. Refer to the
34-
`quick recommendations section
35-
<https://python-packaging-user-guide.readthedocs.org/en/latest/current.html>`__
31+
This guide only covers the basic tools for building and distributing
32+
extensions that are provided as part of this version of Python. Third party
33+
tools offer easier to use and more secure alternatives. Refer to the `quick
34+
recommendations section <https://packaging.python.org/en/latest/current/>`__
3635
in the Python Packaging User Guide for more information.
3736

3837

3938
.. _inst-intro:
4039

40+
4141
Introduction
4242
============
4343

@@ -148,7 +148,7 @@ into. For example, if you've just downloaded a module source distribution
148148

149149
On Windows, you'd probably download :file:`foo-1.0.zip`. If you downloaded the
150150
archive file to :file:`C:\\Temp`, then it would unpack into
151-
:file:`C:\\Temp\\foo-1.0`; you can use either a archive manipulator with a
151+
:file:`C:\\Temp\\foo-1.0`; you can use either an archive manipulator with a
152152
graphical user interface (such as WinZip) or a command-line tool (such as
153153
:program:`unzip` or :program:`pkunzip`) to unpack the archive. Then, open a
154154
command prompt window and run::

Doc/library/argparse.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ allow_abbrev
530530
^^^^^^^^^^^^
531531

532532
Normally, when you pass an argument list to the
533-
:meth:`~ArgumentParser.parse_args` method of a :class:`ArgumentParser`,
533+
:meth:`~ArgumentParser.parse_args` method of an :class:`ArgumentParser`,
534534
it :ref:`recognizes abbreviations <prefix-matching>` of long options.
535535

536536
This feature can be disabled by setting ``allow_abbrev`` to ``False``::

Doc/library/asyncio-eventloops.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ asyncio currently provides two implementations of event loops:
5757

5858
Example to use a :class:`ProactorEventLoop` on Windows::
5959

60-
import asyncio, os
60+
import asyncio, sys
6161

62-
if os.name == 'nt':
62+
if sys.platform == 'win32':
6363
loop = asyncio.ProactorEventLoop()
6464
asyncio.set_event_loop(loop)
6565

@@ -198,4 +198,3 @@ Access to the global loop policy
198198

199199
Set the current event loop policy. If *policy* is ``None``, the default
200200
policy is restored.
201-

Doc/library/asyncio-protocol.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ WriteTransport
148148
high-water limit. Neither *high* nor *low* can be negative.
149149

150150
The defaults are implementation-specific. If only the
151-
high-water limit is given, the low-water limit defaults to a
151+
high-water limit is given, the low-water limit defaults to an
152152
implementation-specific value less than or equal to the
153153
high-water limit. Setting *high* to zero forces *low* to zero as
154154
well, and causes :meth:`pause_writing` to be called whenever the

Doc/library/asyncio-stream.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ Streams (high-level API)
99
Stream functions
1010
================
1111

12+
.. note::
13+
14+
The top-level functions in this module are meant convenience wrappers
15+
only; there's really nothing special there, and if they don't do
16+
exactly what you want, feel free to copy their code.
17+
18+
1219
.. coroutinefunction:: open_connection(host=None, port=None, \*, loop=None, limit=None, \*\*kwds)
1320

1421
A wrapper for :meth:`~BaseEventLoop.create_connection()` returning a (reader,
@@ -26,10 +33,6 @@ Stream functions
2633
instance to use) and *limit* (to set the buffer limit passed to the
2734
:class:`StreamReader`).
2835

29-
(If you want to customize the :class:`StreamReader` and/or
30-
:class:`StreamReaderProtocol` classes, just copy the code -- there's really
31-
nothing special here except some convenience.)
32-
3336
This function is a :ref:`coroutine <coroutine>`.
3437

3538
.. coroutinefunction:: start_server(client_connected_cb, host=None, port=None, \*, loop=None, limit=None, \*\*kwds)

Doc/library/asyncio-subprocess.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ On Windows, the default event loop is :class:`SelectorEventLoop` which does not
1212
support subprocesses. :class:`ProactorEventLoop` should be used instead.
1313
Example to use it on Windows::
1414

15-
import asyncio, os
15+
import asyncio, sys
1616

17-
if os.name == 'nt':
17+
if sys.platform == 'win32':
1818
loop = asyncio.ProactorEventLoop()
1919
asyncio.set_event_loop(loop)
2020

Doc/library/chunk.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Usually an IFF-type file consists of one or more chunks. The proposed usage of
4747
the :class:`Chunk` class defined here is to instantiate an instance at the start
4848
of each chunk and read from the instance until it reaches the end, after which a
4949
new instance can be instantiated. At the end of the file, creating a new
50-
instance will fail with a :exc:`EOFError` exception.
50+
instance will fail with an :exc:`EOFError` exception.
5151

5252

5353
.. class:: Chunk(file, align=True, bigendian=True, inclheader=False)

Doc/library/concurrent.futures.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Executor Objects
9090
ThreadPoolExecutor
9191
------------------
9292

93-
:class:`ThreadPoolExecutor` is a :class:`Executor` subclass that uses a pool of
93+
:class:`ThreadPoolExecutor` is an :class:`Executor` subclass that uses a pool of
9494
threads to execute calls asynchronously.
9595

9696
Deadlocks can occur when the callable associated with a :class:`Future` waits on
@@ -304,7 +304,7 @@ The :class:`Future` class encapsulates the asynchronous execution of a callable.
304304

305305
Added callables are called in the order that they were added and are
306306
always called in a thread belonging to the process that added them. If
307-
the callable raises a :exc:`Exception` subclass, it will be logged and
307+
the callable raises an :exc:`Exception` subclass, it will be logged and
308308
ignored. If the callable raises a :exc:`BaseException` subclass, the
309309
behavior is undefined.
310310

Doc/library/contextlib.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Functions and classes provided:
142142
is hardwired to stdout.
143143

144144
For example, the output of :func:`help` normally is sent to *sys.stdout*.
145-
You can capture that output in a string by redirecting the output to a
145+
You can capture that output in a string by redirecting the output to an
146146
:class:`io.StringIO` object::
147147

148148
f = io.StringIO()

Doc/library/ctypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ loads libraries which export functions using the standard ``cdecl`` calling
3939
convention, while *windll* libraries call functions using the ``stdcall``
4040
calling convention. *oledll* also uses the ``stdcall`` calling convention, and
4141
assumes the functions return a Windows :c:type:`HRESULT` error code. The error
42-
code is used to automatically raise a :class:`OSError` exception when the
42+
code is used to automatically raise an :class:`OSError` exception when the
4343
function call fails.
4444

4545
.. versionchanged:: 3.3

Doc/library/difflib.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
9898
*wrapcolumn* is an optional keyword to specify column number where lines are
9999
broken and wrapped, defaults to ``None`` where lines are not wrapped.
100100

101-
*linejunk* and *charjunk* are optional keyword arguments passed into ``ndiff()``
101+
*linejunk* and *charjunk* are optional keyword arguments passed into :func:`ndiff`
102102
(used by :class:`HtmlDiff` to generate the side by side HTML differences). See
103-
``ndiff()`` documentation for argument default values and descriptions.
103+
:func:`ndiff` documentation for argument default values and descriptions.
104104

105105
The following methods are public:
106106

@@ -278,7 +278,7 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
278278
generating the delta lines) in unified diff format.
279279

280280
Unified diffs are a compact way of showing just the lines that have changed plus
281-
a few lines of context. The changes are shown in a inline style (instead of
281+
a few lines of context. The changes are shown in an inline style (instead of
282282
separate before/after blocks). The number of context lines is set by *n* which
283283
defaults to three.
284284

Doc/library/email.parser.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ have the same API as the :class:`Parser` and :class:`BytesParser` classes.
146146
methods on file-like objects.
147147

148148
The text contained in *fp* must be formatted as a block of :rfc:`2822`
149-
style headers and header continuation lines, optionally preceded by a
149+
style headers and header continuation lines, optionally preceded by an
150150
envelope header. The header block is terminated either by the end of the
151151
data or by a blank line. Following the header block is the body of the
152152
message (which may contain MIME-encoded subparts).
@@ -189,7 +189,7 @@ have the same API as the :class:`Parser` and :class:`BytesParser` classes.
189189
methods on file-like objects.
190190

191191
The bytes contained in *fp* must be formatted as a block of :rfc:`2822`
192-
style headers and header continuation lines, optionally preceded by a
192+
style headers and header continuation lines, optionally preceded by an
193193
envelope header. The header block is terminated either by the end of the
194194
data or by a blank line. Following the header block is the body of the
195195
message (which may contain MIME-encoded subparts, including subparts

0 commit comments

Comments
 (0)