~ubuntu-branches/ubuntu/raring/python3.2/raring

« back to all changes in this revision

Viewing changes to debian/patches/hg-updates.diff

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-10-21 18:38:17 UTC
  • Revision ID: package-import@ubuntu.com-20121021183817-vens8z6676vw3qyf
Tags: 3.2.3-6ubuntu4
* Update to 20121021 from the 3.2 branch.
* Backport python-config's --configdir option to 3.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# DP: hg updates of the 3.2 release branch (until 2012-09-21).
 
1
# DP: hg updates of the 3.2 release branch (until 2012-10-21).
2
2
 
3
3
# hg diff -r v3.2.3 | filterdiff --exclude=.hgignore --exclude=.hgeol --exclude=.hgtags --remove-timestamps
4
4
 
579
579
diff -r 3d0686d90f55 Doc/extending/newtypes.rst
580
580
--- a/Doc/extending/newtypes.rst
581
581
+++ b/Doc/extending/newtypes.rst
 
582
@@ -1299,9 +1299,9 @@
 
583
 bit does not indicate that the slot values are non-*NULL*. The flag may be set
 
584
 to indicate the presence of a slot, but a slot may still be unfilled.) ::
 
585
 
 
586
-   PyNumberMethods   tp_as_number;
 
587
-   PySequenceMethods tp_as_sequence;
 
588
-   PyMappingMethods  tp_as_mapping;
 
589
+   PyNumberMethods   *tp_as_number;
 
590
+   PySequenceMethods *tp_as_sequence;
 
591
+   PyMappingMethods  *tp_as_mapping;
 
592
 
 
593
 If you wish your object to be able to act like a number, a sequence, or a
 
594
 mapping object, then you place the address of a structure that implements the C
582
595
@@ -1459,9 +1459,8 @@
583
596
    }
584
597
 
1045
1058
       (for example standard input/output, in-memory buffers, sockets, pipes,
1046
1059
       etc.).  File objects are also called :dfn:`file-like objects` or
1047
1060
       :dfn:`streams`.
 
1061
@@ -354,7 +354,7 @@
 
1062
 
 
1063
    iterator
 
1064
       An object representing a stream of data.  Repeated calls to the iterator's
 
1065
-      :meth:`__next__` method (or passing it to the built-in function
 
1066
+      :meth:`~iterator.__next__` method (or passing it to the built-in function
 
1067
       :func:`next`) return successive items in the stream.  When no more data
 
1068
       are available a :exc:`StopIteration` exception is raised instead.  At this
 
1069
       point, the iterator object is exhausted and any further calls to its
1048
1070
@@ -385,7 +385,7 @@
1049
1071
       :meth:`str.lower` method can serve as a key function for case insensitive
1050
1072
       sorts.  Alternatively, an ad-hoc key function can be built from a
1054
1076
       :func:`~operator.attrgetter`, :func:`~operator.itemgetter`, and
1055
1077
       :func:`~operator.methodcaller`.  See the :ref:`Sorting HOW TO
1056
1078
       <sortinghowto>` for examples of how to create and use key functions.
 
1079
@@ -562,7 +562,7 @@
 
1080
    sequence
 
1081
       An :term:`iterable` which supports efficient element access using integer
 
1082
       indices via the :meth:`__getitem__` special method and defines a
 
1083
-      :meth:`len` method that returns the length of the sequence.
 
1084
+      :meth:`__len__` method that returns the length of the sequence.
 
1085
       Some built-in sequence types are :class:`list`, :class:`str`,
 
1086
       :class:`tuple`, and :class:`bytes`. Note that :class:`dict` also
 
1087
       supports :meth:`__getitem__` and :meth:`__len__`, but is considered a
1057
1088
@@ -600,6 +600,13 @@
1058
1089
       object has a type.  An object's type is accessible as its
1059
1090
       :attr:`__class__` attribute or can be retrieved with ``type(obj)``.
2054
2085
diff -r 3d0686d90f55 Doc/howto/functional.rst
2055
2086
--- a/Doc/howto/functional.rst
2056
2087
+++ b/Doc/howto/functional.rst
2057
 
@@ -246,9 +246,9 @@
 
2088
@@ -181,26 +181,26 @@
 
2089
 
 
2090
 An iterator is an object representing a stream of data; this object returns the
 
2091
 data one element at a time.  A Python iterator must support a method called
 
2092
-``__next__()`` that takes no arguments and always returns the next element of
 
2093
-the stream.  If there are no more elements in the stream, ``__next__()`` must
 
2094
-raise the ``StopIteration`` exception.  Iterators don't have to be finite,
 
2095
-though; it's perfectly reasonable to write an iterator that produces an infinite
 
2096
-stream of data.
 
2097
+:meth:`~iterator.__next__` that takes no arguments and always returns the next
 
2098
+element of the stream.  If there are no more elements in the stream,
 
2099
+:meth:`~iterator.__next__` must raise the :exc:`StopIteration` exception.
 
2100
+Iterators don't have to be finite, though; it's perfectly reasonable to write
 
2101
+an iterator that produces an infinite stream of data.
 
2102
 
 
2103
 The built-in :func:`iter` function takes an arbitrary object and tries to return
 
2104
 an iterator that will return the object's contents or elements, raising
 
2105
 :exc:`TypeError` if the object doesn't support iteration.  Several of Python's
 
2106
 built-in data types support iteration, the most common being lists and
 
2107
-dictionaries.  An object is called an **iterable** object if you can get an
 
2108
-iterator for it.
 
2109
+dictionaries.  An object is called :term:`iterable` if you can get an iterator
 
2110
+for it.
 
2111
 
 
2112
 You can experiment with the iteration interface manually:
 
2113
 
 
2114
     >>> L = [1,2,3]
 
2115
     >>> it = iter(L)
 
2116
-    >>> it
 
2117
+    >>> it  #doctest: +ELLIPSIS
 
2118
     <...iterator object at ...>
 
2119
-    >>> it.__next__()
 
2120
+    >>> it.__next__()  # same as next(it)
 
2121
     1
 
2122
     >>> next(it)
 
2123
     2
 
2124
@@ -213,9 +213,9 @@
 
2125
     >>>
 
2126
 
 
2127
 Python expects iterable objects in several different contexts, the most
 
2128
-important being the ``for`` statement.  In the statement ``for X in Y``, Y must
 
2129
-be an iterator or some object for which ``iter()`` can create an iterator.
 
2130
-These two statements are equivalent::
 
2131
+important being the :keyword:`for` statement.  In the statement ``for X in Y``,
 
2132
+Y must be an iterator or some object for which :func:`iter` can create an
 
2133
+iterator.  These two statements are equivalent::
 
2134
 
 
2135
 
 
2136
     for i in iter(obj):
 
2137
@@ -246,16 +246,16 @@
2058
2138
 iterator argument and will return the largest or smallest element.  The ``"in"``
2059
2139
 and ``"not in"`` operators also support iterators: ``X in iterator`` is true if
2060
2140
 X is found in the stream returned by the iterator.  You'll run into obvious
2061
2141
-problems if the iterator is infinite; ``max()``, ``min()``, and ``"not in"``
2062
 
+problems if the iterator is infinite; ``max()``, ``min()``
 
2142
+problems if the iterator is infinite; :func:`max`, :func:`min`
2063
2143
 will never return, and if the element X never appears in the stream, the
2064
2144
-``"in"`` operator won't return either.
2065
2145
+``"in"`` and ``"not in"`` operators won't return either.
2066
2146
 
2067
2147
 Note that you can only go forward in an iterator; there's no way to get the
2068
2148
 previous element, reset the iterator, or make a copy of it.  Iterator objects
 
2149
 can optionally provide these additional capabilities, but the iterator protocol
 
2150
-only specifies the ``next()`` method.  Functions may therefore consume all of
 
2151
-the iterator's output, and if you need to do something different with the same
 
2152
-stream, you'll have to create a new iterator.
 
2153
+only specifies the :meth:`~iterator.__next__` method.  Functions may therefore
 
2154
+consume all of the iterator's output, and if you need to do something different
 
2155
+with the same stream, you'll have to create a new iterator.
 
2156
 
 
2157
 
 
2158
 
 
2159
@@ -267,15 +267,11 @@
 
2160
 iterator.
 
2161
 
 
2162
 Calling :func:`iter` on a dictionary returns an iterator that will loop over the
 
2163
-dictionary's keys:
 
2164
-
 
2165
-.. not a doctest since dict ordering varies across Pythons
 
2166
-
 
2167
-::
 
2168
+dictionary's keys::
 
2169
 
 
2170
     >>> m = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6,
 
2171
     ...      'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12}
 
2172
-    >>> for key in m:
 
2173
+    >>> for key in m:  #doctest: +SKIP
 
2174
     ...     print(key, m[key])
 
2175
     Mar 3
 
2176
     Feb 2
 
2177
@@ -296,7 +292,7 @@
 
2178
 Applying :func:`iter` to a dictionary always loops over the keys, but
 
2179
 dictionaries have methods that return other iterators.  If you want to iterate
 
2180
 over values or key/value pairs, you can explicitly call the
 
2181
-:meth:`values` or :meth:`items` methods to get an appropriate iterator.
 
2182
+:meth:`~dict.values` or :meth:`~dict.items` methods to get an appropriate iterator.
 
2183
 
 
2184
 The :func:`dict` constructor can accept an iterator that returns a finite stream
 
2185
 of ``(key, value)`` tuples:
 
2186
@@ -305,9 +301,9 @@
 
2187
     >>> dict(iter(L))
 
2188
     {'Italy': 'Rome', 'US': 'Washington DC', 'France': 'Paris'}
 
2189
 
 
2190
-Files also support iteration by calling the ``readline()`` method until there
 
2191
-are no more lines in the file.  This means you can read each line of a file like
 
2192
-this::
 
2193
+Files also support iteration by calling the :meth:`~io.TextIOBase.readline`
 
2194
+method until there are no more lines in the file.  This means you can read each
 
2195
+line of a file like this::
 
2196
 
 
2197
     for line in file:
 
2198
         # do something for each line
 
2199
@@ -410,12 +406,9 @@
 
2200
 lengths of all the sequences.  If you have two lists of length 3, the output
 
2201
 list is 9 elements long:
 
2202
 
 
2203
-.. doctest::
 
2204
-    :options: +NORMALIZE_WHITESPACE
 
2205
-
 
2206
     >>> seq1 = 'abc'
 
2207
     >>> seq2 = (1,2,3)
 
2208
-    >>> [(x,y) for x in seq1 for y in seq2]
 
2209
+    >>> [(x, y) for x in seq1 for y in seq2]  #doctest: +NORMALIZE_WHITESPACE
 
2210
     [('a', 1), ('a', 2), ('a', 3),
 
2211
      ('b', 1), ('b', 2), ('b', 3),
 
2212
      ('c', 1), ('c', 2), ('c', 3)]
 
2213
@@ -425,9 +418,9 @@
 
2214
 comprehension below is a syntax error, while the second one is correct::
 
2215
 
 
2216
     # Syntax error
 
2217
-    [ x,y for x in seq1 for y in seq2]
 
2218
+    [x, y for x in seq1 for y in seq2]
 
2219
     # Correct
 
2220
-    [ (x,y) for x in seq1 for y in seq2]
 
2221
+    [(x, y) for x in seq1 for y in seq2]
 
2222
 
 
2223
 
 
2224
 Generators
 
2225
@@ -448,15 +441,13 @@
 
2226
 
 
2227
 Here's the simplest example of a generator function:
 
2228
 
 
2229
-.. testcode::
 
2230
+    >>> def generate_ints(N):
 
2231
+    ...    for i in range(N):
 
2232
+    ...        yield i
 
2233
 
 
2234
-    def generate_ints(N):
 
2235
-        for i in range(N):
 
2236
-            yield i
 
2237
-
 
2238
-Any function containing a ``yield`` keyword is a generator function; this is
 
2239
-detected by Python's :term:`bytecode` compiler which compiles the function
 
2240
-specially as a result.
 
2241
+Any function containing a :keyword:`yield` keyword is a generator function;
 
2242
+this is detected by Python's :term:`bytecode` compiler which compiles the
 
2243
+function specially as a result.
 
2244
 
 
2245
 When you call a generator function, it doesn't return a single value; instead it
 
2246
 returns a generator object that supports the iterator protocol.  On executing
 
2247
@@ -464,12 +455,13 @@
 
2248
 ``return`` statement.  The big difference between ``yield`` and a ``return``
 
2249
 statement is that on reaching a ``yield`` the generator's state of execution is
 
2250
 suspended and local variables are preserved.  On the next call to the
 
2251
-generator's ``.__next__()`` method, the function will resume executing.
 
2252
+generator's :meth:`~generator.__next__` method, the function will resume
 
2253
+executing.
 
2254
 
 
2255
 Here's a sample usage of the ``generate_ints()`` generator:
 
2256
 
 
2257
     >>> gen = generate_ints(3)
 
2258
-    >>> gen
 
2259
+    >>> gen  #doctest: +ELLIPSIS
 
2260
     <generator object generate_ints at ...>
 
2261
     >>> next(gen)
 
2262
     0
 
2263
@@ -491,17 +483,19 @@
 
2264
 ``return`` the generator cannot return any further values.  ``return`` with a
 
2265
 value, such as ``return 5``, is a syntax error inside a generator function.  The
 
2266
 end of the generator's results can also be indicated by raising
 
2267
-``StopIteration`` manually, or by just letting the flow of execution fall off
 
2268
+:exc:`StopIteration` manually, or by just letting the flow of execution fall off
 
2269
 the bottom of the function.
 
2270
 
 
2271
 You could achieve the effect of generators manually by writing your own class
 
2272
 and storing all the local variables of the generator as instance variables.  For
 
2273
 example, returning a list of integers could be done by setting ``self.count`` to
 
2274
-0, and having the ``__next__()`` method increment ``self.count`` and return it.
 
2275
+0, and having the :meth:`~iterator.__next__` method increment ``self.count`` and
 
2276
+return it.
 
2277
 However, for a moderately complicated generator, writing a corresponding class
 
2278
 can be much messier.
 
2279
 
 
2280
-The test suite included with Python's library, ``test_generators.py``, contains
 
2281
+The test suite included with Python's library,
 
2282
+:source:`Lib/test/test_generators.py`, contains
 
2283
 a number of more interesting examples.  Here's one generator that implements an
 
2284
 in-order traversal of a tree using generators recursively. ::
 
2285
 
 
2286
@@ -544,23 +538,23 @@
 
2287
 The parentheses aren't always necessary, but it's easier to always add them
 
2288
 instead of having to remember when they're needed.
 
2289
 
 
2290
-(PEP 342 explains the exact rules, which are that a ``yield``-expression must
 
2291
+(:pep:`342` explains the exact rules, which are that a ``yield``-expression must
 
2292
 always be parenthesized except when it occurs at the top-level expression on the
 
2293
 right-hand side of an assignment.  This means you can write ``val = yield i``
 
2294
 but have to use parentheses when there's an operation, as in ``val = (yield i)
 
2295
 + 12``.)
 
2296
 
 
2297
-Values are sent into a generator by calling its ``send(value)`` method.  This
 
2298
-method resumes the generator's code and the ``yield`` expression returns the
 
2299
-specified value.  If the regular ``__next__()`` method is called, the ``yield``
 
2300
-returns ``None``.
 
2301
+Values are sent into a generator by calling its :meth:`send(value)
 
2302
+<generator.send>` method.  This method resumes the generator's code and the
 
2303
+``yield`` expression returns the specified value.  If the regular
 
2304
+:meth:`~generator.__next__` method is called, the ``yield`` returns ``None``.
 
2305
 
 
2306
 Here's a simple counter that increments by 1 and allows changing the value of
 
2307
 the internal counter.
 
2308
 
 
2309
 .. testcode::
 
2310
 
 
2311
-    def counter (maximum):
 
2312
+    def counter(maximum):
 
2313
         i = 0
 
2314
         while i < maximum:
 
2315
             val = (yield i)
 
2316
@@ -572,16 +566,16 @@
 
2317
 
 
2318
 And here's an example of changing the counter:
 
2319
 
 
2320
-    >>> it = counter(10)
 
2321
-    >>> next(it)
 
2322
+    >>> it = counter(10)  #doctest: +SKIP
 
2323
+    >>> next(it)  #doctest: +SKIP
 
2324
     0
 
2325
-    >>> next(it)
 
2326
+    >>> next(it)  #doctest: +SKIP
 
2327
     1
 
2328
-    >>> it.send(8)
 
2329
+    >>> it.send(8)  #doctest: +SKIP
 
2330
     8
 
2331
-    >>> next(it)
 
2332
+    >>> next(it)  #doctest: +SKIP
 
2333
     9
 
2334
-    >>> next(it)
 
2335
+    >>> next(it)  #doctest: +SKIP
 
2336
     Traceback (most recent call last):
 
2337
       File "t.py", line 15, in ?
 
2338
         it.next()
 
2339
@@ -589,20 +583,23 @@
 
2340
 
 
2341
 Because ``yield`` will often be returning ``None``, you should always check for
 
2342
 this case.  Don't just use its value in expressions unless you're sure that the
 
2343
-``send()`` method will be the only method used resume your generator function.
 
2344
+:meth:`~generator.send` method will be the only method used resume your
 
2345
+generator function.
 
2346
 
 
2347
-In addition to ``send()``, there are two other new methods on generators:
 
2348
+In addition to :meth:`~generator.send`, there are two other methods on
 
2349
+generators:
 
2350
 
 
2351
-* ``throw(type, value=None, traceback=None)`` is used to raise an exception
 
2352
-  inside the generator; the exception is raised by the ``yield`` expression
 
2353
-  where the generator's execution is paused.
 
2354
+* :meth:`throw(type, value=None, traceback=None) <generator.throw>` is used to
 
2355
+  raise an exception inside the generator; the exception is raised by the
 
2356
+  ``yield`` expression where the generator's execution is paused.
 
2357
 
 
2358
-* ``close()`` raises a :exc:`GeneratorExit` exception inside the generator to
 
2359
-  terminate the iteration.  On receiving this exception, the generator's code
 
2360
-  must either raise :exc:`GeneratorExit` or :exc:`StopIteration`; catching the
 
2361
-  exception and doing anything else is illegal and will trigger a
 
2362
-  :exc:`RuntimeError`.  ``close()`` will also be called by Python's garbage
 
2363
-  collector when the generator is garbage-collected.
 
2364
+* :meth:`~generator.close` raises a :exc:`GeneratorExit` exception inside the
 
2365
+  generator to terminate the iteration.  On receiving this exception, the
 
2366
+  generator's code must either raise :exc:`GeneratorExit` or
 
2367
+  :exc:`StopIteration`; catching the exception and doing anything else is
 
2368
+  illegal and will trigger a :exc:`RuntimeError`.  :meth:`~generator.close`
 
2369
+  will also be called by Python's garbage collector when the generator is
 
2370
+  garbage-collected.
 
2371
 
 
2372
   If you need to run cleanup code when a :exc:`GeneratorExit` occurs, I suggest
 
2373
   using a ``try: ... finally:`` suite instead of catching :exc:`GeneratorExit`.
 
2374
@@ -624,13 +621,12 @@
 
2375
 Two of Python's built-in functions, :func:`map` and :func:`filter` duplicate the
 
2376
 features of generator expressions:
 
2377
 
 
2378
-``map(f, iterA, iterB, ...)`` returns an iterator over the sequence
 
2379
+:func:`map(f, iterA, iterB, ...) <map>` returns an iterator over the sequence
 
2380
  ``f(iterA[0], iterB[0]), f(iterA[1], iterB[1]), f(iterA[2], iterB[2]), ...``.
 
2381
 
 
2382
     >>> def upper(s):
 
2383
     ...     return s.upper()
 
2384
 
 
2385
-
 
2386
     >>> list(map(upper, ['sentence', 'fragment']))
 
2387
     ['SENTENCE', 'FRAGMENT']
 
2388
     >>> [upper(s) for s in ['sentence', 'fragment']]
 
2389
@@ -638,11 +634,11 @@
 
2390
 
 
2391
 You can of course achieve the same effect with a list comprehension.
 
2392
 
 
2393
-``filter(predicate, iter)`` returns an iterator over all the sequence elements
 
2394
-that meet a certain condition, and is similarly duplicated by list
 
2395
-comprehensions.  A **predicate** is a function that returns the truth value of
 
2396
-some condition; for use with :func:`filter`, the predicate must take a single
 
2397
-value.
 
2398
+:func:`filter(predicate, iter) <filter>` returns an iterator over all the
 
2399
+sequence elements that meet a certain condition, and is similarly duplicated by
 
2400
+list comprehensions.  A **predicate** is a function that returns the truth
 
2401
+value of some condition; for use with :func:`filter`, the predicate must take a
 
2402
+single value.
 
2403
 
 
2404
     >>> def is_even(x):
 
2405
     ...     return (x % 2) == 0
 
2406
@@ -657,8 +653,8 @@
 
2407
     [0, 2, 4, 6, 8]
 
2408
 
 
2409
 
 
2410
-``enumerate(iter)`` counts off the elements in the iterable, returning 2-tuples
 
2411
-containing the count and each element. ::
 
2412
+:func:`enumerate(iter) <enumerate>` counts off the elements in the iterable,
 
2413
+returning 2-tuples containing the count and each element. ::
 
2414
 
 
2415
     >>> for item in enumerate(['subject', 'verb', 'object']):
 
2416
     ...     print(item)
 
2417
@@ -674,29 +670,28 @@
 
2418
         if line.strip() == '':
 
2419
             print('Blank line at line #%i' % i)
 
2420
 
 
2421
-``sorted(iterable, [key=None], [reverse=False])`` collects all the elements of
 
2422
-the iterable into a list, sorts the list, and returns the sorted result.  The
 
2423
-``key``, and ``reverse`` arguments are passed through to the constructed list's
 
2424
-``.sort()`` method. ::
 
2425
+:func:`sorted(iterable, key=None, reverse=False) <sorted>` collects all the
 
2426
+elements of the iterable into a list, sorts the list, and returns the sorted
 
2427
+result.  The *key*, and *reverse* arguments are passed through to the
 
2428
+constructed list's :meth:`~list.sort` method. ::
 
2429
 
 
2430
     >>> import random
 
2431
     >>> # Generate 8 random numbers between [0, 10000)
 
2432
     >>> rand_list = random.sample(range(10000), 8)
 
2433
-    >>> rand_list
 
2434
+    >>> rand_list  #doctest: +SKIP
 
2435
     [769, 7953, 9828, 6431, 8442, 9878, 6213, 2207]
 
2436
-    >>> sorted(rand_list)
 
2437
+    >>> sorted(rand_list)  #doctest: +SKIP
 
2438
     [769, 2207, 6213, 6431, 7953, 8442, 9828, 9878]
 
2439
-    >>> sorted(rand_list, reverse=True)
 
2440
+    >>> sorted(rand_list, reverse=True)  #doctest: +SKIP
 
2441
     [9878, 9828, 8442, 7953, 6431, 6213, 2207, 769]
 
2442
 
 
2443
-(For a more detailed discussion of sorting, see the Sorting mini-HOWTO in the
 
2444
-Python wiki at http://wiki.python.org/moin/HowTo/Sorting.)
 
2445
+(For a more detailed discussion of sorting, see the :ref:`sortinghowto`.)
 
2446
 
 
2447
 
 
2448
-The ``any(iter)`` and ``all(iter)`` built-ins look at the truth values of an
 
2449
-iterable's contents.  :func:`any` returns True if any element in the iterable is
 
2450
-a true value, and :func:`all` returns True if all of the elements are true
 
2451
-values:
 
2452
+The :func:`any(iter) <any>` and :func:`all(iter) <all>` built-ins look at the
 
2453
+truth values of an iterable's contents.  :func:`any` returns True if any element
 
2454
+in the iterable is a true value, and :func:`all` returns True if all of the
 
2455
+elements are true values:
 
2456
 
 
2457
     >>> any([0,1,0])
 
2458
     True
 
2459
@@ -712,7 +707,7 @@
 
2460
     True
 
2461
 
 
2462
 
 
2463
-``zip(iterA, iterB, ...)`` takes one element from each iterable and
 
2464
+:func:`zip(iterA, iterB, ...) <zip>` takes one element from each iterable and
 
2465
 returns them in a tuple::
 
2466
 
 
2467
     zip(['a', 'b', 'c'], (1, 2, 3)) =>
 
2468
@@ -752,42 +747,44 @@
 
2469
 Creating new iterators
 
2470
 ----------------------
 
2471
 
 
2472
-``itertools.count(n)`` returns an infinite stream of integers, increasing by 1
 
2473
-each time.  You can optionally supply the starting number, which defaults to 0::
 
2474
+:func:`itertools.count(n) <itertools.count>` returns an infinite stream of
 
2475
+integers, increasing by 1 each time.  You can optionally supply the starting
 
2476
+number, which defaults to 0::
 
2477
 
 
2478
     itertools.count() =>
 
2479
       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...
 
2480
     itertools.count(10) =>
 
2481
       10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...
 
2482
 
 
2483
-``itertools.cycle(iter)`` saves a copy of the contents of a provided iterable
 
2484
-and returns a new iterator that returns its elements from first to last.  The
 
2485
-new iterator will repeat these elements infinitely. ::
 
2486
+:func:`itertools.cycle(iter) <itertools.cycle>` saves a copy of the contents of
 
2487
+a provided iterable and returns a new iterator that returns its elements from
 
2488
+first to last.  The new iterator will repeat these elements infinitely. ::
 
2489
 
 
2490
     itertools.cycle([1,2,3,4,5]) =>
 
2491
       1, 2, 3, 4, 5, 1, 2, 3, 4, 5, ...
 
2492
 
 
2493
-``itertools.repeat(elem, [n])`` returns the provided element ``n`` times, or
 
2494
-returns the element endlessly if ``n`` is not provided. ::
 
2495
+:func:`itertools.repeat(elem, [n]) <itertools.repeat>` returns the provided
 
2496
+element *n* times, or returns the element endlessly if *n* is not provided. ::
 
2497
 
 
2498
     itertools.repeat('abc') =>
 
2499
       abc, abc, abc, abc, abc, abc, abc, abc, abc, abc, ...
 
2500
     itertools.repeat('abc', 5) =>
 
2501
       abc, abc, abc, abc, abc
 
2502
 
 
2503
-``itertools.chain(iterA, iterB, ...)`` takes an arbitrary number of iterables as
 
2504
-input, and returns all the elements of the first iterator, then all the elements
 
2505
-of the second, and so on, until all of the iterables have been exhausted. ::
 
2506
+:func:`itertools.chain(iterA, iterB, ...) <itertools.chain>` takes an arbitrary
 
2507
+number of iterables as input, and returns all the elements of the first
 
2508
+iterator, then all the elements of the second, and so on, until all of the
 
2509
+iterables have been exhausted. ::
 
2510
 
 
2511
     itertools.chain(['a', 'b', 'c'], (1, 2, 3)) =>
 
2512
       a, b, c, 1, 2, 3
 
2513
 
 
2514
-``itertools.islice(iter, [start], stop, [step])`` returns a stream that's a
 
2515
-slice of the iterator.  With a single ``stop`` argument, it will return the
 
2516
-first ``stop`` elements.  If you supply a starting index, you'll get
 
2517
-``stop-start`` elements, and if you supply a value for ``step``, elements will
 
2518
-be skipped accordingly.  Unlike Python's string and list slicing, you can't use
 
2519
-negative values for ``start``, ``stop``, or ``step``. ::
 
2520
+:func:`itertools.islice(iter, [start], stop, [step]) <itertools.islice>` returns
 
2521
+a stream that's a slice of the iterator.  With a single *stop* argument, it
 
2522
+will return the first *stop* elements.  If you supply a starting index, you'll
 
2523
+get *stop-start* elements, and if you supply a value for *step*, elements
 
2524
+will be skipped accordingly.  Unlike Python's string and list slicing, you can't
 
2525
+use negative values for *start*, *stop*, or *step*. ::
 
2526
 
 
2527
     itertools.islice(range(10), 8) =>
 
2528
       0, 1, 2, 3, 4, 5, 6, 7
 
2529
@@ -796,9 +793,10 @@
 
2530
     itertools.islice(range(10), 2, 8, 2) =>
 
2531
       2, 4, 6
 
2532
 
 
2533
-``itertools.tee(iter, [n])`` replicates an iterator; it returns ``n``
 
2534
-independent iterators that will all return the contents of the source iterator.
 
2535
-If you don't supply a value for ``n``, the default is 2.  Replicating iterators
 
2536
+:func:`itertools.tee(iter, [n]) <itertools.tee>` replicates an iterator; it
 
2537
+returns *n* independent iterators that will all return the contents of the
 
2538
+source iterator.
 
2539
+If you don't supply a value for *n*, the default is 2.  Replicating iterators
 
2540
 requires saving some of the contents of the source iterator, so this can consume
 
2541
 significant memory if the iterator is large and one of the new iterators is
 
2542
 consumed more than the others. ::
 
2543
@@ -816,19 +814,21 @@
 
2544
 Calling functions on elements
 
2545
 -----------------------------
 
2546
 
 
2547
-The ``operator`` module contains a set of functions corresponding to Python's
 
2548
-operators.  Some examples are ``operator.add(a, b)`` (adds two values),
 
2549
-``operator.ne(a, b)`` (same as ``a!=b``), and ``operator.attrgetter('id')``
 
2550
-(returns a callable that fetches the ``"id"`` attribute).
 
2551
+The :mod:`operator` module contains a set of functions corresponding to Python's
 
2552
+operators.  Some examples are :func:`operator.add(a, b) <operator.add>` (adds
 
2553
+two values), :func:`operator.ne(a, b)  <operator.ne>` (same as ``a != b``), and
 
2554
+:func:`operator.attrgetter('id') <operator.attrgetter>`
 
2555
+(returns a callable that fetches the ``.id`` attribute).
 
2556
 
 
2557
-``itertools.starmap(func, iter)`` assumes that the iterable will return a stream
 
2558
-of tuples, and calls ``f()`` using these tuples as the arguments::
 
2559
+:func:`itertools.starmap(func, iter) <itertools.starmap>` assumes that the
 
2560
+iterable will return a stream of tuples, and calls *func* using these tuples as
 
2561
+the arguments::
 
2562
 
 
2563
     itertools.starmap(os.path.join,
 
2564
-                      [('/usr', 'bin', 'java'), ('/bin', 'python'),
 
2565
-                       ('/usr', 'bin', 'perl'),('/usr', 'bin', 'ruby')])
 
2566
+                      [('/bin', 'python'), ('/usr', 'bin', 'java'),
 
2567
+                       ('/usr', 'bin', 'perl'), ('/usr', 'bin', 'ruby')])
 
2568
     =>
 
2569
-      /usr/bin/java, /bin/python, /usr/bin/perl, /usr/bin/ruby
 
2570
+      /bin/python, /usr/bin/java, /usr/bin/perl, /usr/bin/ruby
 
2571
 
 
2572
 
 
2573
 Selecting elements
 
2574
@@ -837,20 +837,18 @@
 
2575
 Another group of functions chooses a subset of an iterator's elements based on a
 
2576
 predicate.
 
2577
 
 
2578
-``itertools.filterfalse(predicate, iter)`` is the opposite, returning all
 
2579
-elements for which the predicate returns false::
 
2580
+:func:`itertools.filterfalse(predicate, iter) <itertools.filterfalse>` is the
 
2581
+opposite, returning all elements for which the predicate returns false::
 
2582
 
 
2583
     itertools.filterfalse(is_even, itertools.count()) =>
 
2584
       1, 3, 5, 7, 9, 11, 13, 15, ...
 
2585
 
 
2586
-``itertools.takewhile(predicate, iter)`` returns elements for as long as the
 
2587
-predicate returns true.  Once the predicate returns false, the iterator will
 
2588
-signal the end of its results.
 
2589
-
 
2590
-::
 
2591
+:func:`itertools.takewhile(predicate, iter) <itertools.takewhile>` returns
 
2592
+elements for as long as the predicate returns true.  Once the predicate returns
 
2593
+false, the iterator will signal the end of its results. ::
 
2594
 
 
2595
     def less_than_10(x):
 
2596
-        return (x < 10)
 
2597
+        return x < 10
 
2598
 
 
2599
     itertools.takewhile(less_than_10, itertools.count()) =>
 
2600
       0, 1, 2, 3, 4, 5, 6, 7, 8, 9
 
2601
@@ -858,10 +856,9 @@
 
2602
     itertools.takewhile(is_even, itertools.count()) =>
 
2603
       0
 
2604
 
 
2605
-``itertools.dropwhile(predicate, iter)`` discards elements while the predicate
 
2606
-returns true, and then returns the rest of the iterable's results.
 
2607
-
 
2608
-::
 
2609
+:func:`itertools.dropwhile(predicate, iter) <itertools.dropwhile>` discards
 
2610
+elements while the predicate returns true, and then returns the rest of the
 
2611
+iterable's results. ::
 
2612
 
 
2613
     itertools.dropwhile(less_than_10, itertools.count()) =>
 
2614
       10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...
 
2615
@@ -873,14 +870,14 @@
 
2616
 Grouping elements
 
2617
 -----------------
 
2618
 
 
2619
-The last function I'll discuss, ``itertools.groupby(iter, key_func=None)``, is
 
2620
-the most complicated.  ``key_func(elem)`` is a function that can compute a key
 
2621
-value for each element returned by the iterable.  If you don't supply a key
 
2622
-function, the key is simply each element itself.
 
2623
+The last function I'll discuss, :func:`itertools.groupby(iter, key_func=None)
 
2624
+<itertools.groupby>`, is the most complicated.  ``key_func(elem)`` is a function
 
2625
+that can compute a key value for each element returned by the iterable.  If you
 
2626
+don't supply a key function, the key is simply each element itself.
 
2627
 
 
2628
-``groupby()`` collects all the consecutive elements from the underlying iterable
 
2629
-that have the same key value, and returns a stream of 2-tuples containing a key
 
2630
-value and an iterator for the elements with that key.
 
2631
+:func:`~itertools.groupby` collects all the consecutive elements from the
 
2632
+underlying iterable that have the same key value, and returns a stream of
 
2633
+2-tuples containing a key value and an iterator for the elements with that key.
 
2634
 
 
2635
 ::
 
2636
 
 
2637
@@ -890,7 +887,7 @@
 
2638
                  ...
 
2639
                 ]
 
2640
 
 
2641
-    def get_state (city_state):
 
2642
+    def get_state(city_state):
 
2643
         return city_state[1]
 
2644
 
 
2645
     itertools.groupby(city_list, get_state) =>
 
2646
@@ -906,9 +903,9 @@
 
2647
     iterator-3 =>
 
2648
       ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ')
 
2649
 
 
2650
-``groupby()`` assumes that the underlying iterable's contents will already be
 
2651
-sorted based on the key.  Note that the returned iterators also use the
 
2652
-underlying iterable, so you have to consume the results of iterator-1 before
 
2653
+:func:`~itertools.groupby` assumes that the underlying iterable's contents will
 
2654
+already be sorted based on the key.  Note that the returned iterators also use
 
2655
+the underlying iterable, so you have to consume the results of iterator-1 before
 
2656
 requesting iterator-2 and its corresponding key.
 
2657
 
 
2658
 
 
2659
@@ -926,33 +923,34 @@
 
2660
 ``g(b, c)`` that's equivalent to ``f(1, b, c)``; you're filling in a value for
 
2661
 one of ``f()``'s parameters.  This is called "partial function application".
 
2662
 
 
2663
-The constructor for ``partial`` takes the arguments ``(function, arg1, arg2,
 
2664
-... kwarg1=value1, kwarg2=value2)``.  The resulting object is callable, so you
 
2665
-can just call it to invoke ``function`` with the filled-in arguments.
 
2666
+The constructor for :func:`~functools.partial` takes the arguments
 
2667
+``(function, arg1, arg2, ..., kwarg1=value1, kwarg2=value2)``.  The resulting
 
2668
+object is callable, so you can just call it to invoke ``function`` with the
 
2669
+filled-in arguments.
 
2670
 
 
2671
 Here's a small but realistic example::
 
2672
 
 
2673
     import functools
 
2674
 
 
2675
-    def log (message, subsystem):
 
2676
-        "Write the contents of 'message' to the specified subsystem."
 
2677
+    def log(message, subsystem):
 
2678
+        """Write the contents of 'message' to the specified subsystem."""
 
2679
         print('%s: %s' % (subsystem, message))
 
2680
         ...
 
2681
 
 
2682
     server_log = functools.partial(log, subsystem='server')
 
2683
     server_log('Unable to open socket')
 
2684
 
 
2685
-``functools.reduce(func, iter, [initial_value])`` cumulatively performs an
 
2686
-operation on all the iterable's elements and, therefore, can't be applied to
 
2687
-infinite iterables.  (Note it is not in :mod:`builtins`, but in the
 
2688
-:mod:`functools` module.)  ``func`` must be a function that takes two elements
 
2689
-and returns a single value.  :func:`functools.reduce` takes the first two
 
2690
-elements A and B returned by the iterator and calculates ``func(A, B)``.  It
 
2691
-then requests the third element, C, calculates ``func(func(A, B), C)``, combines
 
2692
-this result with the fourth element returned, and continues until the iterable
 
2693
-is exhausted.  If the iterable returns no values at all, a :exc:`TypeError`
 
2694
-exception is raised.  If the initial value is supplied, it's used as a starting
 
2695
-point and ``func(initial_value, A)`` is the first calculation. ::
 
2696
+:func:`functools.reduce(func, iter, [initial_value]) <functools.reduce>`
 
2697
+cumulatively performs an operation on all the iterable's elements and,
 
2698
+therefore, can't be applied to infinite iterables. *func* must be a function
 
2699
+that takes two elements and returns a single value.  :func:`functools.reduce`
 
2700
+takes the first two elements A and B returned by the iterator and calculates
 
2701
+``func(A, B)``.  It then requests the third element, C, calculates
 
2702
+``func(func(A, B), C)``, combines this result with the fourth element returned,
 
2703
+and continues until the iterable is exhausted.  If the iterable returns no
 
2704
+values at all, a :exc:`TypeError` exception is raised.  If the initial value is
 
2705
+supplied, it's used as a starting point and ``func(initial_value, A)`` is the
 
2706
+first calculation. ::
 
2707
 
 
2708
     >>> import operator, functools
 
2709
     >>> functools.reduce(operator.concat, ['A', 'BB', 'C'])
 
2710
@@ -978,8 +976,8 @@
 
2711
     >>> sum([])
 
2712
     0
 
2713
 
 
2714
-For many uses of :func:`functools.reduce`, though, it can be clearer to just write the
 
2715
-obvious :keyword:`for` loop::
 
2716
+For many uses of :func:`functools.reduce`, though, it can be clearer to just
 
2717
+write the obvious :keyword:`for` loop::
 
2718
 
 
2719
    import functools
 
2720
    # Instead of:
 
2721
@@ -1023,28 +1021,23 @@
 
2722
     existing_files = filter(os.path.exists, file_list)
 
2723
 
 
2724
 If the function you need doesn't exist, you need to write it.  One way to write
 
2725
-small functions is to use the ``lambda`` statement.  ``lambda`` takes a number
 
2726
-of parameters and an expression combining these parameters, and creates a small
 
2727
-function that returns the value of the expression::
 
2728
+small functions is to use the :keyword:`lambda` statement.  ``lambda`` takes a
 
2729
+number of parameters and an expression combining these parameters, and creates
 
2730
+an anonymous function that returns the value of the expression::
 
2731
 
 
2732
-    lowercase = lambda x: x.lower()
 
2733
+    adder = lambda x, y: x+y
 
2734
 
 
2735
     print_assign = lambda name, value: name + '=' + str(value)
 
2736
 
 
2737
-    adder = lambda x, y: x+y
 
2738
-
 
2739
 An alternative is to just use the ``def`` statement and define a function in the
 
2740
 usual way::
 
2741
 
 
2742
-    def lowercase(x):
 
2743
-        return x.lower()
 
2744
+    def adder(x, y):
 
2745
+        return x + y
 
2746
 
 
2747
     def print_assign(name, value):
 
2748
         return name + '=' + str(value)
 
2749
 
 
2750
-    def adder(x,y):
 
2751
-        return x + y
 
2752
-
 
2753
 Which alternative is preferable?  That's a style question; my usual course is to
 
2754
 avoid using ``lambda``.
 
2755
 
 
2756
@@ -1053,9 +1046,7 @@
 
2757
 expression, which means you can't have multiway ``if... elif... else``
 
2758
 comparisons or ``try... except`` statements.  If you try to do too much in a
 
2759
 ``lambda`` statement, you'll end up with an overly complicated expression that's
 
2760
-hard to read.  Quick, what's the following code doing?
 
2761
-
 
2762
-::
 
2763
+hard to read.  Quick, what's the following code doing? ::
 
2764
 
 
2765
     import functools
 
2766
     total = functools.reduce(lambda a, b: (0, a[1] + b[1]), items)[1]
 
2767
@@ -1065,7 +1056,7 @@
 
2768
 little bit better::
 
2769
 
 
2770
     import functools
 
2771
-    def combine (a, b):
 
2772
+    def combine(a, b):
 
2773
         return 0, a[1] + b[1]
 
2774
 
 
2775
     total = functools.reduce(combine, items)[1]
 
2776
@@ -1085,12 +1076,12 @@
 
2777
 Fredrik Lundh once suggested the following set of rules for refactoring uses of
 
2778
 ``lambda``:
 
2779
 
 
2780
-1) Write a lambda function.
 
2781
-2) Write a comment explaining what the heck that lambda does.
 
2782
-3) Study the comment for a while, and think of a name that captures the essence
 
2783
+1. Write a lambda function.
 
2784
+2. Write a comment explaining what the heck that lambda does.
 
2785
+3. Study the comment for a while, and think of a name that captures the essence
 
2786
    of the comment.
 
2787
-4) Convert the lambda to a def statement, using that name.
 
2788
-5) Remove the comment.
 
2789
+4. Convert the lambda to a def statement, using that name.
 
2790
+5. Remove the comment.
 
2791
 
 
2792
 I really like these rules, but you're free to disagree
 
2793
 about whether this lambda-free style is better.
2069
2794
diff -r 3d0686d90f55 Doc/howto/index.rst
2070
2795
--- a/Doc/howto/index.rst
2071
2796
+++ b/Doc/howto/index.rst
2879
3604
+      invalid start byte
2880
3605
     >>> b'\x80abc'.decode("utf-8", "replace")
2881
3606
-    '?abc'
2882
 
+    '�abc'
 
3607
+    '\ufffdabc'
2883
3608
     >>> b'\x80abc'.decode("utf-8", "ignore")
2884
3609
     'abc'
2885
3610
 
2927
3652
     req = urllib.request.Request(url, data)
2928
3653
     response = urllib.request.urlopen(req)
2929
3654
     the_page = response.read()
 
3655
@@ -136,7 +137,7 @@
 
3656
     >>> data['location'] = 'Northampton'
 
3657
     >>> data['language'] = 'Python'
 
3658
     >>> url_values = urllib.parse.urlencode(data)
 
3659
-    >>> print(url_values)
 
3660
+    >>> print(url_values)  # The order may differ from below.  #doctest: +SKIP
 
3661
     name=Somebody+Here&language=Python&location=Northampton
 
3662
     >>> url = 'http://www.example.com/example.cgi'
 
3663
     >>> full_url = url + '?' + url_values
2930
3664
@@ -172,7 +173,8 @@
2931
3665
               'language' : 'Python' }
2932
3666
     headers = { 'User-Agent' : user_agent }
2937
3671
     req = urllib.request.Request(url, data, headers)
2938
3672
     response = urllib.request.urlopen(req)
2939
3673
     the_page = response.read()
2940
 
@@ -446,12 +448,12 @@
 
3674
@@ -205,9 +207,9 @@
 
3675
 
 
3676
     >>> req = urllib.request.Request('http://www.pretend_server.org')
 
3677
     >>> try: urllib.request.urlopen(req)
 
3678
-    >>> except urllib.error.URLError as e:
 
3679
-    >>>    print(e.reason)
 
3680
-    >>>
 
3681
+    ... except urllib.error.URLError as e:
 
3682
+    ...    print(e.reason)      #doctest: +SKIP
 
3683
+    ...
 
3684
     (4, 'getaddrinfo failed')
 
3685
 
 
3686
 
 
3687
@@ -313,18 +315,17 @@
 
3688
 
 
3689
     >>> req = urllib.request.Request('http://www.python.org/fish.html')
 
3690
     >>> try:
 
3691
-    >>>     urllib.request.urlopen(req)
 
3692
-    >>> except urllib.error.HTTPError as e:
 
3693
-    >>>     print(e.code)
 
3694
-    >>>     print(e.read())
 
3695
-    >>>
 
3696
+    ...     urllib.request.urlopen(req)
 
3697
+    ... except urllib.error.HTTPError as e:
 
3698
+    ...     print(e.code)
 
3699
+    ...     print(e.read())  #doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
 
3700
+    ...
 
3701
     404
 
3702
-    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 
3703
-        "http://www.w3.org/TR/html4/loose.dtd">
 
3704
-    <?xml-stylesheet href="./css/ht2html.css"
 
3705
-        type="text/css"?>
 
3706
-    <html><head><title>Error 404: File Not Found</title>
 
3707
-    ...... etc...
 
3708
+    b'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
3709
+      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n\n\n<html
 
3710
+      ...
 
3711
+      <title>Page Not Found</title>\n
 
3712
+      ...
 
3713
 
 
3714
 Wrapping it Up
 
3715
 --------------
 
3716
@@ -446,12 +447,12 @@
2941
3717
 
2942
3718
 When authentication is required, the server sends a header (as well as the 401
2943
3719
 error code) requesting authentication.  This specifies the authentication scheme
3090
3866
+#endif /* #if PY_VERSION_HEX < 0x02070000 */
3091
3867
+
3092
3868
+#endif /* __CAPSULETHUNK_H */
 
3869
diff -r 3d0686d90f55 Doc/library/2to3.rst
 
3870
--- a/Doc/library/2to3.rst
 
3871
+++ b/Doc/library/2to3.rst
 
3872
@@ -23,7 +23,7 @@
 
3873
 also located in the :file:`Tools/scripts` directory of the Python root.
 
3874
 
 
3875
 2to3's basic arguments are a list of files or directories to transform.  The
 
3876
-directories are to recursively traversed for Python sources.
 
3877
+directories are recursively traversed for Python sources.
 
3878
 
 
3879
 Here is a sample Python 2.x source file, :file:`example.py`::
 
3880
 
3093
3881
diff -r 3d0686d90f55 Doc/library/__future__.rst
3094
3882
--- a/Doc/library/__future__.rst
3095
3883
+++ b/Doc/library/__future__.rst
3143
3931
 
3144
3932
 * ``option_string`` - The option string that was used to invoke this action.
3145
3933
   The ``option_string`` argument is optional, and will be absent if the action
3146
 
@@ -1076,6 +1085,9 @@
 
3934
@@ -895,6 +904,17 @@
 
3935
    >>> parser.parse_args(''.split())
 
3936
    Namespace(foo=42)
 
3937
 
 
3938
+If the ``default`` value is a string, the parser parses the value as if it
 
3939
+were a command-line argument.  In particular, the parser applies any type_
 
3940
+conversion argument, if provided, before setting the attribute on the
 
3941
+:class:`Namespace` return value.  Otherwise, the parser uses the value as is::
 
3942
+
 
3943
+   >>> parser = argparse.ArgumentParser()
 
3944
+   >>> parser.add_argument('--length', default='10', type=int)
 
3945
+   >>> parser.add_argument('--width', default=10.5, type=int)
 
3946
+   >>> parser.parse_args()
 
3947
+   Namespace(length=10, width=10.5)
 
3948
+
 
3949
 For positional arguments with nargs_ equal to ``?`` or ``*``, the ``default`` value
 
3950
 is used when no command-line argument was present::
 
3951
 
 
3952
@@ -933,6 +953,9 @@
 
3953
    >>> parser.parse_args('2 temp.txt'.split())
 
3954
    Namespace(bar=<_io.TextIOWrapper name='temp.txt' encoding='UTF-8'>, foo=2)
 
3955
 
 
3956
+See the section on the default_ keyword argument for information on when the
 
3957
+``type`` argument is applied to default arguments.
 
3958
+
 
3959
 To ease the use of various types of files, the argparse module provides the
 
3960
 factory FileType which takes the ``mode=`` and ``bufsize=`` arguments of the
 
3961
 :func:`open` function.  For example, ``FileType('w')`` can be used to create a
 
3962
@@ -1076,6 +1099,9 @@
3147
3963
    optional arguments:
3148
3964
     -h, --help  show this help message and exit
3149
3965
 
3153
3969
 :mod:`argparse` supports silencing the help entry for certain options, by
3154
3970
 setting the ``help`` value to ``argparse.SUPPRESS``::
3155
3971
 
3156
 
@@ -1642,8 +1654,8 @@
 
3972
@@ -1642,8 +1668,8 @@
3157
3973
 
3158
3974
        --bar BAR  bar help
3159
3975
 
3164
3980
 
3165
3981
 
3166
3982
 Mutual exclusion
3167
 
@@ -1833,9 +1845,10 @@
 
3983
@@ -1833,9 +1859,10 @@
3168
3984
 * Replace all :meth:`optparse.OptionParser.add_option` calls with
3169
3985
   :meth:`ArgumentParser.add_argument` calls.
3170
3986
 
3285
4101
 If a new entry overwrites an existing entry, the
3286
4102
 original insertion position is changed and moved to the end::
3287
4103
 
 
4104
diff -r 3d0686d90f55 Doc/library/concurrent.futures.rst
 
4105
--- a/Doc/library/concurrent.futures.rst
 
4106
+++ b/Doc/library/concurrent.futures.rst
 
4107
@@ -42,12 +42,13 @@
 
4108
 
 
4109
        Equivalent to ``map(func, *iterables)`` except *func* is executed
 
4110
        asynchronously and several calls to *func* may be made concurrently.  The
 
4111
-       returned iterator raises a :exc:`TimeoutError` if :meth:`__next__()` is
 
4112
-       called and the result isn't available after *timeout* seconds from the
 
4113
-       original call to :meth:`Executor.map`. *timeout* can be an int or a
 
4114
-       float.  If *timeout* is not specified or ``None``, there is no limit to
 
4115
-       the wait time.  If a call raises an exception, then that exception will
 
4116
-       be raised when its value is retrieved from the iterator.
 
4117
+       returned iterator raises a :exc:`TimeoutError` if
 
4118
+       :meth:`~iterator.__next__` is called and the result isn't available
 
4119
+       after *timeout* seconds from the original call to :meth:`Executor.map`.
 
4120
+       *timeout* can be an int or a float.  If *timeout* is not specified or
 
4121
+       ``None``, there is no limit to the wait time.  If a call raises an
 
4122
+       exception, then that exception will be raised when its value is
 
4123
+       retrieved from the iterator.
 
4124
 
 
4125
     .. method:: shutdown(wait=True)
 
4126
 
 
4127
@@ -358,10 +359,11 @@
 
4128
    different :class:`Executor` instances) given by *fs* that yields futures as
 
4129
    they complete (finished or were cancelled).  Any futures that completed
 
4130
    before :func:`as_completed` is called will be yielded first.  The returned
 
4131
-   iterator raises a :exc:`TimeoutError` if :meth:`__next__` is called and the
 
4132
-   result isn't available after *timeout* seconds from the original call to
 
4133
-   :func:`as_completed`.  *timeout* can be an int or float.  If *timeout* is not
 
4134
-   specified or ``None``, there is no limit to the wait time.
 
4135
+   iterator raises a :exc:`TimeoutError` if :meth:`~iterator.__next__` is
 
4136
+   called and the result isn't available after *timeout* seconds from the
 
4137
+   original call to :func:`as_completed`.  *timeout* can be an int or float.
 
4138
+   If *timeout* is not specified or ``None``, there is no limit to the wait
 
4139
+   time.
 
4140
 
 
4141
 
 
4142
 .. seealso::
3288
4143
diff -r 3d0686d90f55 Doc/library/configparser.rst
3289
4144
--- a/Doc/library/configparser.rst
3290
4145
+++ b/Doc/library/configparser.rst
 
4146
@@ -770,9 +770,9 @@
 
4147
    # values using the mapping protocol or ConfigParser's set() does not allow
 
4148
    # such assignments to take place.
 
4149
    config.add_section('Section1')
 
4150
-   config.set('Section1', 'int', '15')
 
4151
-   config.set('Section1', 'bool', 'true')
 
4152
-   config.set('Section1', 'float', '3.1415')
 
4153
+   config.set('Section1', 'an_int', '15')
 
4154
+   config.set('Section1', 'a_bool', 'true')
 
4155
+   config.set('Section1', 'a_float', '3.1415')
 
4156
    config.set('Section1', 'baz', 'fun')
 
4157
    config.set('Section1', 'bar', 'Python')
 
4158
    config.set('Section1', 'foo', '%(bar)s is %(baz)s!')
 
4159
@@ -790,13 +790,13 @@
 
4160
 
 
4161
    # getfloat() raises an exception if the value is not a float
 
4162
    # getint() and getboolean() also do this for their respective types
 
4163
-   float = config.getfloat('Section1', 'float')
 
4164
-   int = config.getint('Section1', 'int')
 
4165
-   print(float + int)
 
4166
+   a_float = config.getfloat('Section1', 'a_float')
 
4167
+   an_int = config.getint('Section1', 'an_int')
 
4168
+   print(a_float + an_int)
 
4169
 
 
4170
    # Notice that the next output does not interpolate '%(bar)s' or '%(baz)s'.
 
4171
    # This is because we are using a RawConfigParser().
 
4172
-   if config.getboolean('Section1', 'bool'):
 
4173
+   if config.getboolean('Section1', 'a_bool'):
 
4174
        print(config.get('Section1', 'foo'))
 
4175
 
 
4176
 To get interpolation, use :class:`ConfigParser`::
3291
4177
@@ -1007,7 +1007,7 @@
3292
4178
       .. versionadded:: 3.2
3293
4179
 
3748
4634
+.. rubric:: Footnotes
3749
4635
+
3750
4636
+.. [#] If, that is, we ignore the effects of Relativity
 
4637
diff -r 3d0686d90f55 Doc/library/dis.rst
 
4638
--- a/Doc/library/dis.rst
 
4639
+++ b/Doc/library/dis.rst
 
4640
@@ -658,10 +658,10 @@
 
4641
 
 
4642
 .. opcode:: FOR_ITER (delta)
 
4643
 
 
4644
-   ``TOS`` is an :term:`iterator`.  Call its :meth:`__next__` method.  If this
 
4645
-   yields a new value, push it on the stack (leaving the iterator below it).  If
 
4646
-   the iterator indicates it is exhausted ``TOS`` is popped, and the byte code
 
4647
-   counter is incremented by *delta*.
 
4648
+   ``TOS`` is an :term:`iterator`.  Call its :meth:`~iterator.__next__` method.
 
4649
+   If this yields a new value, push it on the stack (leaving the iterator below
 
4650
+   it).  If the iterator indicates it is exhausted ``TOS`` is popped, and the
 
4651
+   byte code counter is incremented by *delta*.
 
4652
 
 
4653
 
 
4654
 .. opcode:: LOAD_GLOBAL (namei)
3751
4655
diff -r 3d0686d90f55 Doc/library/doctest.rst
3752
4656
--- a/Doc/library/doctest.rst
3753
4657
+++ b/Doc/library/doctest.rst
3754
 
@@ -338,7 +338,7 @@
 
4658
@@ -1,3 +1,5 @@
 
4659
+:keepdoctest:
 
4660
+
 
4661
 :mod:`doctest` --- Test interactive Python examples
 
4662
 ===================================================
 
4663
 
 
4664
@@ -338,7 +340,7 @@
3755
4665
      Backslashes in a raw docstring: m\n
3756
4666
 
3757
4667
   Otherwise, the backslash will be interpreted as part of the string. For example,
3760
4670
   can double each backslash in the doctest version (and not use a raw string)::
3761
4671
 
3762
4672
      >>> def f(x):
3763
 
@@ -1024,6 +1024,16 @@
 
4673
@@ -652,7 +654,7 @@
 
4674
 
 
4675
 For example, this test passes::
 
4676
 
 
4677
-   >>> print(list(range(20))) #doctest: +NORMALIZE_WHITESPACE
 
4678
+   >>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE
 
4679
    [0,   1,  2,  3,  4,  5,  6,  7,  8,  9,
 
4680
    10,  11, 12, 13, 14, 15, 16, 17, 18, 19]
 
4681
 
 
4682
@@ -664,7 +666,8 @@
 
4683
    >>> print(list(range(20))) # doctest: +ELLIPSIS
 
4684
    [0, 1, ..., 18, 19]
 
4685
 
 
4686
-Multiple directives can be used on a single physical line, separated by commas::
 
4687
+Multiple directives can be used on a single physical line, separated by
 
4688
+commas::
 
4689
 
 
4690
    >>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
 
4691
    [0,    1, ...,   18,    19]
 
4692
@@ -1024,6 +1027,16 @@
3764
4693
 
3765
4694
    This function uses the same search technique as :func:`testmod`.
3766
4695
 
3777
4706
 
3778
4707
 Under the covers, :func:`DocTestSuite` creates a :class:`unittest.TestSuite` out
3779
4708
 of :class:`doctest.DocTestCase` instances, and :class:`DocTestCase` is a
 
4709
diff -r 3d0686d90f55 Doc/library/dummy_threading.rst
 
4710
--- a/Doc/library/dummy_threading.rst
 
4711
+++ b/Doc/library/dummy_threading.rst
 
4712
@@ -17,7 +17,7 @@
 
4713
    try:
 
4714
        import threading
 
4715
    except ImportError:
 
4716
-       import dummy_threading
 
4717
+       import dummy_threading as threading
 
4718
 
 
4719
 Be careful to not use this module where deadlock might occur from a thread being
 
4720
 created that blocks waiting for another thread to be created.  This often occurs
3780
4721
diff -r 3d0686d90f55 Doc/library/email.charset.rst
3781
4722
--- a/Doc/library/email.charset.rst
3782
4723
+++ b/Doc/library/email.charset.rst
3935
4876
 
3936
4877
 .. module:: email.utils
3937
4878
    :synopsis: Miscellaneous email package utilities.
 
4879
diff -r 3d0686d90f55 Doc/library/exceptions.rst
 
4880
--- a/Doc/library/exceptions.rst
 
4881
+++ b/Doc/library/exceptions.rst
 
4882
@@ -262,7 +262,7 @@
 
4883
 .. exception:: StopIteration
 
4884
 
 
4885
    Raised by built-in function :func:`next` and an :term:`iterator`\'s
 
4886
-   :meth:`__next__` method to signal that there are no further values.
 
4887
+   :meth:`~iterator.__next__` method to signal that there are no further values.
 
4888
 
 
4889
 
 
4890
 .. exception:: SyntaxError
3938
4891
diff -r 3d0686d90f55 Doc/library/filecmp.rst
3939
4892
--- a/Doc/library/filecmp.rst
3940
4893
+++ b/Doc/library/filecmp.rst
4010
4963
+    >>> dcmp = dircmp('dir1', 'dir2')
4011
4964
+    >>> print_diff_files(dcmp)
4012
4965
+
 
4966
diff -r 3d0686d90f55 Doc/library/ftplib.rst
 
4967
--- a/Doc/library/ftplib.rst
 
4968
+++ b/Doc/library/ftplib.rst
 
4969
@@ -259,12 +259,12 @@
 
4970
 .. method:: FTP.storbinary(cmd, file, blocksize=8192, callback=None, rest=None)
 
4971
 
 
4972
    Store a file in binary transfer mode.  *cmd* should be an appropriate
 
4973
-   ``STOR`` command: ``"STOR filename"``. *file* is an open :term:`file object`
 
4974
-   which is read until EOF using its :meth:`read` method in blocks of size
 
4975
-   *blocksize* to provide the data to be stored.  The *blocksize* argument
 
4976
-   defaults to 8192.  *callback* is an optional single parameter callable that
 
4977
-   is called on each block of data after it is sent. *rest* means the same thing
 
4978
-   as in the :meth:`transfercmd` method.
 
4979
+   ``STOR`` command: ``"STOR filename"``. *file* is a :term:`file object`
 
4980
+   (opened in binary mode) which is read until EOF using its :meth:`read`
 
4981
+   method in blocks of size *blocksize* to provide the data to be stored.
 
4982
+   The *blocksize* argument defaults to 8192.  *callback* is an optional single
 
4983
+   parameter callable that is called on each block of data after it is sent.
 
4984
+   *rest* means the same thing as in the :meth:`transfercmd` method.
 
4985
 
 
4986
    .. versionchanged:: 3.2
 
4987
       *rest* parameter added.
 
4988
@@ -274,9 +274,9 @@
 
4989
 
 
4990
    Store a file in ASCII transfer mode.  *cmd* should be an appropriate
 
4991
    ``STOR`` command (see :meth:`storbinary`).  Lines are read until EOF from the
 
4992
-   open :term:`file object` *file* using its :meth:`readline` method to provide
 
4993
-   the data to be stored.  *callback* is an optional single parameter callable
 
4994
-   that is called on each line after it is sent.
 
4995
+   :term:`file object` *file* (opened in binary mode) using its :meth:`readline`
 
4996
+   method to provide the data to be stored.  *callback* is an optional single
 
4997
+   parameter callable that is called on each line after it is sent.
 
4998
 
 
4999
 
 
5000
 .. method:: FTP.transfercmd(cmd, rest=None)
4013
5001
diff -r 3d0686d90f55 Doc/library/functions.rst
4014
5002
--- a/Doc/library/functions.rst
4015
5003
+++ b/Doc/library/functions.rst
4027
5015
    The complex type is described in :ref:`typesnumeric`.
4028
5016
 
4029
5017
 
4030
 
@@ -410,7 +417,10 @@
 
5018
@@ -259,14 +266,17 @@
 
5019
 
 
5020
 
 
5021
 .. _func-dict:
 
5022
-.. function:: dict([arg])
 
5023
+.. function:: dict(**kwarg)
 
5024
+              dict(mapping, **kwarg)
 
5025
+              dict(iterable, **kwarg)
 
5026
    :noindex:
 
5027
 
 
5028
-   Create a new data dictionary, optionally with items taken from *arg*.
 
5029
-   The dictionary type is described in :ref:`typesmapping`.
 
5030
+   Create a new dictionary.  The :class:`dict` object is the dictionary class.
 
5031
+   See :class:`dict` and :ref:`typesmapping` for documentation about this
 
5032
+   class.
 
5033
 
 
5034
-   For other containers see the built in :class:`list`, :class:`set`, and
 
5035
-   :class:`tuple` classes, and the :mod:`collections` module.
 
5036
+   For other containers see the built-in :class:`list`, :class:`set`, and
 
5037
+   :class:`tuple` classes, as well as the :mod:`collections` module.
 
5038
 
 
5039
 
 
5040
 .. function:: dir([object])
 
5041
@@ -339,10 +349,10 @@
 
5042
 .. function:: enumerate(iterable, start=0)
 
5043
 
 
5044
    Return an enumerate object. *iterable* must be a sequence, an
 
5045
-   :term:`iterator`, or some other object which supports iteration.  The
 
5046
-   :meth:`__next__` method of the iterator returned by :func:`enumerate` returns a
 
5047
-   tuple containing a count (from *start* which defaults to 0) and the
 
5048
-   values obtained from iterating over *iterable*.
 
5049
+   :term:`iterator`, or some other object which supports iteration.
 
5050
+   The :meth:`~iterator.__next__` method of the iterator returned by
 
5051
+   :func:`enumerate` returns a tuple containing a count (from *start* which
 
5052
+   defaults to 0) and the values obtained from iterating over *iterable*.
 
5053
 
 
5054
       >>> seasons = ['Spring', 'Summer', 'Fall', 'Winter']
 
5055
       >>> list(enumerate(seasons))
 
5056
@@ -410,7 +420,10 @@
4031
5057
    current scope.  If only *globals* is provided, it must be a dictionary, which
4032
5058
    will be used for both the global and the local variables.  If *globals* and
4033
5059
    *locals* are given, they are used for the global and local variables,
4039
5065
 
4040
5066
    If the *globals* dictionary does not contain a value for the key
4041
5067
    ``__builtins__``, a reference to the dictionary of the built-in module
4042
 
@@ -717,11 +727,16 @@
 
5068
@@ -617,14 +630,19 @@
 
5069
    to provide elaborate line editing and history features.
 
5070
 
 
5071
 
 
5072
-.. function:: int([number | string[, base]])
 
5073
+.. function:: int(x=0)
 
5074
+              int(x, base=10)
 
5075
 
 
5076
-   Convert a number or string to an integer.  If no arguments are given, return
 
5077
-   ``0``.  If a number is given, return ``number.__int__()``.  Conversion of
 
5078
-   floating point numbers to integers truncates towards zero.  A string must be
 
5079
-   a base-radix integer literal optionally preceded by '+' or '-' (with no space
 
5080
-   in between) and optionally surrounded by whitespace.  A base-n literal
 
5081
-   consists of the digits 0 to n-1, with 'a' to 'z' (or 'A' to 'Z') having
 
5082
+   Convert a number or string *x* to an integer, or return ``0`` if no
 
5083
+   arguments are given.  If *x* is a number, return :meth:`x.__int__()
 
5084
+   <object.__int__>`.  For floating point numbers, this truncates towards zero.
 
5085
+
 
5086
+   If *x* is not a number or if *base* is given, then *x* must be a string,
 
5087
+   :class:`bytes`, or :class:`bytearray` instance representing an :ref:`integer
 
5088
+   literal <integers>` in radix *base*.  Optionally, the literal can be
 
5089
+   preceded by ``+`` or ``-`` (with no space in between) and surrounded by
 
5090
+   whitespace.  A base-n literal consists of the digits 0 to n-1, with ``a``
 
5091
+   to ``z`` (or ``A`` to ``Z``) having
 
5092
    values 10 to 35.  The default *base* is 10. The allowed values are 0 and 2-36.
 
5093
    Base-2, -8, and -16 literals can be optionally prefixed with ``0b``/``0B``,
 
5094
    ``0o``/``0O``, or ``0x``/``0X``, as with integer literals in code.  Base 0
 
5095
@@ -666,9 +684,10 @@
 
5096
    starting at ``0``).  If it does not support either of those protocols,
 
5097
    :exc:`TypeError` is raised. If the second argument, *sentinel*, is given,
 
5098
    then *object* must be a callable object.  The iterator created in this case
 
5099
-   will call *object* with no arguments for each call to its :meth:`__next__`
 
5100
-   method; if the value returned is equal to *sentinel*, :exc:`StopIteration`
 
5101
-   will be raised, otherwise the value will be returned.
 
5102
+   will call *object* with no arguments for each call to its
 
5103
+   :meth:`~iterator.__next__` method; if the value returned is equal to
 
5104
+   *sentinel*, :exc:`StopIteration` will be raised, otherwise the value will
 
5105
+   be returned.
 
5106
 
 
5107
    One useful application of the second form of :func:`iter` is to read lines of
 
5108
    a file until a certain line is reached.  The following example reads a file
 
5109
@@ -717,11 +736,16 @@
4043
5110
    already arranged into argument tuples, see :func:`itertools.starmap`\.
4044
5111
 
4045
5112
 
4060
5127
 
4061
5128
    The optional keyword-only *key* argument specifies a one-argument ordering
4062
5129
    function like that used for :meth:`list.sort`.
4063
 
@@ -740,11 +755,16 @@
 
5130
@@ -740,11 +764,16 @@
4064
5131
    :ref:`typememoryview` for more information.
4065
5132
 
4066
5133
 
4081
5148
 
4082
5149
    The optional keyword-only *key* argument specifies a one-argument ordering
4083
5150
    function like that used for :meth:`list.sort`.
4084
 
@@ -780,10 +800,13 @@
 
5151
@@ -756,9 +785,9 @@
 
5152
 
 
5153
 .. function:: next(iterator[, default])
 
5154
 
 
5155
-   Retrieve the next item from the *iterator* by calling its :meth:`__next__`
 
5156
-   method.  If *default* is given, it is returned if the iterator is exhausted,
 
5157
-   otherwise :exc:`StopIteration` is raised.
 
5158
+   Retrieve the next item from the *iterator* by calling its
 
5159
+   :meth:`~iterator.__next__` method.  If *default* is given, it is returned
 
5160
+   if the iterator is exhausted, otherwise :exc:`StopIteration` is raised.
 
5161
 
 
5162
 
 
5163
 .. function:: object()
 
5164
@@ -780,10 +809,13 @@
4085
5165
    :meth:`__index__` method that returns an integer.
4086
5166
 
4087
5167
 
4097
5177
 
4098
5178
    *file* is either a string or bytes object giving the pathname (absolute or
4099
5179
    relative to the current working directory) of the file to be opened or
4100
 
@@ -809,7 +832,7 @@
 
5180
@@ -809,7 +841,7 @@
4101
5181
    ``'b'``   binary mode
4102
5182
    ``'t'``   text mode (default)
4103
5183
    ``'+'``   open a disk file for updating (reading and writing)
4106
5186
              not be used in new code)
4107
5187
    ========= ===============================================================
4108
5188
 
4109
 
@@ -864,32 +887,35 @@
 
5189
@@ -864,32 +896,35 @@
4110
5190
    used.  Any other error handling name that has been registered with
4111
5191
    :func:`codecs.register_error` is also valid.
4112
5192
 
4160
5240
    :class:`io.TextIOBase` (specifically :class:`io.TextIOWrapper`).  When used
4161
5241
    to open a file in a binary mode with buffering, the returned class is a
4162
5242
    subclass of :class:`io.BufferedIOBase`.  The exact class varies: in read
4163
 
@@ -941,16 +967,16 @@
 
5243
@@ -941,16 +976,16 @@
4164
5244
    must be of integer types, and *y* must be non-negative.
4165
5245
 
4166
5246
 
4180
5260
    *end*.
4181
5261
 
4182
5262
    The *file* argument must be an object with a ``write(string)`` method; if it
4183
 
@@ -1029,7 +1055,8 @@
 
5263
@@ -1029,7 +1064,8 @@
4184
5264
 
4185
5265
 
4186
5266
 .. XXX does accept objects with __index__ too
4190
5270
 
4191
5271
    This is a versatile function to create iterables yielding arithmetic
4192
5272
    progressions.  It is most often used in :keyword:`for` loops.  The arguments
4193
 
@@ -1105,18 +1132,18 @@
 
5273
@@ -1105,18 +1141,18 @@
4194
5274
    arguments starting at ``0``).
4195
5275
 
4196
5276
 
4218
5298
 
4219
5299
    .. note::
4220
5300
 
4221
 
@@ -1144,7 +1171,8 @@
 
5301
@@ -1144,7 +1180,8 @@
4222
5302
    ``x.foobar = 123``.
4223
5303
 
4224
5304
 
4228
5308
 
4229
5309
    .. index:: single: Numerical Python
4230
5310
 
4231
 
@@ -1400,7 +1428,7 @@
 
5311
@@ -1203,7 +1240,8 @@
 
5312
    standard type hierarchy in :ref:`types`.
 
5313
 
 
5314
 
 
5315
-.. function:: str([object[, encoding[, errors]]])
 
5316
+.. function:: str(object='')
 
5317
+              str(object[, encoding[, errors]])
 
5318
 
 
5319
    Return a string version of an object, using one of the following modes:
 
5320
 
 
5321
@@ -1400,7 +1438,7 @@
4232
5322
       True
4233
5323
 
4234
5324
 
4237
5327
 
4238
5328
    .. index::
4239
5329
       statement: import
4240
 
@@ -1425,10 +1453,13 @@
 
5330
@@ -1425,10 +1463,13 @@
4241
5331
    not use its *locals* argument at all, and uses its *globals* only to
4242
5332
    determine the package context of the :keyword:`import` statement.
4243
5333
 
4351
5441
 the previous example, this serves files relative to the current directory. ::
4352
5442
 
4353
5443
         python -m http.server 8000
 
5444
diff -r 3d0686d90f55 Doc/library/idle.rst
 
5445
--- a/Doc/library/idle.rst
 
5446
+++ b/Doc/library/idle.rst
 
5447
@@ -154,27 +154,56 @@
 
5448
 it to the foreground (deiconifying it if necessary).
 
5449
 
 
5450
 
 
5451
-Debug menu (in the Python Shell window only)
 
5452
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
5453
+Debug menu
 
5454
+^^^^^^^^^^
 
5455
+
 
5456
+* in the Python Shell window only
 
5457
 
 
5458
 Go to file/line
 
5459
-   look around the insert point for a filename and linenumber, open the file, and
 
5460
-   show the line.
 
5461
+   Look around the insert point for a filename and line number, open the file,
 
5462
+   and show the line.  Useful to view the source lines referenced in an
 
5463
+   exception traceback.
 
5464
 
 
5465
-Open stack viewer
 
5466
-   show the stack traceback of the last exception
 
5467
+Debugger
 
5468
+   Run commands in the shell under the debugger.
 
5469
 
 
5470
-Debugger toggle
 
5471
-   Run commands in the shell under the debugger
 
5472
+Stack viewer
 
5473
+   Show the stack traceback of the last exception.
 
5474
 
 
5475
-JIT Stack viewer toggle
 
5476
-   Open stack viewer on traceback
 
5477
+Auto-open Stack Viewer
 
5478
+   Open stack viewer on traceback.
 
5479
 
 
5480
 .. index::
 
5481
    single: stack viewer
 
5482
    single: debugger
 
5483
 
 
5484
 
 
5485
+Edit context menu
 
5486
+^^^^^^^^^^^^^^^^^
 
5487
+
 
5488
+* Right-click in Edit window (Control-click on OS X)
 
5489
+
 
5490
+Set Breakpoint
 
5491
+   Sets a breakpoint.  Breakpoints are only enabled when the debugger is open.
 
5492
+
 
5493
+Clear Breakpoint
 
5494
+   Clears the breakpoint on that line.
 
5495
+
 
5496
+.. index::
 
5497
+   single: Set Breakpoint
 
5498
+   single: Clear Breakpoint
 
5499
+   single: breakpoints
 
5500
+
 
5501
+
 
5502
+Shell context menu
 
5503
+^^^^^^^^^^^^^^^^^^
 
5504
+
 
5505
+* Right-click in Python Shell window (Control-click on OS X)
 
5506
+
 
5507
+Go to file/line
 
5508
+   Same as in Debug menu.
 
5509
+
 
5510
+
 
5511
 Basic editing and navigation
 
5512
 ----------------------------
 
5513
 
4354
5514
diff -r 3d0686d90f55 Doc/library/imp.rst
4355
5515
--- a/Doc/library/imp.rst
4356
5516
+++ b/Doc/library/imp.rst
4923
6083
diff -r 3d0686d90f55 Doc/library/mailbox.rst
4924
6084
--- a/Doc/library/mailbox.rst
4925
6085
+++ b/Doc/library/mailbox.rst
 
6086
@@ -10,9 +10,9 @@
 
6087
 This module defines two classes, :class:`Mailbox` and :class:`Message`, for
 
6088
 accessing and manipulating on-disk mailboxes and the messages they contain.
 
6089
 :class:`Mailbox` offers a dictionary-like mapping from keys to messages.
 
6090
-:class:`Message` extends the :mod:`email.Message` module's :class:`Message`
 
6091
-class with format-specific state and behavior. Supported mailbox formats are
 
6092
-Maildir, mbox, MH, Babyl, and MMDF.
 
6093
+:class:`Message` extends the :mod:`email.message` module's
 
6094
+:class:`~email.message.Message` class with format-specific state and behavior.
 
6095
+Supported mailbox formats are Maildir, mbox, MH, Babyl, and MMDF.
 
6096
 
 
6097
 
 
6098
 .. seealso::
 
6099
@@ -81,7 +81,7 @@
 
6100
       it.
 
6101
 
 
6102
       Parameter *message* may be a :class:`Message` instance, an
 
6103
-      :class:`email.Message.Message` instance, a string, a byte string, or a
 
6104
+      :class:`email.message.Message` instance, a string, a byte string, or a
 
6105
       file-like object (which should be open in binary mode). If *message* is
 
6106
       an instance of the
 
6107
       appropriate format-specific :class:`Message` subclass (e.g., if it's an
4926
6108
@@ -89,7 +89,8 @@
4927
6109
       format-specific information is used. Otherwise, reasonable defaults for
4928
6110
       format-specific information are used.
4933
6115
 
4934
6116
 
4935
6117
    .. method:: remove(key)
 
6118
@@ -111,7 +112,7 @@
 
6119
       :exc:`KeyError` exception if no message already corresponds to *key*.
 
6120
 
 
6121
       As with :meth:`add`, parameter *message* may be a :class:`Message`
 
6122
-      instance, an :class:`email.Message.Message` instance, a string, a byte
 
6123
+      instance, an :class:`email.message.Message` instance, a string, a byte
 
6124
       string, or a file-like object (which should be open in binary mode). If
 
6125
       *message* is an
 
6126
       instance of the appropriate format-specific :class:`Message` subclass
 
6127
@@ -756,11 +757,12 @@
 
6128
 
 
6129
 .. class:: Message(message=None)
 
6130
 
 
6131
-   A subclass of the :mod:`email.Message` module's :class:`Message`. Subclasses of
 
6132
-   :class:`mailbox.Message` add mailbox-format-specific state and behavior.
 
6133
+   A subclass of the :mod:`email.message` module's
 
6134
+   :class:`~email.message.Message`. Subclasses of :class:`mailbox.Message` add
 
6135
+   mailbox-format-specific state and behavior.
 
6136
 
 
6137
    If *message* is omitted, the new instance is created in a default, empty state.
 
6138
-   If *message* is an :class:`email.Message.Message` instance, its contents are
 
6139
+   If *message* is an :class:`email.message.Message` instance, its contents are
 
6140
    copied; furthermore, any format-specific information is converted insofar as
 
6141
    possible if *message* is a :class:`Message` instance. If *message* is a string,
 
6142
    a byte string,
 
6143
@@ -1266,7 +1268,7 @@
 
6144
 
 
6145
       Set the message's visible headers to be the same as the headers in
 
6146
       *message*.  Parameter *visible* should be a :class:`Message` instance, an
 
6147
-      :class:`email.Message.Message` instance, a string, or a file-like object
 
6148
+      :class:`email.message.Message` instance, a string, or a file-like object
 
6149
       (which should be open in text mode).
 
6150
 
 
6151
 
4936
6152
diff -r 3d0686d90f55 Doc/library/markup.rst
4937
6153
--- a/Doc/library/markup.rst
4938
6154
+++ b/Doc/library/markup.rst
5305
6521
 
5306
6522
    Create a filesystem node (file, device special file or named pipe) named
5307
6523
    *filename*. *mode* specifies both the permissions to use and the type of node
 
6524
@@ -1175,18 +1183,21 @@
 
6525
       single: UNC paths; and os.makedirs()
 
6526
 
 
6527
    Recursive directory creation function.  Like :func:`mkdir`, but makes all
 
6528
-   intermediate-level directories needed to contain the leaf directory.  If
 
6529
-   the target directory with the same mode as specified already exists,
 
6530
-   raises an :exc:`OSError` exception if *exist_ok* is False, otherwise no
 
6531
-   exception is raised.  If the directory cannot be created in other cases,
 
6532
-   raises an :exc:`OSError` exception.  The default *mode* is ``0o777`` (octal).
 
6533
-   On some systems, *mode* is ignored.  Where it is used, the current umask
 
6534
-   value is first masked out.
 
6535
+   intermediate-level directories needed to contain the leaf directory.
 
6536
+
 
6537
+   The default *mode* is ``0o777`` (octal).  On some systems, *mode* is
 
6538
+   ignored.  Where it is used, the current umask value is first masked out.
 
6539
+
 
6540
+   If *exists_ok* is ``False`` (the default), an :exc:`OSError` is raised if
 
6541
+   the target directory already exists.  If *exists_ok* is ``True`` an
 
6542
+   :exc:`OSError` is still raised if the umask-masked *mode* is different from
 
6543
+   the existing mode, on systems where the mode is used.  :exc:`OSError` will
 
6544
+   also be raised if the directory creation fails.
 
6545
 
 
6546
    .. note::
 
6547
 
 
6548
       :func:`makedirs` will become confused if the path elements to create
 
6549
-      include :data:`pardir`.
 
6550
+      include :data:`pardir` (eg. ".." on UNIX systems).
 
6551
 
 
6552
    This function handles UNC paths correctly.
 
6553
 
5308
6554
diff -r 3d0686d90f55 Doc/library/ossaudiodev.rst
5309
6555
--- a/Doc/library/ossaudiodev.rst
5310
6556
+++ b/Doc/library/ossaudiodev.rst
6016
7262
              ('2006-04-06', 'SELL', 'IBM', 500, 53.00),
6017
7263
             ]:
6018
7264
        c.execute('insert into stocks values (?,?,?,?,?)', t)
6019
 
@@ -271,7 +272,6 @@
6020
 
    calling the cursor method, then calls the cursor's :meth:`executemany
6021
 
    <Cursor.executemany>` method with the parameters given.
6022
 
 
6023
 
-
6024
 
 .. method:: Connection.executescript(sql_script)
6025
 
 
6026
 
    This is a nonstandard shortcut that creates an intermediate cursor object by
6027
 
@@ -376,22 +376,22 @@
6028
 
    aggregates or whole new virtual table implementations.  One well-known
6029
 
    extension is the fulltext-search extension distributed with SQLite.
6030
 
 
6031
 
+   Loadable extensions are disabled by default. See [#f1]_.
6032
 
+
6033
 
    .. versionadded:: 3.2
6034
 
 
6035
 
    .. literalinclude:: ../includes/sqlite3/load_extension.py
6036
 
 
6037
 
-   Loadable extensions are disabled by default. See [#f1]_.
6038
 
-
6039
 
 .. method:: Connection.load_extension(path)
6040
 
 
6041
 
    This routine loads a SQLite extension from a shared library.  You have to
6042
 
    enable extension loading with :meth:`enable_load_extension` before you can
6043
 
    use this routine.
6044
 
 
6045
 
+   Loadable extensions are disabled by default. See [#f1]_.
6046
 
+
6047
 
    .. versionadded:: 3.2
6048
 
 
6049
 
-   Loadable extensions are disabled by default. See [#f1]_.
6050
 
-
6051
 
 .. attribute:: Connection.row_factory
6052
 
 
6053
 
    You can change this attribute to a callable that accepts the cursor and the
6054
 
@@ -514,7 +514,7 @@
6055
 
    or :const:`None` when no more data is available.
 
7265
@@ -221,239 +222,238 @@
 
7266
 
 
7267
    A SQLite database connection has the following attributes and methods:
 
7268
 
 
7269
-.. attribute:: Connection.isolation_level
 
7270
+   .. attribute:: isolation_level
 
7271
 
 
7272
-   Get or set the current isolation level. :const:`None` for autocommit mode or
 
7273
-   one of "DEFERRED", "IMMEDIATE" or "EXCLUSIVE". See section
 
7274
-   :ref:`sqlite3-controlling-transactions` for a more detailed explanation.
 
7275
+      Get or set the current isolation level. :const:`None` for autocommit mode or
 
7276
+      one of "DEFERRED", "IMMEDIATE" or "EXCLUSIVE". See section
 
7277
+      :ref:`sqlite3-controlling-transactions` for a more detailed explanation.
 
7278
 
 
7279
-.. attribute:: Connection.in_transaction
 
7280
+   .. attribute:: in_transaction
 
7281
 
 
7282
-   :const:`True` if a transaction is active (there are uncommitted changes),
 
7283
-   :const:`False` otherwise.  Read-only attribute.
 
7284
+      :const:`True` if a transaction is active (there are uncommitted changes),
 
7285
+      :const:`False` otherwise.  Read-only attribute.
 
7286
 
 
7287
-   .. versionadded:: 3.2
 
7288
+      .. versionadded:: 3.2
 
7289
 
 
7290
-.. method:: Connection.cursor([cursorClass])
 
7291
+   .. method:: cursor([cursorClass])
 
7292
 
 
7293
-   The cursor method accepts a single optional parameter *cursorClass*. If
 
7294
-   supplied, this must be a custom cursor class that extends
 
7295
-   :class:`sqlite3.Cursor`.
 
7296
+      The cursor method accepts a single optional parameter *cursorClass*. If
 
7297
+      supplied, this must be a custom cursor class that extends
 
7298
+      :class:`sqlite3.Cursor`.
 
7299
 
 
7300
-.. method:: Connection.commit()
 
7301
+   .. method:: commit()
 
7302
 
 
7303
-   This method commits the current transaction. If you don't call this method,
 
7304
-   anything you did since the last call to ``commit()`` is not visible from
 
7305
-   other database connections. If you wonder why you don't see the data you've
 
7306
-   written to the database, please check you didn't forget to call this method.
 
7307
+      This method commits the current transaction. If you don't call this method,
 
7308
+      anything you did since the last call to ``commit()`` is not visible from
 
7309
+      other database connections. If you wonder why you don't see the data you've
 
7310
+      written to the database, please check you didn't forget to call this method.
 
7311
 
 
7312
-.. method:: Connection.rollback()
 
7313
+   .. method:: rollback()
 
7314
 
 
7315
-   This method rolls back any changes to the database since the last call to
 
7316
-   :meth:`commit`.
 
7317
+      This method rolls back any changes to the database since the last call to
 
7318
+      :meth:`commit`.
 
7319
 
 
7320
-.. method:: Connection.close()
 
7321
+   .. method:: close()
 
7322
 
 
7323
-   This closes the database connection. Note that this does not automatically
 
7324
-   call :meth:`commit`. If you just close your database connection without
 
7325
-   calling :meth:`commit` first, your changes will be lost!
 
7326
+      This closes the database connection. Note that this does not automatically
 
7327
+      call :meth:`commit`. If you just close your database connection without
 
7328
+      calling :meth:`commit` first, your changes will be lost!
 
7329
 
 
7330
-.. method:: Connection.execute(sql, [parameters])
 
7331
+   .. method:: execute(sql, [parameters])
 
7332
 
 
7333
-   This is a nonstandard shortcut that creates an intermediate cursor object by
 
7334
-   calling the cursor method, then calls the cursor's :meth:`execute
 
7335
-   <Cursor.execute>` method with the parameters given.
 
7336
+      This is a nonstandard shortcut that creates an intermediate cursor object by
 
7337
+      calling the cursor method, then calls the cursor's :meth:`execute
 
7338
+      <Cursor.execute>` method with the parameters given.
 
7339
 
 
7340
 
 
7341
-.. method:: Connection.executemany(sql, [parameters])
 
7342
+   .. method:: executemany(sql, [parameters])
 
7343
 
 
7344
-   This is a nonstandard shortcut that creates an intermediate cursor object by
 
7345
-   calling the cursor method, then calls the cursor's :meth:`executemany
 
7346
-   <Cursor.executemany>` method with the parameters given.
 
7347
+      This is a nonstandard shortcut that creates an intermediate cursor object by
 
7348
+      calling the cursor method, then calls the cursor's :meth:`executemany
 
7349
+      <Cursor.executemany>` method with the parameters given.
 
7350
 
 
7351
+   .. method:: executescript(sql_script)
 
7352
 
 
7353
-.. method:: Connection.executescript(sql_script)
 
7354
+      This is a nonstandard shortcut that creates an intermediate cursor object by
 
7355
+      calling the cursor method, then calls the cursor's :meth:`executescript
 
7356
+      <Cursor.executescript>` method with the parameters given.
 
7357
 
 
7358
-   This is a nonstandard shortcut that creates an intermediate cursor object by
 
7359
-   calling the cursor method, then calls the cursor's :meth:`executescript
 
7360
-   <Cursor.executescript>` method with the parameters given.
 
7361
 
 
7362
+   .. method:: create_function(name, num_params, func)
 
7363
 
 
7364
-.. method:: Connection.create_function(name, num_params, func)
 
7365
+      Creates a user-defined function that you can later use from within SQL
 
7366
+      statements under the function name *name*. *num_params* is the number of
 
7367
+      parameters the function accepts, and *func* is a Python callable that is called
 
7368
+      as the SQL function.
 
7369
 
 
7370
-   Creates a user-defined function that you can later use from within SQL
 
7371
-   statements under the function name *name*. *num_params* is the number of
 
7372
-   parameters the function accepts, and *func* is a Python callable that is called
 
7373
-   as the SQL function.
 
7374
+      The function can return any of the types supported by SQLite: bytes, str, int,
 
7375
+      float and None.
 
7376
 
 
7377
-   The function can return any of the types supported by SQLite: bytes, str, int,
 
7378
-   float and None.
 
7379
+      Example:
 
7380
 
 
7381
-   Example:
 
7382
+      .. literalinclude:: ../includes/sqlite3/md5func.py
 
7383
 
 
7384
-   .. literalinclude:: ../includes/sqlite3/md5func.py
 
7385
 
 
7386
+   .. method:: create_aggregate(name, num_params, aggregate_class)
 
7387
 
 
7388
-.. method:: Connection.create_aggregate(name, num_params, aggregate_class)
 
7389
+      Creates a user-defined aggregate function.
 
7390
 
 
7391
-   Creates a user-defined aggregate function.
 
7392
+      The aggregate class must implement a ``step`` method, which accepts the number
 
7393
+      of parameters *num_params*, and a ``finalize`` method which will return the
 
7394
+      final result of the aggregate.
 
7395
 
 
7396
-   The aggregate class must implement a ``step`` method, which accepts the number
 
7397
-   of parameters *num_params*, and a ``finalize`` method which will return the
 
7398
-   final result of the aggregate.
 
7399
+      The ``finalize`` method can return any of the types supported by SQLite:
 
7400
+      bytes, str, int, float and None.
 
7401
 
 
7402
-   The ``finalize`` method can return any of the types supported by SQLite:
 
7403
-   bytes, str, int, float and None.
 
7404
+      Example:
 
7405
 
 
7406
-   Example:
 
7407
+      .. literalinclude:: ../includes/sqlite3/mysumaggr.py
 
7408
 
 
7409
-   .. literalinclude:: ../includes/sqlite3/mysumaggr.py
 
7410
 
 
7411
+   .. method:: create_collation(name, callable)
 
7412
 
 
7413
-.. method:: Connection.create_collation(name, callable)
 
7414
+      Creates a collation with the specified *name* and *callable*. The callable will
 
7415
+      be passed two string arguments. It should return -1 if the first is ordered
 
7416
+      lower than the second, 0 if they are ordered equal and 1 if the first is ordered
 
7417
+      higher than the second.  Note that this controls sorting (ORDER BY in SQL) so
 
7418
+      your comparisons don't affect other SQL operations.
 
7419
 
 
7420
-   Creates a collation with the specified *name* and *callable*. The callable will
 
7421
-   be passed two string arguments. It should return -1 if the first is ordered
 
7422
-   lower than the second, 0 if they are ordered equal and 1 if the first is ordered
 
7423
-   higher than the second.  Note that this controls sorting (ORDER BY in SQL) so
 
7424
-   your comparisons don't affect other SQL operations.
 
7425
+      Note that the callable will get its parameters as Python bytestrings, which will
 
7426
+      normally be encoded in UTF-8.
 
7427
 
 
7428
-   Note that the callable will get its parameters as Python bytestrings, which will
 
7429
-   normally be encoded in UTF-8.
 
7430
+      The following example shows a custom collation that sorts "the wrong way":
 
7431
 
 
7432
-   The following example shows a custom collation that sorts "the wrong way":
 
7433
+      .. literalinclude:: ../includes/sqlite3/collation_reverse.py
 
7434
 
 
7435
-   .. literalinclude:: ../includes/sqlite3/collation_reverse.py
 
7436
+      To remove a collation, call ``create_collation`` with None as callable::
 
7437
 
 
7438
-   To remove a collation, call ``create_collation`` with None as callable::
 
7439
+         con.create_collation("reverse", None)
 
7440
 
 
7441
-      con.create_collation("reverse", None)
 
7442
 
 
7443
+   .. method:: interrupt()
 
7444
 
 
7445
-.. method:: Connection.interrupt()
 
7446
+      You can call this method from a different thread to abort any queries that might
 
7447
+      be executing on the connection. The query will then abort and the caller will
 
7448
+      get an exception.
 
7449
 
 
7450
-   You can call this method from a different thread to abort any queries that might
 
7451
-   be executing on the connection. The query will then abort and the caller will
 
7452
-   get an exception.
 
7453
 
 
7454
+   .. method:: set_authorizer(authorizer_callback)
 
7455
 
 
7456
-.. method:: Connection.set_authorizer(authorizer_callback)
 
7457
+      This routine registers a callback. The callback is invoked for each attempt to
 
7458
+      access a column of a table in the database. The callback should return
 
7459
+      :const:`SQLITE_OK` if access is allowed, :const:`SQLITE_DENY` if the entire SQL
 
7460
+      statement should be aborted with an error and :const:`SQLITE_IGNORE` if the
 
7461
+      column should be treated as a NULL value. These constants are available in the
 
7462
+      :mod:`sqlite3` module.
 
7463
 
 
7464
-   This routine registers a callback. The callback is invoked for each attempt to
 
7465
-   access a column of a table in the database. The callback should return
 
7466
-   :const:`SQLITE_OK` if access is allowed, :const:`SQLITE_DENY` if the entire SQL
 
7467
-   statement should be aborted with an error and :const:`SQLITE_IGNORE` if the
 
7468
-   column should be treated as a NULL value. These constants are available in the
 
7469
-   :mod:`sqlite3` module.
 
7470
+      The first argument to the callback signifies what kind of operation is to be
 
7471
+      authorized. The second and third argument will be arguments or :const:`None`
 
7472
+      depending on the first argument. The 4th argument is the name of the database
 
7473
+      ("main", "temp", etc.) if applicable. The 5th argument is the name of the
 
7474
+      inner-most trigger or view that is responsible for the access attempt or
 
7475
+      :const:`None` if this access attempt is directly from input SQL code.
 
7476
 
 
7477
-   The first argument to the callback signifies what kind of operation is to be
 
7478
-   authorized. The second and third argument will be arguments or :const:`None`
 
7479
-   depending on the first argument. The 4th argument is the name of the database
 
7480
-   ("main", "temp", etc.) if applicable. The 5th argument is the name of the
 
7481
-   inner-most trigger or view that is responsible for the access attempt or
 
7482
-   :const:`None` if this access attempt is directly from input SQL code.
 
7483
+      Please consult the SQLite documentation about the possible values for the first
 
7484
+      argument and the meaning of the second and third argument depending on the first
 
7485
+      one. All necessary constants are available in the :mod:`sqlite3` module.
 
7486
 
 
7487
-   Please consult the SQLite documentation about the possible values for the first
 
7488
-   argument and the meaning of the second and third argument depending on the first
 
7489
-   one. All necessary constants are available in the :mod:`sqlite3` module.
 
7490
 
 
7491
+   .. method:: set_progress_handler(handler, n)
 
7492
 
 
7493
-.. method:: Connection.set_progress_handler(handler, n)
 
7494
+      This routine registers a callback. The callback is invoked for every *n*
 
7495
+      instructions of the SQLite virtual machine. This is useful if you want to
 
7496
+      get called from SQLite during long-running operations, for example to update
 
7497
+      a GUI.
 
7498
 
 
7499
-   This routine registers a callback. The callback is invoked for every *n*
 
7500
-   instructions of the SQLite virtual machine. This is useful if you want to
 
7501
-   get called from SQLite during long-running operations, for example to update
 
7502
-   a GUI.
 
7503
+      If you want to clear any previously installed progress handler, call the
 
7504
+      method with :const:`None` for *handler*.
 
7505
 
 
7506
-   If you want to clear any previously installed progress handler, call the
 
7507
-   method with :const:`None` for *handler*.
 
7508
 
 
7509
+   .. method:: enable_load_extension(enabled)
 
7510
 
 
7511
-.. method:: Connection.enable_load_extension(enabled)
 
7512
+      This routine allows/disallows the SQLite engine to load SQLite extensions
 
7513
+      from shared libraries.  SQLite extensions can define new functions,
 
7514
+      aggregates or whole new virtual table implementations.  One well-known
 
7515
+      extension is the fulltext-search extension distributed with SQLite.
 
7516
 
 
7517
-   This routine allows/disallows the SQLite engine to load SQLite extensions
 
7518
-   from shared libraries.  SQLite extensions can define new functions,
 
7519
-   aggregates or whole new virtual table implementations.  One well-known
 
7520
-   extension is the fulltext-search extension distributed with SQLite.
 
7521
+      Loadable extensions are disabled by default. See [#f1]_.
 
7522
 
 
7523
-   .. versionadded:: 3.2
 
7524
+      .. versionadded:: 3.2
 
7525
 
 
7526
-   .. literalinclude:: ../includes/sqlite3/load_extension.py
 
7527
+      .. literalinclude:: ../includes/sqlite3/load_extension.py
 
7528
 
 
7529
-   Loadable extensions are disabled by default. See [#f1]_.
 
7530
+   .. method:: load_extension(path)
 
7531
 
 
7532
-.. method:: Connection.load_extension(path)
 
7533
+      This routine loads a SQLite extension from a shared library.  You have to
 
7534
+      enable extension loading with :meth:`enable_load_extension` before you can
 
7535
+      use this routine.
 
7536
 
 
7537
-   This routine loads a SQLite extension from a shared library.  You have to
 
7538
-   enable extension loading with :meth:`enable_load_extension` before you can
 
7539
-   use this routine.
 
7540
+      Loadable extensions are disabled by default. See [#f1]_.
 
7541
 
 
7542
-   .. versionadded:: 3.2
 
7543
+      .. versionadded:: 3.2
 
7544
 
 
7545
-   Loadable extensions are disabled by default. See [#f1]_.
 
7546
+   .. attribute:: row_factory
 
7547
 
 
7548
-.. attribute:: Connection.row_factory
 
7549
+      You can change this attribute to a callable that accepts the cursor and the
 
7550
+      original row as a tuple and will return the real result row.  This way, you can
 
7551
+      implement more advanced ways of returning results, such  as returning an object
 
7552
+      that can also access columns by name.
 
7553
 
 
7554
-   You can change this attribute to a callable that accepts the cursor and the
 
7555
-   original row as a tuple and will return the real result row.  This way, you can
 
7556
-   implement more advanced ways of returning results, such  as returning an object
 
7557
-   that can also access columns by name.
 
7558
+      Example:
 
7559
 
 
7560
-   Example:
 
7561
+      .. literalinclude:: ../includes/sqlite3/row_factory.py
 
7562
 
 
7563
-   .. literalinclude:: ../includes/sqlite3/row_factory.py
 
7564
+      If returning a tuple doesn't suffice and you want name-based access to
 
7565
+      columns, you should consider setting :attr:`row_factory` to the
 
7566
+      highly-optimized :class:`sqlite3.Row` type. :class:`Row` provides both
 
7567
+      index-based and case-insensitive name-based access to columns with almost no
 
7568
+      memory overhead. It will probably be better than your own custom
 
7569
+      dictionary-based approach or even a db_row based solution.
 
7570
 
 
7571
-   If returning a tuple doesn't suffice and you want name-based access to
 
7572
-   columns, you should consider setting :attr:`row_factory` to the
 
7573
-   highly-optimized :class:`sqlite3.Row` type. :class:`Row` provides both
 
7574
-   index-based and case-insensitive name-based access to columns with almost no
 
7575
-   memory overhead. It will probably be better than your own custom
 
7576
-   dictionary-based approach or even a db_row based solution.
 
7577
+      .. XXX what's a db_row-based solution?
 
7578
 
 
7579
-   .. XXX what's a db_row-based solution?
 
7580
 
 
7581
+   .. attribute:: text_factory
 
7582
 
 
7583
-.. attribute:: Connection.text_factory
 
7584
+      Using this attribute you can control what objects are returned for the ``TEXT``
 
7585
+      data type. By default, this attribute is set to :class:`str` and the
 
7586
+      :mod:`sqlite3` module will return Unicode objects for ``TEXT``. If you want to
 
7587
+      return bytestrings instead, you can set it to :class:`bytes`.
 
7588
 
 
7589
-   Using this attribute you can control what objects are returned for the ``TEXT``
 
7590
-   data type. By default, this attribute is set to :class:`str` and the
 
7591
-   :mod:`sqlite3` module will return Unicode objects for ``TEXT``. If you want to
 
7592
-   return bytestrings instead, you can set it to :class:`bytes`.
 
7593
+      For efficiency reasons, there's also a way to return :class:`str` objects
 
7594
+      only for non-ASCII data, and :class:`bytes` otherwise. To activate it, set
 
7595
+      this attribute to :const:`sqlite3.OptimizedUnicode`.
 
7596
 
 
7597
-   For efficiency reasons, there's also a way to return :class:`str` objects
 
7598
-   only for non-ASCII data, and :class:`bytes` otherwise. To activate it, set
 
7599
-   this attribute to :const:`sqlite3.OptimizedUnicode`.
 
7600
+      You can also set it to any other callable that accepts a single bytestring
 
7601
+      parameter and returns the resulting object.
 
7602
 
 
7603
-   You can also set it to any other callable that accepts a single bytestring
 
7604
-   parameter and returns the resulting object.
 
7605
+      See the following example code for illustration:
 
7606
 
 
7607
-   See the following example code for illustration:
 
7608
+      .. literalinclude:: ../includes/sqlite3/text_factory.py
 
7609
 
 
7610
-   .. literalinclude:: ../includes/sqlite3/text_factory.py
 
7611
 
 
7612
+   .. attribute:: total_changes
 
7613
 
 
7614
-.. attribute:: Connection.total_changes
 
7615
+      Returns the total number of database rows that have been modified, inserted, or
 
7616
+      deleted since the database connection was opened.
 
7617
 
 
7618
-   Returns the total number of database rows that have been modified, inserted, or
 
7619
-   deleted since the database connection was opened.
 
7620
 
 
7621
+   .. attribute:: iterdump
 
7622
 
 
7623
-.. attribute:: Connection.iterdump
 
7624
+      Returns an iterator to dump the database in an SQL text format.  Useful when
 
7625
+      saving an in-memory database for later restoration.  This function provides
 
7626
+      the same capabilities as the :kbd:`.dump` command in the :program:`sqlite3`
 
7627
+      shell.
 
7628
 
 
7629
-   Returns an iterator to dump the database in an SQL text format.  Useful when
 
7630
-   saving an in-memory database for later restoration.  This function provides
 
7631
-   the same capabilities as the :kbd:`.dump` command in the :program:`sqlite3`
 
7632
-   shell.
 
7633
+      Example::
 
7634
 
 
7635
-   Example::
 
7636
+         # Convert file existing_db.db to SQL dump file dump.sql
 
7637
+         import sqlite3, os
 
7638
 
 
7639
-      # Convert file existing_db.db to SQL dump file dump.sql
 
7640
-      import sqlite3, os
 
7641
-
 
7642
-      con = sqlite3.connect('existing_db.db')
 
7643
-      with open('dump.sql', 'w') as f:
 
7644
-          for line in con.iterdump():
 
7645
-              f.write('%s\n' % line)
 
7646
+         con = sqlite3.connect('existing_db.db')
 
7647
+         with open('dump.sql', 'w') as f:
 
7648
+             for line in con.iterdump():
 
7649
+                 f.write('%s\n' % line)
 
7650
 
 
7651
 
 
7652
 .. _sqlite3-cursor-objects:
 
7653
@@ -465,110 +465,110 @@
 
7654
 
 
7655
    A :class:`Cursor` instance has the following attributes and methods.
 
7656
 
 
7657
-.. method:: Cursor.execute(sql, [parameters])
 
7658
+   .. method:: execute(sql, [parameters])
 
7659
 
 
7660
-   Executes an SQL statement. The SQL statement may be parametrized (i. e.
 
7661
-   placeholders instead of SQL literals). The :mod:`sqlite3` module supports two
 
7662
-   kinds of placeholders: question marks (qmark style) and named placeholders
 
7663
-   (named style).
 
7664
+      Executes an SQL statement. The SQL statement may be parametrized (i. e.
 
7665
+      placeholders instead of SQL literals). The :mod:`sqlite3` module supports two
 
7666
+      kinds of placeholders: question marks (qmark style) and named placeholders
 
7667
+      (named style).
 
7668
 
 
7669
-   Here's an example of both styles:
 
7670
+      Here's an example of both styles:
 
7671
 
 
7672
-   .. literalinclude:: ../includes/sqlite3/execute_1.py
 
7673
+      .. literalinclude:: ../includes/sqlite3/execute_1.py
 
7674
 
 
7675
-   :meth:`execute` will only execute a single SQL statement. If you try to execute
 
7676
-   more than one statement with it, it will raise a Warning. Use
 
7677
-   :meth:`executescript` if you want to execute multiple SQL statements with one
 
7678
-   call.
 
7679
+      :meth:`execute` will only execute a single SQL statement. If you try to execute
 
7680
+      more than one statement with it, it will raise a Warning. Use
 
7681
+      :meth:`executescript` if you want to execute multiple SQL statements with one
 
7682
+      call.
 
7683
 
 
7684
 
 
7685
-.. method:: Cursor.executemany(sql, seq_of_parameters)
 
7686
+   .. method:: executemany(sql, seq_of_parameters)
 
7687
 
 
7688
-   Executes an SQL command against all parameter sequences or mappings found in
 
7689
-   the sequence *sql*.  The :mod:`sqlite3` module also allows using an
 
7690
-   :term:`iterator` yielding parameters instead of a sequence.
 
7691
+      Executes an SQL command against all parameter sequences or mappings found in
 
7692
+      the sequence *sql*.  The :mod:`sqlite3` module also allows using an
 
7693
+      :term:`iterator` yielding parameters instead of a sequence.
 
7694
 
 
7695
-   .. literalinclude:: ../includes/sqlite3/executemany_1.py
 
7696
+      .. literalinclude:: ../includes/sqlite3/executemany_1.py
 
7697
 
 
7698
-   Here's a shorter example using a :term:`generator`:
 
7699
+      Here's a shorter example using a :term:`generator`:
 
7700
 
 
7701
-   .. literalinclude:: ../includes/sqlite3/executemany_2.py
 
7702
+      .. literalinclude:: ../includes/sqlite3/executemany_2.py
 
7703
 
 
7704
 
 
7705
-.. method:: Cursor.executescript(sql_script)
 
7706
+   .. method:: executescript(sql_script)
 
7707
 
 
7708
-   This is a nonstandard convenience method for executing multiple SQL statements
 
7709
-   at once. It issues a ``COMMIT`` statement first, then executes the SQL script it
 
7710
-   gets as a parameter.
 
7711
+      This is a nonstandard convenience method for executing multiple SQL statements
 
7712
+      at once. It issues a ``COMMIT`` statement first, then executes the SQL script it
 
7713
+      gets as a parameter.
 
7714
 
 
7715
-   *sql_script* can be an instance of :class:`str` or :class:`bytes`.
 
7716
+      *sql_script* can be an instance of :class:`str` or :class:`bytes`.
 
7717
 
 
7718
-   Example:
 
7719
+      Example:
 
7720
 
 
7721
-   .. literalinclude:: ../includes/sqlite3/executescript.py
 
7722
+      .. literalinclude:: ../includes/sqlite3/executescript.py
 
7723
 
 
7724
 
 
7725
-.. method:: Cursor.fetchone()
 
7726
+   .. method:: fetchone()
 
7727
 
 
7728
-   Fetches the next row of a query result set, returning a single sequence,
 
7729
-   or :const:`None` when no more data is available.
 
7730
+      Fetches the next row of a query result set, returning a single sequence,
 
7731
+      or :const:`None` when no more data is available.
6056
7732
 
6057
7733
 
6058
7734
-.. method:: Cursor.fetchmany([size=cursor.arraysize])
6059
 
+.. method:: Cursor.fetchmany(size=cursor.arraysize)
6060
 
 
6061
 
    Fetches the next set of rows of a query result, returning a list.  An empty
6062
 
    list is returned when no more rows are available.
 
7735
+   .. method:: fetchmany(size=cursor.arraysize)
 
7736
 
 
7737
-   Fetches the next set of rows of a query result, returning a list.  An empty
 
7738
-   list is returned when no more rows are available.
 
7739
+      Fetches the next set of rows of a query result, returning a list.  An empty
 
7740
+      list is returned when no more rows are available.
 
7741
 
 
7742
-   The number of rows to fetch per call is specified by the *size* parameter.
 
7743
-   If it is not given, the cursor's arraysize determines the number of rows
 
7744
-   to be fetched. The method should try to fetch as many rows as indicated by
 
7745
-   the size parameter. If this is not possible due to the specified number of
 
7746
-   rows not being available, fewer rows may be returned.
 
7747
+      The number of rows to fetch per call is specified by the *size* parameter.
 
7748
+      If it is not given, the cursor's arraysize determines the number of rows
 
7749
+      to be fetched. The method should try to fetch as many rows as indicated by
 
7750
+      the size parameter. If this is not possible due to the specified number of
 
7751
+      rows not being available, fewer rows may be returned.
 
7752
 
 
7753
-   Note there are performance considerations involved with the *size* parameter.
 
7754
-   For optimal performance, it is usually best to use the arraysize attribute.
 
7755
-   If the *size* parameter is used, then it is best for it to retain the same
 
7756
-   value from one :meth:`fetchmany` call to the next.
 
7757
+      Note there are performance considerations involved with the *size* parameter.
 
7758
+      For optimal performance, it is usually best to use the arraysize attribute.
 
7759
+      If the *size* parameter is used, then it is best for it to retain the same
 
7760
+      value from one :meth:`fetchmany` call to the next.
 
7761
 
 
7762
-.. method:: Cursor.fetchall()
 
7763
+   .. method:: fetchall()
 
7764
 
 
7765
-   Fetches all (remaining) rows of a query result, returning a list.  Note that
 
7766
-   the cursor's arraysize attribute can affect the performance of this operation.
 
7767
-   An empty list is returned when no rows are available.
 
7768
+      Fetches all (remaining) rows of a query result, returning a list.  Note that
 
7769
+      the cursor's arraysize attribute can affect the performance of this operation.
 
7770
+      An empty list is returned when no rows are available.
 
7771
 
 
7772
 
 
7773
-.. attribute:: Cursor.rowcount
 
7774
+   .. attribute:: rowcount
 
7775
 
 
7776
-   Although the :class:`Cursor` class of the :mod:`sqlite3` module implements this
 
7777
-   attribute, the database engine's own support for the determination of "rows
 
7778
-   affected"/"rows selected" is quirky.
 
7779
+      Although the :class:`Cursor` class of the :mod:`sqlite3` module implements this
 
7780
+      attribute, the database engine's own support for the determination of "rows
 
7781
+      affected"/"rows selected" is quirky.
 
7782
 
 
7783
-   For :meth:`executemany` statements, the number of modifications are summed up
 
7784
-   into :attr:`rowcount`.
 
7785
+      For :meth:`executemany` statements, the number of modifications are summed up
 
7786
+      into :attr:`rowcount`.
 
7787
 
 
7788
-   As required by the Python DB API Spec, the :attr:`rowcount` attribute "is -1 in
 
7789
-   case no ``executeXX()`` has been performed on the cursor or the rowcount of the
 
7790
-   last operation is not determinable by the interface". This includes ``SELECT``
 
7791
-   statements because we cannot determine the number of rows a query produced
 
7792
-   until all rows were fetched.
 
7793
+      As required by the Python DB API Spec, the :attr:`rowcount` attribute "is -1 in
 
7794
+      case no ``executeXX()`` has been performed on the cursor or the rowcount of the
 
7795
+      last operation is not determinable by the interface". This includes ``SELECT``
 
7796
+      statements because we cannot determine the number of rows a query produced
 
7797
+      until all rows were fetched.
 
7798
 
 
7799
-   With SQLite versions before 3.6.5, :attr:`rowcount` is set to 0 if
 
7800
-   you make a ``DELETE FROM table`` without any condition.
 
7801
+      With SQLite versions before 3.6.5, :attr:`rowcount` is set to 0 if
 
7802
+      you make a ``DELETE FROM table`` without any condition.
 
7803
 
 
7804
-.. attribute:: Cursor.lastrowid
 
7805
+   .. attribute:: lastrowid
 
7806
 
 
7807
-   This read-only attribute provides the rowid of the last modified row. It is
 
7808
-   only set if you issued a ``INSERT`` statement using the :meth:`execute`
 
7809
-   method. For operations other than ``INSERT`` or when :meth:`executemany` is
 
7810
-   called, :attr:`lastrowid` is set to :const:`None`.
 
7811
+      This read-only attribute provides the rowid of the last modified row. It is
 
7812
+      only set if you issued a ``INSERT`` statement using the :meth:`execute`
 
7813
+      method. For operations other than ``INSERT`` or when :meth:`executemany` is
 
7814
+      called, :attr:`lastrowid` is set to :const:`None`.
 
7815
 
 
7816
-.. attribute:: Cursor.description
 
7817
+   .. attribute:: description
 
7818
 
 
7819
-   This read-only attribute provides the column names of the last query. To
 
7820
-   remain compatible with the Python DB API, it returns a 7-tuple for each
 
7821
-   column where the last six items of each tuple are :const:`None`.
 
7822
+      This read-only attribute provides the column names of the last query. To
 
7823
+      remain compatible with the Python DB API, it returns a 7-tuple for each
 
7824
+      column where the last six items of each tuple are :const:`None`.
 
7825
 
 
7826
-   It is set for ``SELECT`` statements without any matching rows as well.
 
7827
+      It is set for ``SELECT`` statements without any matching rows as well.
 
7828
 
 
7829
 .. _sqlite3-row-objects:
 
7830
 
6063
7831
diff -r 3d0686d90f55 Doc/library/ssl.rst
6064
7832
--- a/Doc/library/ssl.rst
6065
7833
+++ b/Doc/library/ssl.rst
6121
7889
diff -r 3d0686d90f55 Doc/library/stdtypes.rst
6122
7890
--- a/Doc/library/stdtypes.rst
6123
7891
+++ b/Doc/library/stdtypes.rst
6124
 
@@ -819,7 +819,8 @@
 
7892
@@ -775,9 +775,9 @@
 
7893
 specific types are not important beyond their implementation of the iterator
 
7894
 protocol.
 
7895
 
 
7896
-Once an iterator's :meth:`__next__` method raises :exc:`StopIteration`, it must
 
7897
-continue to do so on subsequent calls.  Implementations that do not obey this
 
7898
-property are deemed broken.
 
7899
+Once an iterator's :meth:`~iterator.__next__` method raises
 
7900
+:exc:`StopIteration`, it must continue to do so on subsequent calls.
 
7901
+Implementations that do not obey this property are deemed broken.
 
7902
 
 
7903
 
 
7904
 .. _generator-types:
 
7905
@@ -788,7 +788,8 @@
 
7906
 Python's :term:`generator`\s provide a convenient way to implement the iterator
 
7907
 protocol.  If a container object's :meth:`__iter__` method is implemented as a
 
7908
 generator, it will automatically return an iterator object (technically, a
 
7909
-generator object) supplying the :meth:`__iter__` and :meth:`__next__` methods.
 
7910
+generator object) supplying the :meth:`__iter__` and :meth:`~generator.__next__`
 
7911
+methods.
 
7912
 More information about generators can be found in :ref:`the documentation for
 
7913
 the yield expression <yieldexpr>`.
 
7914
 
 
7915
@@ -819,7 +820,8 @@
6125
7916
 also string-specific methods described in the :ref:`string-methods` section.
6126
7917
 
6127
7918
 Bytes and bytearray objects contain single bytes -- the former is immutable
6131
7922
 constructor, :func:`bytes`, and from literals; use a ``b`` prefix with normal
6132
7923
 string syntax: ``b'xyzzy'``.  To construct byte arrays, use the
6133
7924
 :func:`bytearray` function.
6134
 
@@ -1304,8 +1305,8 @@
 
7925
@@ -1304,8 +1306,8 @@
6135
7926
    Return a list of the words in the string, using *sep* as the delimiter
6136
7927
    string.  If *maxsplit* is given, at most *maxsplit* splits are done (thus,
6137
7928
    the list will have at most ``maxsplit+1`` elements).  If *maxsplit* is not
6142
7933
 
6143
7934
    If *sep* is given, consecutive delimiters are not grouped together and are
6144
7935
    deemed to delimit empty strings (for example, ``'1,,2'.split(',')`` returns
6145
 
@@ -1324,11 +1325,23 @@
 
7936
@@ -1324,11 +1326,23 @@
6146
7937
    ``'  1  2   3  '.split(None, 1)`` returns ``['1', '2   3  ']``.
6147
7938
 
6148
7939
 
6169
7960
 
6170
7961
 
6171
7962
 .. method:: str.startswith(prefix[, start[, end]])
6172
 
@@ -1437,8 +1450,13 @@
 
7963
@@ -1437,8 +1451,13 @@
6173
7964
 
6174
7965
 .. note::
6175
7966
 
6185
7976
 
6186
7977
 String objects have one unique built-in operation: the ``%`` operator (modulo).
6187
7978
 This is also known as the string *formatting* or *interpolation* operator.
 
7979
@@ -2095,33 +2114,41 @@
 
7980
 pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098:
 
7981
 'jack', 4127: 'sjoerd'}``, or by the :class:`dict` constructor.
 
7982
 
 
7983
-.. class:: dict([arg])
 
7984
-
 
7985
-   Return a new dictionary initialized from an optional positional argument or
 
7986
-   from a set of keyword arguments.  If no arguments are given, return a new
 
7987
-   empty dictionary.  If the positional argument *arg* is a mapping object,
 
7988
-   return a dictionary mapping the same keys to the same values as does the
 
7989
-   mapping object.  Otherwise the positional argument must be a sequence, a
 
7990
-   container that supports iteration, or an iterator object.  The elements of
 
7991
-   the argument must each also be of one of those kinds, and each must in turn
 
7992
-   contain exactly two objects.  The first is used as a key in the new
 
7993
-   dictionary, and the second as the key's value.  If a given key is seen more
 
7994
-   than once, the last value associated with it is retained in the new
 
7995
+.. class:: dict(**kwarg)
 
7996
+           dict(mapping, **kwarg)
 
7997
+           dict(iterable, **kwarg)
 
7998
+
 
7999
+   Return a new dictionary initialized from an optional positional argument
 
8000
+   and a possibly empty set of keyword arguments.
 
8001
+
 
8002
+   If no positional argument is given, an empty dictionary is created.
 
8003
+   If a positional argument is given and it is a mapping object, a dictionary
 
8004
+   is created with the same key-value pairs as the mapping object.  Otherwise,
 
8005
+   the positional argument must be an :term:`iterator` object.  Each item in
 
8006
+   the iterable must itself be an iterator with exactly two objects.  The
 
8007
+   first object of each item becomes a key in the new dictionary, and the
 
8008
+   second object the corresponding value.  If a key occurs more than once, the
 
8009
+   last value for that key becomes the corresponding value in the new
 
8010
    dictionary.
 
8011
 
 
8012
-   If keyword arguments are given, the keywords themselves with their associated
 
8013
-   values are added as items to the dictionary.  If a key is specified both in
 
8014
-   the positional argument and as a keyword argument, the value associated with
 
8015
-   the keyword is retained in the dictionary.  For example, these all return a
 
8016
-   dictionary equal to ``{"one": 1, "two": 2}``:
 
8017
-
 
8018
-   * ``dict(one=1, two=2)``
 
8019
-   * ``dict({'one': 1, 'two': 2})``
 
8020
-   * ``dict(zip(('one', 'two'), (1, 2)))``
 
8021
-   * ``dict([['two', 2], ['one', 1]])``
 
8022
-
 
8023
-   The first example only works for keys that are valid Python identifiers; the
 
8024
-   others work with any valid keys.
 
8025
+   If keyword arguments are given, the keyword arguments and their values are
 
8026
+   added to the dictionary created from the positional argument.  If a key
 
8027
+   being added is already present, the value from the keyword argument
 
8028
+   replaces the value from the positional argument.
 
8029
+
 
8030
+   To illustrate, the following examples all return a dictionary equal to
 
8031
+   ``{"one": 1, "two": 2}``::
 
8032
+
 
8033
+      >>> a = dict(one=1, two=2)
 
8034
+      >>> b = dict({'one': 1, 'two': 2})
 
8035
+      >>> c = dict(zip(('one', 'two'), (1, 2)))
 
8036
+      >>> d = dict([['two', 2], ['one', 1]])
 
8037
+      >>> e = {"one": 1, "two": 2}
 
8038
+      >>> a == b == c == d == e
 
8039
+      True
 
8040
+
 
8041
+   Providing keyword arguments as in the first example only works for keys that
 
8042
+   are valid Python identifiers.  Otherwise, any valid keys can be used.
 
8043
 
 
8044
 
 
8045
    These are the operations that dictionaries support (and therefore, custom
6188
8046
diff -r 3d0686d90f55 Doc/library/string.rst
6189
8047
--- a/Doc/library/string.rst
6190
8048
+++ b/Doc/library/string.rst
6326
8184
 
6327
8185
    .. warning::
6328
8186
 
6329
 
@@ -408,18 +446,9 @@
 
8187
@@ -222,8 +260,8 @@
 
8188
       untrusted source makes a program vulnerable to `shell injection
 
8189
       <http://en.wikipedia.org/wiki/Shell_injection#Shell_injection>`_,
 
8190
       a serious security flaw which can result in arbitrary command execution.
 
8191
-      For this reason, the use of *shell=True* is **strongly discouraged** in cases
 
8192
-      where the command string is constructed from external input::
 
8193
+      For this reason, the use of ``shell=True`` is **strongly discouraged**
 
8194
+      in cases where the command string is constructed from external input::
 
8195
 
 
8196
          >>> from subprocess import call
 
8197
          >>> filename = input("What file would you like to display?\n")
 
8198
@@ -248,24 +286,27 @@
 
8199
 functions.
 
8200
 
 
8201
 
 
8202
-.. class:: Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=True, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False, pass_fds=())
 
8203
+.. class:: Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, \
 
8204
+                 stderr=None, preexec_fn=None, close_fds=True, shell=False, \
 
8205
+                 cwd=None, env=None, universal_newlines=False, \
 
8206
+                 startupinfo=None, creationflags=0, restore_signals=True, \
 
8207
+                 start_new_session=False, pass_fds=())
 
8208
 
 
8209
-   Arguments are:
 
8210
+   Execute a child program in a new process.  On Unix, the class uses
 
8211
+   :meth:`os.execvp`-like behavior to execute the child program.  On Windows,
 
8212
+   the class uses the Windows ``CreateProcess()`` function.  The arguments to
 
8213
+   :class:`Popen` are as follows.
 
8214
 
 
8215
-   *args* should be a string, or a sequence of program arguments.  The program
 
8216
-   to execute is normally the first item in the args sequence or the string if
 
8217
-   a string is given, but can be explicitly set by using the *executable*
 
8218
-   argument.  When *executable* is given, the first item in the args sequence
 
8219
-   is still treated by most programs as the command name, which can then be
 
8220
-   different from the actual executable name.  On Unix, it becomes the display
 
8221
-   name for the executing program in utilities such as :program:`ps`.
 
8222
+   *args* should be a sequence of program arguments or else a single string.
 
8223
+   By default, the program to execute is the first item in *args* if *args* is
 
8224
+   a sequence.  If *args* is a string, the interpretation is
 
8225
+   platform-dependent and described below.  See the *shell* and *executable*
 
8226
+   arguments for additional differences from the default behavior.  Unless
 
8227
+   otherwise stated, it is recommended to pass *args* as a sequence.
 
8228
 
 
8229
-   On Unix, with *shell=False* (default): In this case, the Popen class uses
 
8230
-   :meth:`os.execvp` like behavior to execute the child program.
 
8231
-   *args* should normally be a
 
8232
-   sequence.  If a string is specified for *args*, it will be used as the name
 
8233
-   or path of the program to execute; this will only work if the program is
 
8234
-   being given no arguments.
 
8235
+   On Unix, if *args* is a string, the string is interpreted as the name or
 
8236
+   path of the program to execute.  However, this can only be done if not
 
8237
+   passing arguments to the program.
 
8238
 
 
8239
    .. note::
 
8240
 
 
8241
@@ -286,27 +327,37 @@
 
8242
       used in the shell (such as filenames containing spaces or the *echo* command
 
8243
       shown above) are single list elements.
 
8244
 
 
8245
-   On Unix, with *shell=True*: If args is a string, it specifies the command
 
8246
-   string to execute through the shell.  This means that the string must be
 
8247
+   On Windows, if *args* is a sequence, it will be converted to a string in a
 
8248
+   manner described in :ref:`converting-argument-sequence`.  This is because
 
8249
+   the underlying ``CreateProcess()`` operates on strings.
 
8250
+
 
8251
+   The *shell* argument (which defaults to *False*) specifies whether to use
 
8252
+   the shell as the program to execute.  If *shell* is *True*, it is
 
8253
+   recommended to pass *args* as a string rather than as a sequence.
 
8254
+
 
8255
+   On Unix with ``shell=True``, the shell defaults to :file:`/bin/sh`.  If
 
8256
+   *args* is a string, the string specifies the command
 
8257
+   to execute through the shell.  This means that the string must be
 
8258
    formatted exactly as it would be when typed at the shell prompt.  This
 
8259
    includes, for example, quoting or backslash escaping filenames with spaces in
 
8260
    them.  If *args* is a sequence, the first item specifies the command string, and
 
8261
    any additional items will be treated as additional arguments to the shell
 
8262
-   itself.  That is to say, *Popen* does the equivalent of::
 
8263
+   itself.  That is to say, :class:`Popen` does the equivalent of::
 
8264
 
 
8265
       Popen(['/bin/sh', '-c', args[0], args[1], ...])
 
8266
 
 
8267
+   On Windows with ``shell=True``, the :envvar:`COMSPEC` environment variable
 
8268
+   specifies the default shell.  The only time you need to specify
 
8269
+   ``shell=True`` on Windows is when the command you wish to execute is built
 
8270
+   into the shell (e.g. :command:`dir` or :command:`copy`).  You do not need
 
8271
+   ``shell=True`` to run a batch file or console-based executable.
 
8272
+
 
8273
    .. warning::
 
8274
 
 
8275
-      Enabling this option can be a security hazard if combined with untrusted
 
8276
-      input. See the warning under :ref:`frequently-used-arguments`
 
8277
+      Passing ``shell=True`` can be a security hazard if combined with
 
8278
+      untrusted input.  See the warning under :ref:`frequently-used-arguments`
 
8279
       for details.
 
8280
 
 
8281
-   On Windows: the :class:`Popen` class uses CreateProcess() to execute the
 
8282
-   child program, which operates on strings.  If *args* is a sequence, it will
 
8283
-   be converted to a string in a manner described in
 
8284
-   :ref:`converting-argument-sequence`.
 
8285
-
 
8286
    *bufsize*, if given, has the same meaning as the corresponding argument to the
 
8287
    built-in open() function: :const:`0` means unbuffered, :const:`1` means line
 
8288
    buffered, any other positive value means use a buffer of (approximately) that
 
8289
@@ -319,15 +370,15 @@
 
8290
       enable buffering by setting *bufsize* to either -1 or a large enough
 
8291
       positive value (such as 4096).
 
8292
 
 
8293
-   The *executable* argument specifies the program to execute. It is very seldom
 
8294
-   needed: Usually, the program to execute is defined by the *args* argument. If
 
8295
-   ``shell=True``, the *executable* argument specifies which shell to use. On Unix,
 
8296
-   the default shell is :file:`/bin/sh`.  On Windows, the default shell is
 
8297
-   specified by the :envvar:`COMSPEC` environment variable. The only reason you
 
8298
-   would need to specify ``shell=True`` on Windows is where the command you
 
8299
-   wish to execute is actually built in to the shell, eg ``dir``, ``copy``.
 
8300
-   You don't need ``shell=True`` to run a batch file, nor to run a console-based
 
8301
-   executable.
 
8302
+   The *executable* argument specifies a replacement program to execute.   It
 
8303
+   is very seldom needed.  When ``shell=False``, *executable* replaces the
 
8304
+   program to execute specified by *args*.  However, the original *args* is
 
8305
+   still passed to the program.  Most programs treat the program specified
 
8306
+   by *args* as the command name, which can then be different from the program
 
8307
+   actually executed.  On Unix, the *args* name
 
8308
+   becomes the display name for the executable in utilities such as
 
8309
+   :program:`ps`.  If ``shell=True``, on Unix the *executable* argument
 
8310
+   specifies a replacement shell for the default :file:`/bin/sh`.
 
8311
 
 
8312
    *stdin*, *stdout* and *stderr* specify the executed program's standard input,
 
8313
    standard output and standard error file handles, respectively.  Valid values
 
8314
@@ -377,10 +428,10 @@
 
8315
    .. versionadded:: 3.2
 
8316
       The *pass_fds* parameter was added.
 
8317
 
 
8318
-   If *cwd* is not ``None``, the child's current directory will be changed to *cwd*
 
8319
-   before it is executed.  Note that this directory is not considered when
 
8320
-   searching the executable, so you can't specify the program's path relative to
 
8321
-   *cwd*.
 
8322
+   If *cwd* is not ``None``, the function changes the working directory to
 
8323
+   *cwd* before executing the child.  In particular, the function looks for
 
8324
+   *executable* (or for the first item in *args*) relative to *cwd* if the
 
8325
+   executable path is a relative path.
 
8326
 
 
8327
    If *restore_signals* is True (the default) all signals that Python has set to
 
8328
    SIG_IGN are restored to SIG_DFL in the child process before the exec.
 
8329
@@ -408,18 +459,9 @@
6330
8330
 
6331
8331
    .. _side-by-side assembly: http://en.wikipedia.org/wiki/Side-by-Side_Assembly
6332
8332
 
6348
8348
 
6349
8349
    If given, *startupinfo* will be a :class:`STARTUPINFO` object, which is
6350
8350
    passed to the underlying ``CreateProcess`` function.
6351
 
@@ -540,8 +569,8 @@
 
8351
@@ -540,8 +582,8 @@
6352
8352
 
6353
8353
 .. warning::
6354
8354
 
6359
8359
    deadlocks due to any of the other OS pipe buffers filling up and blocking the
6360
8360
    child process.
6361
8361
 
6362
 
@@ -735,7 +764,7 @@
 
8362
@@ -735,7 +777,7 @@
6363
8363
 to receive a SIGPIPE if p2 exits before p1.
6364
8364
 
6365
8365
 Alternatively, for trusted input, the shell's own pipeline support may still
6391
8391
 
6392
8392
 Log options:
6393
8393
    :const:`LOG_PID`, :const:`LOG_CONS`, :const:`LOG_NDELAY`, :const:`LOG_NOWAIT`
 
8394
diff -r 3d0686d90f55 Doc/library/tempfile.rst
 
8395
--- a/Doc/library/tempfile.rst
 
8396
+++ b/Doc/library/tempfile.rst
 
8397
@@ -76,7 +76,8 @@
 
8398
    data is spooled in memory until the file size exceeds *max_size*, or
 
8399
    until the file's :func:`fileno` method is called, at which point the
 
8400
    contents are written to disk and operation proceeds as with
 
8401
-   :func:`TemporaryFile`.
 
8402
+   :func:`TemporaryFile`.  Also, it's ``truncate`` method does not
 
8403
+   accept a ``size`` argument.
 
8404
 
 
8405
    The resulting file has one additional method, :func:`rollover`, which
 
8406
    causes the file to roll over to an on-disk file regardless of its size.
6394
8407
diff -r 3d0686d90f55 Doc/library/test.rst
6395
8408
--- a/Doc/library/test.rst
6396
8409
+++ b/Doc/library/test.rst
7039
9052
diff -r 3d0686d90f55 Doc/library/timeit.rst
7040
9053
--- a/Doc/library/timeit.rst
7041
9054
+++ b/Doc/library/timeit.rst
7042
 
@@ -31,13 +31,13 @@
7043
 
    may also contain multiple statements separated by ``;`` or newlines, as long as
7044
 
    they don't contain multi-line string literals.
 
9055
@@ -14,107 +14,157 @@
 
9056
 --------------
 
9057
 
 
9058
 This module provides a simple way to time small bits of Python code. It has both
 
9059
-command line as well as callable interfaces.  It avoids a number of common traps
 
9060
-for measuring execution times.  See also Tim Peters' introduction to the
 
9061
-"Algorithms" chapter in the Python Cookbook, published by O'Reilly.
 
9062
+a :ref:`command-line-interface` as well as a :ref:`callable <python-interface>`
 
9063
+one.  It avoids a number of common traps for measuring execution times.
 
9064
+See also Tim Peters' introduction to the "Algorithms" chapter in the *Python
 
9065
+Cookbook*, published by O'Reilly.
 
9066
 
 
9067
-The module defines the following public class:
 
9068
+
 
9069
+Basic Examples
 
9070
+--------------
 
9071
+
 
9072
+The following example shows how the :ref:`command-line-interface`
 
9073
+can be used to compare three different expressions:
 
9074
+
 
9075
+.. code-block:: sh
 
9076
+
 
9077
+   $ python -m timeit '"-".join(str(n) for n in range(100))'
 
9078
+   10000 loops, best of 3: 40.3 usec per loop
 
9079
+   $ python -m timeit '"-".join([str(n) for n in range(100)])'
 
9080
+   10000 loops, best of 3: 33.4 usec per loop
 
9081
+   $ python -m timeit '"-".join(map(str, range(100)))'
 
9082
+   10000 loops, best of 3: 25.2 usec per loop
 
9083
+
 
9084
+This can be achieved from the :ref:`python-interface` with::
 
9085
+
 
9086
+   >>> import timeit
 
9087
+   >>> timeit.timeit('"-".join(str(n) for n in range(100))', number=10000)
 
9088
+   0.8187260627746582
 
9089
+   >>> timeit.timeit('"-".join([str(n) for n in range(100)])', number=10000)
 
9090
+   0.7288308143615723
 
9091
+   >>> timeit.timeit('"-".join(map(str, range(100)))', number=10000)
 
9092
+   0.5858950614929199
 
9093
+
 
9094
+Note however that :mod:`timeit` will automatically determine the number of
 
9095
+repetitions only when the command-line interface is used.  In the
 
9096
+:ref:`timeit-examples` section you can find more advanced examples.
 
9097
+
 
9098
+
 
9099
+.. _python-interface:
 
9100
+
 
9101
+Python Interface
 
9102
+----------------
 
9103
+
 
9104
+The module defines three convenience functions and a public class:
 
9105
+
 
9106
+
 
9107
+.. function:: timeit(stmt='pass', setup='pass', timer=<default timer>, number=1000000)
 
9108
+
 
9109
+   Create a :class:`Timer` instance with the given statement, *setup* code and
 
9110
+   *timer* function and run its :meth:`.timeit` method with *number* executions.
 
9111
+
 
9112
+
 
9113
+.. function:: repeat(stmt='pass', setup='pass', timer=<default timer>, repeat=3, number=1000000)
 
9114
+
 
9115
+   Create a :class:`Timer` instance with the given statement, *setup* code and
 
9116
+   *timer* function and run its :meth:`.repeat` method with the given *repeat*
 
9117
+   count and *number* executions.
 
9118
+
 
9119
+
 
9120
+.. function:: default_timer()
 
9121
+
 
9122
+   Define a default timer, in a platform-specific manner. On Windows,
 
9123
+   :func:`time.clock` has microsecond granularity, but :func:`time.time`'s
 
9124
+   granularity is 1/60th of a second.  On Unix, :func:`time.clock` has 1/100th of
 
9125
+   a second granularity, and :func:`time.time` is much more precise.  On either
 
9126
+   platform, :func:`default_timer` measures wall clock time, not the CPU
 
9127
+   time.  This means that other processes running on the same computer may
 
9128
+   interfere with the timing.
 
9129
 
 
9130
 
 
9131
 .. class:: Timer(stmt='pass', setup='pass', timer=<timer function>)
 
9132
 
 
9133
    Class for timing execution speed of small code snippets.
 
9134
 
 
9135
-   The constructor takes a statement to be timed, an additional statement used for
 
9136
-   setup, and a timer function.  Both statements default to ``'pass'``; the timer
 
9137
-   function is platform-dependent (see the module doc string).  *stmt* and *setup*
 
9138
-   may also contain multiple statements separated by ``;`` or newlines, as long as
 
9139
-   they don't contain multi-line string literals.
 
9140
+   The constructor takes a statement to be timed, an additional statement used
 
9141
+   for setup, and a timer function.  Both statements default to ``'pass'``;
 
9142
+   the timer function is platform-dependent (see the module doc string).
 
9143
+   *stmt* and *setup* may also contain multiple statements separated by ``;``
 
9144
+   or newlines, as long as they don't contain multi-line string literals.
7045
9145
 
7046
9146
-   To measure the execution time of the first statement, use the :meth:`timeit`
7047
9147
-   method.  The :meth:`repeat` method is a convenience to call :meth:`timeit`
7048
 
+   To measure the execution time of the first statement, use the :meth:`Timer.timeit`
7049
 
+   method.  The :meth:`repeat` method is a convenience to call :meth:`.timeit`
 
9148
+   To measure the execution time of the first statement, use the :meth:`.timeit`
 
9149
+   method.  The :meth:`.repeat` method is a convenience to call :meth:`.timeit`
7050
9150
    multiple times and return a list of results.
7051
9151
 
7052
9152
    The *stmt* and *setup* parameters can also take objects that are callable
7053
 
    without arguments. This will embed calls to them in a timer function that
 
9153
-   without arguments. This will embed calls to them in a timer function that
7054
9154
-   will then be executed by :meth:`timeit`.  Note that the timing overhead is a
 
9155
+   without arguments.  This will embed calls to them in a timer function that
7055
9156
+   will then be executed by :meth:`.timeit`.  Note that the timing overhead is a
7056
9157
    little larger in this case because of the extra function calls.
7057
9158
 
7058
9159
 
7059
 
@@ -60,12 +60,12 @@
7060
 
 
7061
 
 .. method:: Timer.repeat(repeat=3, number=1000000)
 
9160
-.. method:: Timer.print_exc(file=None)
 
9161
+   .. method:: Timer.timeit(number=1000000)
 
9162
 
 
9163
-   Helper to print a traceback from the timed code.
 
9164
+      Time *number* executions of the main statement.  This executes the setup
 
9165
+      statement once, and then returns the time it takes to execute the main
 
9166
+      statement a number of times, measured in seconds as a float.
 
9167
+      The argument is the number of times through the loop, defaulting to one
 
9168
+      million.  The main statement, the setup statement and the timer function
 
9169
+      to be used are passed to the constructor.
 
9170
 
 
9171
-   Typical use::
 
9172
+      .. note::
 
9173
 
 
9174
-      t = Timer(...)       # outside the try/except
 
9175
-      try:
 
9176
-          t.timeit(...)    # or t.repeat(...)
 
9177
-      except:
 
9178
-          t.print_exc()
 
9179
+         By default, :meth:`.timeit` temporarily turns off :term:`garbage
 
9180
+         collection` during the timing.  The advantage of this approach is that
 
9181
+         it makes independent timings more comparable.  This disadvantage is
 
9182
+         that GC may be an important component of the performance of the
 
9183
+         function being measured.  If so, GC can be re-enabled as the first
 
9184
+         statement in the *setup* string.  For example::
 
9185
 
 
9186
-   The advantage over the standard traceback is that source lines in the compiled
 
9187
-   template will be displayed. The optional *file* argument directs where the
 
9188
-   traceback is sent; it defaults to ``sys.stderr``.
 
9189
+            timeit.Timer('for i in range(10): oct(i)', 'gc.enable()').timeit()
 
9190
 
 
9191
 
 
9192
-.. method:: Timer.repeat(repeat=3, number=1000000)
 
9193
+   .. method:: Timer.repeat(repeat=3, number=1000000)
7062
9194
 
7063
9195
-   Call :meth:`timeit` a few times.
7064
 
+   Call :meth:`.timeit` a few times.
 
9196
+      Call :meth:`.timeit` a few times.
7065
9197
 
7066
9198
-   This is a convenience function that calls the :meth:`timeit` repeatedly,
7067
 
+   This is a convenience function that calls the :meth:`.timeit` repeatedly,
7068
 
    returning a list of results.  The first argument specifies how many times to
 
9199
-   returning a list of results.  The first argument specifies how many times to
7069
9200
-   call :meth:`timeit`.  The second argument specifies the *number* argument for
7070
9201
-   :func:`timeit`.
7071
 
+   call :meth:`.timeit`.  The second argument specifies the *number* argument for
7072
 
+   :meth:`.timeit`.
7073
 
 
7074
 
    .. note::
7075
 
 
7076
 
@@ -89,7 +89,7 @@
7077
 
 
7078
 
    .. note::
 
9202
+      This is a convenience function that calls the :meth:`.timeit` repeatedly,
 
9203
+      returning a list of results.  The first argument specifies how many times
 
9204
+      to call :meth:`.timeit`.  The second argument specifies the *number*
 
9205
+      argument for :meth:`.timeit`.
 
9206
 
 
9207
-   .. note::
 
9208
+      .. note::
 
9209
 
 
9210
-      It's tempting to calculate mean and standard deviation from the result vector
 
9211
-      and report these.  However, this is not very useful.  In a typical case, the
 
9212
-      lowest value gives a lower bound for how fast your machine can run the given
 
9213
-      code snippet; higher values in the result vector are typically not caused by
 
9214
-      variability in Python's speed, but by other processes interfering with your
 
9215
-      timing accuracy.  So the :func:`min` of the result is probably the only number
 
9216
-      you should be interested in.  After that, you should look at the entire vector
 
9217
-      and apply common sense rather than statistics.
 
9218
+         It's tempting to calculate mean and standard deviation from the result
 
9219
+         vector and report these.  However, this is not very useful.
 
9220
+         In a typical case, the lowest value gives a lower bound for how fast
 
9221
+         your machine can run the given code snippet; higher values in the
 
9222
+         result vector are typically not caused by variability in Python's
 
9223
+         speed, but by other processes interfering with your timing accuracy.
 
9224
+         So the :func:`min` of the result is probably the only number you
 
9225
+         should be interested in.  After that, you should look at the entire
 
9226
+         vector and apply common sense rather than statistics.
 
9227
 
 
9228
 
 
9229
-.. method:: Timer.timeit(number=1000000)
 
9230
+   .. method:: Timer.print_exc(file=None)
 
9231
 
 
9232
-   Time *number* executions of the main statement. This executes the setup
 
9233
-   statement once, and then returns the time it takes to execute the main statement
 
9234
-   a number of times, measured in seconds as a float.  The argument is the number
 
9235
-   of times through the loop, defaulting to one million.  The main statement, the
 
9236
-   setup statement and the timer function to be used are passed to the constructor.
 
9237
+      Helper to print a traceback from the timed code.
 
9238
 
 
9239
-   .. note::
 
9240
+      Typical use::
7079
9241
 
7080
9242
-      By default, :meth:`timeit` temporarily turns off :term:`garbage collection`
7081
 
+      By default, :meth:`.timeit` temporarily turns off :term:`garbage collection`
7082
 
       during the timing.  The advantage of this approach is that it makes
7083
 
       independent timings more comparable.  This disadvantage is that GC may be
7084
 
       an important component of the performance of the function being measured.
7085
 
@@ -99,7 +99,19 @@
7086
 
          timeit.Timer('for i in range(10): oct(i)', 'gc.enable()').timeit()
 
9243
-      during the timing.  The advantage of this approach is that it makes
 
9244
-      independent timings more comparable.  This disadvantage is that GC may be
 
9245
-      an important component of the performance of the function being measured.
 
9246
-      If so, GC can be re-enabled as the first statement in the *setup* string.
 
9247
-      For example::
 
9248
+         t = Timer(...)       # outside the try/except
 
9249
+         try:
 
9250
+             t.timeit(...)    # or t.repeat(...)
 
9251
+         except:
 
9252
+             t.print_exc()
 
9253
 
 
9254
-         timeit.Timer('for i in range(10): oct(i)', 'gc.enable()').timeit()
 
9255
+      The advantage over the standard traceback is that source lines in the
 
9256
+      compiled template will be displayed.  The optional *file* argument directs
 
9257
+      where the traceback is sent; it defaults to :data:`sys.stderr`.
7087
9258
 
7088
9259
 
7089
9260
-The module also defines two convenience functions:
7090
 
+The module also defines three convenience functions:
7091
 
+
7092
 
+
7093
 
+.. function:: default_timer()
7094
 
+
7095
 
+   Define a default timer, in a platform specific manner. On Windows,
7096
 
+   :func:`time.clock` has microsecond granularity but :func:`time.time`'s
7097
 
+   granularity is 1/60th of a second; on Unix, :func:`time.clock` has 1/100th of
7098
 
+   a second granularity and :func:`time.time` is much more precise.  On either
7099
 
+   platform, :func:`default_timer` measures wall clock time, not the CPU
7100
 
+   time.  This means that other processes running on the same computer may
7101
 
+   interfere with the timing.
7102
 
+
7103
 
 
7104
 
 .. function:: repeat(stmt='pass', setup='pass', timer=<default timer>, repeat=3, number=1000000)
7105
 
 
7106
 
@@ -111,7 +123,7 @@
7107
 
 .. function:: timeit(stmt='pass', setup='pass', timer=<default timer>, number=1000000)
7108
 
 
7109
 
    Create a :class:`Timer` instance with the given statement, setup code and timer
 
9261
+.. _command-line-interface:
 
9262
 
 
9263
-.. function:: repeat(stmt='pass', setup='pass', timer=<default timer>, repeat=3, number=1000000)
 
9264
-
 
9265
-   Create a :class:`Timer` instance with the given statement, setup code and timer
 
9266
-   function and run its :meth:`repeat` method with the given repeat count and
 
9267
-   *number* executions.
 
9268
-
 
9269
-
 
9270
-.. function:: timeit(stmt='pass', setup='pass', timer=<default timer>, number=1000000)
 
9271
-
 
9272
-   Create a :class:`Timer` instance with the given statement, setup code and timer
7110
9273
-   function and run its :meth:`timeit` method with *number* executions.
7111
 
+   function and run its :meth:`.timeit` method with *number* executions.
7112
 
 
7113
 
 
7114
 
 Command Line Interface
7115
 
@@ -161,13 +173,9 @@
 
9274
-
 
9275
-
 
9276
-Command Line Interface
 
9277
+Command-Line Interface
 
9278
 ----------------------
 
9279
 
 
9280
 When called as a program from the command line, the following form is used::
 
9281
@@ -161,13 +211,9 @@
7116
9282
 If :option:`-n` is not given, a suitable number of loops is calculated by trying
7117
9283
 successive powers of 10 until the total time is at least 0.2 seconds.
7118
9284
 
7129
9295
 the timing a few times and use the best time.  The :option:`-r` option is good
7130
9296
 for this; the default of 3 repetitions is probably enough in most cases.  On
7131
9297
 Unix, you can use :func:`time.clock` to measure CPU time.
7132
 
@@ -235,7 +243,7 @@
7133
 
    3.15 usec/pass
 
9298
@@ -176,25 +222,53 @@
 
9299
 
 
9300
    There is a certain baseline overhead associated with executing a pass statement.
 
9301
    The code here doesn't try to hide it, but you should be aware of it.  The
 
9302
-   baseline overhead can be measured by invoking the program without arguments.
 
9303
+   baseline overhead can be measured by invoking the program without arguments,
 
9304
+   and it might differ between Python versions.
 
9305
 
 
9306
-The baseline overhead differs between Python versions!  Also, to fairly compare
 
9307
-older Python versions to Python 2.3, you may want to use Python's :option:`-O`
 
9308
-option for the older versions to avoid timing ``SET_LINENO`` instructions.
 
9309
 
 
9310
+.. _timeit-examples:
 
9311
 
 
9312
 Examples
 
9313
 --------
 
9314
 
 
9315
-Here are two example sessions (one using the command line, one using the module
 
9316
-interface) that compare the cost of using :func:`hasattr` vs.
 
9317
-:keyword:`try`/:keyword:`except` to test for missing and present object
 
9318
-attributes. ::
 
9319
+It is possible to provide a setup statement that is executed only once at the beginning:
 
9320
+
 
9321
+.. code-block:: sh
 
9322
+
 
9323
+   $ python -m timeit -s 'text = "sample string"; char = "g"'  'char in text'
 
9324
+   10000000 loops, best of 3: 0.0877 usec per loop
 
9325
+   $ python -m timeit -s 'text = "sample string"; char = "g"'  'text.find(char)'
 
9326
+   1000000 loops, best of 3: 0.342 usec per loop
 
9327
+
 
9328
+::
 
9329
+
 
9330
+   >>> import timeit
 
9331
+   >>> timeit.timeit('char in text', setup='text = "sample string"; char = "g"')
 
9332
+   0.41440500499993504
 
9333
+   >>> timeit.timeit('text.find(char)', setup='text = "sample string"; char = "g"')
 
9334
+   1.7246671520006203
 
9335
+
 
9336
+The same can be done using the :class:`Timer` class and its methods::
 
9337
+
 
9338
+   >>> import timeit
 
9339
+   >>> t = timeit.Timer('char in text', setup='text = "sample string"; char = "g"')
 
9340
+   >>> t.timeit()
 
9341
+   0.3955516149999312
 
9342
+   >>> t.repeat()
 
9343
+   [0.40193588800002544, 0.3960157959998014, 0.39594301399984033]
 
9344
+
 
9345
+
 
9346
+The following examples show how to time expressions that contain multiple lines.
 
9347
+Here we compare the cost of using :func:`hasattr` vs. :keyword:`try`/:keyword:`except`
 
9348
+to test for missing and present object attributes:
 
9349
+
 
9350
+.. code-block:: sh
 
9351
 
 
9352
    $ python -m timeit 'try:' '  str.__bool__' 'except AttributeError:' '  pass'
 
9353
    100000 loops, best of 3: 15.7 usec per loop
 
9354
    $ python -m timeit 'if hasattr(str, "__bool__"): pass'
 
9355
    100000 loops, best of 3: 4.26 usec per loop
 
9356
+
 
9357
    $ python -m timeit 'try:' '  int.__bool__' 'except AttributeError:' '  pass'
 
9358
    1000000 loops, best of 3: 1.43 usec per loop
 
9359
    $ python -m timeit 'if hasattr(int, "__bool__"): pass'
 
9360
@@ -203,46 +277,40 @@
 
9361
 ::
 
9362
 
 
9363
    >>> import timeit
 
9364
+   >>> # attribute is missing
 
9365
    >>> s = """\
 
9366
    ... try:
 
9367
    ...     str.__bool__
 
9368
    ... except AttributeError:
 
9369
    ...     pass
 
9370
    ... """
 
9371
-   >>> t = timeit.Timer(stmt=s)
 
9372
-   >>> print("%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000))
 
9373
-   17.09 usec/pass
 
9374
-   >>> s = """\
 
9375
-   ... if hasattr(str, '__bool__'): pass
 
9376
-   ... """
 
9377
-   >>> t = timeit.Timer(stmt=s)
 
9378
-   >>> print("%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000))
 
9379
-   4.85 usec/pass
 
9380
+   >>> timeit.timeit(stmt=s, number=100000)
 
9381
+   0.9138244460009446
 
9382
+   >>> s = "if hasattr(str, '__bool__'): pass"
 
9383
+   >>> timeit.timeit(stmt=s, number=100000)
 
9384
+   0.5829014980008651
 
9385
+   >>>
 
9386
+   >>> # attribute is present
 
9387
    >>> s = """\
 
9388
    ... try:
 
9389
    ...     int.__bool__
 
9390
    ... except AttributeError:
 
9391
    ...     pass
 
9392
    ... """
 
9393
-   >>> t = timeit.Timer(stmt=s)
 
9394
-   >>> print("%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000))
 
9395
-   1.97 usec/pass
 
9396
-   >>> s = """\
 
9397
-   ... if hasattr(int, '__bool__'): pass
 
9398
-   ... """
 
9399
-   >>> t = timeit.Timer(stmt=s)
 
9400
-   >>> print("%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000))
 
9401
-   3.15 usec/pass
 
9402
+   >>> timeit.timeit(stmt=s, number=100000)
 
9403
+   0.04215312199994514
 
9404
+   >>> s = "if hasattr(int, '__bool__'): pass"
 
9405
+   >>> timeit.timeit(stmt=s, number=100000)
 
9406
+   0.08588060699912603
 
9407
+
7134
9408
 
7135
9409
 To give the :mod:`timeit` module access to functions you define, you can pass a
7136
9410
-``setup`` parameter which contains an import statement::
7138
9412
 
7139
9413
    def test():
7140
9414
        """Stupid test function"""
 
9415
        L = [i for i in range(100)]
 
9416
 
 
9417
    if __name__ == '__main__':
 
9418
-       from timeit import Timer
 
9419
-       t = Timer("test()", "from __main__ import test")
 
9420
-       print(t.timeit())
 
9421
-
 
9422
+       import timeit
 
9423
+       print(timeit.timeit("test()", setup="from __main__ import test"))
7141
9424
diff -r 3d0686d90f55 Doc/library/tkinter.rst
7142
9425
--- a/Doc/library/tkinter.rst
7143
9426
+++ b/Doc/library/tkinter.rst
7814
10097
diff -r 3d0686d90f55 Doc/library/zipfile.rst
7815
10098
--- a/Doc/library/zipfile.rst
7816
10099
+++ b/Doc/library/zipfile.rst
 
10100
@@ -61,7 +61,7 @@
 
10101
 .. class:: ZipInfo(filename='NoName', date_time=(1980,1,1,0,0,0))
 
10102
 
 
10103
    Class used to represent information about a member of an archive. Instances
 
10104
-   of this class are returned by the :meth:`getinfo` and :meth:`infolist`
 
10105
+   of this class are returned by the :meth:`.getinfo` and :meth:`.infolist`
 
10106
    methods of :class:`ZipFile` objects.  Most users of the :mod:`zipfile` module
 
10107
    will not need to create these, but only use those created by this
 
10108
    module. *filename* should be the full name of the archive member, and
 
10109
@@ -87,7 +87,7 @@
 
10110
 .. data:: ZIP_DEFLATED
 
10111
 
 
10112
    The numeric constant for the usual ZIP compression method.  This requires the
 
10113
-   zlib module.  No other compression methods are currently supported.
 
10114
+   :mod:`zlib` module.  No other compression methods are currently supported.
 
10115
 
 
10116
 
 
10117
 .. seealso::
 
10118
@@ -130,7 +130,7 @@
 
10119
    these extensions.
 
10120
 
 
10121
    If the file is created with mode ``'a'`` or ``'w'`` and then
 
10122
-   :meth:`close`\ d without adding any files to the archive, the appropriate
 
10123
+   :meth:`closed <close>` without adding any files to the archive, the appropriate
 
10124
    ZIP structures for an empty archive will be written to the file.
 
10125
 
 
10126
    ZipFile is also a context manager and therefore supports the
7817
10127
@@ -169,14 +169,18 @@
7818
10128
    Return a list of archive members by name.
7819
10129
 
7834
10144
+   *mode* parameter, if included, must be one of the following: ``'r'`` (the
7835
10145
+   default), ``'U'``, or ``'rU'``. Choosing ``'U'`` or  ``'rU'`` will enable
7836
10146
+   :term:`universal newlines` support in the read-only object.  *pwd* is the
7837
 
+   password used for encrypted files.  Calling  :meth:`open` on a closed
 
10147
+   password used for encrypted files.  Calling  :meth:`.open` on a closed
7838
10148
+   ZipFile will raise a  :exc:`RuntimeError`.
7839
10149
 
7840
10150
    .. note::
7841
10151
 
 
10152
@@ -197,7 +201,7 @@
 
10153
 
 
10154
    .. note::
 
10155
 
 
10156
-      The :meth:`open`, :meth:`read` and :meth:`extract` methods can take a filename
 
10157
+      The :meth:`.open`, :meth:`read` and :meth:`extract` methods can take a filename
 
10158
       or a :class:`ZipInfo` object.  You will appreciate this when trying to read a
 
10159
       ZIP file that contains members with duplicate names.
 
10160
 
 
10161
@@ -303,7 +307,7 @@
 
10162
       :class:`ZipInfo` constructor sets this member to :const:`ZIP_STORED`.
 
10163
 
 
10164
    .. versionchanged:: 3.2
 
10165
-      The *compression_type* argument.
 
10166
+      The *compress_type* argument.
 
10167
 
 
10168
 The following data attributes are also available:
 
10169
 
 
10170
@@ -319,7 +323,7 @@
 
10171
    The comment text associated with the ZIP file.  If assigning a comment to a
 
10172
    :class:`ZipFile` instance created with mode 'a' or 'w', this should be a
 
10173
    string no longer than 65535 bytes.  Comments longer than this will be
 
10174
-   truncated in the written archive when :meth:`ZipFile.close` is called.
 
10175
+   truncated in the written archive when :meth:`close` is called.
 
10176
 
 
10177
 
 
10178
 .. _pyzipfile-objects:
 
10179
@@ -375,8 +379,8 @@
 
10180
 ZipInfo Objects
 
10181
 ---------------
 
10182
 
 
10183
-Instances of the :class:`ZipInfo` class are returned by the :meth:`getinfo` and
 
10184
-:meth:`infolist` methods of :class:`ZipFile` objects.  Each object stores
 
10185
+Instances of the :class:`ZipInfo` class are returned by the :meth:`.getinfo` and
 
10186
+:meth:`.infolist` methods of :class:`ZipFile` objects.  Each object stores
 
10187
 information about a single member of the ZIP archive.
 
10188
 
 
10189
 Instances have the following attributes:
 
10190
diff -r 3d0686d90f55 Doc/license.rst
 
10191
--- a/Doc/license.rst
 
10192
+++ b/Doc/license.rst
 
10193
@@ -325,7 +325,7 @@
 
10194
 ----------------
 
10195
 
 
10196
 The :mod:`_random` module includes code based on a download from
 
10197
-http://www.math.keio.ac.jp/ matumoto/MT2002/emt19937ar.html. The following are
 
10198
+http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html. The following are
 
10199
 the verbatim comments from the original code::
 
10200
 
 
10201
    A C-program for MT19937, with initialization improved 2002/1/26.
 
10202
@@ -366,8 +366,8 @@
 
10203
 
 
10204
 
 
10205
    Any feedback is very welcome.
 
10206
-   http://www.math.keio.ac.jp/matumoto/emt.html
 
10207
-   email: matumoto@math.keio.ac.jp
 
10208
+   http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
 
10209
+   email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
 
10210
 
 
10211
 
 
10212
 Sockets
7842
10213
diff -r 3d0686d90f55 Doc/reference/compound_stmts.rst
7843
10214
--- a/Doc/reference/compound_stmts.rst
7844
10215
+++ b/Doc/reference/compound_stmts.rst
7852
10223
-saved exception is set as the context of the new exception.  The exception
7853
10224
-information is not available to the program during execution of the
7854
10225
-:keyword:`finally` clause.
7855
 
+is executed.  If there is a saved exception or :keyword:`break` statement,
7856
 
+it is re-raised at the end of the :keyword:`finally` clause. If the
7857
 
+:keyword:`finally` clause raises another exception the saved exception
7858
 
+is set as the context of the new exception; if the :keyword:`finally` clause
7859
 
+executes a :keyword:`return` statement, the saved exception is discarded::
 
10226
+is executed.  If there is a saved exception it is re-raised at the end of the
 
10227
+:keyword:`finally` clause.  If the :keyword:`finally` clause raises another
 
10228
+exception, the saved exception is set as the context of the new exception.
 
10229
+If the :keyword:`finally` clause executes a :keyword:`return` or :keyword:`break`
 
10230
+statement, the saved exception is discarded::
7860
10231
+
7861
10232
+    def f():
7862
10233
+        try:
7887
10258
diff -r 3d0686d90f55 Doc/reference/datamodel.rst
7888
10259
--- a/Doc/reference/datamodel.rst
7889
10260
+++ b/Doc/reference/datamodel.rst
 
10261
@@ -305,7 +305,7 @@
 
10262
 
 
10263
          A bytes object is an immutable array.  The items are 8-bit bytes,
 
10264
          represented by integers in the range 0 <= x < 256.  Bytes literals
 
10265
-         (like ``b'abc'`` and the built-in function :func:`bytes` can be used to
 
10266
+         (like ``b'abc'``) and the built-in function :func:`bytes` can be used to
 
10267
          construct bytes objects.  Also, bytes objects can be decoded to strings
 
10268
          via the :meth:`decode` method.
 
10269
 
 
10270
@@ -588,9 +588,9 @@
 
10271
       A function or method which uses the :keyword:`yield` statement (see section
 
10272
       :ref:`yield`) is called a :dfn:`generator function`.  Such a function, when
 
10273
       called, always returns an iterator object which can be used to execute the
 
10274
-      body of the function:  calling the iterator's :meth:`__next__` method will
 
10275
-      cause the function to execute until it provides a value using the
 
10276
-      :keyword:`yield` statement.  When the function executes a
 
10277
+      body of the function:  calling the iterator's :meth:`iterator__next__`
 
10278
+      method will cause the function to execute until it provides a value
 
10279
+      using the :keyword:`yield` statement.  When the function executes a
 
10280
       :keyword:`return` statement or falls off the end, a :exc:`StopIteration`
 
10281
       exception is raised and the iterator will have reached the end of the set of
 
10282
       values to be returned.
 
10283
@@ -1173,7 +1173,7 @@
 
10284
       builtin: print
 
10285
 
 
10286
    Called by the :func:`format` built-in function (and by extension, the
 
10287
-   :meth:`format` method of class :class:`str`) to produce a "formatted"
 
10288
+   :meth:`str.format` method of class :class:`str`) to produce a "formatted"
 
10289
    string representation of an object. The ``format_spec`` argument is
 
10290
    a string that contains a description of the formatting options desired.
 
10291
    The interpretation of the ``format_spec`` argument is up to the type
7890
10292
@@ -1255,22 +1255,22 @@
7891
10293
    by default; with them, all objects compare unequal (except with themselves)
7892
10294
    and ``x.__hash__()`` returns ``id(x)``.
7926
10328
diff -r 3d0686d90f55 Doc/reference/expressions.rst
7927
10329
--- a/Doc/reference/expressions.rst
7928
10330
+++ b/Doc/reference/expressions.rst
 
10331
@@ -294,13 +294,13 @@
 
10332
 brackets or curly braces.
 
10333
 
 
10334
 Variables used in the generator expression are evaluated lazily when the
 
10335
-:meth:`__next__` method is called for generator object (in the same fashion as
 
10336
-normal generators).  However, the leftmost :keyword:`for` clause is immediately
 
10337
-evaluated, so that an error produced by it can be seen before any other possible
 
10338
-error in the code that handles the generator expression.  Subsequent
 
10339
-:keyword:`for` clauses cannot be evaluated immediately since they may depend on
 
10340
-the previous :keyword:`for` loop. For example: ``(x*y for x in range(10) for y
 
10341
-in bar(x))``.
 
10342
+:meth:`~generator.__next__` method is called for generator object (in the same
 
10343
+fashion as normal generators).  However, the leftmost :keyword:`for` clause is
 
10344
+immediately evaluated, so that an error produced by it can be seen before any
 
10345
+other possible error in the code that handles the generator expression.
 
10346
+Subsequent :keyword:`for` clauses cannot be evaluated immediately since they
 
10347
+may depend on the previous :keyword:`for` loop. For example: ``(x*y for x in
 
10348
+range(10) for y in bar(x))``.
 
10349
 
 
10350
 The parentheses can be omitted on calls with only one argument.  See section
 
10351
 :ref:`calls` for the detail.
7929
10352
@@ -354,8 +354,15 @@
7930
10353
 
7931
10354
 .. index:: object: generator
7944
10367
 
7945
10368
 .. index:: exception: StopIteration
7946
10369
 
 
10370
@@ -364,10 +371,11 @@
 
10371
 
 
10372
    Starts the execution of a generator function or resumes it at the last
 
10373
    executed :keyword:`yield` expression.  When a generator function is resumed
 
10374
-   with a :meth:`__next__` method, the current :keyword:`yield` expression
 
10375
-   always evaluates to :const:`None`.  The execution then continues to the next
 
10376
-   :keyword:`yield` expression, where the generator is suspended again, and the
 
10377
-   value of the :token:`expression_list` is returned to :meth:`next`'s caller.
 
10378
+   with a :meth:`~generator.__next__` method, the current :keyword:`yield`
 
10379
+   expression always evaluates to :const:`None`.  The execution then continues
 
10380
+   to the next :keyword:`yield` expression, where the generator is suspended
 
10381
+   again, and the value of the :token:`expression_list` is returned to
 
10382
+   :meth:`next`'s caller.
 
10383
    If the generator exits without yielding another value, a :exc:`StopIteration`
 
10384
    exception is raised.
 
10385
 
 
10386
@@ -1060,16 +1068,10 @@
 
10387
   another one is made arbitrarily but consistently within one execution of a
 
10388
   program.
 
10389
 
 
10390
-Comparison of objects of the differing types depends on whether either
 
10391
-of the types provide explicit support for the comparison.  Most numeric types
 
10392
-can be compared with one another, but comparisons of :class:`float` and
 
10393
-:class:`Decimal` are not supported to avoid the inevitable confusion arising
 
10394
-from representation issues such as ``float('1.1')`` being inexactly represented
 
10395
-and therefore not exactly equal to ``Decimal('1.1')`` which is.  When
 
10396
-cross-type comparison is not supported, the comparison method returns
 
10397
-``NotImplemented``.  This can create the illusion of non-transitivity between
 
10398
-supported cross-type comparisons and unsupported comparisons.  For example,
 
10399
-``Decimal(2) == 2`` and ``2 == float(2)`` but ``Decimal(2) != float(2)``.
 
10400
+Comparison of objects of the differing types depends on whether either of the
 
10401
+types provide explicit support for the comparison.  Most numeric types can be
 
10402
+compared with one another.  When cross-type comparison is not supported, the
 
10403
+comparison method returns ``NotImplemented``.
 
10404
 
 
10405
 .. _membership-test-details:
 
10406
 
7947
10407
diff -r 3d0686d90f55 Doc/reference/simple_stmts.rst
7948
10408
--- a/Doc/reference/simple_stmts.rst
7949
10409
+++ b/Doc/reference/simple_stmts.rst
8212
10672
diff -r 3d0686d90f55 Doc/tools/sphinxext/pyspecific.py
8213
10673
--- a/Doc/tools/sphinxext/pyspecific.py
8214
10674
+++ b/Doc/tools/sphinxext/pyspecific.py
8215
 
@@ -27,10 +27,10 @@
 
10675
@@ -27,15 +27,44 @@
8216
10676
     self.body.append(self.starttag(node, 'p', CLASS=node['type']))
8217
10677
     text = versionlabels[node['type']] % node['version']
8218
10678
     if len(node):
8224
10684
+    self.body.append('<span class="versionmodified">%s</span> ' % text)
8225
10685
 
8226
10686
 from sphinx.writers.html import HTMLTranslator
 
10687
+from sphinx.writers.latex import LaTeXTranslator
8227
10688
 from sphinx.locale import versionlabels
 
10689
 HTMLTranslator.visit_versionmodified = new_visit_versionmodified
 
10690
+HTMLTranslator.visit_versionmodified = new_visit_versionmodified
 
10691
 
 
10692
+# monkey-patch HTML and LaTeX translators to keep doctest blocks in the
 
10693
+# doctest docs themselves
 
10694
+orig_visit_literal_block = HTMLTranslator.visit_literal_block
 
10695
+def new_visit_literal_block(self, node):
 
10696
+    meta = self.builder.env.metadata[self.builder.current_docname]
 
10697
+    old_trim_doctest_flags = self.highlighter.trim_doctest_flags
 
10698
+    if 'keepdoctest' in meta:
 
10699
+        self.highlighter.trim_doctest_flags = False
 
10700
+    try:
 
10701
+        orig_visit_literal_block(self, node)
 
10702
+    finally:
 
10703
+        self.highlighter.trim_doctest_flags = old_trim_doctest_flags
 
10704
+
 
10705
+HTMLTranslator.visit_literal_block = new_visit_literal_block
 
10706
+
 
10707
+orig_depart_literal_block = LaTeXTranslator.depart_literal_block
 
10708
+def new_depart_literal_block(self, node):
 
10709
+    meta = self.builder.env.metadata[self.curfilestack[-1]]
 
10710
+    old_trim_doctest_flags = self.highlighter.trim_doctest_flags
 
10711
+    if 'keepdoctest' in meta:
 
10712
+        self.highlighter.trim_doctest_flags = False
 
10713
+    try:
 
10714
+        orig_depart_literal_block(self, node)
 
10715
+    finally:
 
10716
+        self.highlighter.trim_doctest_flags = old_trim_doctest_flags
 
10717
+
 
10718
+LaTeXTranslator.depart_literal_block = new_depart_literal_block
 
10719
 
 
10720
 # Support for marking up and linking to bugs.python.org issues
 
10721
 
8228
10722
diff -r 3d0686d90f55 Doc/tools/sphinxext/static/copybutton.js
8229
10723
--- a/Doc/tools/sphinxext/static/copybutton.js
8230
10724
+++ b/Doc/tools/sphinxext/static/copybutton.js
8412
10906
 
8413
10907
    After local assignment: test spam
8414
10908
    After nonlocal assignment: nonlocal spam
 
10909
@@ -735,11 +738,11 @@
 
10910
 This style of access is clear, concise, and convenient.  The use of iterators
 
10911
 pervades and unifies Python.  Behind the scenes, the :keyword:`for` statement
 
10912
 calls :func:`iter` on the container object.  The function returns an iterator
 
10913
-object that defines the method :meth:`__next__` which accesses elements in the
 
10914
-container one at a time.  When there are no more elements, :meth:`__next__`
 
10915
-raises a :exc:`StopIteration` exception which tells the :keyword:`for` loop to
 
10916
-terminate.  You can call the :meth:`__next__` method using the :func:`next`
 
10917
-built-in function; this example shows how it all works::
 
10918
+object that defines the method :meth:`~iterator.__next__` which accesses
 
10919
+elements in the container one at a time.  When there are no more elements,
 
10920
+:meth:`__next__` raises a :exc:`StopIteration` exception which tells the
 
10921
+:keyword:`for` loop to terminate.  You can call the :meth:`__next__` method
 
10922
+using the :func:`next` built-in function; this example shows how it all works::
 
10923
 
 
10924
    >>> s = 'abc'
 
10925
    >>> it = iter(s)
 
10926
@@ -759,8 +762,8 @@
 
10927
 
 
10928
 Having seen the mechanics behind the iterator protocol, it is easy to add
 
10929
 iterator behavior to your classes.  Define an :meth:`__iter__` method which
 
10930
-returns an object with a :meth:`__next__` method.  If the class defines
 
10931
-:meth:`__next__`, then :meth:`__iter__` can just return ``self``::
 
10932
+returns an object with a :meth:`~iterator.__next__` method.  If the class
 
10933
+defines :meth:`__next__`, then :meth:`__iter__` can just return ``self``::
 
10934
 
 
10935
    class Reverse:
 
10936
        """Iterator for looping over a sequence backwards."""
 
10937
@@ -817,8 +820,8 @@
 
10938
 
 
10939
 Anything that can be done with generators can also be done with class based
 
10940
 iterators as described in the previous section.  What makes generators so
 
10941
-compact is that the :meth:`__iter__` and :meth:`__next__` methods are created
 
10942
-automatically.
 
10943
+compact is that the :meth:`__iter__` and :meth:`~generator.__next__` methods
 
10944
+are created automatically.
 
10945
 
 
10946
 Another key feature is that the local variables and execution state are
 
10947
 automatically saved between calls.  This made the function easier to write and
8415
10948
diff -r 3d0686d90f55 Doc/tutorial/controlflow.rst
8416
10949
--- a/Doc/tutorial/controlflow.rst
8417
10950
+++ b/Doc/tutorial/controlflow.rst
 
10951
@@ -58,24 +58,24 @@
 
10952
 ::
 
10953
 
 
10954
    >>> # Measure some strings:
 
10955
-   ... a = ['cat', 'window', 'defenestrate']
 
10956
-   >>> for x in a:
 
10957
-   ...     print(x, len(x))
 
10958
+   ... words = ['cat', 'window', 'defenestrate']
 
10959
+   >>> for w in words:
 
10960
+   ...     print(w, len(w))
 
10961
    ...
 
10962
    cat 3
 
10963
    window 6
 
10964
    defenestrate 12
 
10965
 
 
10966
-It is not safe to modify the sequence being iterated over in the loop (this can
 
10967
-only happen for mutable sequence types, such as lists).  If you need to modify
 
10968
-the list you are iterating over (for example, to duplicate selected items) you
 
10969
-must iterate over a copy.  The slice notation makes this particularly
 
10970
-convenient::
 
10971
+If you need to modify the sequence you are iterating over while inside the loop
 
10972
+(for example to duplicate selected items), it is recommended that you first
 
10973
+make a copy.  Iterating over a sequence does not implicitly make a copy.  The
 
10974
+slice notation makes this especially convenient::
 
10975
 
 
10976
-   >>> for x in a[:]: # make a slice copy of the entire list
 
10977
-   ...    if len(x) > 6: a.insert(0, x)
 
10978
+   >>> for w in words[:]:  # Loop over a slice copy of the entire list.
 
10979
+   ...     if len(w) > 6:
 
10980
+   ...         words.insert(0, w)
 
10981
    ...
 
10982
-   >>> a
 
10983
+   >>> words
 
10984
    ['defenestrate', 'cat', 'window', 'defenestrate']
 
10985
 
 
10986
 
8418
10987
@@ -157,9 +157,6 @@
8419
10988
 The :keyword:`break` statement, like in C, breaks out of the smallest enclosing
8420
10989
 :keyword:`for` or :keyword:`while` loop.
8458
11027
diff -r 3d0686d90f55 Doc/tutorial/datastructures.rst
8459
11028
--- a/Doc/tutorial/datastructures.rst
8460
11029
+++ b/Doc/tutorial/datastructures.rst
 
11030
@@ -181,7 +181,7 @@
 
11031
 
 
11032
    squares = [x**2 for x in range(10)]
 
11033
 
 
11034
-This is also equivalent to ``squares = map(lambda x: x**2, range(10))``,
 
11035
+This is also equivalent to ``squares = list(map(lambda x: x**2, range(10)))``,
 
11036
 but it's more concise and readable.
 
11037
 
 
11038
 A list comprehension consists of brackets containing an expression followed
8461
11039
@@ -292,7 +292,7 @@
8462
11040
 In the real world, you should prefer built-in functions to complex flow statements.
8463
11041
 The :func:`zip` function would do a great job for this use case::
8514
11092
 
8515
11093
 .. _tut-sets:
8516
11094
 
 
11095
@@ -572,6 +584,19 @@
 
11096
    orange
 
11097
    pear
 
11098
 
 
11099
+To change a sequence you are iterating over while inside the loop (for
 
11100
+example to duplicate certain items), it is recommended that you first make
 
11101
+a copy.  Looping over a sequence does not implicitly make a copy.  The slice
 
11102
+notation makes this especially convenient::
 
11103
+
 
11104
+   >>> words = ['cat', 'window', 'defenestrate']
 
11105
+   >>> for w in words[:]:  # Loop over a slice copy of the entire list.
 
11106
+   ...     if len(w) > 6:
 
11107
+   ...         words.insert(0, w)
 
11108
+   ...
 
11109
+   >>> words
 
11110
+   ['defenestrate', 'cat', 'window', 'defenestrate']
 
11111
+
 
11112
 
 
11113
 .. _tut-conditions:
 
11114
 
8517
11115
diff -r 3d0686d90f55 Doc/tutorial/inputoutput.rst
8518
11116
--- a/Doc/tutorial/inputoutput.rst
8519
11117
+++ b/Doc/tutorial/inputoutput.rst
8526
11124
 representation for human consumption, :func:`str` will return the same value as
8527
11125
 :func:`repr`.  Many values, such as numbers or structures like lists and
8528
11126
 dictionaries, have the same representation using either function.  Strings, in
 
11127
@@ -184,7 +184,7 @@
 
11128
 
 
11129
    >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}
 
11130
    >>> print('Jack: {0[Jack]:d}; Sjoerd: {0[Sjoerd]:d}; '
 
11131
-             'Dcab: {0[Dcab]:d}'.format(table))
 
11132
+   ...       'Dcab: {0[Dcab]:d}'.format(table))
 
11133
    Jack: 4098; Sjoerd: 4127; Dcab: 8637678
 
11134
 
 
11135
 This could also be done by passing the table as keyword arguments with the '**'
 
11136
@@ -256,9 +256,10 @@
 
11137
 :dfn:`binary mode`: now the data is read and written in the form of bytes
 
11138
 objects.  This mode should be used for all files that don't contain text.
 
11139
 
 
11140
-In text mode, the default is to convert platform-specific line endings (``\n``
 
11141
-on Unix, ``\r\n`` on Windows) to just ``\n`` on reading and ``\n`` back to
 
11142
-platform-specific line endings on writing.  This behind-the-scenes modification
 
11143
+In text mode, the default when reading is to convert platform-specific line
 
11144
+endings (``\n`` on Unix, ``\r\n`` on Windows) to just ``\n``.  When writing in
 
11145
+text mode, the default is to convert occurrences of ``\n`` back to
 
11146
+platform-specific line endings.  This behind-the-scenes modification
 
11147
 to file data is fine for text files, but will corrupt binary data like that in
 
11148
 :file:`JPEG` or :file:`EXE` files.  Be very careful to use binary mode when
 
11149
 reading and writing such files.
 
11150
diff -r 3d0686d90f55 Doc/tutorial/interpreter.rst
 
11151
--- a/Doc/tutorial/interpreter.rst
 
11152
+++ b/Doc/tutorial/interpreter.rst
 
11153
@@ -12,7 +12,9 @@
 
11154
 
 
11155
 The Python interpreter is usually installed as :file:`/usr/local/bin/python3.2`
 
11156
 on those machines where it is available; putting :file:`/usr/local/bin` in your
 
11157
-Unix shell's search path makes it possible to start it by typing the command ::
 
11158
+Unix shell's search path makes it possible to start it by typing the command:
 
11159
+
 
11160
+.. code-block:: text
 
11161
 
 
11162
    python3.2
 
11163
 
 
11164
@@ -94,8 +96,8 @@
 
11165
 before printing the first prompt::
 
11166
 
 
11167
    $ python3.2
 
11168
-   Python 3.2 (py3k, Sep 12 2007, 12:21:02)
 
11169
-   [GCC 3.4.6 20060404 (Red Hat 3.4.6-8)] on linux2
 
11170
+   Python 3.2.3 (default, May  3 2012, 15:54:42)
 
11171
+   [GCC 4.6.3] on linux2
 
11172
    Type "help", "copyright", "credits" or "license" for more information.
 
11173
    >>>
 
11174
 
8529
11175
diff -r 3d0686d90f55 Doc/tutorial/introduction.rst
8530
11176
--- a/Doc/tutorial/introduction.rst
8531
11177
+++ b/Doc/tutorial/introduction.rst
8532
 
@@ -413,7 +413,7 @@
 
11178
@@ -94,8 +94,7 @@
 
11179
 Variables must be "defined" (assigned a value) before they can be used, or an
 
11180
 error will occur::
 
11181
 
 
11182
-   >>> # try to access an undefined variable
 
11183
-   ... n
 
11184
+   >>> n  # try to access an undefined variable
 
11185
    Traceback (most recent call last):
 
11186
      File "<stdin>", line 1, in <module>
 
11187
    NameError: name 'n' is not defined
 
11188
@@ -413,7 +412,7 @@
8533
11189
 About Unicode
8534
11190
 -------------
8535
11191
 
8550
11206
 provided on Windows systems. One particular module deserves some attention:
8551
11207
 :mod:`sys`, which is built into every Python interpreter.  The variables
8552
11208
 ``sys.ps1`` and ``sys.ps2`` define the strings used as primary and secondary
 
11209
diff -r 3d0686d90f55 Doc/tutorial/stdlib.rst
 
11210
--- a/Doc/tutorial/stdlib.rst
 
11211
+++ b/Doc/tutorial/stdlib.rst
 
11212
@@ -148,7 +148,7 @@
 
11213
 
 
11214
 There are a number of modules for accessing the internet and processing internet
 
11215
 protocols. Two of the simplest are :mod:`urllib.request` for retrieving data
 
11216
-from urls and :mod:`smtplib` for sending mail::
 
11217
+from URLs and :mod:`smtplib` for sending mail::
 
11218
 
 
11219
    >>> from urllib.request import urlopen
 
11220
    >>> for line in urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl'):
 
11221
diff -r 3d0686d90f55 Doc/tutorial/stdlib2.rst
 
11222
--- a/Doc/tutorial/stdlib2.rst
 
11223
+++ b/Doc/tutorial/stdlib2.rst
 
11224
@@ -95,7 +95,7 @@
 
11225
    >>> d = dict(item='unladen swallow')
 
11226
    >>> t.substitute(d)
 
11227
    Traceback (most recent call last):
 
11228
-     . . .
 
11229
+     ...
 
11230
    KeyError: 'owner'
 
11231
    >>> t.safe_substitute(d)
 
11232
    'Return the unladen swallow to $owner.'
 
11233
@@ -218,7 +218,9 @@
 
11234
    logging.error('Error occurred')
 
11235
    logging.critical('Critical error -- shutting down')
 
11236
 
 
11237
-This produces the following output::
 
11238
+This produces the following output:
 
11239
+
 
11240
+.. code-block:: none
 
11241
 
 
11242
    WARNING:root:Warning:config file server.conf not found
 
11243
    ERROR:root:Error occurred
 
11244
@@ -309,6 +311,8 @@
 
11245
    >>> print("Handling", d.popleft())
 
11246
    Handling task1
 
11247
 
 
11248
+::
 
11249
+
 
11250
    unsearched = deque([starting_node])
 
11251
    def breadth_first_search(unsearched):
 
11252
        node = unsearched.popleft()
 
11253
diff -r 3d0686d90f55 Doc/using/cmdline.rst
 
11254
--- a/Doc/using/cmdline.rst
 
11255
+++ b/Doc/using/cmdline.rst
 
11256
@@ -379,7 +379,10 @@
 
11257
 Environment variables
 
11258
 ---------------------
 
11259
 
 
11260
-These environment variables influence Python's behavior.
 
11261
+These environment variables influence Python's behavior, they are processed
 
11262
+before the command-line switches other than -E.  It is customary that
 
11263
+command-line switches override environmental variables where there is a
 
11264
+conflict.
 
11265
 
 
11266
 .. envvar:: PYTHONHOME
 
11267
 
 
11268
@@ -570,4 +573,3 @@
 
11269
 
 
11270
    If set, Python will print memory allocation statistics every time a new
 
11271
    object arena is created, and on shutdown.
 
11272
-
8553
11273
diff -r 3d0686d90f55 Doc/using/unix.rst
8554
11274
--- a/Doc/using/unix.rst
8555
11275
+++ b/Doc/using/unix.rst
8761
11481
 
8762
11482
 * The :file:`regrtest.py` script now takes a :option:`--randseed=`
8763
11483
   switch that takes an integer that will be used as the random seed
 
11484
diff -r 3d0686d90f55 Doc/whatsnew/3.0.rst
 
11485
--- a/Doc/whatsnew/3.0.rst
 
11486
+++ b/Doc/whatsnew/3.0.rst
 
11487
@@ -771,7 +771,7 @@
 
11488
   respectively).
 
11489
 
 
11490
 * :pep:`3114`: the standard :meth:`next` method has been renamed to
 
11491
-  :meth:`__next__`.
 
11492
+  :meth:`~iterator.__next__`.
 
11493
 
 
11494
 * The :meth:`__oct__` and :meth:`__hex__` special methods are removed
 
11495
   -- :func:`oct` and :func:`hex` use :meth:`__index__` now to convert
 
11496
@@ -807,7 +807,7 @@
 
11497
   To get the old behavior of :func:`input`, use ``eval(input())``.
 
11498
 
 
11499
 * A new built-in function :func:`next` was added to call the
 
11500
-  :meth:`__next__` method on an object.
 
11501
+  :meth:`~iterator.__next__` method on an object.
 
11502
 
 
11503
 * The :func:`round` function rounding strategy and return type have
 
11504
   changed.  Exact halfway cases are now rounded to the nearest even
8764
11505
diff -r 3d0686d90f55 Include/Python.h
8765
11506
--- a/Include/Python.h
8766
11507
+++ b/Include/Python.h
8831
11572
 
8832
11573
 #ifdef __cplusplus
8833
11574
 }
8834
 
diff -r 3d0686d90f55 Include/patchlevel.h
8835
 
--- a/Include/patchlevel.h
8836
 
+++ b/Include/patchlevel.h
8837
 
@@ -2,7 +2,7 @@
8838
 
 /* Python version identification scheme.
8839
 
 
8840
 
    When the major or minor version changes, the VERSION variable in
8841
 
-   configure.in must also be changed.
8842
 
+   configure.ac must also be changed.
8843
 
 
8844
 
    There is also (independent) API version information in modsupport.h.
8845
 
 */
8846
11575
diff -r 3d0686d90f55 Include/pyfpe.h
8847
11576
--- a/Include/pyfpe.h
8848
11577
+++ b/Include/pyfpe.h
9332
12061
         self._set_stopinfo(None, None)
9333
12062
 
9334
12063
     def set_next(self, frame):
 
12064
diff -r 3d0686d90f55 Lib/calendar.py
 
12065
--- a/Lib/calendar.py
 
12066
+++ b/Lib/calendar.py
 
12067
@@ -161,7 +161,11 @@
 
12068
         oneday = datetime.timedelta(days=1)
 
12069
         while True:
 
12070
             yield date
 
12071
-            date += oneday
 
12072
+            try:
 
12073
+                date += oneday
 
12074
+            except OverflowError:
 
12075
+                # Adding one day could fail after datetime.MAXYEAR
 
12076
+                break
 
12077
             if date.month != month and date.weekday() == self.firstweekday:
 
12078
                 break
 
12079
 
9335
12080
diff -r 3d0686d90f55 Lib/concurrent/futures/_base.py
9336
12081
--- a/Lib/concurrent/futures/_base.py
9337
12082
+++ b/Lib/concurrent/futures/_base.py
10037
12782
             self._set_content_length(body)
10038
12783
         for hdr, value in headers.items():
10039
12784
             self.putheader(hdr, value)
 
12785
diff -r 3d0686d90f55 Lib/http/cookiejar.py
 
12786
--- a/Lib/http/cookiejar.py
 
12787
+++ b/Lib/http/cookiejar.py
 
12788
@@ -1825,7 +1825,7 @@
 
12789
 
 
12790
 class LWPCookieJar(FileCookieJar):
 
12791
     """
 
12792
-    The LWPCookieJar saves a sequence of"Set-Cookie3" lines.
 
12793
+    The LWPCookieJar saves a sequence of "Set-Cookie3" lines.
 
12794
     "Set-Cookie3" is the format used by the libwww-perl libary, not known
 
12795
     to be compatible with any browser, but which is easy to read and
 
12796
     doesn't lose information about RFC 2965 cookies.
 
12797
@@ -1837,7 +1837,7 @@
 
12798
     """
 
12799
 
 
12800
     def as_lwp_str(self, ignore_discard=True, ignore_expires=True):
 
12801
-        """Return cookies as a string of "\n"-separated "Set-Cookie3" headers.
 
12802
+        """Return cookies as a string of "\\n"-separated "Set-Cookie3" headers.
 
12803
 
 
12804
         ignore_discard and ignore_expires: see docstring for FileCookieJar.save
 
12805
 
10040
12806
diff -r 3d0686d90f55 Lib/http/cookies.py
10041
12807
--- a/Lib/http/cookies.py
10042
12808
+++ b/Lib/http/cookies.py
10852
13618
         text.mark_set("insert", first)
10853
13619
         text.undo_block_start()
10854
13620
         if m.group():
 
13621
diff -r 3d0686d90f55 Lib/idlelib/config-extensions.def
 
13622
--- a/Lib/idlelib/config-extensions.def
 
13623
+++ b/Lib/idlelib/config-extensions.def
 
13624
@@ -46,6 +46,8 @@
 
13625
 
 
13626
 [ScriptBinding]
 
13627
 enable=1
 
13628
+enable_shell=0
 
13629
+enable_editor=1
 
13630
 [ScriptBinding_cfgBindings]
 
13631
 run-module=<Key-F5>
 
13632
 check-module=<Alt-Key-x>
10855
13633
diff -r 3d0686d90f55 Lib/idlelib/configDialog.py
10856
13634
--- a/Lib/idlelib/configDialog.py
10857
13635
+++ b/Lib/idlelib/configDialog.py
10888
13666
             '<<smart-indent>>': ['<Key-Tab>'],
10889
13667
             '<<indent-region>>': ['<Control-Key-bracketright>'],
10890
13668
             '<<dedent-region>>': ['<Control-Key-bracketleft>'],
 
13669
diff -r 3d0686d90f55 Lib/idlelib/help.txt
 
13670
--- a/Lib/idlelib/help.txt
 
13671
+++ b/Lib/idlelib/help.txt
 
13672
@@ -80,7 +80,7 @@
 
13673
 Debug Menu (only in Shell window):
 
13674
 
 
13675
        Go to File/Line   -- look around the insert point for a filename
 
13676
-                            and linenumber, open the file, and show the line
 
13677
+                            and line number, open the file, and show the line
 
13678
        Debugger (toggle) -- Run commands in the shell under the debugger
 
13679
        Stack Viewer      -- Show the stack traceback of the last exception
 
13680
        Auto-open Stack Viewer (toggle) -- Open stack viewer on traceback
 
13681
@@ -92,7 +92,7 @@
 
13682
                           Startup Preferences may be set, and Additional Help
 
13683
                           Sources can be specified.
 
13684
                          
 
13685
-                         On MacOS X this menu is not present, use
 
13686
+                         On OS X this menu is not present, use
 
13687
                          menu 'IDLE -> Preferences...' instead.
 
13688
        ---
 
13689
        Code Context --   Open a pane at the top of the edit window which
 
13690
@@ -120,6 +120,15 @@
 
13691
        ---
 
13692
        (Additional Help Sources may be added here)
 
13693
 
 
13694
+Edit context menu (Right-click / Control-click in Edit window):
 
13695
+
 
13696
+       Set Breakpoint   -- Sets a breakpoint (when debugger open)
 
13697
+       Clear Breakpoint -- Clears the breakpoint on that line
 
13698
+
 
13699
+Shell context menu (Right-click / Control-click in Shell window):
 
13700
+
 
13701
+       Go to file/line -- Same as in Debug menu
 
13702
+
 
13703
 
 
13704
 ** TIPS **
 
13705
 ==========
 
13706
@@ -222,7 +231,7 @@
 
13707
 
 
13708
        Alt-p retrieves previous command matching what you have typed.
 
13709
        Alt-n retrieves next.
 
13710
-             (These are Control-p, Control-n on the Mac)
 
13711
+             (These are Control-p, Control-n on OS X)
 
13712
        Return while cursor is on a previous command retrieves that command.
 
13713
        Expand word is also useful to reduce typing.
 
13714
 
10891
13715
diff -r 3d0686d90f55 Lib/idlelib/macosxSupport.py
10892
13716
--- a/Lib/idlelib/macosxSupport.py
10893
13717
+++ b/Lib/idlelib/macosxSupport.py
11146
13970
 
11147
13971
 """
11148
13972
 import sys
 
13973
diff -r 3d0686d90f55 Lib/lib2to3/fixer_util.py
 
13974
--- a/Lib/lib2to3/fixer_util.py
 
13975
+++ b/Lib/lib2to3/fixer_util.py
 
13976
@@ -274,9 +274,9 @@
 
13977
     """Find the top level namespace."""
 
13978
     # Scamper up to the top level namespace
 
13979
     while node.type != syms.file_input:
 
13980
-        assert node.parent, "Tree is insane! root found before "\
 
13981
-                           "file_input node was found."
 
13982
         node = node.parent
 
13983
+        if not node:
 
13984
+            raise ValueError("root found before file_input node was found.")
 
13985
     return node
 
13986
 
 
13987
 def does_tree_import(package, name, node):
11149
13988
diff -r 3d0686d90f55 Lib/lib2to3/pgen2/driver.py
11150
13989
--- a/Lib/lib2to3/pgen2/driver.py
11151
13990
+++ b/Lib/lib2to3/pgen2/driver.py
11170
14009
+
11171
14010
+if __name__ == "__main__":
11172
14011
+    sys.exit(int(not main()))
 
14012
diff -r 3d0686d90f55 Lib/lib2to3/refactor.py
 
14013
--- a/Lib/lib2to3/refactor.py
 
14014
+++ b/Lib/lib2to3/refactor.py
 
14015
@@ -445,7 +445,7 @@
 
14016
 
 
14017
                         try:
 
14018
                             find_root(node)
 
14019
-                        except AssertionError:
 
14020
+                        except ValueError:
 
14021
                             # this node has been cut off from a
 
14022
                             # previous transformation ; skip
 
14023
                             continue
11173
14024
diff -r 3d0686d90f55 Lib/lib2to3/tests/test_parser.py
11174
14025
--- a/Lib/lib2to3/tests/test_parser.py
11175
14026
+++ b/Lib/lib2to3/tests/test_parser.py
11307
14158
 from stat import ST_DEV, ST_INO, ST_MTIME
11308
14159
 import queue
11309
14160
 try:
11310
 
@@ -271,9 +270,10 @@
 
14161
@@ -138,7 +137,6 @@
 
14162
             if os.path.exists(dfn):
 
14163
                 os.remove(dfn)
 
14164
             os.rename(self.baseFilename, dfn)
 
14165
-        self.mode = 'w'
 
14166
         self.stream = self._open()
 
14167
 
 
14168
     def shouldRollover(self, record):
 
14169
@@ -271,9 +269,10 @@
11311
14170
                         dstAtRollover = time.localtime(newRolloverAt)[-1]
11312
14171
                         if dstNow != dstAtRollover:
11313
14172
                             if not dstNow:  # DST kicks in before next rollover, so we need to deduct an hour
11320
14179
                     result = newRolloverAt
11321
14180
         return result
11322
14181
 
11323
 
@@ -324,11 +324,20 @@
 
14182
@@ -324,11 +323,20 @@
11324
14183
             self.stream.close()
11325
14184
             self.stream = None
11326
14185
         # get the time that this sequence started at and make it a TimeTuple
11341
14200
         dfn = self.baseFilename + "." + time.strftime(self.suffix, timeTuple)
11342
14201
         if os.path.exists(dfn):
11343
14202
             os.remove(dfn)
11344
 
@@ -338,19 +347,18 @@
 
14203
@@ -336,21 +344,19 @@
 
14204
         if self.backupCount > 0:
 
14205
             for s in self.getFilesToDelete():
11345
14206
                 os.remove(s)
11346
 
         self.mode = 'w'
 
14207
-        self.mode = 'w'
11347
14208
         self.stream = self._open()
11348
14209
-        currentTime = int(time.time())
11349
14210
         newRolloverAt = self.computeRollover(currentTime)
11364
14225
         self.rolloverAt = newRolloverAt
11365
14226
 
11366
14227
 class WatchedFileHandler(logging.FileHandler):
11367
 
@@ -375,11 +383,13 @@
 
14228
@@ -375,11 +381,13 @@
11368
14229
     """
11369
14230
     def __init__(self, filename, mode='a', encoding=None, delay=0):
11370
14231
         logging.FileHandler.__init__(self, filename, mode, encoding, delay)
11383
14244
 
11384
14245
     def emit(self, record):
11385
14246
         """
11386
 
@@ -389,21 +399,30 @@
 
14247
@@ -389,21 +397,30 @@
11387
14248
         has, close the old stream and reopen the file to get the
11388
14249
         current stream.
11389
14250
         """
11427
14288
 class SocketHandler(logging.Handler):
11428
14289
     """
11429
14290
     A handler class which writes logging records, in pickle format, to
11430
 
@@ -511,11 +530,16 @@
 
14291
@@ -511,11 +528,16 @@
11431
14292
         """
11432
14293
         ei = record.exc_info
11433
14294
         if ei:
11449
14310
         slen = struct.pack(">L", len(s))
11450
14311
         return slen + s
11451
14312
 
11452
 
@@ -554,10 +578,14 @@
 
14313
@@ -554,10 +576,14 @@
11453
14314
         """
11454
14315
         Closes the socket.
11455
14316
         """
11468
14329
 
11469
14330
 class DatagramHandler(SocketHandler):
11470
14331
     """
11471
 
@@ -733,7 +761,11 @@
 
14332
@@ -726,14 +752,12 @@
 
14333
         self.formatter = None
 
14334
 
 
14335
     def _connect_unixsocket(self, address):
 
14336
-        self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
 
14337
-        # syslog may require either DGRAM or STREAM sockets
 
14338
+        self.socket = socket.socket(socket.AF_UNIX, self.socktype)
 
14339
         try:
 
14340
             self.socket.connect(address)
11472
14341
         except socket.error:
11473
14342
             self.socket.close()
11474
 
             self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
 
14343
-            self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
11475
14344
-            self.socket.connect(address)
11476
 
+            try:
11477
 
+                self.socket.connect(address)
11478
 
+            except socket.error:
11479
 
+                self.socket.close()
11480
 
+                raise
 
14345
+            raise
11481
14346
 
11482
14347
     def encodePriority(self, facility, priority):
11483
14348
         """
11484
 
@@ -752,9 +784,13 @@
 
14349
@@ -752,9 +776,13 @@
11485
14350
         """
11486
14351
         Closes the socket.
11487
14352
         """
11498
14363
 
11499
14364
     def mapPriority(self, levelName):
11500
14365
         """
11501
 
@@ -787,8 +823,6 @@
 
14366
@@ -787,8 +815,6 @@
11502
14367
         prio = prio.encode('utf-8')
11503
14368
         # Message is a string. Convert to bytes as required by RFC 5424
11504
14369
         msg = msg.encode('utf-8')
11507
14372
         msg = prio + msg
11508
14373
         try:
11509
14374
             if self.unixsocket:
11510
 
@@ -841,6 +875,7 @@
 
14375
@@ -841,6 +867,7 @@
11511
14376
         self.toaddrs = toaddrs
11512
14377
         self.subject = subject
11513
14378
         self.secure = secure
11515
14380
 
11516
14381
     def getSubject(self, record):
11517
14382
         """
11518
 
@@ -863,7 +898,7 @@
 
14383
@@ -863,7 +890,7 @@
11519
14384
             port = self.mailport
11520
14385
             if not port:
11521
14386
                 port = smtplib.SMTP_PORT
11524
14389
             msg = self.format(record)
11525
14390
             msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\nDate: %s\r\n\r\n%s" % (
11526
14391
                             self.fromaddr,
11527
 
@@ -1095,7 +1130,11 @@
 
14392
@@ -1095,7 +1122,11 @@
11528
14393
 
11529
14394
         This version just zaps the buffer to empty.
11530
14395
         """
11537
14402
 
11538
14403
     def close(self):
11539
14404
         """
11540
 
@@ -1145,18 +1184,26 @@
 
14405
@@ -1145,18 +1176,26 @@
11541
14406
 
11542
14407
         The record buffer is also cleared by this operation.
11543
14408
         """
11573
14438
diff -r 3d0686d90f55 Lib/mailbox.py
11574
14439
--- a/Lib/mailbox.py
11575
14440
+++ b/Lib/mailbox.py
11576
 
@@ -587,16 +587,19 @@
 
14441
@@ -208,6 +208,9 @@
 
14442
             raise ValueError("String input must be ASCII-only; "
 
14443
                 "use bytes or a Message instead")
 
14444
 
 
14445
+    # Whether each message must end in a newline
 
14446
+    _append_newline = False
 
14447
+
 
14448
     def _dump_message(self, message, target, mangle_from_=False):
 
14449
         # This assumes the target file is open in binary mode.
 
14450
         """Dump message contents to target file."""
 
14451
@@ -219,6 +222,9 @@
 
14452
             data = buffer.read()
 
14453
             data = data.replace(b'\n', linesep)
 
14454
             target.write(data)
 
14455
+            if self._append_newline and not data.endswith(linesep):
 
14456
+                # Make sure the message ends with a newline
 
14457
+                target.write(linesep)
 
14458
         elif isinstance(message, (str, bytes, io.StringIO)):
 
14459
             if isinstance(message, io.StringIO):
 
14460
                 warnings.warn("Use of StringIO input is deprecated, "
 
14461
@@ -230,11 +236,15 @@
 
14462
                 message = message.replace(b'\nFrom ', b'\n>From ')
 
14463
             message = message.replace(b'\n', linesep)
 
14464
             target.write(message)
 
14465
+            if self._append_newline and not message.endswith(linesep):
 
14466
+                # Make sure the message ends with a newline
 
14467
+                target.write(linesep)
 
14468
         elif hasattr(message, 'read'):
 
14469
             if hasattr(message, 'buffer'):
 
14470
                 warnings.warn("Use of text mode files is deprecated, "
 
14471
                     "use a binary mode file instead", DeprecationWarning, 3)
 
14472
                 message = message.buffer
 
14473
+            lastline = None
 
14474
             while True:
 
14475
                 line = message.readline()
 
14476
                 # Universal newline support.
 
14477
@@ -248,6 +258,10 @@
 
14478
                     line = b'>From ' + line[5:]
 
14479
                 line = line.replace(b'\n', linesep)
 
14480
                 target.write(line)
 
14481
+                lastline = line
 
14482
+            if self._append_newline and lastline and not lastline.endswith(linesep):
 
14483
+                # Make sure the message ends with a newline
 
14484
+                target.write(linesep)
 
14485
         else:
 
14486
             raise TypeError('Invalid message type: %s' % type(message))
 
14487
 
 
14488
@@ -587,16 +601,19 @@
11577
14489
         self._file = f
11578
14490
         self._toc = None
11579
14491
         self._next_key = 0
11596
14508
         return self._next_key - 1
11597
14509
 
11598
14510
     def remove(self, key):
11599
 
@@ -642,6 +645,11 @@
 
14511
@@ -642,6 +659,11 @@
11600
14512
     def flush(self):
11601
14513
         """Write any pending changes to disk."""
11602
14514
         if not self._pending:
11608
14520
             return
11609
14521
 
11610
14522
         # In order to be writing anything out at all, self._toc must
11611
 
@@ -675,6 +683,7 @@
 
14523
@@ -675,6 +697,7 @@
11612
14524
                     new_file.write(buffer)
11613
14525
                 new_toc[key] = (new_start, new_file.tell())
11614
14526
                 self._post_message_hook(new_file)
11616
14528
         except:
11617
14529
             new_file.close()
11618
14530
             os.remove(new_file.name)
11619
 
@@ -682,6 +691,9 @@
 
14531
@@ -682,6 +705,9 @@
11620
14532
         _sync_close(new_file)
11621
14533
         # self._file is about to get replaced, so no need to sync.
11622
14534
         self._file.close()
11626
14538
         try:
11627
14539
             os.rename(new_file.name, self._path)
11628
14540
         except OSError as e:
11629
 
@@ -694,6 +706,7 @@
 
14541
@@ -694,6 +720,7 @@
11630
14542
         self._file = open(self._path, 'rb+')
11631
14543
         self._toc = new_toc
11632
14544
         self._pending = False
11634
14546
         if self._locked:
11635
14547
             _lock_file(self._file, dotlock=False)
11636
14548
 
11637
 
@@ -730,6 +743,12 @@
 
14549
@@ -730,6 +757,12 @@
11638
14550
         """Append message to mailbox and return (start, stop) offsets."""
11639
14551
         self._file.seek(0, 2)
11640
14552
         before = self._file.tell()
11647
14559
         try:
11648
14560
             self._pre_message_hook(self._file)
11649
14561
             offsets = self._install_message(message)
11650
 
@@ -1424,17 +1443,24 @@
 
14562
@@ -814,30 +847,48 @@
 
14563
 
 
14564
     _mangle_from_ = True
 
14565
 
 
14566
+    # All messages must end in a newline character, and
 
14567
+    # _post_message_hooks outputs an empty line between messages.
 
14568
+    _append_newline = True
 
14569
+
 
14570
     def __init__(self, path, factory=None, create=True):
 
14571
         """Initialize an mbox mailbox."""
 
14572
         self._message_factory = mboxMessage
 
14573
         _mboxMMDF.__init__(self, path, factory, create)
 
14574
 
 
14575
-    def _pre_message_hook(self, f):
 
14576
-        """Called before writing each message to file f."""
 
14577
-        if f.tell() != 0:
 
14578
-            f.write(linesep)
 
14579
+    def _post_message_hook(self, f):
 
14580
+        """Called after writing each message to file f."""
 
14581
+        f.write(linesep)
 
14582
 
 
14583
     def _generate_toc(self):
 
14584
         """Generate key-to-(start, stop) table of contents."""
 
14585
         starts, stops = [], []
 
14586
+        last_was_empty = False
 
14587
         self._file.seek(0)
 
14588
         while True:
 
14589
             line_pos = self._file.tell()
 
14590
             line = self._file.readline()
 
14591
             if line.startswith(b'From '):
 
14592
                 if len(stops) < len(starts):
 
14593
+                    if last_was_empty:
 
14594
+                        stops.append(line_pos - len(linesep))
 
14595
+                    else:
 
14596
+                        # The last line before the "From " line wasn't
 
14597
+                        # blank, but we consider it a start of a
 
14598
+                        # message anyway.
 
14599
+                        stops.append(line_pos)
 
14600
+                starts.append(line_pos)
 
14601
+                last_was_empty = False
 
14602
+            elif not line:
 
14603
+                if last_was_empty:
 
14604
                     stops.append(line_pos - len(linesep))
 
14605
-                starts.append(line_pos)
 
14606
-            elif not line:
 
14607
-                stops.append(line_pos)
 
14608
+                else:
 
14609
+                    stops.append(line_pos)
 
14610
                 break
 
14611
+            elif line == linesep:
 
14612
+                last_was_empty = True
 
14613
+            else:
 
14614
+                last_was_empty = False
 
14615
         self._toc = dict(enumerate(zip(starts, stops)))
 
14616
         self._next_key = len(self._toc)
 
14617
         self._file_length = self._file.tell()
 
14618
@@ -1424,17 +1475,24 @@
11651
14619
                     line = line[:-1] + b'\n'
11652
14620
                 self._file.write(line.replace(b'\n', linesep))
11653
14621
                 if line == b'\n' or not line:
11944
14912
             raise
11945
14913
 
11946
14914
 def removedirs(name):
 
14915
diff -r 3d0686d90f55 Lib/platform.py
 
14916
--- a/Lib/platform.py
 
14917
+++ b/Lib/platform.py
 
14918
@@ -111,7 +111,7 @@
 
14919
 
 
14920
 __version__ = '1.0.7'
 
14921
 
 
14922
-import sys, os, re
 
14923
+import sys, os, re, subprocess
 
14924
 
 
14925
 ### Globals & Constants
 
14926
 
 
14927
@@ -668,8 +668,13 @@
 
14928
                     release = '7'
 
14929
                 else:
 
14930
                     release = '2008ServerR2'
 
14931
+            elif min == 2:
 
14932
+                if product_type == VER_NT_WORKSTATION:
 
14933
+                    release = '8'
 
14934
+                else:
 
14935
+                    release = '2012Server'
 
14936
             else:
 
14937
-                release = 'post2008Server'
 
14938
+                release = 'post2012Server'
 
14939
 
 
14940
     else:
 
14941
         if not release:
 
14942
@@ -995,13 +1000,14 @@
 
14943
     if sys.platform in ('dos','win32','win16','os2'):
 
14944
         # XXX Others too ?
 
14945
         return default
 
14946
-    target = _follow_symlinks(target).replace('"', '\\"')
 
14947
+    target = _follow_symlinks(target)
 
14948
     try:
 
14949
-        f = os.popen('file -b "%s" 2> %s' % (target, DEV_NULL))
 
14950
+        proc = subprocess.Popen(['file', target],
 
14951
+                stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 
14952
     except (AttributeError,os.error):
 
14953
         return default
 
14954
-    output = f.read().strip()
 
14955
-    rc = f.close()
 
14956
+    output = proc.communicate()[0].decode("latin-1")
 
14957
+    rc = proc.wait()
 
14958
     if not output or rc:
 
14959
         return default
 
14960
     else:
11947
14961
diff -r 3d0686d90f55 Lib/posixpath.py
11948
14962
--- a/Lib/posixpath.py
11949
14963
+++ b/Lib/posixpath.py
12008
15022
         if rv is NotImplemented:
12009
15023
             rv = (str(type(self.obj)), id(self.obj)) < \
12010
15024
                  (str(type(other.obj)), id(other.obj))
 
15025
diff -r 3d0686d90f55 Lib/pstats.py
 
15026
--- a/Lib/pstats.py
 
15027
+++ b/Lib/pstats.py
 
15028
@@ -159,15 +159,19 @@
 
15029
     # along with some printable description
 
15030
     sort_arg_dict_default = {
 
15031
               "calls"     : (((1,-1),              ), "call count"),
 
15032
+              "ncalls"    : (((1,-1),              ), "call count"),
 
15033
+              "cumtime"   : (((3,-1),              ), "cumulative time"),
 
15034
               "cumulative": (((3,-1),              ), "cumulative time"),
 
15035
               "file"      : (((4, 1),              ), "file name"),
 
15036
+              "filename"  : (((4, 1),              ), "file name"),
 
15037
               "line"      : (((5, 1),              ), "line number"),
 
15038
               "module"    : (((4, 1),              ), "file name"),
 
15039
               "name"      : (((6, 1),              ), "function name"),
 
15040
               "nfl"       : (((6, 1),(4, 1),(5, 1),), "name/file/line"),
 
15041
-              "pcalls"    : (((0,-1),              ), "call count"),
 
15042
+              "pcalls"    : (((0,-1),              ), "primitive call count"),
 
15043
               "stdname"   : (((7, 1),              ), "standard name"),
 
15044
               "time"      : (((2,-1),              ), "internal time"),
 
15045
+              "tottime"   : (((2,-1),              ), "internal time"),
 
15046
               }
 
15047
 
 
15048
     def get_sort_arg_defs(self):
12011
15049
diff -r 3d0686d90f55 Lib/pyclbr.py
12012
15050
--- a/Lib/pyclbr.py
12013
15051
+++ b/Lib/pyclbr.py
12366
15404
 
12367
15405
         kill = terminate
12368
15406
 
 
15407
@@ -1159,6 +1169,7 @@
 
15408
 
 
15409
             if executable is None:
 
15410
                 executable = args[0]
 
15411
+            orig_executable = executable
 
15412
 
 
15413
             # For transferring possible exec failure from child to parent.
 
15414
             # Data format: "exception name:hex errno:description"
 
15415
@@ -1214,6 +1225,7 @@
 
15416
                         self._child_created = True
 
15417
                         if self.pid == 0:
 
15418
                             # Child
 
15419
+                            reached_preexec = False
 
15420
                             try:
 
15421
                                 # Close parent's pipe ends
 
15422
                                 if p2cwrite != -1:
 
15423
@@ -1278,6 +1290,7 @@
 
15424
                                 if start_new_session and hasattr(os, 'setsid'):
 
15425
                                     os.setsid()
 
15426
 
 
15427
+                                reached_preexec = True
 
15428
                                 if preexec_fn:
 
15429
                                     preexec_fn()
 
15430
 
 
15431
@@ -1293,6 +1306,8 @@
 
15432
                                         errno_num = exc_value.errno
 
15433
                                     else:
 
15434
                                         errno_num = 0
 
15435
+                                    if not reached_preexec:
 
15436
+                                        exc_value = "noexec"
 
15437
                                     message = '%s:%x:%s' % (exc_type.__name__,
 
15438
                                                             errno_num, exc_value)
 
15439
                                     message = message.encode(errors="surrogatepass")
 
15440
@@ -1354,10 +1369,17 @@
 
15441
                 err_msg = err_msg.decode(errors="surrogatepass")
 
15442
                 if issubclass(child_exception_type, OSError) and hex_errno:
 
15443
                     errno_num = int(hex_errno, 16)
 
15444
+                    child_exec_never_called = (err_msg == "noexec")
 
15445
+                    if child_exec_never_called:
 
15446
+                        err_msg = ""
 
15447
                     if errno_num != 0:
 
15448
                         err_msg = os.strerror(errno_num)
 
15449
                         if errno_num == errno.ENOENT:
 
15450
-                            err_msg += ': ' + repr(args[0])
 
15451
+                            if child_exec_never_called:
 
15452
+                                # The error must be from chdir(cwd).
 
15453
+                                err_msg += ': ' + repr(cwd)
 
15454
+                            else:
 
15455
+                                err_msg += ': ' + repr(orig_executable)
 
15456
                     raise child_exception_type(errno_num, err_msg)
 
15457
                 raise child_exception_type(err_msg)
 
15458
 
 
15459
@@ -1390,9 +1412,16 @@
 
15460
                     pid, sts = _waitpid(self.pid, _WNOHANG)
 
15461
                     if pid == self.pid:
 
15462
                         self._handle_exitstatus(sts)
 
15463
-                except _os_error:
 
15464
+                except _os_error as e:
 
15465
                     if _deadstate is not None:
 
15466
                         self.returncode = _deadstate
 
15467
+                    elif e.errno == errno.ECHILD:
 
15468
+                        # This happens if SIGCLD is set to be ignored or
 
15469
+                        # waiting for child processes has otherwise been
 
15470
+                        # disabled for our process.  This child is dead, we
 
15471
+                        # can't get the status.
 
15472
+                        # http://bugs.python.org/issue15756
 
15473
+                        self.returncode = 0
 
15474
             return self.returncode
 
15475
 
 
15476
 
12369
15477
diff -r 3d0686d90f55 Lib/tarfile.py
12370
15478
--- a/Lib/tarfile.py
12371
15479
+++ b/Lib/tarfile.py
12870
15978
     def test_floatformatting(self):
12871
15979
         # float formatting
12872
15980
         for prec in range(100):
 
15981
diff -r 3d0686d90f55 Lib/test/subprocessdata/sigchild_ignore.py
 
15982
--- a/Lib/test/subprocessdata/sigchild_ignore.py
 
15983
+++ b/Lib/test/subprocessdata/sigchild_ignore.py
 
15984
@@ -1,6 +1,15 @@
 
15985
-import signal, subprocess, sys
 
15986
+import signal, subprocess, sys, time
 
15987
 # On Linux this causes os.waitpid to fail with OSError as the OS has already
 
15988
 # reaped our child process.  The wait() passing the OSError on to the caller
 
15989
 # and causing us to exit with an error is what we are testing against.
 
15990
 signal.signal(signal.SIGCHLD, signal.SIG_IGN)
 
15991
 subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait()
 
15992
+# Also ensure poll() handles an errno.ECHILD appropriately.
 
15993
+p = subprocess.Popen([sys.executable, '-c', 'print("albatross")'])
 
15994
+num_polls = 0
 
15995
+while p.poll() is None:
 
15996
+    # Waiting for the process to finish.
 
15997
+    time.sleep(0.01)  # Avoid being a CPU busy loop.
 
15998
+    num_polls += 1
 
15999
+    if num_polls > 3000:
 
16000
+        raise RuntimeError('poll should have returned 0 within 30 seconds')
12873
16001
diff -r 3d0686d90f55 Lib/test/support.py
12874
16002
--- a/Lib/test/support.py
12875
16003
+++ b/Lib/test/support.py
12976
16104
     except OSError as error:
12977
16105
         # Unix returns ENOENT, Windows returns ESRCH.
12978
16106
         if error.errno not in (errno.ENOENT, errno.ESRCH):
 
16107
@@ -533,7 +600,7 @@
 
16108
     except OSError:
 
16109
         if not quiet:
 
16110
             raise
 
16111
-        warnings.warn('tests may fail, unable to change the CWD to ' + name,
 
16112
+        warnings.warn('tests may fail, unable to change the CWD to ' + path,
 
16113
                       RuntimeWarning, stacklevel=3)
 
16114
     try:
 
16115
         yield os.getcwd()
12979
16116
@@ -984,6 +1051,31 @@
12980
16117
     return final_opt and final_opt != '-O0'
12981
16118
 
13710
16847
     def test_random(self, n=25):
13711
16848
         from random import randrange
13712
16849
         for i in range(n):
 
16850
diff -r 3d0686d90f55 Lib/test/test_calendar.py
 
16851
--- a/Lib/test/test_calendar.py
 
16852
+++ b/Lib/test/test_calendar.py
 
16853
@@ -5,6 +5,7 @@
 
16854
 from test.script_helper import assert_python_ok
 
16855
 import time
 
16856
 import locale
 
16857
+import datetime
 
16858
 
 
16859
 result_2004_text = """
 
16860
                                   2004
 
16861
@@ -265,6 +266,11 @@
 
16862
         new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
 
16863
         self.assertEqual(old_october, new_october)
 
16864
 
 
16865
+    def test_itermonthdates(self):
 
16866
+        # ensure itermonthdates doesn't overflow after datetime.MAXYEAR
 
16867
+        # see #15421
 
16868
+        list(calendar.Calendar().itermonthdates(datetime.MAXYEAR, 12))
 
16869
+
 
16870
 
 
16871
 class MonthCalendarTestCase(unittest.TestCase):
 
16872
     def setUp(self):
13713
16873
diff -r 3d0686d90f55 Lib/test/test_capi.py
13714
16874
--- a/Lib/test/test_capi.py
13715
16875
+++ b/Lib/test/test_capi.py
13889
17049
 def test_main():
13890
17050
     support.run_unittest(CmdLineTest)
13891
17051
     support.reap_children()
 
17052
diff -r 3d0686d90f55 Lib/test/test_codeccallbacks.py
 
17053
--- a/Lib/test/test_codeccallbacks.py
 
17054
+++ b/Lib/test/test_codeccallbacks.py
 
17055
@@ -744,7 +744,7 @@
 
17056
                 raise ValueError
 
17057
         self.assertRaises(UnicodeError, codecs.charmap_decode, b"\xff", "strict", {0xff: None})
 
17058
         self.assertRaises(ValueError, codecs.charmap_decode, b"\xff", "strict", D())
 
17059
-        self.assertRaises(TypeError, codecs.charmap_decode, b"\xff", "strict", {0xff: sys.maxunicode+1})
 
17060
+        self.assertRaises(TypeError, codecs.charmap_decode, b"\xff", "strict", {0xff: 0x110000})
 
17061
 
 
17062
     def test_encodehelper(self):
 
17063
         # enhance coverage of:
13892
17064
diff -r 3d0686d90f55 Lib/test/test_codecs.py
13893
17065
--- a/Lib/test/test_codecs.py
13894
17066
+++ b/Lib/test/test_codecs.py
13936
17108
 
13937
17109
     def test_nonbmp(self):
13938
17110
         self.assertEqual("\U00010203".encode(self.encoding),
 
17111
@@ -1524,6 +1546,10 @@
 
17112
             ("abc", 3)
 
17113
         )
 
17114
 
 
17115
+        self.assertRaises(UnicodeDecodeError,
 
17116
+            codecs.charmap_decode, b"\x00\x01\x02", "strict", "ab"
 
17117
+        )
 
17118
+
 
17119
         self.assertEqual(
 
17120
             codecs.charmap_decode(b"\x00\x01\x02", "replace", "ab"),
 
17121
             ("ab\ufffd", 3)
 
17122
@@ -1550,6 +1576,107 @@
 
17123
             ("", len(allbytes))
 
17124
         )
 
17125
 
 
17126
+    def test_decode_with_int2str_map(self):
 
17127
+        self.assertEqual(
 
17128
+            codecs.charmap_decode(b"\x00\x01\x02", "strict",
 
17129
+                                  {0: 'a', 1: 'b', 2: 'c'}),
 
17130
+            ("abc", 3)
 
17131
+        )
 
17132
+
 
17133
+        self.assertEqual(
 
17134
+            codecs.charmap_decode(b"\x00\x01\x02", "strict",
 
17135
+                                  {0: 'Aa', 1: 'Bb', 2: 'Cc'}),
 
17136
+            ("AaBbCc", 3)
 
17137
+        )
 
17138
+
 
17139
+        self.assertEqual(
 
17140
+            codecs.charmap_decode(b"\x00\x01\x02", "strict",
 
17141
+                                  {0: '\U0010FFFF', 1: 'b', 2: 'c'}),
 
17142
+            ("\U0010FFFFbc", 3)
 
17143
+        )
 
17144
+
 
17145
+        self.assertEqual(
 
17146
+            codecs.charmap_decode(b"\x00\x01\x02", "strict",
 
17147
+                                  {0: 'a', 1: 'b', 2: ''}),
 
17148
+            ("ab", 3)
 
17149
+        )
 
17150
+
 
17151
+        self.assertRaises(UnicodeDecodeError,
 
17152
+            codecs.charmap_decode, b"\x00\x01\x02", "strict",
 
17153
+                                   {0: 'a', 1: 'b'}
 
17154
+        )
 
17155
+
 
17156
+        self.assertEqual(
 
17157
+            codecs.charmap_decode(b"\x00\x01\x02", "replace",
 
17158
+                                  {0: 'a', 1: 'b'}),
 
17159
+            ("ab\ufffd", 3)
 
17160
+        )
 
17161
+
 
17162
+        self.assertEqual(
 
17163
+            codecs.charmap_decode(b"\x00\x01\x02", "replace",
 
17164
+                                  {0: 'a', 1: 'b', 2: None}),
 
17165
+            ("ab\ufffd", 3)
 
17166
+        )
 
17167
+
 
17168
+        self.assertEqual(
 
17169
+            codecs.charmap_decode(b"\x00\x01\x02", "ignore",
 
17170
+                                  {0: 'a', 1: 'b'}),
 
17171
+            ("ab", 3)
 
17172
+        )
 
17173
+
 
17174
+        self.assertEqual(
 
17175
+            codecs.charmap_decode(b"\x00\x01\x02", "ignore",
 
17176
+                                  {0: 'a', 1: 'b', 2: None}),
 
17177
+            ("ab", 3)
 
17178
+        )
 
17179
+
 
17180
+        allbytes = bytes(range(256))
 
17181
+        self.assertEqual(
 
17182
+            codecs.charmap_decode(allbytes, "ignore", {}),
 
17183
+            ("", len(allbytes))
 
17184
+        )
 
17185
+
 
17186
+    def test_decode_with_int2int_map(self):
 
17187
+        a = ord('a')
 
17188
+        b = ord('b')
 
17189
+        c = ord('c')
 
17190
+
 
17191
+        self.assertEqual(
 
17192
+            codecs.charmap_decode(b"\x00\x01\x02", "strict",
 
17193
+                                  {0: a, 1: b, 2: c}),
 
17194
+            ("abc", 3)
 
17195
+        )
 
17196
+
 
17197
+        # Issue #15379
 
17198
+        self.assertEqual(
 
17199
+            codecs.charmap_decode(b"\x00\x01\x02", "strict",
 
17200
+                                  {0: 0x10FFFF, 1: b, 2: c}),
 
17201
+            ("\U0010FFFFbc", 3)
 
17202
+        )
 
17203
+
 
17204
+        self.assertRaises(TypeError,
 
17205
+            codecs.charmap_decode, b"\x00\x01\x02", "strict",
 
17206
+                                   {0: 0x110000, 1: b, 2: c}
 
17207
+        )
 
17208
+
 
17209
+        self.assertRaises(UnicodeDecodeError,
 
17210
+            codecs.charmap_decode, b"\x00\x01\x02", "strict",
 
17211
+                                   {0: a, 1: b},
 
17212
+        )
 
17213
+
 
17214
+        self.assertEqual(
 
17215
+            codecs.charmap_decode(b"\x00\x01\x02", "replace",
 
17216
+                                  {0: a, 1: b}),
 
17217
+            ("ab\ufffd", 3)
 
17218
+        )
 
17219
+
 
17220
+        self.assertEqual(
 
17221
+            codecs.charmap_decode(b"\x00\x01\x02", "ignore",
 
17222
+                                  {0: a, 1: b}),
 
17223
+            ("ab", 3)
 
17224
+        )
 
17225
+
 
17226
+
 
17227
 class WithStmtTest(unittest.TestCase):
 
17228
     def test_encodedfile(self):
 
17229
         f = io.BytesIO(b"\xc3\xbc")
 
17230
diff -r 3d0686d90f55 Lib/test/test_compileall.py
 
17231
--- a/Lib/test/test_compileall.py
 
17232
+++ b/Lib/test/test_compileall.py
 
17233
@@ -134,15 +134,21 @@
 
17234
 class CommandLineTests(unittest.TestCase):
 
17235
     """Test compileall's CLI."""
 
17236
 
 
17237
+    def _get_run_args(self, args):
 
17238
+        interp_args = ['-S']
 
17239
+        if sys.flags.optimize:
 
17240
+            interp_args.append({1 : '-O', 2 : '-OO'}[sys.flags.optimize])
 
17241
+        return interp_args + ['-m', 'compileall'] + list(args)
 
17242
+
 
17243
     def assertRunOK(self, *args, **env_vars):
 
17244
         rc, out, err = script_helper.assert_python_ok(
 
17245
-                        '-S', '-m', 'compileall', *args, **env_vars)
 
17246
+                         *self._get_run_args(args), **env_vars)
 
17247
         self.assertEqual(b'', err)
 
17248
         return out
 
17249
 
 
17250
     def assertRunNotOK(self, *args, **env_vars):
 
17251
         rc, out, err = script_helper.assert_python_failure(
 
17252
-                        '-S', '-m', 'compileall', *args, **env_vars)
 
17253
+                        *self._get_run_args(args), **env_vars)
 
17254
         return rc, out, err
 
17255
 
 
17256
     def assertCompiled(self, fn):
 
17257
@@ -198,7 +204,9 @@
 
17258
         self.assertRunOK('-b', '-q', self.pkgdir)
 
17259
         # Verify the __pycache__ directory contents.
 
17260
         self.assertFalse(os.path.exists(self.pkgdir_cachedir))
 
17261
-        expected = sorted(['__init__.py', '__init__.pyc', 'bar.py', 'bar.pyc'])
 
17262
+        opt = 'c' if __debug__ else 'o'
 
17263
+        expected = sorted(['__init__.py', '__init__.py' + opt, 'bar.py',
 
17264
+                           'bar.py' + opt])
 
17265
         self.assertEqual(sorted(os.listdir(self.pkgdir)), expected)
 
17266
 
 
17267
     def test_multiple_runs(self):
 
17268
@@ -326,7 +334,7 @@
 
17269
         f2 = script_helper.make_script(self.pkgdir, 'f2', '')
 
17270
         f3 = script_helper.make_script(self.pkgdir, 'f3', '')
 
17271
         f4 = script_helper.make_script(self.pkgdir, 'f4', '')
 
17272
-        p = script_helper.spawn_python('-m', 'compileall', '-i', '-')
 
17273
+        p = script_helper.spawn_python(*(self._get_run_args(()) + ['-i', '-']))
 
17274
         p.stdin.write((f3+os.linesep).encode('ascii'))
 
17275
         script_helper.kill_python(p)
 
17276
         self.assertNotCompiled(f1)
13939
17277
diff -r 3d0686d90f55 Lib/test/test_concurrent_futures.py
13940
17278
--- a/Lib/test/test_concurrent_futures.py
13941
17279
+++ b/Lib/test/test_concurrent_futures.py
13972
17310
 
13973
17311
 
13974
17312
 class ProcessPoolWaitTests(ProcessPoolMixin, WaitTests):
 
17313
diff -r 3d0686d90f55 Lib/test/test_csv.py
 
17314
--- a/Lib/test/test_csv.py
 
17315
+++ b/Lib/test/test_csv.py
 
17316
@@ -225,6 +225,15 @@
 
17317
         self.assertRaises(csv.Error, self._read_test, ['a,b\nc,d'], [])
 
17318
         self.assertRaises(csv.Error, self._read_test, ['a,b\r\nc,d'], [])
 
17319
 
 
17320
+    def test_read_eof(self):
 
17321
+        self._read_test(['a,"'], [['a', '']])
 
17322
+        self._read_test(['"a'], [['a']])
 
17323
+        self._read_test(['^'], [['\n']], escapechar='^')
 
17324
+        self.assertRaises(csv.Error, self._read_test, ['a,"'], [], strict=True)
 
17325
+        self.assertRaises(csv.Error, self._read_test, ['"a'], [], strict=True)
 
17326
+        self.assertRaises(csv.Error, self._read_test,
 
17327
+                          ['^'], [], escapechar='^', strict=True)
 
17328
+
 
17329
     def test_read_escape(self):
 
17330
         self._read_test(['a,\\b,c'], [['a', 'b', 'c']], escapechar='\\')
 
17331
         self._read_test(['a,b\\,c'], [['a', 'b,c']], escapechar='\\')
13975
17332
diff -r 3d0686d90f55 Lib/test/test_decimal.py
13976
17333
--- a/Lib/test/test_decimal.py
13977
17334
+++ b/Lib/test/test_decimal.py
14468
17825
diff -r 3d0686d90f55 Lib/test/test_fileio.py
14469
17826
--- a/Lib/test/test_fileio.py
14470
17827
+++ b/Lib/test/test_fileio.py
14471
 
@@ -127,6 +127,14 @@
 
17828
@@ -9,6 +9,7 @@
 
17829
 from functools import wraps
 
17830
 
 
17831
 from test.support import TESTFN, check_warnings, run_unittest, make_bad_fd
 
17832
+from collections import UserList
 
17833
 
 
17834
 from _io import FileIO as _FileIO
 
17835
 
 
17836
@@ -67,6 +68,27 @@
 
17837
         n = self.f.readinto(a)
 
17838
         self.assertEqual(array('b', [1, 2]), a[:n])
 
17839
 
 
17840
+    def testWritelinesList(self):
 
17841
+        l = [b'123', b'456']
 
17842
+        self.f.writelines(l)
 
17843
+        self.f.close()
 
17844
+        self.f = _FileIO(TESTFN, 'rb')
 
17845
+        buf = self.f.read()
 
17846
+        self.assertEqual(buf, b'123456')
 
17847
+
 
17848
+    def testWritelinesUserList(self):
 
17849
+        l = UserList([b'123', b'456'])
 
17850
+        self.f.writelines(l)
 
17851
+        self.f.close()
 
17852
+        self.f = _FileIO(TESTFN, 'rb')
 
17853
+        buf = self.f.read()
 
17854
+        self.assertEqual(buf, b'123456')
 
17855
+
 
17856
+    def testWritelinesError(self):
 
17857
+        self.assertRaises(TypeError, self.f.writelines, [1, 2, 3])
 
17858
+        self.assertRaises(TypeError, self.f.writelines, None)
 
17859
+        self.assertRaises(TypeError, self.f.writelines, "abc")
 
17860
+
 
17861
     def test_none_args(self):
 
17862
         self.f.write(b"hi\nbye\nabc")
 
17863
         self.f.close()
 
17864
@@ -127,6 +149,14 @@
14472
17865
         else:
14473
17866
             self.fail("Should have raised IOError")
14474
17867
 
14483
17876
     #A set of functions testing that we get expected behaviour if someone has
14484
17877
     #manually closed the internal file descriptor.  First, a decorator:
14485
17878
     def ClosedFD(func):
14486
 
@@ -403,6 +411,17 @@
 
17879
@@ -403,6 +433,17 @@
14487
17880
             self.assertRaises(ValueError, _FileIO, "/some/invalid/name", "rt")
14488
17881
             self.assertEqual(w.warnings, [])
14489
17882
 
14852
18245
diff -r 3d0686d90f55 Lib/test/test_httpservers.py
14853
18246
--- a/Lib/test/test_httpservers.py
14854
18247
+++ b/Lib/test/test_httpservers.py
14855
 
@@ -313,6 +313,8 @@
 
18248
@@ -62,6 +62,7 @@
 
18249
 
 
18250
     def tearDown(self):
 
18251
         self.thread.stop()
 
18252
+        self.thread = None
 
18253
         os.environ.__exit__()
 
18254
         support.threading_cleanup(*self._threads)
 
18255
 
 
18256
@@ -313,6 +314,8 @@
14856
18257
     class request_handler(NoLogRequestHandler, CGIHTTPRequestHandler):
14857
18258
         pass
14858
18259
 
14861
18262
     def setUp(self):
14862
18263
         BaseTestCase.setUp(self)
14863
18264
         self.cwd = os.getcwd()
14864
 
@@ -366,48 +368,51 @@
 
18265
@@ -366,48 +369,51 @@
14865
18266
         finally:
14866
18267
             BaseTestCase.tearDown(self)
14867
18268
 
14939
18340
             (res.read(), res.getheader('Content-type'), res.status))
14940
18341
 
14941
18342
     def test_post(self):
14942
 
@@ -416,7 +421,7 @@
 
18343
@@ -416,7 +422,7 @@
14943
18344
         headers = {'Content-type' : 'application/x-www-form-urlencoded'}
14944
18345
         res = self.request('/cgi-bin/file2.py', 'POST', params, headers)
14945
18346
 
14948
18349
 
14949
18350
     def test_invaliduri(self):
14950
18351
         res = self.request('/cgi-bin/invalid')
14951
 
@@ -427,20 +432,20 @@
 
18352
@@ -427,20 +433,20 @@
14952
18353
         headers = {b'Authorization' : b'Basic ' +
14953
18354
                    base64.b64encode(b'username:pass')}
14954
18355
         res = self.request('/cgi-bin/file1.py', 'GET', headers=headers)
15032
18433
diff -r 3d0686d90f55 Lib/test/test_import.py
15033
18434
--- a/Lib/test/test_import.py
15034
18435
+++ b/Lib/test/test_import.py
15035
 
@@ -461,6 +461,13 @@
 
18436
@@ -20,12 +20,23 @@
 
18437
 from test import script_helper
 
18438
 
 
18439
 
 
18440
+def _files(name):
 
18441
+    return (name + os.extsep + "py",
 
18442
+            name + os.extsep + "pyc",
 
18443
+            name + os.extsep + "pyo",
 
18444
+            name + os.extsep + "pyw",
 
18445
+            name + "$py.class")
 
18446
+
 
18447
+def chmod_files(name):
 
18448
+    for f in _files(name):
 
18449
+        try:
 
18450
+            os.chmod(f, 0o600)
 
18451
+        except OSError as exc:
 
18452
+            if exc.errno != errno.ENOENT:
 
18453
+                raise
 
18454
+
 
18455
 def remove_files(name):
 
18456
-    for f in (name + ".py",
 
18457
-              name + ".pyc",
 
18458
-              name + ".pyo",
 
18459
-              name + ".pyw",
 
18460
-              name + "$py.class"):
 
18461
+    for f in _files(name):
 
18462
         unlink(f)
 
18463
     rmtree('__pycache__')
 
18464
 
 
18465
@@ -122,6 +133,45 @@
 
18466
                 remove_files(TESTFN)
 
18467
                 unload(TESTFN)
 
18468
 
 
18469
+    def test_rewrite_pyc_with_read_only_source(self):
 
18470
+        # Issue 6074: a long time ago on posix, and more recently on Windows,
 
18471
+        # a read only source file resulted in a read only pyc file, which
 
18472
+        # led to problems with updating it later
 
18473
+        sys.path.insert(0, os.curdir)
 
18474
+        fname = TESTFN + os.extsep + "py"
 
18475
+        try:
 
18476
+            # Write a Python file, make it read-only and import it
 
18477
+            with open(fname, 'w') as f:
 
18478
+                f.write("x = 'original'\n")
 
18479
+            # Tweak the mtime of the source to ensure pyc gets updated later
 
18480
+            s = os.stat(fname)
 
18481
+            os.utime(fname, (s.st_atime, s.st_mtime-100000000))
 
18482
+            os.chmod(fname, 0o400)
 
18483
+            m1 = __import__(TESTFN)
 
18484
+            self.assertEqual(m1.x, 'original')
 
18485
+            # Change the file and then reimport it
 
18486
+            os.chmod(fname, 0o600)
 
18487
+            with open(fname, 'w') as f:
 
18488
+                f.write("x = 'rewritten'\n")
 
18489
+            unload(TESTFN)
 
18490
+            m2 = __import__(TESTFN)
 
18491
+            self.assertEqual(m2.x, 'rewritten')
 
18492
+            # Now delete the source file and check the pyc was rewritten
 
18493
+            unlink(fname)
 
18494
+            unload(TESTFN)
 
18495
+            if __debug__:
 
18496
+                bytecode_name = fname + "c"
 
18497
+            else:
 
18498
+                bytecode_name = fname + "o"
 
18499
+            os.rename(imp.cache_from_source(fname), bytecode_name)
 
18500
+            m3 = __import__(TESTFN)
 
18501
+            self.assertEqual(m3.x, 'rewritten')
 
18502
+        finally:
 
18503
+            chmod_files(TESTFN)
 
18504
+            remove_files(TESTFN)
 
18505
+            unload(TESTFN)
 
18506
+            del sys.path[0]
 
18507
+
 
18508
     def test_imp_module(self):
 
18509
         # Verify that the imp module can correctly load and find .py files
 
18510
         # XXX (ncoghlan): It would be nice to use support.CleanImport
 
18511
@@ -461,6 +511,13 @@
15036
18512
         drive = path[0]
15037
18513
         unc = "\\\\%s\\%s$"%(hn, drive)
15038
18514
         unc += path[2:]
15046
18522
         sys.path.append(path)
15047
18523
         mod = __import__("test_trailing_slash")
15048
18524
         self.assertEqual(mod.testdata, 'test_trailing_slash')
 
18525
@@ -568,7 +625,7 @@
 
18526
         self.assertTrue(os.path.exists('__pycache__'))
 
18527
         self.assertTrue(os.path.exists(os.path.join(
 
18528
             '__pycache__', '{}.{}.py{}'.format(
 
18529
-            TESTFN, self.tag, __debug__ and 'c' or 'o'))))
 
18530
+            TESTFN, self.tag, 'c' if __debug__ else 'o'))))
 
18531
 
 
18532
     @unittest.skipUnless(os.name == 'posix',
 
18533
                          "test meaningful only on posix systems")
15049
18534
diff -r 3d0686d90f55 Lib/test/test_io.py
15050
18535
--- a/Lib/test/test_io.py
15051
18536
+++ b/Lib/test/test_io.py
 
18537
@@ -32,7 +32,7 @@
 
18538
 import warnings
 
18539
 import pickle
 
18540
 from itertools import cycle, count
 
18541
-from collections import deque
 
18542
+from collections import deque, UserList
 
18543
 from test import support
 
18544
 
 
18545
 import codecs
15052
18546
@@ -634,6 +634,19 @@
15053
18547
         for obj in test:
15054
18548
             self.assertTrue(hasattr(obj, "__dict__"))
15099
18593
     tp = io.BufferedReader
15100
18594
 
15101
18595
     def test_constructor(self):
15102
 
@@ -1232,7 +1259,7 @@
 
18596
@@ -1150,6 +1177,29 @@
 
18597
         bufio.flush()
 
18598
         self.assertEqual(b"abc", writer._write_stack[0])
 
18599
 
 
18600
+    def test_writelines(self):
 
18601
+        l = [b'ab', b'cd', b'ef']
 
18602
+        writer = self.MockRawIO()
 
18603
+        bufio = self.tp(writer, 8)
 
18604
+        bufio.writelines(l)
 
18605
+        bufio.flush()
 
18606
+        self.assertEqual(b''.join(writer._write_stack), b'abcdef')
 
18607
+
 
18608
+    def test_writelines_userlist(self):
 
18609
+        l = UserList([b'ab', b'cd', b'ef'])
 
18610
+        writer = self.MockRawIO()
 
18611
+        bufio = self.tp(writer, 8)
 
18612
+        bufio.writelines(l)
 
18613
+        bufio.flush()
 
18614
+        self.assertEqual(b''.join(writer._write_stack), b'abcdef')
 
18615
+
 
18616
+    def test_writelines_error(self):
 
18617
+        writer = self.MockRawIO()
 
18618
+        bufio = self.tp(writer, 8)
 
18619
+        self.assertRaises(TypeError, bufio.writelines, [1, 2, 3])
 
18620
+        self.assertRaises(TypeError, bufio.writelines, None)
 
18621
+        self.assertRaises(TypeError, bufio.writelines, 'abc')
 
18622
+
 
18623
     def test_destructor(self):
 
18624
         writer = self.MockRawIO()
 
18625
         bufio = self.tp(writer, 8)
 
18626
@@ -1232,7 +1282,7 @@
15103
18627
             self.tp(self.MockRawIO(), 8, 12)
15104
18628
 
15105
18629
 
15108
18632
     tp = io.BufferedWriter
15109
18633
 
15110
18634
     def test_constructor(self):
15111
 
@@ -1623,7 +1650,7 @@
 
18635
@@ -1623,7 +1673,7 @@
15112
18636
     # You can't construct a BufferedRandom over a non-seekable stream.
15113
18637
     test_unseekable = None
15114
18638
 
15117
18641
     tp = io.BufferedRandom
15118
18642
 
15119
18643
     def test_constructor(self):
 
18644
@@ -2237,6 +2287,28 @@
 
18645
             reads += c
 
18646
         self.assertEqual(reads, "A"*127+"\nB")
 
18647
 
 
18648
+    def test_writelines(self):
 
18649
+        l = ['ab', 'cd', 'ef']
 
18650
+        buf = self.BytesIO()
 
18651
+        txt = self.TextIOWrapper(buf)
 
18652
+        txt.writelines(l)
 
18653
+        txt.flush()
 
18654
+        self.assertEqual(buf.getvalue(), b'abcdef')
 
18655
+
 
18656
+    def test_writelines_userlist(self):
 
18657
+        l = UserList(['ab', 'cd', 'ef'])
 
18658
+        buf = self.BytesIO()
 
18659
+        txt = self.TextIOWrapper(buf)
 
18660
+        txt.writelines(l)
 
18661
+        txt.flush()
 
18662
+        self.assertEqual(buf.getvalue(), b'abcdef')
 
18663
+
 
18664
+    def test_writelines_error(self):
 
18665
+        txt = self.TextIOWrapper(self.BytesIO())
 
18666
+        self.assertRaises(TypeError, txt.writelines, [1, 2, 3])
 
18667
+        self.assertRaises(TypeError, txt.writelines, None)
 
18668
+        self.assertRaises(TypeError, txt.writelines, b'abc')
 
18669
+
 
18670
     def test_issue1395_1(self):
 
18671
         txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii")
 
18672
 
15120
18673
diff -r 3d0686d90f55 Lib/test/test_keywordonlyarg.py
15121
18674
--- a/Lib/test/test_keywordonlyarg.py
15122
18675
+++ b/Lib/test/test_keywordonlyarg.py
15307
18860
         elif os.path.exists(target):
15308
18861
             os.remove(target)
15309
18862
 
 
18863
@@ -53,7 +49,7 @@
 
18864
     maxDiff = None
 
18865
 
 
18866
     _factory = None     # Overridden by subclasses to reuse tests
 
18867
-    _template = 'From: foo\n\n%s'
 
18868
+    _template = 'From: foo\n\n%s\n'
 
18869
 
 
18870
     def setUp(self):
 
18871
         self._path = support.TESTFN
15310
18872
@@ -115,10 +111,10 @@
15311
18873
         self.assertMailboxEmpty()
15312
18874
 
15360
18922
 
15361
18923
     def test_add_StringIO_warns(self):
15362
18924
         with self.assertWarns(DeprecationWarning):
 
18925
@@ -238,7 +228,7 @@
 
18926
         key0 = self._box.add(self._template % 0)
 
18927
         msg = self._box.get(key0)
 
18928
         self.assertEqual(msg['from'], 'foo')
 
18929
-        self.assertEqual(msg.get_payload(), '0')
 
18930
+        self.assertEqual(msg.get_payload(), '0\n')
 
18931
         self.assertIs(self._box.get('foo'), None)
 
18932
         self.assertIs(self._box.get('foo', False), False)
 
18933
         self._box.close()
 
18934
@@ -246,14 +236,14 @@
 
18935
         key1 = self._box.add(self._template % 1)
 
18936
         msg = self._box.get(key1)
 
18937
         self.assertEqual(msg['from'], 'foo')
 
18938
-        self.assertEqual(msg.get_payload(), '1')
 
18939
+        self.assertEqual(msg.get_payload(), '1\n')
 
18940
 
 
18941
     def test_getitem(self):
 
18942
         # Retrieve message using __getitem__()
 
18943
         key0 = self._box.add(self._template % 0)
 
18944
         msg = self._box[key0]
 
18945
         self.assertEqual(msg['from'], 'foo')
 
18946
-        self.assertEqual(msg.get_payload(), '0')
 
18947
+        self.assertEqual(msg.get_payload(), '0\n')
 
18948
         self.assertRaises(KeyError, lambda: self._box['foo'])
 
18949
         self._box.discard(key0)
 
18950
         self.assertRaises(KeyError, lambda: self._box[key0])
 
18951
@@ -265,7 +255,7 @@
 
18952
         msg0 = self._box.get_message(key0)
 
18953
         self.assertIsInstance(msg0, mailbox.Message)
 
18954
         self.assertEqual(msg0['from'], 'foo')
 
18955
-        self.assertEqual(msg0.get_payload(), '0')
 
18956
+        self.assertEqual(msg0.get_payload(), '0\n')
 
18957
         self._check_sample(self._box.get_message(key1))
 
18958
 
 
18959
     def test_get_bytes(self):
 
18960
@@ -438,15 +428,15 @@
 
18961
         self.assertIn(key0, self._box)
 
18962
         key1 = self._box.add(self._template % 1)
 
18963
         self.assertIn(key1, self._box)
 
18964
-        self.assertEqual(self._box.pop(key0).get_payload(), '0')
 
18965
+        self.assertEqual(self._box.pop(key0).get_payload(), '0\n')
 
18966
         self.assertNotIn(key0, self._box)
 
18967
         self.assertIn(key1, self._box)
 
18968
         key2 = self._box.add(self._template % 2)
 
18969
         self.assertIn(key2, self._box)
 
18970
-        self.assertEqual(self._box.pop(key2).get_payload(), '2')
 
18971
+        self.assertEqual(self._box.pop(key2).get_payload(), '2\n')
 
18972
         self.assertNotIn(key2, self._box)
 
18973
         self.assertIn(key1, self._box)
 
18974
-        self.assertEqual(self._box.pop(key1).get_payload(), '1')
 
18975
+        self.assertEqual(self._box.pop(key1).get_payload(), '1\n')
 
18976
         self.assertNotIn(key1, self._box)
 
18977
         self.assertEqual(len(self._box), 0)
 
18978
 
15363
18979
@@ -504,6 +494,17 @@
15364
18980
         # Write changes to disk
15365
18981
         self._test_flush_or_close(self._box.flush, True)
15396
19012
 
15397
19013
     _factory = lambda self, path, factory=None: mailbox.Maildir(path, factory)
15398
19014
 
 
19015
@@ -630,7 +631,7 @@
 
19016
         msg_returned = self._box.get_message(key)
 
19017
         self.assertEqual(msg_returned.get_subdir(), 'new')
 
19018
         self.assertEqual(msg_returned.get_flags(), '')
 
19019
-        self.assertEqual(msg_returned.get_payload(), '1')
 
19020
+        self.assertEqual(msg_returned.get_payload(), '1\n')
 
19021
         msg2 = mailbox.MaildirMessage(self._template % 2)
 
19022
         msg2.set_info('2,S')
 
19023
         self._box[key] = msg2
 
19024
@@ -638,7 +639,7 @@
 
19025
         msg_returned = self._box.get_message(key)
 
19026
         self.assertEqual(msg_returned.get_subdir(), 'new')
 
19027
         self.assertEqual(msg_returned.get_flags(), 'S')
 
19028
-        self.assertEqual(msg_returned.get_payload(), '3')
 
19029
+        self.assertEqual(msg_returned.get_payload(), '3\n')
 
19030
 
 
19031
     def test_consistent_factory(self):
 
19032
         # Add a message.
15399
19033
@@ -758,13 +759,13 @@
15400
19034
             self.assertIsNot(match, None, "Invalid file name: '%s'" % tail)
15401
19035
             groups = match.groups()
15466
19100
 
15467
19101
     def tearDown(self):
15468
19102
         super().tearDown()
 
19103
@@ -950,20 +993,20 @@
 
19104
 
 
19105
     def test_add_from_string(self):
 
19106
         # Add a string starting with 'From ' to the mailbox
 
19107
-        key = self._box.add('From foo@bar blah\nFrom: foo\n\n0')
 
19108
+        key = self._box.add('From foo@bar blah\nFrom: foo\n\n0\n')
 
19109
         self.assertEqual(self._box[key].get_from(), 'foo@bar blah')
 
19110
-        self.assertEqual(self._box[key].get_payload(), '0')
 
19111
+        self.assertEqual(self._box[key].get_payload(), '0\n')
 
19112
 
 
19113
     def test_add_from_bytes(self):
 
19114
         # Add a byte string starting with 'From ' to the mailbox
 
19115
-        key = self._box.add(b'From foo@bar blah\nFrom: foo\n\n0')
 
19116
+        key = self._box.add(b'From foo@bar blah\nFrom: foo\n\n0\n')
 
19117
         self.assertEqual(self._box[key].get_from(), 'foo@bar blah')
 
19118
-        self.assertEqual(self._box[key].get_payload(), '0')
 
19119
+        self.assertEqual(self._box[key].get_payload(), '0\n')
 
19120
 
 
19121
     def test_add_mbox_or_mmdf_message(self):
 
19122
         # Add an mboxMessage or MMDFMessage
 
19123
         for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage):
 
19124
-            msg = class_('From foo@bar blah\nFrom: foo\n\n0')
 
19125
+            msg = class_('From foo@bar blah\nFrom: foo\n\n0\n')
 
19126
             key = self._box.add(msg)
 
19127
 
 
19128
     def test_open_close_open(self):
15469
19129
@@ -1047,7 +1090,7 @@
15470
19130
         self._box.close()
15471
19131
 
15475
19135
 
15476
19136
     _factory = lambda self, path, factory=None: mailbox.mbox(path, factory)
15477
19137
 
15478
 
@@ -1070,12 +1113,12 @@
 
19138
@@ -1070,12 +1113,35 @@
15479
19139
             perms = st.st_mode
15480
19140
             self.assertFalse((perms & 0o111)) # Execute bits should all be off.
15481
19141
 
15482
19142
-class TestMMDF(_TestMboxMMDF):
 
19143
+    def test_terminating_newline(self):
 
19144
+        message = email.message.Message()
 
19145
+        message['From'] = 'john@example.com'
 
19146
+        message.set_payload('No newline at the end')
 
19147
+        i = self._box.add(message)
 
19148
+
 
19149
+        # A newline should have been appended to the payload
 
19150
+        message = self._box.get(i)
 
19151
+        self.assertEqual(message.get_payload(), 'No newline at the end\n')
 
19152
+
 
19153
+    def test_message_separator(self):
 
19154
+        # Check there's always a single blank line after each message
 
19155
+        self._box.add('From: foo\n\n0')  # No newline at the end
 
19156
+        with open(self._path) as f:
 
19157
+            data = f.read()
 
19158
+            self.assertEqual(data[-3:], '0\n\n')
 
19159
+
 
19160
+        self._box.add('From: foo\n\n0\n')  # Newline at the end
 
19161
+        with open(self._path) as f:
 
19162
+            data = f.read()
 
19163
+            self.assertEqual(data[-3:], '0\n\n')
 
19164
+
 
19165
+
15483
19166
+class TestMMDF(_TestMboxMMDF, unittest.TestCase):
15484
19167
 
15485
19168
     _factory = lambda self, path, factory=None: mailbox.MMDF(path, factory)
15490
19173
 
15491
19174
     _factory = lambda self, path, factory=None: mailbox.MH(path, factory)
15492
19175
 
15493
 
@@ -1210,7 +1253,7 @@
 
19176
@@ -1210,7 +1276,7 @@
15494
19177
         return os.path.join(self._path, '.mh_sequences.lock')
15495
19178
 
15496
19179
 
15499
19182
 
15500
19183
     _factory = lambda self, path, factory=None: mailbox.Babyl(path, factory)
15501
19184
 
15502
 
@@ -1275,7 +1318,7 @@
 
19185
@@ -1275,7 +1341,7 @@
15503
19186
             self.assertTrue(box.files[i].closed)
15504
19187
 
15505
19188
 
15508
19191
 
15509
19192
     _factory = mailbox.Message      # Overridden by subclasses to reuse tests
15510
19193
 
15511
 
@@ -1355,7 +1398,7 @@
 
19194
@@ -1355,7 +1421,7 @@
15512
19195
         pass
15513
19196
 
15514
19197
 
15517
19200
 
15518
19201
     _factory = mailbox.MaildirMessage
15519
19202
 
15520
 
@@ -1429,7 +1472,7 @@
 
19203
@@ -1429,7 +1495,7 @@
15521
19204
         self._check_sample(msg)
15522
19205
 
15523
19206
 
15526
19209
 
15527
19210
     _factory = mailbox._mboxMMDFMessage
15528
19211
 
15529
 
@@ -1476,12 +1519,12 @@
 
19212
@@ -1476,12 +1542,12 @@
15530
19213
                               r"\d{2} \d{4}", msg.get_from()) is not None)
15531
19214
 
15532
19215
 
15541
19224
 
15542
19225
     _factory = mailbox.MHMessage
15543
19226
 
15544
 
@@ -1512,7 +1555,7 @@
 
19227
@@ -1512,7 +1578,7 @@
15545
19228
         self.assertEqual(msg.get_sequences(), ['foobar', 'replied'])
15546
19229
 
15547
19230
 
15550
19233
 
15551
19234
     _factory = mailbox.BabylMessage
15552
19235
 
15553
 
@@ -1567,12 +1610,12 @@
 
19236
@@ -1567,12 +1633,12 @@
15554
19237
             self.assertEqual(visible[header], msg[header])
15555
19238
 
15556
19239
 
15565
19248
 
15566
19249
     def test_plain_to_x(self):
15567
19250
         # Convert Message to all formats
15568
 
@@ -1913,7 +1956,7 @@
 
19251
@@ -1913,7 +1979,7 @@
15569
19252
         self.assertTrue(proxy.closed)
15570
19253
 
15571
19254
 
15574
19257
 
15575
19258
     def setUp(self):
15576
19259
         self._path = support.TESTFN
15577
 
@@ -1962,7 +2005,7 @@
 
19260
@@ -1962,7 +2028,7 @@
15578
19261
         self._test_close(mailbox._ProxyFile(self._file))
15579
19262
 
15580
19263
 
15583
19266
 
15584
19267
     def setUp(self):
15585
19268
         self._path = support.TESTFN
15586
 
@@ -2029,6 +2072,10 @@
 
19269
@@ -2029,6 +2095,10 @@
15587
19270
     def setUp(self):
15588
19271
         # create a new maildir mailbox to work with:
15589
19272
         self._dir = support.TESTFN
16566
20249
     def test_not_here(self):
16567
20250
         missing_module = "test.i_am_not_here"
16568
20251
         result = str(run_pydoc(missing_module), 'ascii')
 
20252
diff -r 3d0686d90f55 Lib/test/test_pyexpat.py
 
20253
--- a/Lib/test/test_pyexpat.py
 
20254
+++ b/Lib/test/test_pyexpat.py
 
20255
@@ -641,6 +641,16 @@
 
20256
         parser.Parse("<?xml version='1.0'?><element/>")
 
20257
         self.assertEqual(handler_call_args, [(None, None)])
 
20258
 
 
20259
+        # test UseForeignDTD() is equal to UseForeignDTD(True)
 
20260
+        handler_call_args[:] = []
 
20261
+
 
20262
+        parser = expat.ParserCreate()
 
20263
+        parser.UseForeignDTD()
 
20264
+        parser.SetParamEntityParsing(expat.XML_PARAM_ENTITY_PARSING_ALWAYS)
 
20265
+        parser.ExternalEntityRefHandler = resolve_entity
 
20266
+        parser.Parse("<?xml version='1.0'?><element/>")
 
20267
+        self.assertEqual(handler_call_args, [(None, None)])
 
20268
+
 
20269
     def test_ignore_use_foreign_dtd(self):
 
20270
         """
 
20271
         If UseForeignDTD is passed True and a document with an external
16569
20272
diff -r 3d0686d90f55 Lib/test/test_queue.py
16570
20273
--- a/Lib/test/test_queue.py
16571
20274
+++ b/Lib/test/test_queue.py
17282
20985
 
17283
20986
     def test_zipfile_error(self):
17284
20987
         with temp_dir() as script_dir:
17285
 
@@ -419,9 +531,9 @@
 
20988
@@ -411,17 +523,17 @@
 
20989
             with open(filename, 'w', encoding='latin1') as f:
 
20990
                 f.write("""
 
20991
 #coding:latin1
 
20992
-"non-ASCII: h\xe9"
 
20993
+s = "non-ASCII: h\xe9"
 
20994
 """)
 
20995
             result = run_path(filename)
 
20996
-            self.assertEqual(result['__doc__'], "non-ASCII: h\xe9")
 
20997
+            self.assertEqual(result['s'], "non-ASCII: h\xe9")
 
20998
 
17286
20999
 
17287
21000
 def test_main():
17288
21001
     run_unittest(
17371
21084
         self.assertRaises(socket.error, self.cli_conn.recv, 1024)
17372
21085
         self.cli_conn.close()
17373
21086
         # ...but we can create another socket using the (still open)
 
21087
@@ -1626,7 +1638,26 @@
 
21088
         port = support.find_unused_port()
 
21089
         with self.assertRaises(socket.error) as cm:
 
21090
             socket.create_connection((HOST, port))
 
21091
-        self.assertEqual(cm.exception.errno, errno.ECONNREFUSED)
 
21092
+
 
21093
+        # Issue #16257: create_connection() calls getaddrinfo() against
 
21094
+        # 'localhost'.  This may result in an IPV6 addr being returned
 
21095
+        # as well as an IPV4 one:
 
21096
+        #   >>> socket.getaddrinfo('localhost', port, 0, SOCK_STREAM)
 
21097
+        #   >>> [(2,  2, 0, '', ('127.0.0.1', 41230)),
 
21098
+        #        (26, 2, 0, '', ('::1', 41230, 0, 0))]
 
21099
+        #
 
21100
+        # create_connection() enumerates through all the addresses returned
 
21101
+        # and if it doesn't successfully bind to any of them, it propagates
 
21102
+        # the last exception it encountered.
 
21103
+        #
 
21104
+        # On Solaris, ENETUNREACH is returned in this circumstance instead
 
21105
+        # of ECONNREFUSED.  So, if that errno exists, add it to our list of
 
21106
+        # expected errnos.
 
21107
+        expected_errnos = [ errno.ECONNREFUSED, ]
 
21108
+        if hasattr(errno, 'ENETUNREACH'):
 
21109
+            expected_errnos.append(errno.ENETUNREACH)
 
21110
+
 
21111
+        self.assertIn(cm.exception.errno, expected_errnos)
 
21112
 
 
21113
     def test_create_connection_timeout(self):
 
21114
         # Issue #9792: create_connection() should not recast timeout errors
17374
21115
diff -r 3d0686d90f55 Lib/test/test_socketserver.py
17375
21116
--- a/Lib/test/test_socketserver.py
17376
21117
+++ b/Lib/test/test_socketserver.py
17670
21411
diff -r 3d0686d90f55 Lib/test/test_subprocess.py
17671
21412
--- a/Lib/test/test_subprocess.py
17672
21413
+++ b/Lib/test/test_subprocess.py
17673
 
@@ -4,6 +4,7 @@
 
21414
@@ -1,9 +1,11 @@
 
21415
 import unittest
 
21416
+from test import script_helper
 
21417
 from test import support
 
21418
 import subprocess
17674
21419
 import sys
17675
21420
 import signal
17676
21421
 import io
17678
21423
 import os
17679
21424
 import errno
17680
21425
 import tempfile
17681
 
@@ -476,21 +477,22 @@
 
21426
@@ -163,24 +165,108 @@
 
21427
         p.wait()
 
21428
         self.assertEqual(p.stderr, None)
 
21429
 
 
21430
+    # For use in the test_cwd* tests below.
 
21431
+    def _normalize_cwd(self, cwd):
 
21432
+        # Normalize an expected cwd (for Tru64 support).
 
21433
+        # We can't use os.path.realpath since it doesn't expand Tru64 {memb}
 
21434
+        # strings.  See bug #1063571.
 
21435
+        original_cwd = os.getcwd()
 
21436
+        os.chdir(cwd)
 
21437
+        cwd = os.getcwd()
 
21438
+        os.chdir(original_cwd)
 
21439
+        return cwd
 
21440
+
 
21441
+    # For use in the test_cwd* tests below.
 
21442
+    def _split_python_path(self):
 
21443
+        # Return normalized (python_dir, python_base).
 
21444
+        python_path = os.path.realpath(sys.executable)
 
21445
+        return os.path.split(python_path)
 
21446
+
 
21447
+    # For use in the test_cwd* tests below.
 
21448
+    def _assert_cwd(self, expected_cwd, python_arg, **kwargs):
 
21449
+        # Invoke Python via Popen, and assert that (1) the call succeeds,
 
21450
+        # and that (2) the current working directory of the child process
 
21451
+        # matches *expected_cwd*.
 
21452
+        p = subprocess.Popen([python_arg, "-c",
 
21453
+                              "import os, sys; "
 
21454
+                              "sys.stdout.write(os.getcwd()); "
 
21455
+                              "sys.exit(47)"],
 
21456
+                              stdout=subprocess.PIPE,
 
21457
+                              **kwargs)
 
21458
+        self.addCleanup(p.stdout.close)
 
21459
+        p.wait()
 
21460
+        self.assertEqual(47, p.returncode)
 
21461
+        normcase = os.path.normcase
 
21462
+        self.assertEqual(normcase(expected_cwd),
 
21463
+                         normcase(p.stdout.read().decode("utf-8")))
 
21464
+
 
21465
+    def test_cwd(self):
 
21466
+        # Check that cwd changes the cwd for the child process.
 
21467
+        temp_dir = tempfile.gettempdir()
 
21468
+        temp_dir = self._normalize_cwd(temp_dir)
 
21469
+        self._assert_cwd(temp_dir, sys.executable, cwd=temp_dir)
 
21470
+
 
21471
+    @unittest.skipIf(mswindows, "pending resolution of issue #15533")
 
21472
+    def test_cwd_with_relative_arg(self):
 
21473
+        # Check that Popen looks for args[0] relative to cwd if args[0]
 
21474
+        # is relative.
 
21475
+        python_dir, python_base = self._split_python_path()
 
21476
+        rel_python = os.path.join(os.curdir, python_base)
 
21477
+        with support.temp_cwd() as wrong_dir:
 
21478
+            # Before calling with the correct cwd, confirm that the call fails
 
21479
+            # without cwd and with the wrong cwd.
 
21480
+            self.assertRaises(OSError, subprocess.Popen,
 
21481
+                              [rel_python])
 
21482
+            self.assertRaises(OSError, subprocess.Popen,
 
21483
+                              [rel_python], cwd=wrong_dir)
 
21484
+            python_dir = self._normalize_cwd(python_dir)
 
21485
+            self._assert_cwd(python_dir, rel_python, cwd=python_dir)
 
21486
+
 
21487
+    @unittest.skipIf(mswindows, "pending resolution of issue #15533")
 
21488
+    def test_cwd_with_relative_executable(self):
 
21489
+        # Check that Popen looks for executable relative to cwd if executable
 
21490
+        # is relative (and that executable takes precedence over args[0]).
 
21491
+        python_dir, python_base = self._split_python_path()
 
21492
+        rel_python = os.path.join(os.curdir, python_base)
 
21493
+        doesntexist = "somethingyoudonthave"
 
21494
+        with support.temp_cwd() as wrong_dir:
 
21495
+            # Before calling with the correct cwd, confirm that the call fails
 
21496
+            # without cwd and with the wrong cwd.
 
21497
+            self.assertRaises(OSError, subprocess.Popen,
 
21498
+                              [doesntexist], executable=rel_python)
 
21499
+            self.assertRaises(OSError, subprocess.Popen,
 
21500
+                              [doesntexist], executable=rel_python,
 
21501
+                              cwd=wrong_dir)
 
21502
+            python_dir = self._normalize_cwd(python_dir)
 
21503
+            self._assert_cwd(python_dir, doesntexist, executable=rel_python,
 
21504
+                             cwd=python_dir)
 
21505
+
 
21506
+    def test_cwd_with_absolute_arg(self):
 
21507
+        # Check that Popen can find the executable when the cwd is wrong
 
21508
+        # if args[0] is an absolute path.
 
21509
+        python_dir, python_base = self._split_python_path()
 
21510
+        abs_python = os.path.join(python_dir, python_base)
 
21511
+        rel_python = os.path.join(os.curdir, python_base)
 
21512
+        with script_helper.temp_dir() as wrong_dir:
 
21513
+            # Before calling with an absolute path, confirm that using a
 
21514
+            # relative path fails.
 
21515
+            self.assertRaises(OSError, subprocess.Popen,
 
21516
+                              [rel_python], cwd=wrong_dir)
 
21517
+            wrong_dir = self._normalize_cwd(wrong_dir)
 
21518
+            self._assert_cwd(wrong_dir, abs_python, cwd=wrong_dir)
 
21519
+
 
21520
     def test_executable_with_cwd(self):
 
21521
-        python_dir = os.path.dirname(os.path.realpath(sys.executable))
 
21522
-        p = subprocess.Popen(["somethingyoudonthave", "-c",
 
21523
-                              "import sys; sys.exit(47)"],
 
21524
-                             executable=sys.executable, cwd=python_dir)
 
21525
-        p.wait()
 
21526
-        self.assertEqual(p.returncode, 47)
 
21527
+        python_dir, python_base = self._split_python_path()
 
21528
+        python_dir = self._normalize_cwd(python_dir)
 
21529
+        self._assert_cwd(python_dir, "somethingyoudonthave",
 
21530
+                         executable=sys.executable, cwd=python_dir)
 
21531
 
 
21532
     @unittest.skipIf(sysconfig.is_python_build(),
 
21533
                      "need an installed Python. See #7774")
 
21534
     def test_executable_without_cwd(self):
 
21535
         # For a normal installation, it should work without 'cwd'
 
21536
         # argument.  For test runs in the build directory, see #7774.
 
21537
-        p = subprocess.Popen(["somethingyoudonthave", "-c",
 
21538
-                              "import sys; sys.exit(47)"],
 
21539
-                             executable=sys.executable)
 
21540
-        p.wait()
 
21541
-        self.assertEqual(p.returncode, 47)
 
21542
+        self._assert_cwd('', "somethingyoudonthave", executable=sys.executable)
 
21543
 
 
21544
     def test_stdin_pipe(self):
 
21545
         # stdin redirection
 
21546
@@ -312,24 +398,6 @@
 
21547
         rc = subprocess.call([sys.executable, "-c", cmd], stdout=1)
 
21548
         self.assertEqual(rc, 2)
 
21549
 
 
21550
-    def test_cwd(self):
 
21551
-        tmpdir = tempfile.gettempdir()
 
21552
-        # We cannot use os.path.realpath to canonicalize the path,
 
21553
-        # since it doesn't expand Tru64 {memb} strings. See bug 1063571.
 
21554
-        cwd = os.getcwd()
 
21555
-        os.chdir(tmpdir)
 
21556
-        tmpdir = os.getcwd()
 
21557
-        os.chdir(cwd)
 
21558
-        p = subprocess.Popen([sys.executable, "-c",
 
21559
-                              'import sys,os;'
 
21560
-                              'sys.stdout.write(os.getcwd())'],
 
21561
-                             stdout=subprocess.PIPE,
 
21562
-                             cwd=tmpdir)
 
21563
-        self.addCleanup(p.stdout.close)
 
21564
-        normcase = os.path.normcase
 
21565
-        self.assertEqual(normcase(p.stdout.read().decode("utf-8")),
 
21566
-                         normcase(tmpdir))
 
21567
-
 
21568
     def test_env(self):
 
21569
         newenv = os.environ.copy()
 
21570
         newenv["FRUIT"] = "orange"
 
21571
@@ -476,21 +544,22 @@
17682
21572
     def test_universal_newlines(self):
17683
21573
         p = subprocess.Popen([sys.executable, "-c",
17684
21574
                               'import sys,os;' + SETBINARY +
17716
21606
                              stdin=subprocess.PIPE,
17717
21607
                              stdout=subprocess.PIPE,
17718
21608
                              universal_newlines=1)
17719
 
@@ -510,17 +512,18 @@
 
21609
@@ -510,17 +579,18 @@
17720
21610
         # universal newlines through communicate()
17721
21611
         p = subprocess.Popen([sys.executable, "-c",
17722
21612
                               'import sys,os;' + SETBINARY +
17746
21636
                              stderr=subprocess.PIPE,
17747
21637
                              stdout=subprocess.PIPE,
17748
21638
                              universal_newlines=1)
17749
 
@@ -546,6 +549,50 @@
 
21639
@@ -546,6 +616,50 @@
17750
21640
         (stdout, stderr) = p.communicate("line1\nline3\n")
17751
21641
         self.assertEqual(p.returncode, 0)
17752
21642
 
17797
21687
     def test_no_leaking(self):
17798
21688
         # Make sure we leak no resources
17799
21689
         if not mswindows:
17800
 
@@ -989,6 +1036,27 @@
 
21690
@@ -770,24 +884,30 @@
 
21691
 @unittest.skipIf(mswindows, "POSIX specific tests")
 
21692
 class POSIXProcessTestCase(BaseTestCase):
 
21693
 
 
21694
-    def test_exceptions(self):
 
21695
-        nonexistent_dir = "/_this/pa.th/does/not/exist"
 
21696
+    def setUp(self):
 
21697
+        super().setUp()
 
21698
+        self._nonexistent_dir = "/_this/pa.th/does/not/exist"
 
21699
+
 
21700
+    def _get_chdir_exception(self):
 
21701
         try:
 
21702
-            os.chdir(nonexistent_dir)
 
21703
+            os.chdir(self._nonexistent_dir)
 
21704
         except OSError as e:
 
21705
             # This avoids hard coding the errno value or the OS perror()
 
21706
             # string and instead capture the exception that we want to see
 
21707
             # below for comparison.
 
21708
             desired_exception = e
 
21709
-            desired_exception.strerror += ': ' + repr(sys.executable)
 
21710
+            desired_exception.strerror += ': ' + repr(self._nonexistent_dir)
 
21711
         else:
 
21712
             self.fail("chdir to nonexistant directory %s succeeded." %
 
21713
-                      nonexistent_dir)
 
21714
+                      self._nonexistent_dir)
 
21715
+        return desired_exception
 
21716
 
 
21717
-        # Error in the child re-raised in the parent.
 
21718
+    def test_exception_cwd(self):
 
21719
+        """Test error in the child raised in the parent for a bad cwd."""
 
21720
+        desired_exception = self._get_chdir_exception()
 
21721
         try:
 
21722
             p = subprocess.Popen([sys.executable, "-c", ""],
 
21723
-                                 cwd=nonexistent_dir)
 
21724
+                                 cwd=self._nonexistent_dir)
 
21725
         except OSError as e:
 
21726
             # Test that the child process chdir failure actually makes
 
21727
             # it up to the parent process as the correct exception.
 
21728
@@ -796,6 +916,33 @@
 
21729
         else:
 
21730
             self.fail("Expected OSError: %s" % desired_exception)
 
21731
 
 
21732
+    def test_exception_bad_executable(self):
 
21733
+        """Test error in the child raised in the parent for a bad executable."""
 
21734
+        desired_exception = self._get_chdir_exception()
 
21735
+        try:
 
21736
+            p = subprocess.Popen([sys.executable, "-c", ""],
 
21737
+                                 executable=self._nonexistent_dir)
 
21738
+        except OSError as e:
 
21739
+            # Test that the child process exec failure actually makes
 
21740
+            # it up to the parent process as the correct exception.
 
21741
+            self.assertEqual(desired_exception.errno, e.errno)
 
21742
+            self.assertEqual(desired_exception.strerror, e.strerror)
 
21743
+        else:
 
21744
+            self.fail("Expected OSError: %s" % desired_exception)
 
21745
+
 
21746
+    def test_exception_bad_args_0(self):
 
21747
+        """Test error in the child raised in the parent for a bad args[0]."""
 
21748
+        desired_exception = self._get_chdir_exception()
 
21749
+        try:
 
21750
+            p = subprocess.Popen([self._nonexistent_dir, "-c", ""])
 
21751
+        except OSError as e:
 
21752
+            # Test that the child process exec failure actually makes
 
21753
+            # it up to the parent process as the correct exception.
 
21754
+            self.assertEqual(desired_exception.errno, e.errno)
 
21755
+            self.assertEqual(desired_exception.strerror, e.strerror)
 
21756
+        else:
 
21757
+            self.fail("Expected OSError: %s" % desired_exception)
 
21758
+
 
21759
     def test_restore_signals(self):
 
21760
         # Code coverage for both values of restore_signals to make sure it
 
21761
         # at least does not blow up.
 
21762
@@ -989,6 +1136,27 @@
17801
21763
         getattr(p, method)(*args)
17802
21764
         return p
17803
21765
 
17825
21787
     def test_send_signal(self):
17826
21788
         p = self._kill_process('send_signal', signal.SIGINT)
17827
21789
         _, stderr = p.communicate()
17828
 
@@ -1007,6 +1075,18 @@
 
21790
@@ -1007,6 +1175,18 @@
17829
21791
         self.assertStderrEqual(stderr, b'')
17830
21792
         self.assertEqual(p.wait(), -signal.SIGTERM)
17831
21793
 
17844
21806
     def check_close_std_fds(self, fds):
17845
21807
         # Issue #9905: test that subprocess pipes still work properly with
17846
21808
         # some standard fds closed
17847
 
@@ -1568,6 +1648,31 @@
 
21809
@@ -1568,6 +1748,31 @@
17848
21810
         returncode = p.wait()
17849
21811
         self.assertNotEqual(returncode, 0)
17850
21812
 
17876
21838
     def test_send_signal(self):
17877
21839
         self._kill_process('send_signal', signal.SIGTERM)
17878
21840
 
17879
 
@@ -1577,6 +1682,15 @@
 
21841
@@ -1577,6 +1782,15 @@
17880
21842
     def test_terminate(self):
17881
21843
         self._kill_process('terminate')
17882
21844
 
18680
22642
         self.assertEqual(data, expected_output)
18681
22643
 
18682
22644
 class LockTests(lock_tests.LockTests):
 
22645
diff -r 3d0686d90f55 Lib/test/test_timeit.py
 
22646
--- a/Lib/test/test_timeit.py
 
22647
+++ b/Lib/test/test_timeit.py
 
22648
@@ -250,6 +250,7 @@
 
22649
         s = self.run_main(seconds_per_increment=60.0, switches=['-r-5'])
 
22650
         self.assertEqual(s, "10 loops, best of 1: 60 sec per loop\n")
 
22651
 
 
22652
+    @unittest.skipIf(sys.flags.optimize >= 2, "need __doc__")
 
22653
     def test_main_help(self):
 
22654
         s = self.run_main(switches=['-h'])
 
22655
         # Note: It's not clear that the trailing space was intended as part of
18683
22656
diff -r 3d0686d90f55 Lib/test/test_timeout.py
18684
22657
--- a/Lib/test/test_timeout.py
18685
22658
+++ b/Lib/test/test_timeout.py
19308
23281
         QueryValueEx(HKEY_PERFORMANCE_DATA, "")
19309
23282
 
19310
23283
     # Reflection requires XP x64/Vista at a minimum. XP doesn't have this stuff
 
23284
diff -r 3d0686d90f55 Lib/test/test_wsgiref.py
 
23285
--- a/Lib/test/test_wsgiref.py
 
23286
+++ b/Lib/test/test_wsgiref.py
 
23287
@@ -39,9 +39,6 @@
 
23288
         pass
 
23289
 
 
23290
 
 
23291
-
 
23292
-
 
23293
-
 
23294
 def hello_app(environ,start_response):
 
23295
     start_response("200 OK", [
 
23296
         ('Content-Type','text/plain'),
 
23297
@@ -63,28 +60,6 @@
 
23298
 
 
23299
     return out.getvalue(), err.getvalue()
 
23300
 
 
23301
-
 
23302
-
 
23303
-
 
23304
-
 
23305
-
 
23306
-
 
23307
-
 
23308
-
 
23309
-
 
23310
-
 
23311
-
 
23312
-
 
23313
-
 
23314
-
 
23315
-
 
23316
-
 
23317
-
 
23318
-
 
23319
-
 
23320
-
 
23321
-
 
23322
-
 
23323
 def compare_generic_iter(make_it,match):
 
23324
     """Utility to compare a generic 2.1/2.2+ iterator with an iterable
 
23325
 
 
23326
@@ -122,10 +97,6 @@
 
23327
             raise AssertionError("Too many items from .__next__()", it)
 
23328
 
 
23329
 
 
23330
-
 
23331
-
 
23332
-
 
23333
-
 
23334
 class IntegrationTests(TestCase):
 
23335
 
 
23336
     def check_hello(self, out, has_length=True):
 
23337
@@ -195,8 +166,6 @@
 
23338
                 out)
 
23339
 
 
23340
 
 
23341
-
 
23342
-
 
23343
 class UtilityTests(TestCase):
 
23344
 
 
23345
     def checkShift(self,sn_in,pi_in,part,sn_out,pi_out):
 
23346
@@ -235,11 +204,6 @@
 
23347
         util.setup_testing_defaults(kw)
 
23348
         self.assertEqual(util.request_uri(kw,query),uri)
 
23349
 
 
23350
-
 
23351
-
 
23352
-
 
23353
-
 
23354
-
 
23355
     def checkFW(self,text,size,match):
 
23356
 
 
23357
         def make_it(text=text,size=size):
 
23358
@@ -258,7 +222,6 @@
 
23359
         it.close()
 
23360
         self.assertTrue(it.filelike.closed)
 
23361
 
 
23362
-
 
23363
     def testSimpleShifts(self):
 
23364
         self.checkShift('','/', '', '/', '')
 
23365
         self.checkShift('','/x', 'x', '/x', '')
 
23366
@@ -266,7 +229,6 @@
 
23367
         self.checkShift('/a','/x/y', 'x', '/a/x', '/y')
 
23368
         self.checkShift('/a','/x/',  'x', '/a/x', '/')
 
23369
 
 
23370
-
 
23371
     def testNormalizedShifts(self):
 
23372
         self.checkShift('/a/b', '/../y', '..', '/a', '/y')
 
23373
         self.checkShift('', '/../y', '..', '', '/y')
 
23374
@@ -280,7 +242,6 @@
 
23375
         self.checkShift('/a/b', '/x//', 'x', '/a/b/x', '/')
 
23376
         self.checkShift('/a/b', '/.', None, '/a/b', '')
 
23377
 
 
23378
-
 
23379
     def testDefaults(self):
 
23380
         for key, value in [
 
23381
             ('SERVER_NAME','127.0.0.1'),
 
23382
@@ -300,7 +261,6 @@
 
23383
         ]:
 
23384
             self.checkDefault(key,value)
 
23385
 
 
23386
-
 
23387
     def testCrossDefaults(self):
 
23388
         self.checkCrossDefault('HTTP_HOST',"foo.bar",SERVER_NAME="foo.bar")
 
23389
         self.checkCrossDefault('wsgi.url_scheme',"https",HTTPS="on")
 
23390
@@ -310,7 +270,6 @@
 
23391
         self.checkCrossDefault('SERVER_PORT',"80",HTTPS="foo")
 
23392
         self.checkCrossDefault('SERVER_PORT',"443",HTTPS="on")
 
23393
 
 
23394
-
 
23395
     def testGuessScheme(self):
 
23396
         self.assertEqual(util.guess_scheme({}), "http")
 
23397
         self.assertEqual(util.guess_scheme({'HTTPS':"foo"}), "http")
 
23398
@@ -318,10 +277,6 @@
 
23399
         self.assertEqual(util.guess_scheme({'HTTPS':"yes"}), "https")
 
23400
         self.assertEqual(util.guess_scheme({'HTTPS':"1"}), "https")
 
23401
 
 
23402
-
 
23403
-
 
23404
-
 
23405
-
 
23406
     def testAppURIs(self):
 
23407
         self.checkAppURI("http://127.0.0.1/")
 
23408
         self.checkAppURI("http://127.0.0.1/spam", SCRIPT_NAME="/spam")
 
23409
@@ -446,15 +401,6 @@
 
23410
         raise   # for testing, we want to see what's happening
 
23411
 
 
23412
 
 
23413
-
 
23414
-
 
23415
-
 
23416
-
 
23417
-
 
23418
-
 
23419
-
 
23420
-
 
23421
-
 
23422
 class HandlerTests(TestCase):
 
23423
 
 
23424
     def checkEnvironAttrs(self, handler):
 
23425
@@ -495,7 +441,6 @@
 
23426
         h=TestHandler(); h.setup_environ()
 
23427
         self.assertEqual(h.environ['wsgi.url_scheme'],'http')
 
23428
 
 
23429
-
 
23430
     def testAbstractMethods(self):
 
23431
         h = BaseHandler()
 
23432
         for name in [
 
23433
@@ -504,7 +449,6 @@
 
23434
             self.assertRaises(NotImplementedError, getattr(h,name))
 
23435
         self.assertRaises(NotImplementedError, h._write, "test")
 
23436
 
 
23437
-
 
23438
     def testContentLength(self):
 
23439
         # Demo one reason iteration is better than write()...  ;)
 
23440
 
 
23441
@@ -596,7 +540,6 @@
 
23442
             "\r\n".encode("iso-8859-1")+MSG))
 
23443
         self.assertIn("AssertionError", h.stderr.getvalue())
 
23444
 
 
23445
-
 
23446
     def testHeaderFormats(self):
 
23447
 
 
23448
         def non_error_app(e,s):
 
23449
@@ -656,40 +599,27 @@
 
23450
             b"data",
 
23451
             h.stdout.getvalue())
 
23452
 
 
23453
-# This epilogue is needed for compatibility with the Python 2.5 regrtest module
 
23454
+    def testCloseOnError(self):
 
23455
+        side_effects = {'close_called': False}
 
23456
+        MSG = b"Some output has been sent"
 
23457
+        def error_app(e,s):
 
23458
+            s("200 OK",[])(MSG)
 
23459
+            class CrashyIterable(object):
 
23460
+                def __iter__(self):
 
23461
+                    while True:
 
23462
+                        yield b'blah'
 
23463
+                        raise AssertionError("This should be caught by handler")
 
23464
+                def close(self):
 
23465
+                    side_effects['close_called'] = True
 
23466
+            return CrashyIterable()
 
23467
+
 
23468
+        h = ErrorHandler()
 
23469
+        h.run(error_app)
 
23470
+        self.assertEqual(side_effects['close_called'], True)
 
23471
+
 
23472
 
 
23473
 def test_main():
 
23474
     support.run_unittest(__name__)
 
23475
 
 
23476
 if __name__ == "__main__":
 
23477
     test_main()
 
23478
-
 
23479
-
 
23480
-
 
23481
-
 
23482
-
 
23483
-
 
23484
-
 
23485
-
 
23486
-
 
23487
-
 
23488
-
 
23489
-
 
23490
-
 
23491
-
 
23492
-
 
23493
-
 
23494
-
 
23495
-
 
23496
-
 
23497
-
 
23498
-
 
23499
-
 
23500
-
 
23501
-
 
23502
-
 
23503
-
 
23504
-
 
23505
-
 
23506
-
 
23507
-# the above lines intentionally left blank
19311
23508
diff -r 3d0686d90f55 Lib/test/test_xml_etree.py
19312
23509
--- a/Lib/test/test_xml_etree.py
19313
23510
+++ b/Lib/test/test_xml_etree.py
19652
23849
                         expected_dir = os.path.dirname(full_path)
19653
23850
                         msg = ("%r module incorrectly imported from %r. Expected %r. "
19654
23851
                                "Is this module globally installed?")
 
23852
diff -r 3d0686d90f55 Lib/unittest/runner.py
 
23853
--- a/Lib/unittest/runner.py
 
23854
+++ b/Lib/unittest/runner.py
 
23855
@@ -35,7 +35,7 @@
 
23856
     separator2 = '-' * 70
 
23857
 
 
23858
     def __init__(self, stream, descriptions, verbosity):
 
23859
-        super(TextTestResult, self).__init__()
 
23860
+        super(TextTestResult, self).__init__(stream, descriptions, verbosity)
 
23861
         self.stream = stream
 
23862
         self.showAll = verbosity > 1
 
23863
         self.dots = verbosity == 1
 
23864
diff -r 3d0686d90f55 Lib/unittest/test/test_runner.py
 
23865
--- a/Lib/unittest/test/test_runner.py
 
23866
+++ b/Lib/unittest/test/test_runner.py
 
23867
@@ -149,6 +149,19 @@
 
23868
         self.assertEqual(runner.resultclass, unittest.TextTestResult)
 
23869
 
 
23870
 
 
23871
+    def test_multiple_inheritance(self):
 
23872
+        class AResult(unittest.TestResult):
 
23873
+            def __init__(self, stream, descriptions, verbosity):
 
23874
+                super(AResult, self).__init__(stream, descriptions, verbosity)
 
23875
+
 
23876
+        class ATextResult(unittest.TextTestResult, AResult):
 
23877
+            pass
 
23878
+
 
23879
+        # This used to raise an exception due to TextTestResult not passing
 
23880
+        # on arguments in its __init__ super call
 
23881
+        ATextResult(None, None, 1)
 
23882
+
 
23883
+
 
23884
     def testBufferAndFailfast(self):
 
23885
         class Test(unittest.TestCase):
 
23886
             def testFoo(self):
19655
23887
diff -r 3d0686d90f55 Lib/unittest/test/test_skipping.py
19656
23888
--- a/Lib/unittest/test/test_skipping.py
19657
23889
+++ b/Lib/unittest/test/test_skipping.py
19820
24052
             if not request.has_header('Content-type'):
19821
24053
                 request.add_unredirected_header(
19822
24054
                     'Content-type',
 
24055
@@ -2207,13 +2212,7 @@
 
24056
         return (ftpobj, retrlen)
 
24057
 
 
24058
     def endtransfer(self):
 
24059
-        if not self.busy:
 
24060
-            return
 
24061
         self.busy = 0
 
24062
-        try:
 
24063
-            self.ftp.voidresp()
 
24064
-        except ftperrors():
 
24065
-            pass
 
24066
 
 
24067
     def close(self):
 
24068
         self.keepalive = False
19823
24069
diff -r 3d0686d90f55 Lib/urllib/response.py
19824
24070
--- a/Lib/urllib/response.py
19825
24071
+++ b/Lib/urllib/response.py
19889
24135
         success = self._invoke(args, True, autoraise)
19890
24136
         if not success:
19891
24137
             # remote invocation failed, try straight way
 
24138
diff -r 3d0686d90f55 Lib/wsgiref/handlers.py
 
24139
--- a/Lib/wsgiref/handlers.py
 
24140
+++ b/Lib/wsgiref/handlers.py
 
24141
@@ -174,11 +174,13 @@
 
24142
         in the event loop to iterate over the data, and to call
 
24143
         'self.close()' once the response is finished.
 
24144
         """
 
24145
-        if not self.result_is_file() or not self.sendfile():
 
24146
-            for data in self.result:
 
24147
-                self.write(data)
 
24148
-            self.finish_content()
 
24149
-        self.close()
 
24150
+        try:
 
24151
+            if not self.result_is_file() or not self.sendfile():
 
24152
+                for data in self.result:
 
24153
+                    self.write(data)
 
24154
+                self.finish_content()
 
24155
+        finally:
 
24156
+            self.close()
 
24157
 
 
24158
 
 
24159
     def get_scheme(self):
19892
24160
diff -r 3d0686d90f55 Lib/xml/etree/ElementTree.py
19893
24161
--- a/Lib/xml/etree/ElementTree.py
19894
24162
+++ b/Lib/xml/etree/ElementTree.py
20014
24282
diff -r 3d0686d90f55 Makefile.pre.in
20015
24283
--- a/Makefile.pre.in
20016
24284
+++ b/Makefile.pre.in
20017
 
@@ -59,6 +59,8 @@
 
24285
@@ -27,6 +27,9 @@
 
24286
 VERSION=       @VERSION@
 
24287
 srcdir=                @srcdir@
 
24288
 VPATH=         @srcdir@
 
24289
+abs_srcdir=    @abs_srcdir@
 
24290
+abs_builddir=  @abs_builddir@
 
24291
+
 
24292
 
 
24293
 CC=            @CC@
 
24294
 CXX=           @CXX@
 
24295
@@ -59,11 +62,14 @@
20018
24296
 # Also, making them read-only seems to be a good idea...
20019
24297
 INSTALL_SHARED= ${INSTALL} -m 555
20020
24298
 
20023
24301
 MAKESETUP=      $(srcdir)/Modules/makesetup
20024
24302
 
20025
24303
 # Compiler options
20026
 
@@ -161,7 +163,7 @@
 
24304
 OPT=           @OPT@
 
24305
 BASECFLAGS=    @BASECFLAGS@
 
24306
+BASECPPFLAGS=  @BASECPPFLAGS@
 
24307
 CONFIGURE_CFLAGS=      @CFLAGS@
 
24308
 CONFIGURE_CPPFLAGS=    @CPPFLAGS@
 
24309
 CONFIGURE_LDFLAGS=     @LDFLAGS@
 
24310
@@ -74,7 +80,7 @@
 
24311
 # Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
 
24312
 # be able to build extension modules using the directories specified in the
 
24313
 # environment variables
 
24314
-PY_CPPFLAGS=   -I. -IInclude -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)
 
24315
+PY_CPPFLAGS=   $(BASECPPFLAGS) -I. -IInclude -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)
 
24316
 PY_LDFLAGS=    $(CONFIGURE_LDFLAGS) $(LDFLAGS)
 
24317
 NO_AS_NEEDED=  @NO_AS_NEEDED@
 
24318
 LDLAST=                @LDLAST@
 
24319
@@ -161,7 +167,7 @@
20027
24320
 SUBDIRSTOO=    Include Lib Misc
20028
24321
 
20029
24322
 # Files and directories to be distributed
20032
24325
 DISTFILES=     README ChangeLog $(CONFIGFILES)
20033
24326
 DISTDIRS=      $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
20034
24327
 DIST=          $(DISTFILES) $(DISTDIRS)
20035
 
@@ -223,8 +225,8 @@
 
24328
@@ -223,8 +229,8 @@
20036
24329
 
20037
24330
 ##########################################################################
20038
24331
 # Grammar
20043
24336
 GRAMMAR_INPUT= $(srcdir)/Grammar/Grammar
20044
24337
 
20045
24338
 
20046
 
@@ -266,9 +268,9 @@
 
24339
@@ -266,9 +272,9 @@
20047
24340
 
20048
24341
 ##########################################################################
20049
24342
 # AST
20055
24348
 AST_C=         $(AST_C_DIR)/Python-ast.c
20056
24349
 AST_ASDL=      $(srcdir)/Parser/Python.asdl
20057
24350
 
20058
 
@@ -435,11 +437,15 @@
 
24351
@@ -280,7 +286,7 @@
 
24352
 # Python
 
24353
 
 
24354
 OPCODETARGETS_H= \
 
24355
-               $(srcdir)/Python/opcode_targets.h
 
24356
+               Python/opcode_targets.h
 
24357
 
 
24358
 OPCODETARGETGEN= \
 
24359
                $(srcdir)/Python/makeopcodetargets.py
 
24360
@@ -435,11 +441,15 @@
20059
24361
 
20060
24362
 
20061
24363
 # Build the shared modules
20075
24377
 
20076
24378
 # Build static library
20077
24379
 # avoid long command lines, same as LIBRARY_OBJS
20078
 
@@ -605,9 +611,11 @@
 
24380
@@ -605,9 +615,11 @@
20079
24381
 Parser/pgenmain.o:     $(srcdir)/Include/parsetok.h
20080
24382
 
20081
24383
 $(AST_H): $(AST_ASDL) $(ASDLGEN_FILES)
20087
24389
        $(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL)
20088
24390
 
20089
24391
 Python/compile.o Python/symtable.o Python/ast.o: $(GRAMMAR_H) $(AST_H)
20090
 
@@ -917,7 +925,8 @@
 
24392
@@ -655,9 +667,9 @@
 
24393
                                $(BYTESTR_DEPS) \
 
24394
                                $(srcdir)/Objects/stringlib/formatter.h
 
24395
 
 
24396
-Objects/typeobject.o: $(srcdir)/Objects/typeslots.inc
 
24397
-$(srcdir)/Objects/typeslots.inc: $(srcdir)/Include/typeslots.h $(srcdir)/Objects/typeslots.py
 
24398
-       $(PYTHON) $(srcdir)/Objects/typeslots.py < $(srcdir)/Include/typeslots.h > $(srcdir)/Objects/typeslots.inc
 
24399
+Objects/typeobject.o: Objects/typeslots.inc
 
24400
+Objects/typeslots.inc: $(srcdir)/Include/typeslots.h $(srcdir)/Objects/typeslots.py
 
24401
+       $(PYTHON) $(srcdir)/Objects/typeslots.py < $(srcdir)/Include/typeslots.h > Objects/typeslots.inc
 
24402
 
 
24403
 ############################################################################
 
24404
 # Header files
 
24405
@@ -917,7 +929,8 @@
20091
24406
 LIBSUBDIRS=    tkinter tkinter/test tkinter/test/test_tkinter \
20092
24407
                tkinter/test/test_ttk site-packages test \
20093
24408
                test/capath test/data \
20097
24412
                test/tracedmodules test/encoded_modules \
20098
24413
                concurrent concurrent/futures encodings \
20099
24414
                email email/mime email/test email/test/data \
20100
 
@@ -1014,7 +1023,9 @@
 
24415
@@ -1014,7 +1027,9 @@
20101
24416
                -d $(LIBDEST)/site-packages -f \
20102
24417
                -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
20103
24418
        -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
20108
24423
 
20109
24424
 # Create the PLATDIR source directory, if one wasn't distributed..
20110
24425
 $(srcdir)/Lib/$(PLATDIR):
20111
 
@@ -1157,8 +1168,11 @@
 
24426
@@ -1157,8 +1172,11 @@
20112
24427
 # Install a number of symlinks to keep software that expects a normal unix
20113
24428
 # install (which includes python-config) happy.
20114
24429
 frameworkinstallmaclib:
20120
24435
        ln -fs "../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/libpython$(VERSION).dylib"
20121
24436
 
20122
24437
 # This installs the IDE, the Launcher and other apps into /Applications
20123
 
@@ -1210,7 +1224,7 @@
 
24438
@@ -1210,7 +1228,7 @@
20124
24439
        $(SHELL) config.status --recheck
20125
24440
        $(SHELL) config.status
20126
24441
 
20141
24456
 David Abrahams
20142
24457
 Ron Adam
20143
24458
 Jim Ahlstrom
20144
 
@@ -19,24 +21,30 @@
 
24459
@@ -19,19 +21,24 @@
20145
24460
 Nir Aides
20146
24461
 Yaniv Aknin
20147
24462
 Jyrki Alakuijala
20166
24481
 Éric Araujo
20167
24482
 Alicia Arlen
20168
24483
 Jason Asbahr
20169
 
 David Ascher
20170
 
 Chris AtLee
20171
 
+Jesús Cea Avión
 
24484
@@ -40,6 +47,7 @@
20172
24485
 John Aycock
20173
24486
 Jan-Hein Bührman
20174
24487
 Donovan Baarda
 
24488
+Arne Babenhauserheide
 
24489
 Attila Babo
 
24490
 Alfonso Baciero
 
24491
 Marcin Bachry
20175
24492
@@ -48,16 +56,20 @@
20176
24493
 Greg Ball
20177
24494
 Luigi Ballabio
20193
24510
 Nick Bastin
20194
24511
 Jeff Bauer
20195
24512
 Mike Bayer
20196
 
@@ -78,6 +90,7 @@
 
24513
@@ -76,8 +88,10 @@
 
24514
 Thomas Bellman
 
24515
 Alexander “Саша” Belopolsky
20197
24516
 Eli Bendersky
 
24517
+David Benjamin
20198
24518
 Andrew Bennetts
20199
24519
 Andy Bensky
20200
24520
+Bennett Benson
20201
24521
 Michel Van den Bergh
20202
24522
 Julian Berman
20203
24523
 Brice Berna
20204
 
@@ -92,6 +105,7 @@
 
24524
@@ -92,6 +106,7 @@
20205
24525
 Philippe Biondi
20206
24526
 Stuart Bishop
20207
24527
 Roy Bixler
20209
24529
 Mike Bland
20210
24530
 Martin Bless
20211
24531
 Pablo Bleyer
20212
 
@@ -100,6 +114,7 @@
 
24532
@@ -100,6 +115,7 @@
20213
24533
 Finn Bock
20214
24534
 Paul Boddie
20215
24535
 Matthew Boedicker
20217
24537
 David Bolen
20218
24538
 Forest Bond
20219
24539
 Gawain Bolton
20220
 
@@ -109,7 +124,9 @@
 
24540
@@ -109,7 +125,9 @@
20221
24541
 Eric Bouck
20222
24542
 Thierry Bousch
20223
24543
 Sebastian Boving
20227
24547
 Monty Brandenberg
20228
24548
 Georg Brandl
20229
24549
 Christopher Brannon
20230
 
@@ -117,6 +134,7 @@
 
24550
@@ -117,6 +135,7 @@
20231
24551
 Brian Brazil
20232
24552
 Dave Brennan
20233
24553
 Tom Bridgman
20235
24555
 Tobias Brink
20236
24556
 Richard Brodie
20237
24557
 Michael Broghton
20238
 
@@ -126,6 +144,7 @@
 
24558
@@ -126,6 +145,7 @@
20239
24559
 Oleg Broytmann
20240
24560
 Dave Brueck
20241
24561
 Francisco Martín Brugué
20243
24563
 Floris Bruynooghe
20244
24564
 Stan Bubrouski
20245
24565
 Erik de Bueger
20246
 
@@ -145,10 +164,13 @@
 
24566
@@ -145,10 +165,14 @@
20247
24567
 Brett Cannon
20248
24568
 Mike Carlton
20249
24569
 Terry Carroll
20251
24571
 Lorenzo M. Catucci
20252
24572
 Donn Cave
20253
24573
 Charles Cazabon
 
24574
+Jesús Cea Avión
20254
24575
 Per Cederqvist
20255
24576
+Matej Cepl
20256
24577
+Carl Cerecke
20257
24578
 Octavian Cerna
20258
24579
 Pascal Chambon
20259
24580
 John Chandler
20260
 
@@ -167,12 +189,15 @@
 
24581
@@ -167,12 +191,15 @@
20261
24582
 Anders Chrigström
20262
24583
 Tom Christiansen
20263
24584
 Vadim Chugunov
20273
24594
 Nick Coghlan
20274
24595
 Josh Cogliati
20275
24596
 Dave Cole
20276
 
@@ -199,6 +224,7 @@
 
24597
@@ -199,8 +226,10 @@
20277
24598
 Matthew Dixon Cowles
20278
24599
 Ryan Coyner
20279
24600
 Christopher A. Craig
20280
24601
+Jeremy Craven
20281
24602
 Laura Creighton
20282
24603
 Simon Cross
 
24604
+Felipe Cruz
20283
24605
 Drew Csillag
20284
 
@@ -214,6 +240,7 @@
 
24606
 Joaquin Cuenca Abela
 
24607
 John Cugini
 
24608
@@ -214,6 +243,7 @@
20285
24609
 Eric Daniel
20286
24610
 Scott David Daniels
20287
24611
 Ben Darnell
20289
24613
 Jonathan Dasteel
20290
24614
 John DeGood
20291
24615
 Ned Deily
20292
 
@@ -221,6 +248,7 @@
 
24616
@@ -221,6 +251,7 @@
20293
24617
 Arnaud Delobelle
20294
24618
 Erik Demaine
20295
24619
 John Dennis
20297
24621
 Roger Dev
20298
24622
 Philippe Devalkeneer
20299
24623
 Raghuram Devarakonda
20300
 
@@ -236,6 +264,7 @@
 
24624
@@ -236,6 +267,7 @@
20301
24625
 Daniel Dittmar
20302
24626
 Jaromir Dolecek
20303
24627
 Ismail Donmez
20305
24629
 Marcos Donolo
20306
24630
 Dima Dorfman
20307
24631
 Yves Dorfsman
20308
 
@@ -245,6 +274,7 @@
 
24632
@@ -245,6 +277,7 @@
20309
24633
 Derk Drukker
20310
24634
 John DuBois
20311
24635
 Paul Dubois
20313
24637
 Graham Dumpleton
20314
24638
 Quinn Dunkan
20315
24639
 Robin Dunn
20316
 
@@ -292,25 +322,31 @@
 
24640
@@ -292,25 +325,31 @@
20317
24641
 Sebastian Fernandez
20318
24642
 Florian Festi
20319
24643
 John Feuerstein
20345
24669
 Geoff Furnish
20346
24670
 Ulisses Furquim
20347
24671
 Hagen Fürstenau
20348
 
@@ -320,6 +356,7 @@
 
24672
@@ -320,6 +359,7 @@
20349
24673
 Lele Gaifax
20350
24674
 Santiago Gala
20351
24675
 Yitzchak Gale
20353
24677
 Quentin Gallet-Gilles
20354
24678
 Riccardo Attilio Galli
20355
24679
 Raymund Galvin
20356
 
@@ -329,27 +366,35 @@
 
24680
@@ -329,27 +369,35 @@
20357
24681
 Dan Gass
20358
24682
 Andrew Gaul
20359
24683
 Stephen M. Gava
20389
24713
 Michael Guravage
20390
24714
 Lars Gustäbel
20391
24715
 Thomas Güttler
20392
 
@@ -362,7 +407,9 @@
 
24716
@@ -362,7 +410,9 @@
20393
24717
 Bob Halley
20394
24718
 Jesse Hallio
20395
24719
 Jun Hamano
20399
24723
 Manus Hand
20400
24724
 Milton L. Hankins
20401
24725
 Stephen Hansen
20402
 
@@ -371,8 +418,11 @@
 
24726
@@ -371,8 +421,11 @@
20403
24727
 Derek Harland
20404
24728
 Jason Harper
20405
24729
 Brian Harring
20411
24735
 Rycharde Hawkes
20412
24736
 Ben Hayden
20413
24737
 Jochen Hayek
20414
 
@@ -401,9 +451,13 @@
 
24738
@@ -401,9 +454,13 @@
20415
24739
 Joerg-Cyril Hoehle
20416
24740
 Gregor Hoffleit
20417
24741
 Chris Hoffman
20425
24749
 Gerrit Holl
20426
24750
 Shane Holloway
20427
24751
 Rune Holm
20428
 
@@ -426,15 +480,18 @@
 
24752
@@ -426,15 +483,18 @@
20429
24753
 Greg Humphreys
20430
24754
 Eric Huss
20431
24755
 Jeremy Hylton
20444
24768
 Atsuo Ishimoto
20445
24769
 Adam Jackson
20446
24770
 Ben Jackson
20447
 
@@ -447,12 +504,17 @@
 
24771
@@ -447,12 +507,17 @@
20448
24772
 Jack Jansen
20449
24773
 Bill Janssen
20450
24774
 Thomas Jarosch
20462
24786
 Simon Johnston
20463
24787
 Matt Joiner
20464
24788
 Thomas Jollans
20465
 
@@ -467,6 +529,7 @@
 
24789
@@ -467,6 +532,7 @@
20466
24790
 Sijin Joseph
20467
24791
 Andreas Jung
20468
24792
 Tattoo Mabonzo K.
20470
24794
 Bob Kahn
20471
24795
 Kurt B. Kaiser
20472
24796
 Tamito Kajiyama
20473
 
@@ -474,7 +537,6 @@
 
24797
@@ -474,7 +540,6 @@
20474
24798
 Rafe Kaplan
20475
24799
 Jacob Kaplan-Moss
20476
24800
 Jan Kaliszewski
20478
24802
 Lou Kates
20479
24803
 Hiroaki Kawai
20480
24804
 Sebastien Keim
20481
 
@@ -482,16 +544,19 @@
 
24805
@@ -482,16 +547,19 @@
20482
24806
 Dan Kenigsberg
20483
24807
 Robert Kern
20484
24808
 Randall Kern
20499
24823
 Ron Klatchko
20500
24824
 Reid Kleckner
20501
24825
 Bastian Kleineidam
20502
 
@@ -502,11 +567,17 @@
 
24826
@@ -502,11 +570,17 @@
20503
24827
 Kim Knapp
20504
24828
 Lenny Kneler
20505
24829
 Pat Knight
20517
24841
 Maksim Kozyarchuk
20518
24842
 Stefan Krah
20519
24843
 Bob Kras
20520
 
@@ -518,9 +589,12 @@
 
24844
@@ -518,9 +592,12 @@
20521
24845
 Andrej Krpic
20522
24846
 Ivan Krstić
20523
24847
 Andrew Kuchling
20530
24854
 Jean-Baptiste "Jiba" Lamy
20531
24855
 Torsten Landschoff
20532
24856
 Łukasz Langa
20533
 
@@ -531,6 +605,7 @@
 
24857
@@ -531,6 +608,7 @@
20534
24858
 Piers Lauder
20535
24859
 Ben Laurie
20536
24860
 Simon Law
20538
24862
 Chris Lawrence
20539
24863
 Brian Leair
20540
24864
 James Lee
20541
 
@@ -540,28 +615,35 @@
 
24865
@@ -540,28 +618,35 @@
20542
24866
 Christopher Lee
20543
24867
 Tennessee Leeuwenburg
20544
24868
 Luc Lefebvre
20575
24899
 Nick Lockwood
20576
24900
 Stephanie Lockwood
20577
24901
 Anne Lord
20578
 
@@ -577,6 +659,8 @@
 
24902
@@ -577,6 +662,8 @@
20579
24903
 Jim Lynch
20580
24904
 Mikael Lyngvig
20581
24905
 Martin von Löwis
20584
24908
 Andrew I MacIntyre
20585
24909
 Tim MacKenzie
20586
24910
 Nick Maclaren
20587
 
@@ -586,17 +670,23 @@
 
24911
@@ -586,17 +673,23 @@
20588
24912
 David Malcolm
20589
24913
 Ken Manheimer
20590
24914
 Vladimir Marangozov
20608
24932
 Kirk McDonald
20609
24933
 Chris McDonough
20610
24934
 Greg McFarlane
20611
 
@@ -611,14 +701,18 @@
 
24935
@@ -611,14 +704,18 @@
20612
24936
 Bill van Melle
20613
24937
 Lucas Prado Melo
20614
24938
 Ezio Melotti
20627
24951
 Damien Miller
20628
24952
 Chad Miller
20629
24953
 Jason V. Miller
20630
 
@@ -627,12 +721,15 @@
 
24954
@@ -627,12 +724,15 @@
20631
24955
 Andrii V. Mishkovskyi
20632
24956
 Dustin J. Mitchell
20633
24957
 Dom Mitchell
20643
24967
 Pablo Mouzo
20644
24968
 Mher Movsisyan
20645
24969
 Ruslan Mstoi
20646
 
@@ -642,6 +739,7 @@
 
24970
@@ -642,6 +742,7 @@
20647
24971
 Neil Muller
20648
24972
 R. David Murray
20649
24973
 Piotr Meyer
20651
24975
 John Nagle
20652
24976
 Takahiro Nakayama
20653
24977
 Travers Naran
20654
 
@@ -665,17 +763,21 @@
 
24978
@@ -665,17 +766,21 @@
20655
24979
 Tim Northover
20656
24980
 Joe Norton
20657
24981
 Neal Norwitz
20673
24997
 Jason Orendorff
20674
24998
 Douglas Orr
20675
24999
 Michele Orrù
20676
 
@@ -685,6 +787,8 @@
 
25000
@@ -685,6 +790,8 @@
20677
25001
 Michael Otteneder
20678
25002
 R. M. Oudkerk
20679
25003
 Russel Owen
20682
25006
 Ondrej Palkovsky
20683
25007
 Mike Pall
20684
25008
 Todd R. Palmer
20685
 
@@ -694,7 +798,10 @@
 
25009
@@ -694,7 +801,10 @@
20686
25010
 Peter Parente
20687
25011
 Alexandre Parenteau
20688
25012
 Dan Parisien
20693
25017
 Randy Pausch
20694
25018
 Samuele Pedroni
20695
25019
 Marcel van der Peijl
20696
 
@@ -708,6 +815,7 @@
 
25020
@@ -708,6 +818,7 @@
20697
25021
 Joe Peterson
20698
25022
 Chris Petrilli
20699
25023
 Bjorn Pettersen
20701
25025
 Geoff Philbrick
20702
25026
 Gavrie Philipson
20703
25027
 Adrian Phillips
20704
 
@@ -744,12 +852,12 @@
 
25028
@@ -744,12 +855,12 @@
20705
25029
 Antti Rasinen
20706
25030
 Sridhar Ratnakumar
20707
25031
 Ysj Ray
20716
25040
 Gareth Rees
20717
25041
 Steve Reeves
20718
25042
 Lennart Regebro
20719
 
@@ -759,6 +867,7 @@
 
25043
@@ -759,6 +870,7 @@
20720
25044
 Bernhard Reiter
20721
25045
 Steven Reiz
20722
25046
 Roeland Rengelink
20724
25048
 Tim Rice
20725
25049
 Francesco Ricciardi
20726
25050
 Jan Pieter Riegel
20727
 
@@ -766,6 +875,7 @@
 
25051
@@ -766,6 +878,7 @@
20728
25052
 Nicholas Riley
20729
25053
 Jean-Claude Rimbault
20730
25054
 Vlad Riscutia
20732
25056
 Juan M. Bello Rivas
20733
25057
 Davide Rizzo
20734
25058
 Anthony Roach
20735
 
@@ -776,11 +886,13 @@
 
25059
@@ -776,16 +889,19 @@
20736
25060
 Mark Roddy
20737
25061
 Kevin Rodgers
20738
25062
 Giampaolo Rodola
20746
25070
 Just van Rossum
20747
25071
 Hugo van Rossum
20748
25072
 Saskia van Rossum
20749
 
@@ -797,6 +909,8 @@
 
25073
 Donald Wallace Rouse II
 
25074
 Liam Routt
 
25075
+Todd Rovito
 
25076
 Craig Rowland
 
25077
 Clinton Roy
 
25078
 Paul Rubin
 
25079
@@ -797,6 +913,8 @@
20750
25080
 Sam Rushing
20751
25081
 Mark Russell
20752
25082
 Nick Russo
20755
25085
 Sébastien Sablé
20756
25086
 Suman Saha
20757
25087
 Hajime Saitou
20758
 
@@ -807,6 +921,8 @@
 
25088
@@ -807,6 +925,8 @@
20759
25089
 Ilya Sandler
20760
25090
 Mark Sapiro
20761
25091
 Ty Sarna
20764
25094
 Ben Sayer
20765
25095
 sbt
20766
25096
 Marco Scataglini
20767
 
@@ -822,6 +938,8 @@
 
25097
@@ -822,6 +942,8 @@
20768
25098
 Michael Schneider
20769
25099
 Peter Schneider-Kamp
20770
25100
 Arvin Schnell
20773
25103
 Chad J. Schroeder
20774
25104
 Sam Schulenburg
20775
25105
 Stefan Schwarzer
20776
 
@@ -830,16 +948,20 @@
 
25106
@@ -830,16 +952,20 @@
20777
25107
 Steven Scott
20778
25108
 Barry Scott
20779
25109
 Nick Seidenman
20795
25125
 Bruce Sherwood
20796
25126
 Alexander Shigin
20797
25127
 Pete Shinners
20798
 
@@ -847,30 +969,41 @@
 
25128
@@ -847,30 +973,41 @@
20799
25129
 John W. Shipman
20800
25130
 Joel Shprentz
20801
25131
 Itamar Shtull-Trauring
20837
25167
 Oliver Steele
20838
25168
 Greg Stein
20839
25169
 Chris Stern
20840
 
@@ -879,13 +1012,16 @@
 
25170
@@ -879,13 +1016,16 @@
20841
25171
 Peter Stoehr
20842
25172
 Casper Stoel
20843
25173
 Michael Stone
20854
25184
 Hisao Suzuki
20855
25185
 Kalle Svensson
20856
25186
 Andrew Svetlov
20857
 
@@ -916,6 +1052,7 @@
 
25187
@@ -916,6 +1056,7 @@
20858
25188
 Oren Tirosh
20859
25189
 Jason Tishler
20860
25190
 Christian Tismer
20862
25192
 Frank J. Tobin
20863
25193
 R Lindsay Todd
20864
25194
 Bennett Todd
20865
 
@@ -928,6 +1065,7 @@
 
25195
@@ -926,8 +1067,10 @@
 
25196
 Laurence Tratt
 
25197
 John Tromp
20866
25198
 Jason Trowbridge
 
25199
+Brent Tubbs
20867
25200
 Anthony Tuininga
20868
25201
 Erno Tukia
20869
25202
+David Turner
20870
25203
 Stephen Turner
20871
25204
 Theodore Turocy
20872
25205
 Bill Tutt
20873
 
@@ -938,6 +1076,7 @@
 
25206
@@ -938,6 +1081,7 @@
20874
25207
 Daniel Urban
20875
25208
 Michael Urman
20876
25209
 Hector Urtubia
20878
25211
 Andi Vajda
20879
25212
 Case Van Horsen
20880
25213
 Kyle VanderBeek
20881
 
@@ -958,6 +1097,7 @@
 
25214
@@ -958,6 +1102,7 @@
20882
25215
 Norman Vine
20883
25216
 Frank Visser
20884
25217
 Johannes Vogel
20886
25219
 Sjoerd de Vries
20887
25220
 Niki W. Waibel
20888
25221
 Wojtek Walczak
20889
 
@@ -967,6 +1107,7 @@
 
25222
@@ -967,6 +1112,7 @@
20890
25223
 Kevin Walzer
20891
25224
 Rodrigo Steinmuller Wanderley
20892
25225
 Greg Ward
20894
25227
 Barry Warsaw
20895
25228
 Steve Waterbury
20896
25229
 Bob Watson
20897
 
@@ -974,8 +1115,10 @@
 
25230
@@ -974,8 +1120,10 @@
20898
25231
 Aaron Watters
20899
25232
 Henrik Weber
20900
25233
 Corran Webster
20905
25238
 Edward Welbourne
20906
25239
 Cliff Wells
20907
25240
 Rickard Westman
20908
 
@@ -988,12 +1131,17 @@
 
25241
@@ -988,12 +1136,17 @@
20909
25242
 Gerry Wiener
20910
25243
 Frank Wierzbicki
20911
25244
 Bryce "Zooko" Wilcox-O'Hearn
20923
25256
 Jody Winston
20924
25257
 Collin Winter
20925
25258
 Dik Winter
20926
 
@@ -1008,6 +1156,8 @@
 
25259
@@ -1008,6 +1161,8 @@
20927
25260
 Klaus-Juergen Wolf
20928
25261
 Dan Wolfe
20929
25262
 Richard Wolff
20932
25265
 Darren Worrall
20933
25266
 Gordon Worley
20934
25267
 Thomas Wouters
20935
 
@@ -1017,8 +1167,10 @@
 
25268
@@ -1017,8 +1172,10 @@
20936
25269
 Florent Xicluna
20937
25270
 Hirokazu Yamamoto
20938
25271
 Ka-Ping Yee
20943
25276
 George Yoshida
20944
25277
 Masazumi Yoshikawa
20945
25278
 Arnaud Ysmal
20946
 
@@ -1030,6 +1182,7 @@
 
25279
@@ -1030,6 +1187,7 @@
20947
25280
 Siebren van der Zee
20948
25281
 Yuxiao Zeng
20949
25282
 Uwe Zessin
20975
25308
diff -r 3d0686d90f55 Misc/NEWS
20976
25309
--- a/Misc/NEWS
20977
25310
+++ b/Misc/NEWS
20978
 
@@ -2,6 +2,616 @@
 
25311
@@ -2,6 +2,685 @@
20979
25312
 Python News
20980
25313
 +++++++++++
20981
25314
 
20987
25320
+Core and Builtins
20988
25321
+-----------------
20989
25322
+
 
25323
+- Issue #6074: Ensure cached bytecode files can always be updated by the
 
25324
+  user that created them, even when the source file is read-only.
 
25325
+
 
25326
+- Issue #14783: Improve int() docstring and switch docstrings for str(),
 
25327
+  range(), and slice() to use multi-line signatures.
 
25328
+
 
25329
+- Issue #15379: Fix passing of non-BMP characters as integers for the charmap
 
25330
+  decoder (already working as unicode strings).  Patch by Serhiy Storchaka.
 
25331
+
20990
25332
+- Issue #13992: The trashcan mechanism is now thread-safe.  This eliminates
20991
25333
+  sporadic crashes in multi-thread programs when several long deallocator
20992
25334
+  chains ran concurrently and involved subclasses of built-in container
21023
25365
+- Issue #15020: The program name used to search for Python's path is now
21024
25366
+  "python3" under Unix, not "python".
21025
25367
+
 
25368
+- Issue #15897: zipimport.c doesn't check return value of fseek().
 
25369
+  Patch by Felipe Cruz.
 
25370
+
21026
25371
+- Issue #15033: Fix the exit status bug when modules invoked using -m swith,
21027
25372
+  return the proper failure return value (1). Patch contributed by Jeff Knupp.
21028
25373
+
21097
25442
+Library
21098
25443
+-------
21099
25444
+
 
25445
+- Issue #16220: wsgiref now always calls close() on an iterable response.
 
25446
+  Patch by Brent Tubbs.
 
25447
+
 
25448
+- Issue #16270: urllib may hang when used for retrieving files via FTP by using
 
25449
+  a context manager.  Patch by Giampaolo Rodola'.
 
25450
+
 
25451
+- Issue #16176: Properly identify Windows 8 via platform.platform()
 
25452
+
 
25453
+- Issue #16114: The subprocess module no longer provides a misleading
 
25454
+  error message stating that args[0] did not exist when either the cwd or
 
25455
+  executable keyword arguments specified a path that did not exist.
 
25456
+
 
25457
+- Issue #15756: subprocess.poll() now properly handles errno.ECHILD to
 
25458
+  return a returncode of 0 when the child has already exited or cannot
 
25459
+  be waited on.
 
25460
+
 
25461
+- Issue #12376: Pass on parameters in TextTestResult.__init__ super call
 
25462
+
 
25463
+- Issue #15222: Insert blank line after each message in mbox mailboxes
 
25464
+
 
25465
+- Issue #16013: Fix CSV Reader parsing issue with ending quote characters.
 
25466
+  Patch by Serhiy Storchaka.
 
25467
+
 
25468
+- Issue #15421: fix an OverflowError in Calendar.itermonthdates() after
 
25469
+  datetime.MAXYEAR.  Patch by Cédric Krier.
 
25470
+
21100
25471
+- Issue #15970: xml.etree.ElementTree now serializes correctly the empty HTML
21101
25472
+  elements 'meta' and 'param'.
21102
25473
+
21117
25488
+- Issue #15509: webbrowser.UnixBrowser no longer passes empty arguments to
21118
25489
+  Popen when %action substitutions produce empty strings.
21119
25490
+
 
25491
+- Issue #16112: platform.architecture does not correctly escape argument to
 
25492
+  /usr/bin/file.  Patch by David Benjamin.
 
25493
+
21120
25494
+- Issue #12776,#11839: call argparse type function (specified by add_argument)
21121
25495
+  only once. Before, the type function was called twice in the case where the
21122
25496
+  default was specified and the argument was given as well.  This was
21453
25827
+Extension Modules
21454
25828
+-----------------
21455
25829
+
 
25830
+- Issue #16012: Fix a regression in pyexpat. The parser's UseForeignDTD()
 
25831
+  method doesn't require an argument again.
 
25832
+
21456
25833
+- Issue #15676: Now "mmap" check for empty files before doing the
21457
25834
+  offset check.  Patch by Steven Willis.
21458
25835
+
21471
25848
+Tests
21472
25849
+-----
21473
25850
+
 
25851
+- Issue #15304: Fix warning message when os.chdir() fails inside
 
25852
+  test.support.temp_cwd().  Patch by Chris Jerdonek.
 
25853
+
21474
25854
+- Issue #15802: Fix test logic in TestMaildir.test_create_tmp. Patch
21475
25855
+  by Serhiy Storchaka.
21476
25856
+
21518
25898
+Build
21519
25899
+-----
21520
25900
+
 
25901
+- Issue #15923: fix a mistake in asdl_c.py that resulted in a TypeError after
 
25902
+  2801bf875a24 (see #15801).
 
25903
+
21521
25904
+- Issue #11715: Fix multiarch detection without having Debian development
21522
25905
+  tools (dpkg-dev) installed.
21523
25906
+
21551
25934
+Documentation
21552
25935
+-------------
21553
25936
+
 
25937
+- Issue #16115: Improve subprocess.Popen() documentation around args, shell,
 
25938
+  and executable arguments.
 
25939
+
 
25940
+- Issue #13498: Clarify docs of os.makedirs()'s exist_ok argument.  Done with
 
25941
+  great native-speaker help from R. David Murray.
 
25942
+
 
25943
+- Issue #15533: Clarify docs and add tests for subprocess.Popen()'s cwd
 
25944
+  argument.
 
25945
+
 
25946
+- Issue #15979: Improve timeit documentation.
 
25947
+
 
25948
+- Issue #16036: Improve documentation of built-in int()'s signature and
 
25949
+  arguments.
 
25950
+
 
25951
+- Issue #15935: Clarification of argparse docs, re: add_argument() type and
 
25952
+  default arguments.  Patch contributed by Chris Jerdonek.
 
25953
+
21554
25954
+- Issue #11964: Document a change in v3.2 to the behavior of the indent
21555
25955
+  parameter of json encoding operations.
21556
25956
+
21585
25985
+Tools/Demos
21586
25986
+-----------
21587
25987
+
 
25988
+- Issue #15378: Fix Tools/unicode/comparecodecs.py.  Patch by Serhiy Storchaka.
 
25989
+
21588
25990
+- Issue #14695: Fix missing support for starred assignments in
21589
25991
+  Tools/parser/unparse.py.
21590
25992
+
21592
25994
 What's New in Python 3.2.3?
21593
25995
 ===========================
21594
25996
 
21595
 
@@ -156,9 +766,6 @@
 
25997
@@ -156,9 +835,6 @@
21596
25998
 Library
21597
25999
 -------
21598
26000
 
21602
26004
 - HTMLParser is now able to handle slashes in the start tag.
21603
26005
 
21604
26006
 - Issue #14001: CVE-2012-0845: xmlrpc: Fix an endless loop in
21605
 
@@ -773,6 +1380,9 @@
 
26007
@@ -773,6 +1449,9 @@
21606
26008
 - Issue #12451: xml.dom.pulldom: parse() now opens files in binary mode instead
21607
26009
   of the text mode (using the locale encoding) to avoid encoding issues.
21608
26010
 
21725
26127
     return 0;
21726
26128
 }
21727
26129
 
 
26130
@@ -755,9 +759,13 @@
 
26131
         lineobj = PyIter_Next(self->input_iter);
 
26132
         if (lineobj == NULL) {
 
26133
             /* End of input OR exception */
 
26134
-            if (!PyErr_Occurred() && self->field_len != 0)
 
26135
-                PyErr_Format(error_obj,
 
26136
-                             "newline inside string");
 
26137
+            if (!PyErr_Occurred() && (self->field_len != 0 ||
 
26138
+                                      self->state == IN_QUOTED_FIELD)) {
 
26139
+                if (self->dialect->strict)
 
26140
+                    PyErr_SetString(error_obj, "unexpected end of data");
 
26141
+                else if (parse_save_field(self) >= 0)
 
26142
+                    break;
 
26143
+            }
 
26144
             return NULL;
 
26145
         }
 
26146
         if (!PyUnicode_Check(lineobj)) {
21728
26147
diff -r 3d0686d90f55 Modules/_ctypes/cfield.c
21729
26148
--- a/Modules/_ctypes/cfield.c
21730
26149
+++ b/Modules/_ctypes/cfield.c
22971
27390
     if (fd_dir_fd == -1) {
22972
27391
         /* No way to get a list of open fds. */
22973
27392
         _close_fds_by_brute_force(start_fd, end_fd, py_fds_to_keep);
22974
 
@@ -507,6 +525,8 @@
 
27393
@@ -336,7 +354,7 @@
 
27394
            PyObject *preexec_fn,
 
27395
            PyObject *preexec_fn_args_tuple)
 
27396
 {
 
27397
-    int i, saved_errno, unused;
 
27398
+    int i, saved_errno, unused, reached_preexec = 0;
 
27399
     PyObject *result;
 
27400
     const char* err_msg = "";
 
27401
     /* Buffer large enough to hold a hex integer.  We can't malloc. */
 
27402
@@ -420,6 +438,7 @@
 
27403
         POSIX_CALL(setsid());
 
27404
 #endif
 
27405
 
 
27406
+    reached_preexec = 1;
 
27407
     if (preexec_fn != Py_None && preexec_fn_args_tuple) {
 
27408
         /* This is where the user has asked us to deadlock their program. */
 
27409
         result = PyObject_Call(preexec_fn, preexec_fn_args_tuple, NULL);
 
27410
@@ -469,6 +488,10 @@
 
27411
         }
 
27412
         unused = write(errpipe_write, cur, hex_errno + sizeof(hex_errno) - cur);
 
27413
         unused = write(errpipe_write, ":", 1);
 
27414
+        if (!reached_preexec) {
 
27415
+            /* Indicate to the parent that the error happened before exec(). */
 
27416
+            unused = write(errpipe_write, "noexec", 6);
 
27417
+        }
 
27418
         /* We can't call strerror(saved_errno).  It is not async signal safe.
 
27419
          * The parent process will look the error message up. */
 
27420
     } else {
 
27421
@@ -507,6 +530,8 @@
22975
27422
         return NULL;
22976
27423
 
22977
27424
     close_fds = PyObject_IsTrue(py_close_fds);
22980
27427
     if (close_fds && errpipe_write < 3) {  /* precondition */
22981
27428
         PyErr_SetString(PyExc_ValueError, "errpipe_write must be >= 3");
22982
27429
         return NULL;
22983
 
@@ -546,8 +566,10 @@
 
27430
@@ -546,8 +571,10 @@
22984
27431
     }
22985
27432
 
22986
27433
     exec_array = _PySequence_BytesToCharpArray(executable_list);
22992
27439
 
22993
27440
     /* Convert args and env into appropriate arguments for exec() */
22994
27441
     /* These conversions are done in the parent process to avoid allocating
22995
 
@@ -557,6 +579,8 @@
 
27442
@@ -557,6 +584,8 @@
22996
27443
         /* Equivalent to:  */
22997
27444
         /*  tuple(PyUnicode_FSConverter(arg) for arg in process_args)  */
22998
27445
         fast_args = PySequence_Fast(process_args, "argv must be a tuple");
24082
28529
+    int flag = 1;
24083
28530
     enum XML_Error rc;
24084
28531
-    if (!PyArg_UnpackTuple(args, "UseForeignDTD", 0, 1, &flagobj))
24085
 
+    if (!PyArg_ParseTuple(args, "O:UseForeignDTD", &flagobj))
 
28532
+    if (!PyArg_ParseTuple(args, "|O:UseForeignDTD", &flagobj))
24086
28533
         return NULL;
24087
28534
-    if (flagobj != NULL)
24088
28535
-        flag = PyObject_IsTrue(flagobj) ? XML_TRUE : XML_FALSE;
24261
28708
         }
24262
28709
     }
24263
28710
 #endif
 
28711
diff -r 3d0686d90f55 Modules/zipimport.c
 
28712
--- a/Modules/zipimport.c
 
28713
+++ b/Modules/zipimport.c
 
28714
@@ -741,7 +741,12 @@
 
28715
             PyErr_Format(ZipImportError, "can't open Zip file: '%U'", archive_obj);
 
28716
         return NULL;
 
28717
     }
 
28718
-    fseek(fp, -22, SEEK_END);
 
28719
+
 
28720
+    if (fseek(fp, -22, SEEK_END) == -1) {
 
28721
+        fclose(fp);
 
28722
+        PyErr_Format(ZipImportError, "can't read Zip file: %U", archive_obj);
 
28723
+        return NULL;
 
28724
+    }
 
28725
     header_position = ftell(fp);
 
28726
     if (fread(endof_central_dir, 1, 22, fp) != 22) {
 
28727
         fclose(fp);
 
28728
@@ -773,11 +778,13 @@
 
28729
         PyObject *t;
 
28730
         int err;
 
28731
 
 
28732
-        fseek(fp, header_offset, 0);  /* Start of file header */
 
28733
+        if (fseek(fp, header_offset, 0) == -1)  /* Start of file header */
 
28734
+            goto fseek_error;
 
28735
         l = PyMarshal_ReadLongFromFile(fp);
 
28736
         if (l != 0x02014B50)
 
28737
             break;              /* Bad: Central Dir File Header */
 
28738
-        fseek(fp, header_offset + 8, 0);
 
28739
+        if (fseek(fp, header_offset + 8, 0) == -1)
 
28740
+            goto fseek_error;
 
28741
         flags = (unsigned short)PyMarshal_ReadShortFromFile(fp);
 
28742
         compress = PyMarshal_ReadShortFromFile(fp);
 
28743
         time = PyMarshal_ReadShortFromFile(fp);
 
28744
@@ -789,7 +796,8 @@
 
28745
         header_size = 46 + name_size +
 
28746
            PyMarshal_ReadShortFromFile(fp) +
 
28747
            PyMarshal_ReadShortFromFile(fp);
 
28748
-        fseek(fp, header_offset + 42, 0);
 
28749
+        if (fseek(fp, header_offset + 42, 0) == -1)
 
28750
+            goto fseek_error;
 
28751
         file_offset = PyMarshal_ReadLongFromFile(fp) + arc_offset;
 
28752
         if (name_size > MAXPATHLEN)
 
28753
             name_size = MAXPATHLEN;
 
28754
@@ -849,6 +857,12 @@
 
28755
         PySys_FormatStderr("# zipimport: found %ld names in %U\n",
 
28756
             count, archive_obj);
 
28757
     return files;
 
28758
+fseek_error:
 
28759
+    fclose(fp);
 
28760
+    Py_XDECREF(files);
 
28761
+    Py_XDECREF(nameobj);
 
28762
+    PyErr_Format(ZipImportError, "can't read Zip file: %U", archive_obj);
 
28763
+    return NULL;
 
28764
 error:
 
28765
     fclose(fp);
 
28766
     Py_XDECREF(files);
 
28767
@@ -918,7 +932,12 @@
 
28768
     }
 
28769
 
 
28770
     /* Check to make sure the local file header is correct */
 
28771
-    fseek(fp, file_offset, 0);
 
28772
+    if (fseek(fp, file_offset, 0) == -1) {
 
28773
+        fclose(fp);
 
28774
+        PyErr_Format(ZipImportError, "can't read Zip file: %U", archive);
 
28775
+        return NULL;
 
28776
+    }
 
28777
+
 
28778
     l = PyMarshal_ReadLongFromFile(fp);
 
28779
     if (l != 0x04034B50) {
 
28780
         /* Bad: Local File Header */
 
28781
@@ -928,7 +947,12 @@
 
28782
         fclose(fp);
 
28783
         return NULL;
 
28784
     }
 
28785
-    fseek(fp, file_offset + 26, 0);
 
28786
+    if (fseek(fp, file_offset + 26, 0) == -1) {
 
28787
+        fclose(fp);
 
28788
+        PyErr_Format(ZipImportError, "can't read Zip file: %U", archive);
 
28789
+        return NULL;
 
28790
+    }
 
28791
+
 
28792
     l = 30 + PyMarshal_ReadShortFromFile(fp) +
 
28793
         PyMarshal_ReadShortFromFile(fp);        /* local header size */
 
28794
     file_offset += l;           /* Start of file data */
 
28795
@@ -945,8 +969,13 @@
 
28796
     buf = PyBytes_AsString(raw_data);
 
28797
 
 
28798
     err = fseek(fp, file_offset, 0);
 
28799
-    if (err == 0)
 
28800
+    if (err == 0) {
 
28801
         bytes_read = fread(buf, 1, data_size, fp);
 
28802
+    } else {
 
28803
+        fclose(fp);
 
28804
+        PyErr_Format(ZipImportError, "can't read Zip file: %U", archive);
 
28805
+        return NULL;
 
28806
+    }
 
28807
     fclose(fp);
 
28808
     if (err || bytes_read != data_size) {
 
28809
         PyErr_SetString(PyExc_IOError,
24264
28810
diff -r 3d0686d90f55 Objects/abstract.c
24265
28811
--- a/Objects/abstract.c
24266
28812
+++ b/Objects/abstract.c
24680
29226
         CHECK_SMALL_INT(ival);
24681
29227
     }
24682
29228
     result = _PyLong_New(i);
24683
 
@@ -4151,8 +4149,8 @@
 
29229
@@ -928,6 +926,13 @@
 
29230
 PyObject *
 
29231
 PyLong_FromVoidPtr(void *p)
 
29232
 {
 
29233
+#if SIZEOF_VOID_P <= SIZEOF_LONG
 
29234
+    /* special-case null pointer */
 
29235
+    if (!p)
 
29236
+        return PyLong_FromLong(0);
 
29237
+    return PyLong_FromUnsignedLong((unsigned long)(Py_uintptr_t)p);
 
29238
+#else
 
29239
+
 
29240
 #ifndef HAVE_LONG_LONG
 
29241
 #   error "PyLong_FromVoidPtr: sizeof(void*) > sizeof(long), but no long long"
 
29242
 #endif
 
29243
@@ -938,6 +943,7 @@
 
29244
     if (!p)
 
29245
         return PyLong_FromLong(0);
 
29246
     return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)(Py_uintptr_t)p);
 
29247
+#endif /* SIZEOF_VOID_P <= SIZEOF_LONG */
 
29248
 
 
29249
 }
 
29250
 
 
29251
@@ -4151,8 +4157,8 @@
24684
29252
             string = PyByteArray_AS_STRING(x);
24685
29253
         else
24686
29254
             string = PyBytes_AS_STRING(x);
24691
29259
                x is a bytes or buffer, *and* a base is given. */
24692
29260
             PyErr_Format(PyExc_ValueError,
24693
29261
                          "invalid literal for int() with base %d: %R",
 
29262
@@ -4705,13 +4711,20 @@
 
29263
 };
 
29264
 
 
29265
 PyDoc_STRVAR(long_doc,
 
29266
-"int(x[, base]) -> integer\n\
 
29267
+"int(x=0) -> integer\n\
 
29268
+int(x, base=10) -> integer\n\
 
29269
 \n\
 
29270
-Convert a string or number to an integer, if possible.  A floating\n\
 
29271
-point argument will be truncated towards zero (this does not include a\n\
 
29272
-string representation of a floating point number!)  When converting a\n\
 
29273
-string, use the optional base.  It is an error to supply a base when\n\
 
29274
-converting a non-string.");
 
29275
+Convert a number or string to an integer, or return 0 if no arguments\n\
 
29276
+are given.  If x is a number, return x.__int__().  For floating point\n\
 
29277
+numbers, this truncates towards zero.\n\
 
29278
+\n\
 
29279
+If x is not a number or if base is given, then x must be a string,\n\
 
29280
+bytes, or bytearray instance representing an integer literal in the\n\
 
29281
+given base.  The literal can be preceded by '+' or '-' and be surrounded\n\
 
29282
+by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.\n\
 
29283
+Base 0 means to interpret the base from the string as an integer literal.\n\
 
29284
+>>> int('0b100', base=0)\n\
 
29285
+4");
 
29286
 
 
29287
 static PyNumberMethods long_as_number = {
 
29288
     (binaryfunc)long_add,       /*nb_add*/
24694
29289
diff -r 3d0686d90f55 Objects/memoryobject.c
24695
29290
--- a/Objects/memoryobject.c
24696
29291
+++ b/Objects/memoryobject.c
24863
29458
diff -r 3d0686d90f55 Objects/rangeobject.c
24864
29459
--- a/Objects/rangeobject.c
24865
29460
+++ b/Objects/rangeobject.c
24866
 
@@ -307,7 +307,7 @@
 
29461
@@ -135,7 +135,8 @@
 
29462
 }
 
29463
 
 
29464
 PyDoc_STRVAR(range_doc,
 
29465
-"range([start,] stop[, step]) -> range object\n\
 
29466
+"range(stop) -> range object\n\
 
29467
+range(start, stop[, step]) -> range object\n\
 
29468
 \n\
 
29469
 Returns a virtual sequence of numbers from start to stop by step.");
 
29470
 
 
29471
@@ -307,7 +308,7 @@
24867
29472
 static PyObject *
24868
29473
 range_item(rangeobject *r, Py_ssize_t i)
24869
29474
 {
24872
29477
     if (!arg) {
24873
29478
         return NULL;
24874
29479
     }
 
29480
diff -r 3d0686d90f55 Objects/sliceobject.c
 
29481
--- a/Objects/sliceobject.c
 
29482
+++ b/Objects/sliceobject.c
 
29483
@@ -221,7 +221,8 @@
 
29484
 }
 
29485
 
 
29486
 PyDoc_STRVAR(slice_doc,
 
29487
-"slice([start,] stop[, step])\n\
 
29488
+"slice(stop)\n\
 
29489
+slice(start, stop[, step])\n\
 
29490
 \n\
 
29491
 Create a slice object.  This is used for extended slicing (e.g. a[0:10:2]).");
 
29492
 
24875
29493
diff -r 3d0686d90f55 Objects/structseq.c
24876
29494
--- a/Objects/structseq.c
24877
29495
+++ b/Objects/structseq.c
25269
29887
     }
25270
29888
 
25271
29889
     if (byteorder)
25272
 
@@ -7673,7 +7663,9 @@
 
29890
@@ -5260,12 +5250,36 @@
 
29891
             /* Apply mapping */
 
29892
             if (PyLong_Check(x)) {
 
29893
                 long value = PyLong_AS_LONG(x);
 
29894
-                if (value < 0 || value > 65535) {
 
29895
+                if (value < 0 || value > 0x10FFFF) {
 
29896
                     PyErr_SetString(PyExc_TypeError,
 
29897
-                                    "character mapping must be in range(65536)");
 
29898
+                                    "character mapping must be in range(0x110000)");
 
29899
                     Py_DECREF(x);
 
29900
                     goto onError;
 
29901
                 }
 
29902
+
 
29903
+#ifndef Py_UNICODE_WIDE
 
29904
+                if (value > 0xFFFF) {
 
29905
+                    /* see the code for 1-n mapping below */
 
29906
+                    if (extrachars < 2) {
 
29907
+                        /* resize first */
 
29908
+                        Py_ssize_t oldpos = p - PyUnicode_AS_UNICODE(v);
 
29909
+                        Py_ssize_t needed = 10 - extrachars;
 
29910
+                        extrachars += needed;
 
29911
+                        /* XXX overflow detection missing */
 
29912
+                        if (_PyUnicode_Resize(&v,
 
29913
+                                              PyUnicode_GET_SIZE(v) + needed) < 0) {
 
29914
+                            Py_DECREF(x);
 
29915
+                            goto onError;
 
29916
+                        }
 
29917
+                        p = PyUnicode_AS_UNICODE(v) + oldpos;
 
29918
+                    }
 
29919
+                    value -= 0x10000;
 
29920
+                    *p++ = 0xD800 | (value >> 10);
 
29921
+                    *p++ = 0xDC00 | (value & 0x3FF);
 
29922
+                    extrachars -= 2;
 
29923
+                }
 
29924
+                else
 
29925
+#endif
 
29926
                 *p++ = (Py_UNICODE)value;
 
29927
             }
 
29928
             else if (x == Py_None) {
 
29929
@@ -7673,7 +7687,9 @@
25273
29930
     Py_UNICODE *p;
25274
29931
     Py_hash_t x;
25275
29932
 
25279
29936
     if (self->hash != -1)
25280
29937
         return self->hash;
25281
29938
     len = Py_SIZE(self);
25282
 
@@ -9208,10 +9200,6 @@
 
29939
@@ -9208,10 +9224,6 @@
25283
29940
 }
25284
29941
 
25285
29942
 static PyMethodDef unicode_methods[] = {
25290
29947
     {"encode", (PyCFunction) unicode_encode, METH_VARARGS | METH_KEYWORDS, encode__doc__},
25291
29948
     {"replace", (PyCFunction) unicode_replace, METH_VARARGS, replace__doc__},
25292
29949
     {"split", (PyCFunction) unicode_split, METH_VARARGS, split__doc__},
25293
 
@@ -9516,8 +9504,7 @@
 
29950
@@ -9516,8 +9528,7 @@
25294
29951
         arglen = -1;
25295
29952
         argidx = -2;
25296
29953
     }
25300
29957
         dict = args;
25301
29958
 
25302
29959
     while (--fmtcnt >= 0) {
25303
 
@@ -9975,11 +9962,15 @@
 
29960
@@ -9975,11 +9986,16 @@
25304
29961
 }
25305
29962
 
25306
29963
 PyDoc_STRVAR(unicode_doc,
25307
29964
-             "str(string[, encoding[, errors]]) -> str\n\
25308
 
+             "str(object[, encoding[, errors]]) -> str\n\
 
29965
+"str(object='') -> str\n\
 
29966
+str(bytes_or_buffer[, encoding[, errors]]) -> str\n\
25309
29967
 \n\
25310
29968
-Create a new string object from the given encoded string.\n\
25311
29969
-encoding defaults to the current default string encoding.\n\
25913
30571
                                IgnoreDefaultLibraryNames="libc"
25914
30572
                                BaseAddress="0x1D110000"
25915
30573
                                TargetMachine="17"
 
30574
diff -r 3d0686d90f55 Parser/asdl_c.py
 
30575
--- a/Parser/asdl_c.py
 
30576
+++ b/Parser/asdl_c.py
 
30577
@@ -1010,7 +1010,7 @@
 
30578
             self.emit("case %s:" % t.name, 2)
 
30579
             self.emit("Py_INCREF(%s_singleton);" % t.name, 3)
 
30580
             self.emit("return %s_singleton;" % t.name, 3)
 
30581
-        self.emit("default:" % name, 2)
 
30582
+        self.emit("default:", 2)
 
30583
         self.emit('/* should never happen, but just in case ... */', 3)
 
30584
         code = "PyErr_Format(PyExc_SystemError, \"unknown %s found\");" % name
 
30585
         self.emit(code, 3, reflow=False)
25916
30586
diff -r 3d0686d90f55 Parser/myreadline.c
25917
30587
--- a/Parser/myreadline.c
25918
30588
+++ b/Parser/myreadline.c
26285
30955
diff -r 3d0686d90f55 Python/import.c
26286
30956
--- a/Python/import.c
26287
30957
+++ b/Python/import.c
26288
 
@@ -1291,9 +1291,9 @@
 
30958
@@ -1172,15 +1172,21 @@
 
30959
     FILE *fp;
 
30960
     char *dirpath;
 
30961
     time_t mtime = srcstat->st_mtime;
 
30962
+    int saved;
 
30963
 #ifdef MS_WINDOWS   /* since Windows uses different permissions  */
 
30964
     mode_t mode = srcstat->st_mode & ~S_IEXEC;
 
30965
+    /* Issue #6074: We ensure user write access, so we can delete it later
 
30966
+     * when the source file changes. (On POSIX, this only requires write
 
30967
+     * access to the directory, on Windows, we need write access to the file
 
30968
+     * as well)
 
30969
+     */
 
30970
+    mode |= _S_IWRITE;
 
30971
 #else
 
30972
     mode_t mode = srcstat->st_mode & ~S_IXUSR & ~S_IXGRP & ~S_IXOTH;
 
30973
     mode_t dirmode = (srcstat->st_mode |
 
30974
                       S_IXUSR | S_IXGRP | S_IXOTH |
 
30975
                       S_IWUSR | S_IWGRP | S_IWOTH);
 
30976
 #endif
 
30977
-    int saved;
 
30978
 
 
30979
     /* Ensure that the __pycache__ directory exists. */
 
30980
     dirpath = rightmost_sep(cpathname);
 
30981
@@ -1291,9 +1297,9 @@
26289
30982
 {
26290
30983
     struct stat st;
26291
30984
     FILE *fpc;
26297
30990
     PyObject *m;
26298
30991
 
26299
30992
     if (fstat(fileno(fp), &st) != 0) {
26300
 
@@ -1310,6 +1310,10 @@
 
30993
@@ -1310,6 +1316,10 @@
26301
30994
          */
26302
30995
         st.st_mtime &= 0xFFFFFFFF;
26303
30996
     }
26308
31001
     cpathname = make_compiled_pathname(
26309
31002
         pathname, buf, (size_t)MAXPATHLEN + 1, !Py_OptimizeFlag);
26310
31003
     if (cpathname != NULL &&
26311
 
@@ -1317,9 +1321,9 @@
 
31004
@@ -1317,9 +1327,9 @@
26312
31005
         co = read_compiled_module(cpathname, fpc);
26313
31006
         fclose(fpc);
26314
31007
         if (co == NULL)
26320
31013
         if (Py_VerboseFlag)
26321
31014
             PySys_WriteStderr("import %s # precompiled from %s\n",
26322
31015
                 name, cpathname);
26323
 
@@ -1328,13 +1332,16 @@
 
31016
@@ -1328,13 +1338,16 @@
26324
31017
     else {
26325
31018
         co = parse_source_module(pathname, fp);
26326
31019
         if (co == NULL)
26339
31032
                 write_compiled_module(co, cpathname, &st);
26340
31033
         }
26341
31034
     }
26342
 
@@ -1342,7 +1349,13 @@
 
31035
@@ -1342,7 +1355,13 @@
26343
31036
         name, (PyObject *)co, pathname, cpathname);
26344
31037
     Py_DECREF(co);
26345
31038
 
26353
31046
 }
26354
31047
 
26355
31048
 /* Get source file -> unicode or None
26356
 
@@ -1351,7 +1364,7 @@
 
31049
@@ -1351,7 +1370,7 @@
26357
31050
 static PyObject *
26358
31051
 get_sourcefile(char *file)
26359
31052
 {
26362
31055
     Py_ssize_t len;
26363
31056
     PyObject *u;
26364
31057
     struct stat statbuf;
26365
 
@@ -1366,6 +1379,10 @@
 
31058
@@ -1366,6 +1385,10 @@
26366
31059
         return PyUnicode_DecodeFSDefault(file);
26367
31060
     }
26368
31061
 
26373
31066
     /* Start by trying to turn PEP 3147 path into source path.  If that
26374
31067
      * fails, just chop off the trailing character, i.e. legacy pyc path
26375
31068
      * to py.
26376
 
@@ -1382,6 +1399,7 @@
 
31069
@@ -1382,6 +1405,7 @@
26377
31070
     else {
26378
31071
         u = PyUnicode_DecodeFSDefault(file);
26379
31072
     }
26381
31074
     return u;
26382
31075
 }
26383
31076
 
26384
 
@@ -1401,7 +1419,7 @@
 
31077
@@ -1401,7 +1425,7 @@
26385
31078
     PyObject *file = NULL;
26386
31079
     PyObject *path = NULL;
26387
31080
     int err;
26390
31083
     FILE *fp = NULL;
26391
31084
     struct filedescr *fdp;
26392
31085
 
26393
 
@@ -1423,8 +1441,13 @@
 
31086
@@ -1423,8 +1447,13 @@
26394
31087
         err = PyDict_SetItemString(d, "__path__", path);
26395
31088
     if (err != 0)
26396
31089
         goto error;
26405
31098
     if (fdp == NULL) {
26406
31099
         if (PyErr_ExceptionMatches(PyExc_ImportError)) {
26407
31100
             PyErr_Clear();
26408
 
@@ -1442,6 +1465,8 @@
 
31101
@@ -1442,6 +1471,8 @@
26409
31102
   error:
26410
31103
     m = NULL;
26411
31104
   cleanup:
26414
31107
     Py_XDECREF(path);
26415
31108
     Py_XDECREF(file);
26416
31109
     return m;
26417
 
@@ -1571,7 +1596,7 @@
 
31110
@@ -1571,7 +1602,7 @@
26418
31111
     static struct filedescr fd_frozen = {"", "", PY_FROZEN};
26419
31112
     static struct filedescr fd_builtin = {"", "", C_BUILTIN};
26420
31113
     static struct filedescr fd_package = {"", "", PKG_DIRECTORY};
26423
31116
 #if defined(PYOS_OS2)
26424
31117
     size_t saved_len;
26425
31118
     size_t saved_namelen;
26426
 
@@ -1585,6 +1610,11 @@
 
31119
@@ -1585,6 +1616,11 @@
26427
31120
                         "module name is too long");
26428
31121
         return NULL;
26429
31122
     }
26435
31128
     strcpy(name, subname);
26436
31129
 
26437
31130
     /* sys.meta_path import hook */
26438
 
@@ -1596,7 +1626,7 @@
 
31131
@@ -1596,7 +1632,7 @@
26439
31132
             PyErr_SetString(PyExc_RuntimeError,
26440
31133
                             "sys.meta_path must be a list of "
26441
31134
                             "import hooks");
26444
31137
         }
26445
31138
         Py_INCREF(meta_path);  /* zap guard */
26446
31139
         npath = PyList_Size(meta_path);
26447
 
@@ -1609,12 +1639,13 @@
 
31140
@@ -1609,12 +1645,13 @@
26448
31141
                                          path : Py_None);
26449
31142
             if (loader == NULL) {
26450
31143
                 Py_DECREF(meta_path);
26459
31152
                 return &importhookdescr;
26460
31153
             }
26461
31154
             Py_DECREF(loader);
26462
 
@@ -1624,18 +1655,21 @@
 
31155
@@ -1624,18 +1661,21 @@
26463
31156
 
26464
31157
     if (find_frozen(fullname) != NULL) {
26465
31158
         strcpy(buf, fullname);
26481
31174
             return fdp;
26482
31175
         }
26483
31176
 #endif
26484
 
@@ -1645,7 +1679,7 @@
 
31177
@@ -1645,7 +1685,7 @@
26485
31178
     if (path == NULL || !PyList_Check(path)) {
26486
31179
         PyErr_SetString(PyExc_RuntimeError,
26487
31180
                         "sys.path must be a list of directory names");
26490
31183
     }
26491
31184
 
26492
31185
     path_hooks = PySys_GetObject("path_hooks");
26493
 
@@ -1653,14 +1687,14 @@
 
31186
@@ -1653,14 +1693,14 @@
26494
31187
         PyErr_SetString(PyExc_RuntimeError,
26495
31188
                         "sys.path_hooks must be a list of "
26496
31189
                         "import hooks");
26507
31200
     }
26508
31201
 
26509
31202
     npath = PyList_Size(path);
26510
 
@@ -1671,11 +1705,11 @@
 
31203
@@ -1671,11 +1711,11 @@
26511
31204
         const char *base;
26512
31205
         Py_ssize_t size;
26513
31206
         if (!v)
26521
31214
         }
26522
31215
         else if (!PyBytes_Check(v))
26523
31216
             continue;
26524
 
@@ -1703,7 +1737,7 @@
 
31217
@@ -1703,7 +1743,7 @@
26525
31218
             importer = get_path_importer(path_importer_cache,
26526
31219
                                          path_hooks, origv);
26527
31220
             if (importer == NULL) {
26530
31223
             }
26531
31224
             /* Note: importer is a borrowed reference */
26532
31225
             if (importer != Py_None) {
26533
 
@@ -1712,10 +1746,11 @@
 
31226
@@ -1712,10 +1752,11 @@
26534
31227
                                              "find_module",
26535
31228
                                              "s", fullname);
26536
31229
                 if (loader == NULL)
26543
31236
                     return &importhookdescr;
26544
31237
                 }
26545
31238
                 Py_DECREF(loader);
26546
 
@@ -1740,19 +1775,20 @@
 
31239
@@ -1740,19 +1781,20 @@
26547
31240
             S_ISDIR(statbuf.st_mode) &&         /* it's a directory */
26548
31241
             case_ok(buf, len, namelen, name)) { /* case matches */
26549
31242
             if (find_init_module(buf)) { /* and has __init__.py */
26566
31259
             }
26567
31260
         }
26568
31261
 #endif
26569
 
@@ -1833,10 +1869,15 @@
 
31262
@@ -1833,10 +1875,15 @@
26570
31263
     if (fp == NULL) {
26571
31264
         PyErr_Format(PyExc_ImportError,
26572
31265
                      "No module named %.200s", name);
26583
31276
 }
26584
31277
 
26585
31278
 /* case_ok(char* buf, Py_ssize_t len, Py_ssize_t namelen, char* name)
26586
 
@@ -2416,7 +2457,7 @@
 
31279
@@ -2416,7 +2463,7 @@
26587
31280
 import_module_level(char *name, PyObject *globals, PyObject *locals,
26588
31281
                     PyObject *fromlist, int level)
26589
31282
 {
26592
31285
     Py_ssize_t buflen = 0;
26593
31286
     PyObject *parent, *head, *next, *tail;
26594
31287
 
26595
 
@@ -2430,14 +2471,18 @@
 
31288
@@ -2430,14 +2477,18 @@
26596
31289
         return NULL;
26597
31290
     }
26598
31291
 
26613
31306
 
26614
31307
     tail = head;
26615
31308
     Py_INCREF(tail);
26616
 
@@ -2446,7 +2491,7 @@
 
31309
@@ -2446,7 +2497,7 @@
26617
31310
         Py_DECREF(tail);
26618
31311
         if (next == NULL) {
26619
31312
             Py_DECREF(head);
26622
31315
         }
26623
31316
         tail = next;
26624
31317
     }
26625
 
@@ -2458,26 +2503,38 @@
 
31318
@@ -2458,26 +2509,38 @@
26626
31319
         Py_DECREF(head);
26627
31320
         PyErr_SetString(PyExc_ValueError,
26628
31321
                         "Empty module name");
26664
31357
 }
26665
31358
 
26666
31359
 PyObject *
26667
 
@@ -2880,7 +2937,7 @@
 
31360
@@ -2880,7 +2943,7 @@
26668
31361
     }
26669
31362
     else {
26670
31363
         PyObject *path, *loader = NULL;
26673
31366
         struct filedescr *fdp;
26674
31367
         FILE *fp = NULL;
26675
31368
 
26676
 
@@ -2895,11 +2952,16 @@
 
31369
@@ -2895,11 +2958,16 @@
26677
31370
             }
26678
31371
         }
26679
31372
 
26690
31383
             if (!PyErr_ExceptionMatches(PyExc_ImportError))
26691
31384
                 return NULL;
26692
31385
             PyErr_Clear();
26693
 
@@ -2914,6 +2976,7 @@
 
31386
@@ -2914,6 +2982,7 @@
26694
31387
             Py_XDECREF(m);
26695
31388
             m = NULL;
26696
31389
         }
26698
31391
     }
26699
31392
 
26700
31393
     return m;
26701
 
@@ -2931,7 +2994,7 @@
 
31394
@@ -2931,7 +3000,7 @@
26702
31395
     PyObject *modules = PyImport_GetModuleDict();
26703
31396
     PyObject *path = NULL, *loader = NULL, *existing_m = NULL;
26704
31397
     char *name, *subname;
26707
31400
     struct filedescr *fdp;
26708
31401
     FILE *fp = NULL;
26709
31402
     PyObject *newm;
26710
 
@@ -2991,6 +3054,11 @@
 
31403
@@ -2991,6 +3060,11 @@
26711
31404
         if (path == NULL)
26712
31405
             PyErr_Clear();
26713
31406
     }
26719
31412
     buf[0] = '\0';
26720
31413
     fdp = find_module(name, subname, path, buf, MAXPATHLEN+1, &fp, &loader);
26721
31414
     Py_XDECREF(path);
26722
 
@@ -2998,6 +3066,7 @@
 
31415
@@ -2998,6 +3072,7 @@
26723
31416
     if (fdp == NULL) {
26724
31417
         Py_XDECREF(loader);
26725
31418
         imp_modules_reloading_clear();
26727
31420
         return NULL;
26728
31421
     }
26729
31422
 
26730
 
@@ -3015,6 +3084,7 @@
 
31423
@@ -3015,6 +3090,7 @@
26731
31424
         PyDict_SetItemString(modules, name, m);
26732
31425
     }
26733
31426
     imp_modules_reloading_clear();
26735
31428
     return newm;
26736
31429
 }
26737
31430
 
26738
 
@@ -3168,26 +3238,32 @@
 
31431
@@ -3168,26 +3244,32 @@
26739
31432
     PyObject *fob, *ret;
26740
31433
     PyObject *pathobj;
26741
31434
     struct filedescr *fdp;
26772
31465
     }
26773
31466
     if (fd != -1) {
26774
31467
         if (strchr(fdp->mode, 'b') == NULL) {
26775
 
@@ -3197,7 +3273,7 @@
 
31468
@@ -3197,7 +3279,7 @@
26776
31469
             lseek(fd, 0, 0); /* Reset position */
26777
31470
             if (found_encoding == NULL && PyErr_Occurred()) {
26778
31471
                 close(fd);
26781
31474
             }
26782
31475
             encoding = (found_encoding != NULL) ? found_encoding :
26783
31476
                    (char*)PyUnicode_GetDefaultEncoding();
26784
 
@@ -3207,7 +3283,7 @@
 
31477
@@ -3207,7 +3289,7 @@
26785
31478
         if (fob == NULL) {
26786
31479
             close(fd);
26787
31480
             PyMem_FREE(found_encoding);
26790
31483
         }
26791
31484
     }
26792
31485
     else {
26793
 
@@ -3218,8 +3294,12 @@
 
31486
@@ -3218,8 +3300,12 @@
26794
31487
     ret = Py_BuildValue("NN(ssi)",
26795
31488
                   fob, pathobj, fdp->suffix, fdp->mode, fdp->type);
26796
31489
     PyMem_FREE(found_encoding);
26804
31497
 }
26805
31498
 
26806
31499
 static PyObject *
26807
 
@@ -3509,7 +3589,7 @@
 
31500
@@ -3509,7 +3595,7 @@
26808
31501
 {
26809
31502
     static char *kwlist[] = {"path", "debug_override", NULL};
26810
31503
 
26813
31506
     PyObject *pathbytes;
26814
31507
     char *cpathname;
26815
31508
     PyObject *debug_override = NULL;
26816
 
@@ -3526,6 +3606,10 @@
 
31509
@@ -3526,6 +3612,10 @@
26817
31510
         return NULL;
26818
31511
     }
26819
31512
 
26824
31517
     cpathname = make_compiled_pathname(
26825
31518
         PyBytes_AS_STRING(pathbytes),
26826
31519
         buf, MAXPATHLEN+1, debug);
26827
 
@@ -3533,9 +3617,14 @@
 
31520
@@ -3533,9 +3623,14 @@
26828
31521
 
26829
31522
     if (cpathname == NULL) {
26830
31523
         PyErr_Format(PyExc_SystemError, "path buffer too short");
26840
31533
 }
26841
31534
 
26842
31535
 PyDoc_STRVAR(doc_cache_from_source,
26843
 
@@ -3556,7 +3645,7 @@
 
31536
@@ -3556,7 +3651,7 @@
26844
31537
 
26845
31538
     PyObject *pathname_obj;
26846
31539
     char *pathname;
26849
31542
 
26850
31543
     if (!PyArg_ParseTupleAndKeywords(
26851
31544
                 args, kws, "O&", kwlist,
26852
 
@@ -3564,14 +3653,23 @@
 
31545
@@ -3564,14 +3659,23 @@
26853
31546
         return NULL;
26854
31547
 
26855
31548
     pathname = PyBytes_AS_STRING(pathname_obj);
27623
32316
             inv[key] = []
27624
32317
         for item in table[key]:
27625
32318
             store(inv, item, key)
 
32319
diff -r 3d0686d90f55 Tools/unicode/comparecodecs.py
 
32320
--- a/Tools/unicode/comparecodecs.py
 
32321
+++ b/Tools/unicode/comparecodecs.py
 
32322
@@ -30,7 +30,7 @@
 
32323
             mismatch += 1
 
32324
     # Check decoding
 
32325
     for i in range(256):
 
32326
-        c = chr(i)
 
32327
+        c = bytes([i])
 
32328
         try:
 
32329
             u1 = c.decode(encoding1)
 
32330
         except UnicodeError:
27626
32331
diff -r 3d0686d90f55 configure.ac
27627
32332
--- /dev/null
27628
32333
+++ b/configure.ac
27629
 
@@ -0,0 +1,4356 @@
 
32334
@@ -0,0 +1,4372 @@
27630
32335
+dnl ***********************************************
27631
32336
+dnl * Please run autoreconf to test your changes! *
27632
32337
+dnl ***********************************************
28459
33164
+       SVNVERSION="echo Unversioned directory"
28460
33165
+fi
28461
33166
+
 
33167
+AC_SUBST(BASECPPFLAGS)
 
33168
+if test "$abs_srcdir" != "$abs_builddir"; then
 
33169
+    # If we're building out-of-tree, we need to make sure the following
 
33170
+    # resources get picked up before their $srcdir counterparts.
 
33171
+    #   Objects/ -> typeslots.inc
 
33172
+    #   Include/ -> Python-ast.h, graminit.h
 
33173
+    #   Python/  -> importlib.h
 
33174
+    # (A side effect of this is that these resources will automatically be
 
33175
+    #  regenerated when building out-of-tree, regardless of whether or not
 
33176
+    #  the $srcdir counterpart is up-to-date.  This is an acceptable trade
 
33177
+    #  off.)
 
33178
+    BASECPPFLAGS="-IObjects -IInclude -IPython"
 
33179
+else
 
33180
+    BASECPPFLAGS=""
 
33181
+fi
 
33182
+
28462
33183
+AC_SUBST(HGVERSION)
28463
33184
+AC_SUBST(HGTAG)
28464
33185
+AC_SUBST(HGBRANCH)