~ubuntu-branches/ubuntu/quantal/python2.7/quantal-proposed

« 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-01-06 21:57:07 UTC
  • Revision ID: package-import@ubuntu.com-20120106215707-da7ef71vawoka4yy
Tags: 2.7.2-9ubuntu1
* Update to 20120105, taken from the 2.7 branch.
* Test build using db5.1.
* Overwrite some lintian warnings:
  - The -dbg interpreters are not unusual.
  - The -gdb.py files don't need a python dependency.
  - lintian can't handle a whatis entry starting with one word on the line.
* Fix test failures related to distutils debian installation layout.
* Add build-arch/build-indep targets.
* Regenerate Setup and Makefiles after correcting Setup.local.
* profiled-build.diff: Pass PY_CFLAGS instead of CFLAGS for the profiled
  build.
* Pass dpkg-buildflags to the build process, and build third party
  extensions with these flags.
* Add support to build using -flto (and -g1) on some architectures.
* Disable pgo builds for some architectures (for now, keep just
  amd64 armel armhf i386 powerpc ppc64).
* Build-depend on libgdbm-dev to build and run the gdbm tests.
* Build-depend on xvfb to run the tkinter tests.
* python2.7: Provide python2.7-argparse and python-argparse.
* Don't run test_threading on mips/mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# DP: hg updates of the 2.7 release branch (until 2011-12-17).
 
1
# DP: hg updates of the 2.7 release branch (until 2012-01-05).
2
2
 
3
3
# hg diff -r v2.7.2 | filterdiff --exclude=Lib/pstats.py --exclude=Lib/profile.py --exclude=.*ignore --exclude=.hg* --remove-timestamps
4
4
 
45
45
diff -r 8527427914a2 Doc/ACKS.txt
46
46
--- a/Doc/ACKS.txt
47
47
+++ b/Doc/ACKS.txt
48
 
@@ -77,6 +77,7 @@
 
48
@@ -33,6 +33,7 @@
 
49
    * Keith Briggs
 
50
    * Ian Bruntlett
 
51
    * Lee Busby
 
52
+   * Arnaud Calmettes
 
53
    * Lorenzo M. Catucci
 
54
    * Carl Cerecke
 
55
    * Mauro Cicognini
 
56
@@ -77,6 +78,7 @@
49
57
    * Travis B. Hartwell
50
58
    * Tim Hatch
51
59
    * Janko Hauser
53
61
    * Thomas Heller
54
62
    * Bernhard Herzog
55
63
    * Magnus L. Hetland
56
 
@@ -103,6 +104,7 @@
 
64
@@ -103,6 +105,7 @@
57
65
    * Robert Kern
58
66
    * Jim Kerr
59
67
    * Jan Kim
61
69
    * Greg Kochanski
62
70
    * Guido Kollerie
63
71
    * Peter A. Koren
64
 
@@ -139,7 +141,8 @@
 
72
@@ -139,7 +142,8 @@
65
73
    * Ross Moore
66
74
    * Sjoerd Mullender
67
75
    * Dale Nagata
71
79
    * Ng Pheng Siong
72
80
    * Koray Oner
73
81
    * Tomas Oppelstrup
74
 
@@ -180,6 +183,7 @@
 
82
@@ -180,6 +184,7 @@
75
83
    * Joakim Sernbrant
76
84
    * Justin Sheehy
77
85
    * Charlie Shepherd
79
87
    * Michael Simcich
80
88
    * Ionel Simionescu
81
89
    * Michael Sloan
82
 
@@ -197,6 +201,7 @@
 
90
@@ -197,6 +202,7 @@
83
91
    * Kalle Svensson
84
92
    * Jim Tittsler
85
93
    * David Turner
87
95
    * Ville Vainio
88
96
    * Martijn Vries
89
97
    * Charles G. Waldman
90
 
@@ -214,6 +219,7 @@
 
98
@@ -214,6 +220,7 @@
91
99
    * Collin Winter
92
100
    * Blake Winton
93
101
    * Dan Wolfe
95
103
    * Steven Work
96
104
    * Thomas Wouters
97
105
    * Ka-Ping Yee
 
106
diff -r 8527427914a2 Doc/README.txt
 
107
--- a/Doc/README.txt
 
108
+++ b/Doc/README.txt
 
109
@@ -127,7 +127,7 @@
 
110
 as long as you don't change or remove the copyright notice:
 
111
 
 
112
 ----------------------------------------------------------------------
 
113
-Copyright (c) 2000-2008 Python Software Foundation.
 
114
+Copyright (c) 2000-2012 Python Software Foundation.
 
115
 All rights reserved.
 
116
 
 
117
 Copyright (c) 2000 BeOpen.com.
 
118
diff -r 8527427914a2 Doc/bugs.rst
 
119
--- a/Doc/bugs.rst
 
120
+++ b/Doc/bugs.rst
 
121
@@ -57,12 +57,14 @@
 
122
 
 
123
 Each bug report will be assigned to a developer who will determine what needs to
 
124
 be done to correct the problem.  You will receive an update each time action is
 
125
-taken on the bug.  See http://www.python.org/dev/workflow/ for a detailed
 
126
-description of the issue workflow.
 
127
+taken on the bug.
 
128
 
 
129
 
 
130
 .. seealso::
 
131
 
 
132
+   `Python Developer's Guide <http://docs.python.org/devguide/>`_
 
133
+      Detailed description of the issue workflow and developers tools.
 
134
+
 
135
    `How to Report Bugs Effectively <http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>`_
 
136
       Article which goes into some detail about how to create a useful bug report.
 
137
       This describes what kind of information is useful and why it is useful.
 
138
diff -r 8527427914a2 Doc/c-api/arg.rst
 
139
--- a/Doc/c-api/arg.rst
 
140
+++ b/Doc/c-api/arg.rst
 
141
@@ -24,6 +24,11 @@
 
142
 that matches the format unit; and the entry in [square] brackets is the type
 
143
 of the C variable(s) whose address should be passed.
 
144
 
 
145
+These formats allow to access an object as a contiguous chunk of memory.
 
146
+You don't have to provide raw storage for the returned unicode or bytes
 
147
+area.  Also, you won't have to release any memory yourself, except with the
 
148
+``es``, ``es#``, ``et`` and ``et#`` formats.
 
149
+
 
150
 ``s`` (string or Unicode) [const char \*]
 
151
    Convert a Python string or Unicode object to a C pointer to a character
 
152
    string.  You must not provide storage for the string itself; a pointer to
 
153
diff -r 8527427914a2 Doc/c-api/complex.rst
 
154
--- a/Doc/c-api/complex.rst
 
155
+++ b/Doc/c-api/complex.rst
 
156
@@ -63,12 +63,18 @@
 
157
    Return the quotient of two complex numbers, using the C :ctype:`Py_complex`
 
158
    representation.
 
159
 
 
160
+   If *divisor* is null, this method returns zero and sets
 
161
+   :cdata:`errno` to :cdata:`EDOM`.
 
162
+
 
163
 
 
164
 .. cfunction:: Py_complex _Py_c_pow(Py_complex num, Py_complex exp)
 
165
 
 
166
    Return the exponentiation of *num* by *exp*, using the C :ctype:`Py_complex`
 
167
    representation.
 
168
 
 
169
+   If *num* is null and *exp* is not a positive real number,
 
170
+   this method returns zero and sets :cdata:`errno` to :cdata:`EDOM`.
 
171
+
 
172
 
 
173
 Complex Numbers as Python Objects
 
174
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
175
@@ -125,6 +131,7 @@
 
176
 .. cfunction:: Py_complex PyComplex_AsCComplex(PyObject *op)
 
177
 
 
178
    Return the :ctype:`Py_complex` value of the complex number *op*.
 
179
+   Upon failure, this method returns ``-1.0`` as a real value.
 
180
 
 
181
    .. versionchanged:: 2.6
 
182
       If *op* is not a Python complex number object but has a :meth:`__complex__`
98
183
diff -r 8527427914a2 Doc/c-api/exceptions.rst
99
184
--- a/Doc/c-api/exceptions.rst
100
185
+++ b/Doc/c-api/exceptions.rst
134
219
 
135
220
 
136
221
 .. cfunction:: FILE* PyFile_AsFile(PyObject \*p)
 
222
diff -r 8527427914a2 Doc/c-api/float.rst
 
223
--- a/Doc/c-api/float.rst
 
224
+++ b/Doc/c-api/float.rst
 
225
@@ -55,6 +55,8 @@
 
226
    Return a C :ctype:`double` representation of the contents of *pyfloat*.  If
 
227
    *pyfloat* is not a Python floating point object but has a :meth:`__float__`
 
228
    method, this method will first be called to convert *pyfloat* into a float.
 
229
+   This method returns ``-1.0`` upon failure, so one should call
 
230
+   :cfunc:`PyErr_Occurred` to check for errors.
 
231
 
 
232
 
 
233
 .. cfunction:: double PyFloat_AS_DOUBLE(PyObject *pyfloat)
137
234
diff -r 8527427914a2 Doc/c-api/init.rst
138
235
--- a/Doc/c-api/init.rst
139
236
+++ b/Doc/c-api/init.rst
198
295
    indices.
199
296
 
200
297
    .. versionadded:: 2.3
 
298
diff -r 8527427914a2 Doc/c-api/unicode.rst
 
299
--- a/Doc/c-api/unicode.rst
 
300
+++ b/Doc/c-api/unicode.rst
 
301
@@ -327,8 +327,11 @@
 
302
 
 
303
 .. cfunction:: Py_UNICODE* PyUnicode_AsUnicode(PyObject *unicode)
 
304
 
 
305
-   Return a read-only pointer to the Unicode object's internal :ctype:`Py_UNICODE`
 
306
-   buffer, *NULL* if *unicode* is not a Unicode object.
 
307
+   Return a read-only pointer to the Unicode object's internal
 
308
+   :ctype:`Py_UNICODE` buffer, *NULL* if *unicode* is not a Unicode object.
 
309
+   Note that the resulting :ctype:`Py_UNICODE*` string may contain embedded
 
310
+   null characters, which would cause the string to be truncated when used in
 
311
+   most C functions.
 
312
 
 
313
 
 
314
 .. cfunction:: Py_ssize_t PyUnicode_GetSize(PyObject *unicode)
 
315
@@ -391,7 +394,9 @@
 
316
    copied or -1 in case of an error.  Note that the resulting :ctype:`wchar_t`
 
317
    string may or may not be 0-terminated.  It is the responsibility of the caller
 
318
    to make sure that the :ctype:`wchar_t` string is 0-terminated in case this is
 
319
-   required by the application.
 
320
+   required by the application. Also, note that the :ctype:`wchar_t*` string
 
321
+   might contain null characters, which would cause the string to be truncated
 
322
+   when used with most C functions.
 
323
 
 
324
    .. versionchanged:: 2.5
 
325
       This function returned an :ctype:`int` type and used an :ctype:`int`
201
326
diff -r 8527427914a2 Doc/c-api/veryhigh.rst
202
327
--- a/Doc/c-api/veryhigh.rst
203
328
+++ b/Doc/c-api/veryhigh.rst
210
335
    exception), ``1`` if the interpreter exits due to an exception, or ``2``
211
336
    if the parameter list does not represent a valid Python command line.
212
337
 
 
338
diff -r 8527427914a2 Doc/copyright.rst
 
339
--- a/Doc/copyright.rst
 
340
+++ b/Doc/copyright.rst
 
341
@@ -4,7 +4,7 @@
 
342
 
 
343
 Python and this documentation is:
 
344
 
 
345
-Copyright © 2001-2010 Python Software Foundation. All rights reserved.
 
346
+Copyright © 2001-2012 Python Software Foundation. All rights reserved.
 
347
 
 
348
 Copyright © 2000 BeOpen.com. All rights reserved.
 
349
 
213
350
diff -r 8527427914a2 Doc/distutils/apiref.rst
214
351
--- a/Doc/distutils/apiref.rst
215
352
+++ b/Doc/distutils/apiref.rst
992
1129
 in two separate namespaces. When the binding in one namespace changes, the
993
1130
 binding in the other will not, so there will be a discrepancy between them. This
994
1131
 happens when, for example, one module is reloaded, or changes the definition of
 
1132
diff -r 8527427914a2 Doc/howto/functional.rst
 
1133
--- a/Doc/howto/functional.rst
 
1134
+++ b/Doc/howto/functional.rst
 
1135
@@ -44,15 +44,14 @@
 
1136
   functional languages include the ML family (Standard ML, OCaml, and other
 
1137
   variants) and Haskell.
 
1138
 
 
1139
-The designers of some computer languages choose to emphasize one
 
1140
-particular approach to programming.  This often makes it difficult to
 
1141
-write programs that use a different approach.  Other languages are
 
1142
-multi-paradigm languages that support several different approaches.
 
1143
-Lisp, C++, and Python are multi-paradigm; you can write programs or
 
1144
-libraries that are largely procedural, object-oriented, or functional
 
1145
-in all of these languages.  In a large program, different sections
 
1146
-might be written using different approaches; the GUI might be
 
1147
-object-oriented while the processing logic is procedural or
 
1148
+The designers of some computer languages choose to emphasize one particular
 
1149
+approach to programming.  This often makes it difficult to write programs that
 
1150
+use a different approach.  Other languages are multi-paradigm languages that
 
1151
+support several different approaches.  Lisp, C++, and Python are
 
1152
+multi-paradigm; you can write programs or libraries that are largely
 
1153
+procedural, object-oriented, or functional in all of these languages.  In a
 
1154
+large program, different sections might be written using different approaches;
 
1155
+the GUI might be object-oriented while the processing logic is procedural or
 
1156
 functional, for example.
 
1157
 
 
1158
 In a functional program, input flows through a set of functions. Each function
 
1159
@@ -1115,132 +1114,6 @@
 
1160
 Consult the operator module's documentation for a complete list.
 
1161
 
 
1162
 
 
1163
-
 
1164
-The functional module
 
1165
----------------------
 
1166
-
 
1167
-Collin Winter's `functional module <http://oakwinter.com/code/functional/>`__
 
1168
-provides a number of more advanced tools for functional programming. It also
 
1169
-reimplements several Python built-ins, trying to make them more intuitive to
 
1170
-those used to functional programming in other languages.
 
1171
-
 
1172
-This section contains an introduction to some of the most important functions in
 
1173
-``functional``; full documentation can be found at `the project's website
 
1174
-<http://oakwinter.com/code/functional/documentation/>`__.
 
1175
-
 
1176
-``compose(outer, inner, unpack=False)``
 
1177
-
 
1178
-The ``compose()`` function implements function composition.  In other words, it
 
1179
-returns a wrapper around the ``outer`` and ``inner`` callables, such that the
 
1180
-return value from ``inner`` is fed directly to ``outer``.  That is, ::
 
1181
-
 
1182
-    >>> def add(a, b):
 
1183
-    ...     return a + b
 
1184
-    ...
 
1185
-    >>> def double(a):
 
1186
-    ...     return 2 * a
 
1187
-    ...
 
1188
-    >>> compose(double, add)(5, 6)
 
1189
-    22
 
1190
-
 
1191
-is equivalent to ::
 
1192
-
 
1193
-    >>> double(add(5, 6))
 
1194
-    22
 
1195
-
 
1196
-The ``unpack`` keyword is provided to work around the fact that Python functions
 
1197
-are not always `fully curried <http://en.wikipedia.org/wiki/Currying>`__.  By
 
1198
-default, it is expected that the ``inner`` function will return a single object
 
1199
-and that the ``outer`` function will take a single argument. Setting the
 
1200
-``unpack`` argument causes ``compose`` to expect a tuple from ``inner`` which
 
1201
-will be expanded before being passed to ``outer``. Put simply, ::
 
1202
-
 
1203
-    compose(f, g)(5, 6)
 
1204
-
 
1205
-is equivalent to::
 
1206
-
 
1207
-    f(g(5, 6))
 
1208
-
 
1209
-while ::
 
1210
-
 
1211
-    compose(f, g, unpack=True)(5, 6)
 
1212
-
 
1213
-is equivalent to::
 
1214
-
 
1215
-    f(*g(5, 6))
 
1216
-
 
1217
-Even though ``compose()`` only accepts two functions, it's trivial to build up a
 
1218
-version that will compose any number of functions. We'll use ``reduce()``,
 
1219
-``compose()`` and ``partial()`` (the last of which is provided by both
 
1220
-``functional`` and ``functools``). ::
 
1221
-
 
1222
-    from functional import compose, partial
 
1223
-
 
1224
-    multi_compose = partial(reduce, compose)
 
1225
-
 
1226
-
 
1227
-We can also use ``map()``, ``compose()`` and ``partial()`` to craft a version of
 
1228
-``"".join(...)`` that converts its arguments to string::
 
1229
-
 
1230
-    from functional import compose, partial
 
1231
-
 
1232
-    join = compose("".join, partial(map, str))
 
1233
-
 
1234
-
 
1235
-``flip(func)``
 
1236
-
 
1237
-``flip()`` wraps the callable in ``func`` and causes it to receive its
 
1238
-non-keyword arguments in reverse order. ::
 
1239
-
 
1240
-    >>> def triple(a, b, c):
 
1241
-    ...     return (a, b, c)
 
1242
-    ...
 
1243
-    >>> triple(5, 6, 7)
 
1244
-    (5, 6, 7)
 
1245
-    >>>
 
1246
-    >>> flipped_triple = flip(triple)
 
1247
-    >>> flipped_triple(5, 6, 7)
 
1248
-    (7, 6, 5)
 
1249
-
 
1250
-``foldl(func, start, iterable)``
 
1251
-
 
1252
-``foldl()`` takes a binary function, a starting value (usually some kind of
 
1253
-'zero'), and an iterable.  The function is applied to the starting value and the
 
1254
-first element of the list, then the result of that and the second element of the
 
1255
-list, then the result of that and the third element of the list, and so on.
 
1256
-
 
1257
-This means that a call such as::
 
1258
-
 
1259
-    foldl(f, 0, [1, 2, 3])
 
1260
-
 
1261
-is equivalent to::
 
1262
-
 
1263
-    f(f(f(0, 1), 2), 3)
 
1264
-
 
1265
-
 
1266
-``foldl()`` is roughly equivalent to the following recursive function::
 
1267
-
 
1268
-    def foldl(func, start, seq):
 
1269
-        if len(seq) == 0:
 
1270
-            return start
 
1271
-
 
1272
-        return foldl(func, func(start, seq[0]), seq[1:])
 
1273
-
 
1274
-Speaking of equivalence, the above ``foldl`` call can be expressed in terms of
 
1275
-the built-in ``reduce`` like so::
 
1276
-
 
1277
-    reduce(f, [1, 2, 3], 0)
 
1278
-
 
1279
-
 
1280
-We can use ``foldl()``, ``operator.concat()`` and ``partial()`` to write a
 
1281
-cleaner, more aesthetically-pleasing version of Python's ``"".join(...)``
 
1282
-idiom::
 
1283
-
 
1284
-    from functional import foldl, partial from operator import concat
 
1285
-
 
1286
-    join = partial(foldl, concat, "")
 
1287
-
 
1288
-
 
1289
 Revision History and Acknowledgements
 
1290
 =====================================
 
1291
 
 
1292
@@ -1296,9 +1169,10 @@
 
1293
 
 
1294
 Mertz also wrote a 3-part series of articles on functional programming
 
1295
 for IBM's DeveloperWorks site; see
 
1296
-`part 1 <http://www-128.ibm.com/developerworks/library/l-prog.html>`__,
 
1297
-`part 2 <http://www-128.ibm.com/developerworks/library/l-prog2.html>`__, and
 
1298
-`part 3 <http://www-128.ibm.com/developerworks/linux/library/l-prog3.html>`__,
 
1299
+
 
1300
+`part 1 <http://www.ibm.com/developerworks/linux/library/l-prog/index.html>`__,
 
1301
+`part 2 <http://www.ibm.com/developerworks/linux/library/l-prog2/index.html>`__, and
 
1302
+`part 3 <http://www.ibm.com/developerworks/linux/library/l-prog3/index.html>`__,
 
1303
 
 
1304
 
 
1305
 Python documentation
995
1306
diff -r 8527427914a2 Doc/howto/index.rst
996
1307
--- a/Doc/howto/index.rst
997
1308
+++ b/Doc/howto/index.rst
1882
2193
      of mod_python.
1883
2194
 
1884
2195
 
 
2196
@@ -274,7 +274,7 @@
 
2197
 Each web server requires a specific module.
 
2198
 
 
2199
 * Apache has both `mod_fastcgi <http://www.fastcgi.com/drupal/>`_ and `mod_fcgid
 
2200
-  <http://fastcgi.coremail.cn/>`_.  ``mod_fastcgi`` is the original one, but it
 
2201
+  <http://httpd.apache.org/mod_fcgid/>`_.  ``mod_fastcgi`` is the original one, but it
 
2202
   has some licensing issues, which is why it is sometimes considered non-free.
 
2203
   ``mod_fcgid`` is a smaller, compatible alternative.  One of these modules needs
 
2204
   to be loaded by Apache.
 
2205
@@ -364,7 +364,7 @@
 
2206
 
 
2207
 A really great WSGI feature is middleware.  Middleware is a layer around your
 
2208
 program which can add various functionality to it.  There is quite a bit of
 
2209
-`middleware <http://wsgi.org/wsgi/Middleware_and_Utilities>`_ already
 
2210
+`middleware <http://www.wsgi.org/en/latest/libraries.html>`_ already
 
2211
 available.  For example, instead of writing your own session management (HTTP
 
2212
 is a stateless protocol, so to associate multiple HTTP requests with a single
 
2213
 user your application must create and manage such state via a session), you can
 
2214
@@ -395,9 +395,9 @@
 
2215
 
 
2216
 .. seealso::
 
2217
 
 
2218
-   A good overview of WSGI-related code can be found in the `WSGI wiki
 
2219
-   <http://wsgi.org/wsgi>`_, which contains an extensive list of `WSGI servers
 
2220
-   <http://wsgi.org/wsgi/Servers>`_ which can be used by *any* application
 
2221
+   A good overview of WSGI-related code can be found in the `WSGI homepage
 
2222
+   <http://www.wsgi.org/en/latest/index.html>`_, which contains an extensive list of `WSGI servers
 
2223
+   <http://www.wsgi.org/en/latest/servers.html>`_ which can be used by *any* application
 
2224
    supporting WSGI.
 
2225
 
 
2226
    You might be interested in some WSGI-supporting modules already contained in
1885
2227
diff -r 8527427914a2 Doc/includes/capsulethunk.h
1886
2228
--- /dev/null
1887
2229
+++ b/Doc/includes/capsulethunk.h
2579
2921
 
2580
2922
 * ``'append'`` - This stores a list, and appends each argument value to the
2581
2923
   list.  This is useful to allow an option to be specified multiple times.
2582
 
@@ -714,12 +720,12 @@
 
2924
@@ -697,6 +703,19 @@
 
2925
     >>> parser.parse_args('--str --int'.split())
 
2926
     Namespace(types=[<type 'str'>, <type 'int'>])
 
2927
 
 
2928
+* ``'count'`` - This counts the number of times a keyword argument occurs. For
 
2929
+  example, this is useful for increasing verbosity levels::
 
2930
+
 
2931
+    >>> parser = argparse.ArgumentParser()
 
2932
+    >>> parser.add_argument('--verbose', '-v', action='count')
 
2933
+    >>> parser.parse_args('-vvv'.split())
 
2934
+    Namespace(verbose=3)
 
2935
+
 
2936
+* ``'help'`` - This prints a complete help message for all the options in the
 
2937
+  current parser and then exits. By default a help action is automatically
 
2938
+  added to the parser. See :class:`ArgumentParser` for details of how the
 
2939
+  output is created.
 
2940
+
 
2941
 * ``'version'`` - This expects a ``version=`` keyword argument in the
 
2942
   :meth:`~ArgumentParser.add_argument` call, and prints version information
 
2943
   and exits when invoked.
 
2944
@@ -714,12 +733,12 @@
2583
2945
 
2584
2946
 * ``parser`` - The ArgumentParser object which contains this action.
2585
2947
 
2595
2957
   :meth:`~ArgumentParser.add_argument`.
2596
2958
 
2597
2959
 * ``option_string`` - The option string that was used to invoke this action.
2598
 
@@ -751,7 +757,7 @@
 
2960
@@ -751,7 +770,7 @@
2599
2961
 different number of command-line arguments with a single action.  The supported
2600
2962
 values are:
2601
2963
 
2604
2966
   list.  For example::
2605
2967
 
2606
2968
      >>> parser = argparse.ArgumentParser()
2607
 
@@ -763,11 +769,11 @@
 
2969
@@ -763,11 +782,11 @@
2608
2970
   Note that ``nargs=1`` produces a list of one item.  This is different from
2609
2971
   the default, in which the item is produced by itself.
2610
2972
 
2619
2981
   examples to illustrate this::
2620
2982
 
2621
2983
      >>> parser = argparse.ArgumentParser()
2622
 
@@ -795,7 +801,7 @@
 
2984
@@ -795,7 +814,7 @@
2623
2985
      Namespace(infile=<open file '<stdin>', mode 'r' at 0x...>,
2624
2986
                outfile=<open file '<stdout>', mode 'w' at 0x...>)
2625
2987
 
2628
2990
   it generally doesn't make much sense to have more than one positional argument
2629
2991
   with ``nargs='*'``, but multiple optional arguments with ``nargs='*'`` is
2630
2992
   possible.  For example::
2631
 
@@ -809,7 +815,7 @@
 
2993
@@ -809,7 +828,7 @@
2632
2994
 
2633
2995
 * ``'+'``. Just like ``'*'``, all command-line args present are gathered into a
2634
2996
   list.  Additionally, an error message will be generated if there wasn't at
2637
2999
 
2638
3000
      >>> parser = argparse.ArgumentParser(prog='PROG')
2639
3001
      >>> parser.add_argument('foo', nargs='+')
2640
 
@@ -819,8 +825,8 @@
 
3002
@@ -819,8 +838,8 @@
2641
3003
      usage: PROG [-h] foo [foo ...]
2642
3004
      PROG: error: too few arguments
2643
3005
 
2648
3010
 will be consumed and a single item (not a list) will be produced.
2649
3011
 
2650
3012
 
2651
 
@@ -837,9 +843,9 @@
 
3013
@@ -837,9 +856,9 @@
2652
3014
 
2653
3015
 * When :meth:`~ArgumentParser.add_argument` is called with option strings
2654
3016
   (like ``-f`` or ``--foo``) and ``nargs='?'``.  This creates an optional
2660
3022
   See the nargs_ description for examples.
2661
3023
 
2662
3024
 The ``const`` keyword argument defaults to ``None``.
2663
 
@@ -851,7 +857,7 @@
 
3025
@@ -851,7 +870,7 @@
2664
3026
 All optional arguments and some positional arguments may be omitted at the
2665
3027
 command line.  The ``default`` keyword argument of
2666
3028
 :meth:`~ArgumentParser.add_argument`, whose value defaults to ``None``,
2669
3031
 For optional arguments, the ``default`` value is used when the option string
2670
3032
 was not present at the command line::
2671
3033
 
2672
 
@@ -862,8 +868,8 @@
 
3034
@@ -862,8 +881,8 @@
2673
3035
    >>> parser.parse_args(''.split())
2674
3036
    Namespace(foo=42)
2675
3037
 
2680
3042
 
2681
3043
    >>> parser = argparse.ArgumentParser()
2682
3044
    >>> parser.add_argument('foo', nargs='?', default=42)
2683
 
@@ -887,12 +893,12 @@
 
3045
@@ -887,12 +906,12 @@
2684
3046
 type
2685
3047
 ^^^^
2686
3048
 
2698
3060
 
2699
3061
    >>> parser = argparse.ArgumentParser()
2700
3062
    >>> parser.add_argument('foo', type=int)
2701
 
@@ -911,7 +917,7 @@
 
3063
@@ -911,7 +930,7 @@
2702
3064
    Namespace(bar=<open file 'out.txt', mode 'w' at 0x...>)
2703
3065
 
2704
3066
 ``type=`` can take any callable that takes a single string argument and returns
2707
3069
 
2708
3070
    >>> def perfect_square(string):
2709
3071
    ...     value = int(string)
2710
 
@@ -946,11 +952,11 @@
 
3072
@@ -946,11 +965,11 @@
2711
3073
 choices
2712
3074
 ^^^^^^^
2713
3075
 
2722
3084
 
2723
3085
    >>> parser = argparse.ArgumentParser(prog='PROG')
2724
3086
    >>> parser.add_argument('foo', choices='abc')
2725
 
@@ -1052,8 +1058,8 @@
 
3087
@@ -1043,6 +1062,17 @@
 
3088
    optional arguments:
 
3089
     -h, --help  show this help message and exit
 
3090
 
 
3091
+:mod:`argparse` supports silencing the help entry for certain options, by
 
3092
+setting the ``help`` value to ``argparse.SUPPRESS``::
 
3093
+
 
3094
+   >>> parser = argparse.ArgumentParser(prog='frobble')
 
3095
+   >>> parser.add_argument('--foo', help=argparse.SUPPRESS)
 
3096
+   >>> parser.print_help()
 
3097
+   usage: frobble [-h]
 
3098
+
 
3099
+   optional arguments:
 
3100
+     -h, --help  show this help message and exit
 
3101
+
 
3102
 
 
3103
 metavar
 
3104
 ^^^^^^^
 
3105
@@ -1052,8 +1082,8 @@
2726
3106
 value as the "name" of each object.  By default, for positional argument
2727
3107
 actions, the dest_ value is used directly, and for optional argument actions,
2728
3108
 the dest_ value is uppercased.  So, a single positional argument with
2733
3113
 will be referred to as ``FOO``.  An example::
2734
3114
 
2735
3115
    >>> parser = argparse.ArgumentParser()
2736
 
@@ -1125,10 +1131,10 @@
 
3116
@@ -1125,10 +1155,10 @@
2737
3117
 
2738
3118
 For optional argument actions, the value of ``dest`` is normally inferred from
2739
3119
 the option strings.  :class:`ArgumentParser` generates the value of ``dest`` by
2747
3127
 the string is a valid attribute name.  The examples below illustrate this
2748
3128
 behavior::
2749
3129
 
2750
 
@@ -1160,7 +1166,7 @@
 
3130
@@ -1160,7 +1190,7 @@
2751
3131
    created and how they are assigned. See the documentation for
2752
3132
    :meth:`add_argument` for details.
2753
3133
 
2756
3136
    :class:`Namespace` object is created for the attributes.
2757
3137
 
2758
3138
 
2759
 
@@ -1231,15 +1237,15 @@
 
3139
@@ -1231,15 +1261,15 @@
2760
3140
    PROG: error: extra arguments found: badger
2761
3141
 
2762
3142
 
2776
3156
 there are no options in the parser that look like negative numbers::
2777
3157
 
2778
3158
    >>> parser = argparse.ArgumentParser(prog='PROG')
2779
 
@@ -1272,7 +1278,7 @@
 
3159
@@ -1272,7 +1302,7 @@
2780
3160
    usage: PROG [-h] [-1 ONE] [foo]
2781
3161
    PROG: error: argument -1: expected one argument
2782
3162
 
2785
3165
 like negative numbers, you can insert the pseudo-argument ``'--'`` which tells
2786
3166
 :meth:`~ArgumentParser.parse_args` that everything after that is a positional
2787
3167
 argument::
2788
 
@@ -1304,7 +1310,7 @@
 
3168
@@ -1304,7 +1334,7 @@
2789
3169
 Beyond ``sys.argv``
2790
3170
 ^^^^^^^^^^^^^^^^^^^
2791
3171
 
2794
3174
 of :data:`sys.argv`.  This can be accomplished by passing a list of strings to
2795
3175
 :meth:`~ArgumentParser.parse_args`.  This is useful for testing at the
2796
3176
 interactive prompt::
2797
 
@@ -1325,11 +1331,14 @@
 
3177
@@ -1325,11 +1355,14 @@
2798
3178
 The Namespace object
2799
3179
 ^^^^^^^^^^^^^^^^^^^^
2800
3180
 
2814
3194
 
2815
3195
    >>> parser = argparse.ArgumentParser()
2816
3196
    >>> parser.add_argument('--foo')
2817
 
@@ -1387,7 +1396,7 @@
 
3197
@@ -1387,7 +1420,7 @@
2818
3198
      >>> parser_b = subparsers.add_parser('b', help='b help')
2819
3199
      >>> parser_b.add_argument('--baz', choices='XYZ', help='baz help')
2820
3200
      >>>
2823
3203
      >>> parser.parse_args(['a', '12'])
2824
3204
      Namespace(bar=12, foo=False)
2825
3205
      >>> parser.parse_args(['--foo', 'b', '--baz', 'Z'])
2826
 
@@ -1396,8 +1405,8 @@
 
3206
@@ -1396,8 +1429,8 @@
2827
3207
    Note that the object returned by :meth:`parse_args` will only contain
2828
3208
    attributes for the main parser and the subparser that was selected by the
2829
3209
    command line (and not any other subparsers).  So in the example above, when
2834
3214
    ``baz`` attributes are present.
2835
3215
 
2836
3216
    Similarly, when a help message is requested from a subparser, only the help
2837
 
@@ -1519,7 +1528,7 @@
 
3217
@@ -1519,7 +1552,7 @@
2838
3218
 
2839
3219
    The :class:`FileType` factory creates objects that can be passed to the type
2840
3220
    argument of :meth:`ArgumentParser.add_argument`.  Arguments that have
2843
3223
    with the requested modes and buffer sizes:
2844
3224
 
2845
3225
    >>> parser = argparse.ArgumentParser()
2846
 
@@ -1633,7 +1642,7 @@
 
3226
@@ -1633,7 +1666,7 @@
2847
3227
 .. method:: ArgumentParser.set_defaults(**kwargs)
2848
3228
 
2849
3229
    Most of the time, the attributes of the object returned by :meth:`parse_args`
2852
3232
    actions.  :meth:`set_defaults` allows some additional
2853
3233
    attributes that are determined without any inspection of the command line to
2854
3234
    be added::
2855
 
@@ -1757,7 +1766,7 @@
 
3235
@@ -1757,7 +1790,7 @@
2856
3236
 .. method:: ArgumentParser.error(message)
2857
3237
 
2858
3238
    This method prints a usage message including the *message* to the
3049
3429
 
3050
3430
 .. class:: Calendar([firstweekday])
3051
3431
 
 
3432
diff -r 8527427914a2 Doc/library/carbon.rst
 
3433
--- a/Doc/library/carbon.rst
 
3434
+++ b/Doc/library/carbon.rst
 
3435
@@ -14,7 +14,7 @@
 
3436
 in Python (input and output buffers, especially).  All methods and functions
 
3437
 have a :attr:`__doc__` string describing their arguments and return values, and
 
3438
 for additional description you are referred to `Inside Macintosh
 
3439
-<http://developer.apple.com/documentation/macos8/mac8.html>`_ or similar works.
 
3440
+<http://developer.apple.com/legacy/mac/library/#documentation/macos8/mac8.html>`_ or similar works.
 
3441
 
 
3442
 These modules all live in a package called :mod:`Carbon`. Despite that name they
 
3443
 are not all part of the Carbon framework: CF is really in the CoreFoundation
 
3444
@@ -515,7 +515,7 @@
 
3445
 
 
3446
 .. seealso::
 
3447
 
 
3448
-   `Scrap Manager <http://developer.apple.com/documentation/mac/MoreToolbox/MoreToolbox-109.html>`_
 
3449
+   `Scrap Manager <http://developer.apple.com/legacy/mac/library/documentation/mac/MoreToolbox/MoreToolbox-109.html>`_
 
3450
       Apple's documentation for the Scrap Manager gives a lot of useful information
 
3451
       about using the Scrap Manager in applications.
 
3452
 
3052
3453
diff -r 8527427914a2 Doc/library/cgi.rst
3053
3454
--- a/Doc/library/cgi.rst
3054
3455
+++ b/Doc/library/cgi.rst
4687
5088
 
4688
5089
 This module provides a duplicate interface to the :mod:`threading` module.  It
4689
5090
 is meant to be imported when the :mod:`thread` module is not provided on a
 
5091
diff -r 8527427914a2 Doc/library/easydialogs.rst
 
5092
--- a/Doc/library/easydialogs.rst
 
5093
+++ b/Doc/library/easydialogs.rst
 
5094
@@ -143,7 +143,7 @@
 
5095
 
 
5096
 .. seealso::
 
5097
 
 
5098
-   `Navigation Services Reference <http://developer.apple.com/documentation/Carbon/Reference/Navigation_Services_Ref/>`_
 
5099
+   `Navigation Services Reference <http://developer.apple.com/legacy/mac/library/#documentation/Carbon/Conceptual/NavServicesIntro/ns_intro_carb/ns_into_carb.html>`_
 
5100
       Programmer's reference documentation for the Navigation Services, a part of the
 
5101
       Carbon framework.
 
5102
 
4690
5103
diff -r 8527427914a2 Doc/library/email.message.rst
4691
5104
--- a/Doc/library/email.message.rst
4692
5105
+++ b/Doc/library/email.message.rst
5334
5747
 This module defines a class :class:`HTMLParser` which serves as the basis for
5335
5748
 parsing text files formatted in HTML (HyperText Mark-up Language) and XHTML.
5336
5749
 Unlike the parser in :mod:`htmllib`, this parser is not based on the SGML parser
5337
 
@@ -105,9 +109,9 @@
 
5750
@@ -60,7 +64,8 @@
 
5751
 
 
5752
    Feed some text to the parser.  It is processed insofar as it consists of
 
5753
    complete elements; incomplete data is buffered until more data is fed or
 
5754
-   :meth:`close` is called.
 
5755
+   :meth:`close` is called.  *data* can be either :class:`unicode` or
 
5756
+   :class:`str`, but passing :class:`unicode` is advised.
 
5757
 
 
5758
 
 
5759
 .. method:: HTMLParser.close()
 
5760
@@ -105,9 +110,9 @@
5338
5761
 .. method:: HTMLParser.handle_startendtag(tag, attrs)
5339
5762
 
5340
5763
    Similar to :meth:`handle_starttag`, but called when the parser encounters an
5346
5769
 
5347
5770
 
5348
5771
 .. method:: HTMLParser.handle_endtag(tag)
5349
 
@@ -119,7 +123,8 @@
 
5772
@@ -119,7 +124,8 @@
5350
5773
 
5351
5774
 .. method:: HTMLParser.handle_data(data)
5352
5775
 
5356
5779
    overridden by a derived class; the base class implementation does nothing.
5357
5780
 
5358
5781
 
5359
 
@@ -182,16 +187,21 @@
 
5782
@@ -182,16 +188,21 @@
5360
5783
 Example HTML Parser Application
5361
5784
 -------------------------------
5362
5785
 
5404
5827
    it is required to do HTTPS Conection through a proxy server.
5405
5828
 
5406
5829
-   The headers argument should be a mapping of extra HTTP headers to to sent
5407
 
+   The headers argument should be a mapping of extra HTTP headers to sent
 
5830
+   The headers argument should be a mapping of extra HTTP headers to send
5408
5831
    with the CONNECT request.
5409
5832
 
5410
5833
    .. versionadded:: 2.7
5801
6224
+   If this evaluates to false, logging messages are not passed to the handlers
5802
6225
+   of ancestor loggers.
5803
6226
+
5804
 
+   The constructor sets this attribute to 1.
 
6227
+   The constructor sets this attribute to ``True``.
5805
6228
 
5806
6229
 
5807
6230
 .. method:: Logger.setLevel(lvl)
5857
6280
diff -r 8527427914a2 Doc/library/mimetypes.rst
5858
6281
--- a/Doc/library/mimetypes.rst
5859
6282
+++ b/Doc/library/mimetypes.rst
5860
 
@@ -9,6 +9,10 @@
 
6283
@@ -1,4 +1,3 @@
 
6284
-
 
6285
 :mod:`mimetypes` --- Map filenames to MIME types
 
6286
 ================================================
 
6287
 
 
6288
@@ -9,6 +8,10 @@
5861
6289
 
5862
6290
 .. index:: pair: MIME; content type
5863
6291
 
5868
6296
 The :mod:`mimetypes` module converts between a filename or URL and the MIME type
5869
6297
 associated with the filename extension.  Conversions are provided from filename
5870
6298
 to MIME type and from MIME type to filename extension; encodings are not
 
6299
@@ -23,31 +26,31 @@
 
6300
 the information :func:`init` sets up.
 
6301
 
 
6302
 
 
6303
-.. function:: guess_type(filename[, strict])
 
6304
+.. function:: guess_type(url, strict=True)
 
6305
 
 
6306
    .. index:: pair: MIME; headers
 
6307
 
 
6308
-   Guess the type of a file based on its filename or URL, given by *filename*.  The
 
6309
+   Guess the type of a file based on its filename or URL, given by *url*.  The
 
6310
    return value is a tuple ``(type, encoding)`` where *type* is ``None`` if the
 
6311
    type can't be guessed (missing or unknown suffix) or a string of the form
 
6312
    ``'type/subtype'``, usable for a MIME :mailheader:`content-type` header.
 
6313
 
 
6314
    *encoding* is ``None`` for no encoding or the name of the program used to encode
 
6315
    (e.g. :program:`compress` or :program:`gzip`). The encoding is suitable for use
 
6316
-   as a :mailheader:`Content-Encoding` header, *not* as a
 
6317
+   as a :mailheader:`Content-Encoding` header, **not** as a
 
6318
    :mailheader:`Content-Transfer-Encoding` header. The mappings are table driven.
 
6319
    Encoding suffixes are case sensitive; type suffixes are first tried case
 
6320
    sensitively, then case insensitively.
 
6321
 
 
6322
-   Optional *strict* is a flag specifying whether the list of known MIME types
 
6323
+   The optional *strict* argument is a flag specifying whether the list of known MIME types
 
6324
    is limited to only the official types `registered with IANA
 
6325
-   <http://www.iana.org/assignments/media-types/>`_ are recognized.
 
6326
-   When *strict* is true (the default), only the IANA types are supported; when
 
6327
-   *strict* is false, some additional non-standard but commonly used MIME types
 
6328
+   <http://www.iana.org/assignments/media-types/>`_.
 
6329
+   When *strict* is ``True`` (the default), only the IANA types are supported; when
 
6330
+   *strict* is ``False``, some additional non-standard but commonly used MIME types
 
6331
    are also recognized.
 
6332
 
 
6333
 
 
6334
-.. function:: guess_all_extensions(type[, strict])
 
6335
+.. function:: guess_all_extensions(type, strict=True)
 
6336
 
 
6337
    Guess the extensions for a file based on its MIME type, given by *type*. The
 
6338
    return value is a list of strings giving all possible filename extensions,
 
6339
@@ -55,25 +58,25 @@
 
6340
    been associated with any particular data stream, but would be mapped to the MIME
 
6341
    type *type* by :func:`guess_type`.
 
6342
 
 
6343
-   Optional *strict* has the same meaning as with the :func:`guess_type` function.
 
6344
+   The optional *strict* argument has the same meaning as with the :func:`guess_type` function.
 
6345
 
 
6346
 
 
6347
-.. function:: guess_extension(type[, strict])
 
6348
+.. function:: guess_extension(type, strict=True)
 
6349
 
 
6350
    Guess the extension for a file based on its MIME type, given by *type*. The
 
6351
    return value is a string giving a filename extension, including the leading dot
 
6352
    (``'.'``).  The extension is not guaranteed to have been associated with any
 
6353
-   particular data stream, but would be mapped to the  MIME type *type* by
 
6354
+   particular data stream, but would be mapped to the MIME type *type* by
 
6355
    :func:`guess_type`.  If no extension can be guessed for *type*, ``None`` is
 
6356
    returned.
 
6357
 
 
6358
-   Optional *strict* has the same meaning as with the :func:`guess_type` function.
 
6359
+   The optional *strict* argument has the same meaning as with the :func:`guess_type` function.
 
6360
 
 
6361
 Some additional functions and data items are available for controlling the
 
6362
 behavior of the module.
 
6363
 
 
6364
 
 
6365
-.. function:: init([files])
 
6366
+.. function:: init(files=None)
 
6367
 
 
6368
    Initialize the internal data structures.  If given, *files* must be a sequence
 
6369
    of file names which should be used to augment the default type map.  If omitted,
 
6370
@@ -88,26 +91,26 @@
 
6371
 
 
6372
 .. function:: read_mime_types(filename)
 
6373
 
 
6374
-   Load the type map given in the file *filename*, if it exists.  The  type map is
 
6375
+   Load the type map given in the file *filename*, if it exists.  The type map is
 
6376
    returned as a dictionary mapping filename extensions, including the leading dot
 
6377
    (``'.'``), to strings of the form ``'type/subtype'``.  If the file *filename*
 
6378
    does not exist or cannot be read, ``None`` is returned.
 
6379
 
 
6380
 
 
6381
-.. function:: add_type(type, ext[, strict])
 
6382
+.. function:: add_type(type, ext, strict=True)
 
6383
 
 
6384
-   Add a mapping from the mimetype *type* to the extension *ext*. When the
 
6385
+   Add a mapping from the MIME type *type* to the extension *ext*. When the
 
6386
    extension is already known, the new type will replace the old one. When the type
 
6387
    is already known the extension will be added to the list of known extensions.
 
6388
 
 
6389
-   When *strict* is True (the default), the mapping will added to the official MIME
 
6390
+   When *strict* is ``True`` (the default), the mapping will added to the official MIME
 
6391
    types, otherwise to the non-standard ones.
 
6392
 
 
6393
 
 
6394
 .. data:: inited
 
6395
 
 
6396
    Flag indicating whether or not the global data structures have been initialized.
 
6397
-   This is set to true by :func:`init`.
 
6398
+   This is set to ``True`` by :func:`init`.
 
6399
 
 
6400
 
 
6401
 .. data:: knownfiles
 
6402
@@ -142,23 +145,6 @@
 
6403
    Dictionary mapping filename extensions to non-standard, but commonly found MIME
 
6404
    types.
 
6405
 
 
6406
-The :class:`MimeTypes` class may be useful for applications which may want more
 
6407
-than one MIME-type database:
 
6408
-
 
6409
-
 
6410
-.. class:: MimeTypes([filenames])
 
6411
-
 
6412
-   This class represents a MIME-types database.  By default, it provides access to
 
6413
-   the same database as the rest of this module. The initial database is a copy of
 
6414
-   that provided by the module, and may be extended by loading additional
 
6415
-   :file:`mime.types`\ -style files into the database using the :meth:`read` or
 
6416
-   :meth:`readfp` methods.  The mapping dictionaries may also be cleared before
 
6417
-   loading additional data if the default data is not desired.
 
6418
-
 
6419
-   The optional *filenames* parameter can be used to cause additional files to be
 
6420
-   loaded "on top" of the default database.
 
6421
-
 
6422
-   .. versionadded:: 2.2
 
6423
 
 
6424
 An example usage of the module::
 
6425
 
 
6426
@@ -179,70 +165,96 @@
 
6427
 MimeTypes Objects
 
6428
 -----------------
 
6429
 
 
6430
-:class:`MimeTypes` instances provide an interface which is very like that of the
 
6431
+The :class:`MimeTypes` class may be useful for applications which may want more
 
6432
+than one MIME-type database; it provides an interface similar to the one of the
 
6433
 :mod:`mimetypes` module.
 
6434
 
 
6435
 
 
6436
+.. class:: MimeTypes(filenames=(), strict=True)
 
6437
+
 
6438
+   This class represents a MIME-types database.  By default, it provides access to
 
6439
+   the same database as the rest of this module. The initial database is a copy of
 
6440
+   that provided by the module, and may be extended by loading additional
 
6441
+   :file:`mime.types`\ -style files into the database using the :meth:`read` or
 
6442
+   :meth:`readfp` methods.  The mapping dictionaries may also be cleared before
 
6443
+   loading additional data if the default data is not desired.
 
6444
+
 
6445
+   The optional *filenames* parameter can be used to cause additional files to be
 
6446
+   loaded "on top" of the default database.
 
6447
+
 
6448
+
 
6449
 .. attribute:: MimeTypes.suffix_map
 
6450
 
 
6451
    Dictionary mapping suffixes to suffixes.  This is used to allow recognition of
 
6452
    encoded files for which the encoding and the type are indicated by the same
 
6453
    extension.  For example, the :file:`.tgz` extension is mapped to :file:`.tar.gz`
 
6454
    to allow the encoding and type to be recognized separately.  This is initially a
 
6455
-   copy of the global ``suffix_map`` defined in the module.
 
6456
+   copy of the global :data:`suffix_map` defined in the module.
 
6457
 
 
6458
 
 
6459
 .. attribute:: MimeTypes.encodings_map
 
6460
 
 
6461
    Dictionary mapping filename extensions to encoding types.  This is initially a
 
6462
-   copy of the global ``encodings_map`` defined in the module.
 
6463
+   copy of the global :data:`encodings_map` defined in the module.
 
6464
 
 
6465
 
 
6466
 .. attribute:: MimeTypes.types_map
 
6467
 
 
6468
-   Dictionary mapping filename extensions to MIME types.  This is initially a copy
 
6469
-   of the global ``types_map`` defined in the module.
 
6470
+   Tuple containing two dictionaries, mapping filename extensions to MIME types:
 
6471
+   the first dictionary is for the non-standards types and the second one is for
 
6472
+   the standard types. They are initialized by :data:`common_types` and
 
6473
+   :data:`types_map`.
 
6474
 
 
6475
 
 
6476
-.. attribute:: MimeTypes.common_types
 
6477
+.. attribute:: MimeTypes.types_map_inv
 
6478
 
 
6479
-   Dictionary mapping filename extensions to non-standard, but commonly found MIME
 
6480
-   types.  This is initially a copy of the global ``common_types`` defined in the
 
6481
-   module.
 
6482
+   Tuple containing two dictionaries, mapping MIME types to a list of filename
 
6483
+   extensions: the first dictionary is for the non-standards types and the
 
6484
+   second one is for the standard types. They are initialized by
 
6485
+   :data:`common_types` and :data:`types_map`.
 
6486
 
 
6487
 
 
6488
-.. method:: MimeTypes.guess_extension(type[, strict])
 
6489
+.. method:: MimeTypes.guess_extension(type, strict=True)
 
6490
 
 
6491
    Similar to the :func:`guess_extension` function, using the tables stored as part
 
6492
    of the object.
 
6493
 
 
6494
 
 
6495
-.. method:: MimeTypes.guess_all_extensions(type[, strict])
 
6496
-
 
6497
-   Similar to the :func:`guess_all_extensions` function, using the tables stored as part
 
6498
-   of the object.
 
6499
-
 
6500
-
 
6501
-.. method:: MimeTypes.guess_type(url[, strict])
 
6502
+.. method:: MimeTypes.guess_type(url, strict=True)
 
6503
 
 
6504
    Similar to the :func:`guess_type` function, using the tables stored as part of
 
6505
    the object.
 
6506
 
 
6507
 
 
6508
-.. method:: MimeTypes.read(path)
 
6509
+.. method:: MimeTypes.guess_all_extensions(type, strict=True)
 
6510
 
 
6511
-   Load MIME information from a file named *path*.  This uses :meth:`readfp` to
 
6512
+   Similar to the :func:`guess_all_extensions` function, using the tables stored
 
6513
+   as part of the object.
 
6514
+
 
6515
+
 
6516
+.. method:: MimeTypes.read(filename, strict=True)
 
6517
+
 
6518
+   Load MIME information from a file named *filename*.  This uses :meth:`readfp` to
 
6519
    parse the file.
 
6520
 
 
6521
+   If *strict* is ``True``, information will be added to list of standard types,
 
6522
+   else to the list of non-standard types.
 
6523
 
 
6524
-.. method:: MimeTypes.readfp(file)
 
6525
 
 
6526
-   Load MIME type information from an open file.  The file must have the format of
 
6527
+.. method:: MimeTypes.readfp(fp, strict=True)
 
6528
+
 
6529
+   Load MIME type information from an open file *fp*.  The file must have the format of
 
6530
    the standard :file:`mime.types` files.
 
6531
 
 
6532
+   If *strict* is ``True``, information will be added to the list of standard
 
6533
+   types, else to the list of non-standard types.
 
6534
 
 
6535
-.. method:: MimeTypes.read_windows_registry()
 
6536
+
 
6537
+.. method:: MimeTypes.read_windows_registry(strict=True)
 
6538
 
 
6539
    Load MIME type information from the Windows registry.  Availability: Windows.
 
6540
 
 
6541
+   If *strict* is ``True``, information will be added to the list of standard
 
6542
+   types, else to the list of non-standard types.
 
6543
+
 
6544
    .. versionadded:: 2.7
5871
6545
diff -r 8527427914a2 Doc/library/mmap.rst
5872
6546
--- a/Doc/library/mmap.rst
5873
6547
+++ b/Doc/library/mmap.rst
5911
6585
diff -r 8527427914a2 Doc/library/multiprocessing.rst
5912
6586
--- a/Doc/library/multiprocessing.rst
5913
6587
+++ b/Doc/library/multiprocessing.rst
 
6588
@@ -282,7 +282,7 @@
 
6589
 
 
6590
    if __name__ == '__main__':
 
6591
        pool = Pool(processes=4)              # start 4 worker processes
 
6592
-       result = pool.apply_async(f, [10])     # evaluate "f(10)" asynchronously
 
6593
+       result = pool.apply_async(f, [10])    # evaluate "f(10)" asynchronously
 
6594
        print result.get(timeout=1)           # prints "100" unless your computer is *very* slow
 
6595
        print pool.map(f, range(10))          # prints "[0, 1, 4,..., 81]"
 
6596
 
 
6597
@@ -472,7 +472,7 @@
 
6598
 
 
6599
 If you use :class:`JoinableQueue` then you **must** call
 
6600
 :meth:`JoinableQueue.task_done` for each task removed from the queue or else the
 
6601
-semaphore used to count the number of unfinished tasks may eventually overflow
 
6602
+semaphore used to count the number of unfinished tasks may eventually overflow,
 
6603
 raising an exception.
 
6604
 
 
6605
 Note that one can also create a shared queue by using a manager object -- see
 
6606
@@ -490,7 +490,7 @@
 
6607
 
 
6608
    If a process is killed using :meth:`Process.terminate` or :func:`os.kill`
 
6609
    while it is trying to use a :class:`Queue`, then the data in the queue is
 
6610
-   likely to become corrupted.  This may cause any other processes to get an
 
6611
+   likely to become corrupted.  This may cause any other process to get an
 
6612
    exception when it tries to use the queue later on.
 
6613
 
 
6614
 .. warning::
5914
6615
@@ -552,9 +552,9 @@
5915
6616
       Return ``True`` if the queue is full, ``False`` otherwise.  Because of
5916
6617
       multithreading/multiprocessing semantics, this is not reliable.
5937
6638
 
5938
6639
    .. method:: get([block[, timeout]])
5939
6640
 
 
6641
@@ -692,7 +692,7 @@
 
6642
    (By default :data:`sys.executable` is used).  Embedders will probably need to
 
6643
    do some thing like ::
 
6644
 
 
6645
-      setExecutable(os.path.join(sys.exec_prefix, 'pythonw.exe'))
 
6646
+      set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe'))
 
6647
 
 
6648
    before they can create child processes.  (Windows only)
 
6649
 
 
6650
@@ -711,7 +711,7 @@
 
6651
 Connection objects allow the sending and receiving of picklable objects or
 
6652
 strings.  They can be thought of as message oriented connected sockets.
 
6653
 
 
6654
-Connection objects usually created using :func:`Pipe` -- see also
 
6655
+Connection objects are usually created using :func:`Pipe` -- see also
 
6656
 :ref:`multiprocessing-listeners-clients`.
 
6657
 
 
6658
 .. class:: Connection
 
6659
@@ -722,7 +722,7 @@
 
6660
       using :meth:`recv`.
 
6661
 
 
6662
       The object must be picklable.  Very large pickles (approximately 32 MB+,
 
6663
-      though it depends on the OS) may raise a ValueError exception.
 
6664
+      though it depends on the OS) may raise a :exc:`ValueError` exception.
 
6665
 
 
6666
    .. method:: recv()
 
6667
 
 
6668
@@ -732,7 +732,7 @@
 
6669
 
 
6670
    .. method:: fileno()
 
6671
 
 
6672
-      Returns the file descriptor or handle used by the connection.
 
6673
+      Return the file descriptor or handle used by the connection.
 
6674
 
 
6675
    .. method:: close()
 
6676
 
 
6677
@@ -756,7 +756,7 @@
 
6678
       If *offset* is given then data is read from that position in *buffer*.  If
 
6679
       *size* is given then that many bytes will be read from buffer.  Very large
 
6680
       buffers (approximately 32 MB+, though it depends on the OS) may raise a
 
6681
-      ValueError exception
 
6682
+      :exc:`ValueError` exception
 
6683
 
 
6684
    .. method:: recv_bytes([maxlength])
 
6685
 
 
6686
@@ -1329,7 +1329,7 @@
 
6687
 >>>>>>>>>>>>>>>>>>>
 
6688
 
 
6689
 To create one's own manager, one creates a subclass of :class:`BaseManager` and
 
6690
-use the :meth:`~BaseManager.register` classmethod to register new types or
 
6691
+uses the :meth:`~BaseManager.register` classmethod to register new types or
 
6692
 callables with the manager class.  For example::
 
6693
 
 
6694
    from multiprocessing.managers import BaseManager
5940
6695
@@ -1494,7 +1494,7 @@
5941
6696
       a new shared object -- see documentation for the *method_to_typeid*
5942
6697
       argument of :meth:`BaseManager.register`.
5946
6701
       :meth:`_callmethod`.  If some other exception is raised in the manager's
5947
6702
       process then this is converted into a :exc:`RemoteError` exception and is
5948
6703
       raised by :meth:`_callmethod`.
 
6704
@@ -1579,10 +1579,10 @@
 
6705
 
 
6706
    .. method:: apply(func[, args[, kwds]])
 
6707
 
 
6708
-      Equivalent of the :func:`apply` built-in function.  It blocks till the
 
6709
-      result is ready.  Given this blocks, :meth:`apply_async` is better suited
 
6710
-      for performing work in parallel. Additionally, the passed
 
6711
-      in function is only executed in one of the workers of the pool.
 
6712
+      Equivalent of the :func:`apply` built-in function.  It blocks until the
 
6713
+      result is ready, so :meth:`apply_async` is better suited for performing
 
6714
+      work in parallel. Additionally, *func* is only executed in one of the
 
6715
+      workers of the pool.
 
6716
 
 
6717
    .. method:: apply_async(func[, args[, kwds[, callback]]])
 
6718
 
 
6719
@@ -1596,7 +1596,7 @@
 
6720
    .. method:: map(func, iterable[, chunksize])
 
6721
 
 
6722
       A parallel equivalent of the :func:`map` built-in function (it supports only
 
6723
-      one *iterable* argument though).  It blocks till the result is ready.
 
6724
+      one *iterable* argument though).  It blocks until the result is ready.
 
6725
 
 
6726
       This method chops the iterable into a number of chunks which it submits to
 
6727
       the process pool as separate tasks.  The (approximate) size of these
5949
6728
@@ -1617,7 +1617,7 @@
5950
6729
 
5951
6730
       The *chunksize* argument is the same as the one used by the :meth:`.map`
5955
6734
       ``1``.
5956
6735
 
5957
6736
       Also if *chunksize* is ``1`` then the :meth:`!next` method of the iterator
 
6737
@@ -2046,7 +2046,7 @@
 
6738
     On Windows many types from :mod:`multiprocessing` need to be picklable so
 
6739
     that child processes can use them.  However, one should generally avoid
 
6740
     sending shared objects to other processes using pipes or queues.  Instead
 
6741
-    you should arrange the program so that a process which need access to a
 
6742
+    you should arrange the program so that a process which needs access to a
 
6743
     shared resource created elsewhere can inherit it from an ancestor process.
 
6744
 
 
6745
 Avoid terminating processes
 
6746
@@ -2125,7 +2125,7 @@
 
6747
            for i in range(10):
 
6748
                 Process(target=f, args=(lock,)).start()
 
6749
 
 
6750
-Beware replacing sys.stdin with a "file like object"
 
6751
+Beware of replacing :data:`sys.stdin` with a "file like object"
 
6752
 
 
6753
     :mod:`multiprocessing` originally unconditionally called::
 
6754
 
 
6755
@@ -2243,7 +2243,7 @@
 
6756
 
 
6757
 
 
6758
 An example showing how to use queues to feed tasks to a collection of worker
 
6759
-process and collect the results:
 
6760
+processes and collect the results:
 
6761
 
 
6762
 .. literalinclude:: ../includes/mp_workers.py
 
6763
 
5958
6764
diff -r 8527427914a2 Doc/library/netrc.rst
5959
6765
--- a/Doc/library/netrc.rst
5960
6766
+++ b/Doc/library/netrc.rst
5999
6805
 
6000
6806
 
6001
6807
 .. class:: Number
 
6808
diff -r 8527427914a2 Doc/library/operator.rst
 
6809
--- a/Doc/library/operator.rst
 
6810
+++ b/Doc/library/operator.rst
 
6811
@@ -12,11 +12,11 @@
 
6812
    from operator import itemgetter
 
6813
 
 
6814
 
 
6815
-The :mod:`operator` module exports a set of functions implemented in C
 
6816
-corresponding to the intrinsic operators of Python.  For example,
 
6817
-``operator.add(x, y)`` is equivalent to the expression ``x+y``.  The function
 
6818
-names are those used for special class methods; variants without leading and
 
6819
-trailing ``__`` are also provided for convenience.
 
6820
+The :mod:`operator` module exports a set of efficient functions corresponding to
 
6821
+the intrinsic operators of Python.  For example, ``operator.add(x, y)`` is
 
6822
+equivalent to the expression ``x+y``.  The function names are those used for
 
6823
+special class methods; variants without leading and trailing ``__`` are also
 
6824
+provided for convenience.
 
6825
 
 
6826
 The functions fall into categories that perform object comparisons, logical
 
6827
 operations, mathematical operations, sequence operations, and abstract type
6002
6828
diff -r 8527427914a2 Doc/library/optparse.rst
6003
6829
--- a/Doc/library/optparse.rst
6004
6830
+++ b/Doc/library/optparse.rst
6664
7490
 
6665
7491
    Compile a regular expression pattern into a regular expression object, which
6666
7492
    can be used for matching using its :func:`match` and :func:`search` methods,
6667
 
@@ -515,7 +521,7 @@
 
7493
@@ -456,6 +462,11 @@
 
7494
       about compiling regular expressions.
 
7495
 
 
7496
 
 
7497
+.. data:: DEBUG
 
7498
+
 
7499
+   Display debug information about compiled expression.
 
7500
+
 
7501
+
 
7502
 .. data:: I
 
7503
           IGNORECASE
 
7504
 
 
7505
@@ -515,7 +526,7 @@
6668
7506
       b = re.compile(r"\d+\.\d*")
6669
7507
 
6670
7508
 
6673
7511
 
6674
7512
    Scan through *string* looking for a location where the regular expression
6675
7513
    *pattern* produces a match, and return a corresponding :class:`MatchObject`
6676
 
@@ -524,7 +530,7 @@
 
7514
@@ -524,7 +535,7 @@
6677
7515
    string.
6678
7516
 
6679
7517
 
6682
7520
 
6683
7521
    If zero or more characters at the beginning of *string* match the regular
6684
7522
    expression *pattern*, return a corresponding :class:`MatchObject` instance.
6685
 
@@ -537,7 +543,7 @@
 
7523
@@ -537,7 +548,7 @@
6686
7524
       instead.
6687
7525
 
6688
7526
 
6691
7529
 
6692
7530
    Split *string* by the occurrences of *pattern*.  If capturing parentheses are
6693
7531
    used in *pattern*, then the text of all groups in the pattern are also returned
6694
 
@@ -578,7 +584,7 @@
 
7532
@@ -578,7 +589,7 @@
6695
7533
       Added the optional flags argument.
6696
7534
 
6697
7535
 
6700
7538
 
6701
7539
    Return all non-overlapping matches of *pattern* in *string*, as a list of
6702
7540
    strings.  The *string* is scanned left-to-right, and matches are returned in
6703
 
@@ -593,7 +599,7 @@
 
7541
@@ -593,7 +604,7 @@
6704
7542
       Added the optional flags argument.
6705
7543
 
6706
7544
 
6709
7547
 
6710
7548
    Return an :term:`iterator` yielding :class:`MatchObject` instances over all
6711
7549
    non-overlapping matches for the RE *pattern* in *string*.  The *string* is
6712
 
@@ -607,13 +613,13 @@
 
7550
@@ -607,13 +618,13 @@
6713
7551
       Added the optional flags argument.
6714
7552
 
6715
7553
 
6725
7563
    so forth.  Unknown escapes such as ``\j`` are left alone.  Backreferences, such
6726
7564
    as ``\6``, are replaced with the substring matched by group 6 in the pattern.
6727
7565
    For example:
6728
 
@@ -656,7 +662,7 @@
 
7566
@@ -656,7 +667,7 @@
6729
7567
       Added the optional flags argument.
6730
7568
 
6731
7569
 
6734
7572
 
6735
7573
    Perform the same operation as :func:`sub`, but return a tuple ``(new_string,
6736
7574
    number_of_subs_made)``.
6737
 
@@ -741,7 +747,7 @@
 
7575
@@ -741,7 +752,7 @@
6738
7576
       <_sre.SRE_Match object at ...>
6739
7577
 
6740
7578
 
6743
7581
 
6744
7582
       Identical to the :func:`split` function, using the compiled pattern.
6745
7583
 
6746
 
@@ -760,12 +766,12 @@
 
7584
@@ -760,12 +771,12 @@
6747
7585
       region like for :meth:`match`.
6748
7586
 
6749
7587
 
6758
7596
 
6759
7597
       Identical to the :func:`subn` function, using the compiled pattern.
6760
7598
 
6761
 
@@ -994,16 +1000,16 @@
 
7599
@@ -994,16 +1005,16 @@
6762
7600
 
6763
7601
 Suppose you are writing a poker program where a player's hand is represented as
6764
7602
 a 5-character string with each character representing a card, "a" for ace, "k"
7468
8306
 behavior of the underlying server mechanism.
7469
8307
 
7470
8308
 To implement a service, you must derive a class from :class:`BaseRequestHandler`
7471
 
@@ -223,6 +225,7 @@
 
8309
@@ -156,13 +158,14 @@
 
8310
 
 
8311
 .. method:: BaseServer.serve_forever(poll_interval=0.5)
 
8312
 
 
8313
-   Handle requests until an explicit :meth:`shutdown` request.  Polls for
 
8314
-   shutdown every *poll_interval* seconds.
 
8315
+   Handle requests until an explicit :meth:`shutdown` request.
 
8316
+   Poll for shutdown every *poll_interval* seconds. Ignores :attr:`self.timeout`.
 
8317
+   If you need to do periodic tasks, do them in another thread.
 
8318
 
 
8319
 
 
8320
 .. method:: BaseServer.shutdown()
 
8321
 
 
8322
-   Tells the :meth:`serve_forever` loop to stop and waits until it does.
 
8323
+   Tell the :meth:`serve_forever` loop to stop and wait until it does.
 
8324
 
 
8325
    .. versionadded:: 2.6
 
8326
 
 
8327
@@ -223,6 +226,7 @@
7472
8328
    desired.  If :meth:`handle_request` receives no incoming requests within the
7473
8329
    timeout period, the :meth:`handle_timeout` method is called.
7474
8330
 
7476
8332
 There are various server methods that can be overridden by subclasses of base
7477
8333
 server classes like :class:`TCPServer`; these methods aren't useful to external
7478
8334
 users of the server object.
7479
 
@@ -353,7 +356,7 @@
 
8335
@@ -353,7 +357,7 @@
7480
8336
        def handle(self):
7481
8337
            # self.request is the TCP socket connected to the client
7482
8338
            self.data = self.request.recv(1024).strip()
7485
8341
            print self.data
7486
8342
            # just send back the same data, but upper-cased
7487
8343
            self.request.send(self.data.upper())
7488
 
@@ -377,7 +380,7 @@
 
8344
@@ -377,7 +381,7 @@
7489
8345
            # self.rfile is a file-like object created by the handler;
7490
8346
            # we can now use e.g. readline() instead of raw recv() calls
7491
8347
            self.data = self.rfile.readline().strip()
7494
8350
            print self.data
7495
8351
            # Likewise, self.wfile is a file-like object used to write back
7496
8352
            # to the client
7497
 
@@ -400,16 +403,18 @@
 
8353
@@ -400,16 +404,18 @@
7498
8354
    # Create a socket (SOCK_STREAM means a TCP socket)
7499
8355
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
7500
8356
 
7521
8377
 
7522
8378
 
7523
8379
 The output of the example should look something like this:
7524
 
@@ -450,7 +455,7 @@
 
8380
@@ -450,7 +456,7 @@
7525
8381
        def handle(self):
7526
8382
            data = self.request[0].strip()
7527
8383
            socket = self.request[1]
7530
8386
            print data
7531
8387
            socket.sendto(data.upper(), self.client_address)
7532
8388
 
7533
 
@@ -475,8 +480,8 @@
 
8389
@@ -475,8 +481,8 @@
7534
8390
    sock.sendto(data + "\n", (HOST, PORT))
7535
8391
    received = sock.recv(1024)
7536
8392
 
7541
8397
 
7542
8398
 The output of the example should look exactly like for the TCP server example.
7543
8399
 
7544
 
@@ -497,8 +502,8 @@
 
8400
@@ -497,8 +503,8 @@
7545
8401
 
7546
8402
        def handle(self):
7547
8403
            data = self.request.recv(1024)
7552
8408
            self.request.send(response)
7553
8409
 
7554
8410
    class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
7555
 
@@ -507,10 +512,12 @@
 
8411
@@ -507,10 +513,12 @@
7556
8412
    def client(ip, port, message):
7557
8413
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
7558
8414
        sock.connect((ip, port))
7569
8425
 
7570
8426
    if __name__ == "__main__":
7571
8427
        # Port 0 means to select an arbitrary unused port
7572
 
@@ -523,9 +530,9 @@
 
8428
@@ -523,9 +531,9 @@
7573
8429
        # more thread for each request
7574
8430
        server_thread = threading.Thread(target=server.serve_forever)
7575
8431
        # Exit the server thread when the main thread terminates
7581
8437
 
7582
8438
        client(ip, port, "Hello World 1")
7583
8439
        client(ip, port, "Hello World 2")
7584
 
@@ -533,6 +540,7 @@
 
8440
@@ -533,6 +541,7 @@
7585
8441
 
7586
8442
        server.shutdown()
7587
8443
 
8003
8859
 The *arg_name* can be followed by any number of index or
8004
8860
 attribute expressions. An expression of the form ``'.name'`` selects the named
8005
8861
 attribute using :func:`getattr`, while an expression of the form ``'[index]'``
 
8862
@@ -602,7 +602,7 @@
 
8863
 
 
8864
    >>> points = 19.5
 
8865
    >>> total = 22
 
8866
-   >>> 'Correct answers: {:.2%}.'.format(points/total)
 
8867
+   >>> 'Correct answers: {:.2%}'.format(points/total)
 
8868
    'Correct answers: 88.64%'
 
8869
 
 
8870
 Using type-specific formatting::
8006
8871
@@ -729,9 +729,9 @@
8007
8872
 to parse template strings.  To do this, you can override these class attributes:
8008
8873
 
8271
9136
+detail in the :class:`Popen` constructor documentation.
8272
9137
+
8273
9138
+
8274
 
+Popen Constuctor
8275
 
+^^^^^^^^^^^^^^^^
 
9139
+Popen Constructor
 
9140
+^^^^^^^^^^^^^^^^^
8276
9141
+
8277
9142
+The underlying process creation and management in this module is handled by
8278
9143
+the :class:`Popen` class. It offers a lot of flexibility so that developers
8855
9720
 The :mod:`sysconfig` module provides access to Python's configuration
8856
9721
 information like the list of installation paths and the configuration variables
8857
9722
 relevant for the current platform.
 
9723
diff -r 8527427914a2 Doc/library/syslog.rst
 
9724
--- a/Doc/library/syslog.rst
 
9725
+++ b/Doc/library/syslog.rst
 
9726
@@ -30,7 +30,7 @@
 
9727
    ``openlog()`` will be called with no arguments.
 
9728
 
 
9729
 
 
9730
-.. function:: openlog([ident[, logopt[, facility]]])
 
9731
+.. function:: openlog([ident[, logoption[, facility]]])
 
9732
 
 
9733
    Logging options of subsequent :func:`syslog` calls can be set by calling
 
9734
    :func:`openlog`.  :func:`syslog` will call :func:`openlog` with no arguments
 
9735
@@ -38,7 +38,7 @@
 
9736
 
 
9737
    The optional *ident* keyword argument is a string which is prepended to every
 
9738
    message, and defaults to ``sys.argv[0]`` with leading path components
 
9739
-   stripped.  The optional *logopt* keyword argument (default is 0) is a bit
 
9740
+   stripped.  The optional *logoption* keyword argument (default is 0) is a bit
 
9741
    field -- see below for possible values to combine.  The optional *facility*
 
9742
    keyword argument (default is :const:`LOG_USER`) sets the default facility for
 
9743
    messages which do not have a facility explicitly encoded.
 
9744
@@ -98,5 +98,5 @@
 
9745
 logged messages, and write the messages to the destination facility used for
 
9746
 mail logging::
 
9747
 
 
9748
-   syslog.openlog(logopt=syslog.LOG_PID, facility=syslog.LOG_MAIL)
 
9749
+   syslog.openlog(logoption=syslog.LOG_PID, facility=syslog.LOG_MAIL)
 
9750
    syslog.syslog('E-mail processing initiated...')
8858
9751
diff -r 8527427914a2 Doc/library/tabnanny.rst
8859
9752
--- a/Doc/library/tabnanny.rst
8860
9753
+++ b/Doc/library/tabnanny.rst
9175
10068
 
9176
10069
       To understand the format, see the following example (it is not
9177
10070
       intended to do anything useful)::
 
10071
@@ -1294,7 +1294,7 @@
 
10072
 
 
10073
        * sticky=spec
 
10074
           Specifies how the image is placed within the final parcel. spec
 
10075
-          contains zero or more characters “n”, “s”, “w”, or “e”.
 
10076
+          contains zero or more characters "n", "s", "w", or "e".
 
10077
 
 
10078
        * width=width
 
10079
           Specifies a minimum width for the element. If less than zero, the
9178
10080
diff -r 8527427914a2 Doc/library/turtle.rst
9179
10081
--- a/Doc/library/turtle.rst
9180
10082
+++ b/Doc/library/turtle.rst
9240
10142
     imported as ``foo.bar.baz``.
9241
10143
 
9242
10144
     If you have a package installed globally and attempt test discovery on
9243
 
@@ -895,6 +895,8 @@
 
10145
@@ -895,6 +895,7 @@
9244
10146
 
9245
10147
       Test that *obj* is (or is not) an instance of *cls* (which can be a
9246
10148
       class or a tuple of classes, as supported by :func:`isinstance`).
9247
 
+      To check for a specific type (without including superclasses) use
9248
 
+      :func:`assertIs(type(obj), cls) <assertIs>`.
 
10149
+      To check for the exact type, use :func:`assertIs(type(obj), cls) <assertIs>`.
9249
10150
 
9250
10151
       .. versionadded:: 2.7
9251
10152
 
9252
 
@@ -905,11 +907,11 @@
 
10153
@@ -905,11 +906,11 @@
9253
10154
    +---------------------------------------------------------+--------------------------------------+------------+
9254
10155
    | Method                                                  | Checks that                          | New in     |
9255
10156
    +=========================================================+======================================+============+
9264
10165
    +---------------------------------------------------------+--------------------------------------+------------+
9265
10166
 
9266
10167
    .. method:: assertRaises(exception, callable, *args, **kwds)
9267
 
@@ -995,7 +997,7 @@
 
10168
@@ -995,7 +996,7 @@
9268
10169
    | <TestCase.assertItemsEqual>`          | works with unhashable objs     |              |
9269
10170
    +---------------------------------------+--------------------------------+--------------+
9270
10171
    | :meth:`assertDictContainsSubset(a, b) | all the key/value pairs        | 2.7          |
9783
10684
diff -r 8527427914a2 Doc/license.rst
9784
10685
--- a/Doc/license.rst
9785
10686
+++ b/Doc/license.rst
 
10687
@@ -132,7 +132,7 @@
 
10688
    analyze, test, perform and/or display publicly, prepare derivative works,
 
10689
    distribute, and otherwise use Python |release| alone or in any derivative
 
10690
    version, provided, however, that PSF's License Agreement and PSF's notice of
 
10691
-   copyright, i.e., "Copyright © 2001-2010 Python Software Foundation; All Rights
 
10692
+   copyright, i.e., "Copyright © 2001-2012 Python Software Foundation; All Rights
 
10693
    Reserved" are retained in Python |release| alone or in any derivative version
 
10694
    prepared by Licensee.
 
10695
 
9786
10696
@@ -536,36 +536,6 @@
9787
10697
    PERFORMANCE OF THIS SOFTWARE.
9788
10698
 
9926
10836
 If the syntax ``**expression`` appears in the function call, ``expression`` must
9927
10837
 evaluate to a mapping, the contents of which are treated as additional keyword
9928
10838
 arguments.  In the case of a keyword appearing in both ``expression`` and as an
 
10839
diff -r 8527427914a2 Doc/reference/introduction.rst
 
10840
--- a/Doc/reference/introduction.rst
 
10841
+++ b/Doc/reference/introduction.rst
 
10842
@@ -65,7 +65,7 @@
 
10843
    An alternate Python for .NET.  Unlike Python.NET, this is a complete Python
 
10844
    implementation that generates IL, and compiles Python code directly to .NET
 
10845
    assemblies.  It was created by Jim Hugunin, the original creator of Jython.  For
 
10846
-   more information, see `the IronPython website <http://www.ironpython.com/>`_.
 
10847
+   more information, see `the IronPython website <http://www.ironpython.net/>`_.
 
10848
 
 
10849
 PyPy
 
10850
    An implementation of Python written completely in Python. It supports several
 
10851
diff -r 8527427914a2 Doc/reference/simple_stmts.rst
 
10852
--- a/Doc/reference/simple_stmts.rst
 
10853
+++ b/Doc/reference/simple_stmts.rst
 
10854
@@ -352,7 +352,7 @@
 
10855
    del_stmt: "del" `target_list`
 
10856
 
 
10857
 Deletion is recursively defined very similar to the way assignment is defined.
 
10858
-Rather that spelling it out in full details, here are some hints.
 
10859
+Rather than spelling it out in full details, here are some hints.
 
10860
 
 
10861
 Deletion of a target list recursively deletes each target, from left to right.
 
10862
 
9929
10863
diff -r 8527427914a2 Doc/tools/sphinxext/layout.html
9930
10864
--- a/Doc/tools/sphinxext/layout.html
9931
10865
+++ b/Doc/tools/sphinxext/layout.html
10469
11403
 Strings can be concatenated (glued together) with the ``+`` operator, and
10470
11404
 repeated with ``*``::
10471
11405
 
 
11406
@@ -637,13 +630,13 @@
 
11407
   and ``!=`` (not equal to).
 
11408
 
 
11409
 * The *body* of the loop is *indented*: indentation is Python's way of grouping
 
11410
-  statements.  Python does not (yet!) provide an intelligent input line editing
 
11411
-  facility, so you have to type a tab or space(s) for each indented line.  In
 
11412
-  practice you will prepare more complicated input for Python with a text editor;
 
11413
-  most text editors have an auto-indent facility.  When a compound statement is
 
11414
-  entered interactively, it must be followed by a blank line to indicate
 
11415
-  completion (since the parser cannot guess when you have typed the last line).
 
11416
-  Note that each line within a basic block must be indented by the same amount.
 
11417
+  statements.  At the interactive prompt, you have to type a tab or space(s) for
 
11418
+  each indented line.  In practice you will prepare more complicated input
 
11419
+  for Python with a text editor; all decent text editors have an auto-indent
 
11420
+  facility.  When a compound statement is entered interactively, it must be
 
11421
+  followed by a blank line to indicate completion (since the parser cannot
 
11422
+  guess when you have typed the last line).  Note that each line within a basic
 
11423
+  block must be indented by the same amount.
 
11424
 
 
11425
 * The :keyword:`print` statement writes the value of the expression(s) it is
 
11426
   given.  It differs from just writing the expression you want to write (as we did
10472
11427
diff -r 8527427914a2 Doc/tutorial/modules.rst
10473
11428
--- a/Doc/tutorial/modules.rst
10474
11429
+++ b/Doc/tutorial/modules.rst
10547
11502
 
10548
11503
 .. _using-on-unix:
10549
11504
 
 
11505
@@ -26,11 +26,11 @@
 
11506
 
 
11507
 .. seealso::
 
11508
 
 
11509
-   http://www.linux.com/articles/60383
 
11510
+   http://www.debian.org/doc/manuals/maint-guide/first.en.html
 
11511
       for Debian users
 
11512
    http://linuxmafia.com/pub/linux/suse-linux-internals/chapter35.html
 
11513
       for OpenSuse users
 
11514
-   http://docs.fedoraproject.org/drafts/rpm-guide-en/ch-creating-rpms.html
 
11515
+   http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch-creating-rpms.html
 
11516
       for Fedora users
 
11517
    http://www.slackbook.org/html/package-management-making-packages.html
 
11518
       for Slackware users
10550
11519
@@ -55,8 +55,8 @@
10551
11520
 On OpenSolaris
10552
11521
 --------------
10768
11737
    thread-state, even if no auto-thread-state call has been made
10769
11738
    on the main thread.
10770
11739
 */
 
11740
diff -r 8527427914a2 LICENSE
 
11741
--- a/LICENSE
 
11742
+++ b/LICENSE
 
11743
@@ -98,9 +98,9 @@
 
11744
 analyze, test, perform and/or display publicly, prepare derivative works,
 
11745
 distribute, and otherwise use Python alone or in any derivative version,
 
11746
 provided, however, that PSF's License Agreement and PSF's notice of copyright,
 
11747
-i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 
11748
-Python Software Foundation; All Rights Reserved" are retained in Python alone or
 
11749
-in any derivative version prepared by Licensee.
 
11750
+i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
 
11751
+2011, 2012 Python Software Foundation; All Rights Reserved" are retained in Python
 
11752
+alone or in any derivative version prepared by Licensee.
 
11753
 
 
11754
 3. In the event Licensee prepares a derivative work that is based on
 
11755
 or incorporates Python or any part thereof, and wants to make
 
11756
diff -r 8527427914a2 Lib/BaseHTTPServer.py
 
11757
--- a/Lib/BaseHTTPServer.py
 
11758
+++ b/Lib/BaseHTTPServer.py
 
11759
@@ -244,14 +244,11 @@
 
11760
         self.request_version = version = self.default_request_version
 
11761
         self.close_connection = 1
 
11762
         requestline = self.raw_requestline
 
11763
-        if requestline[-2:] == '\r\n':
 
11764
-            requestline = requestline[:-2]
 
11765
-        elif requestline[-1:] == '\n':
 
11766
-            requestline = requestline[:-1]
 
11767
+        requestline = requestline.rstrip('\r\n')
 
11768
         self.requestline = requestline
 
11769
         words = requestline.split()
 
11770
         if len(words) == 3:
 
11771
-            [command, path, version] = words
 
11772
+            command, path, version = words
 
11773
             if version[:5] != 'HTTP/':
 
11774
                 self.send_error(400, "Bad request version (%r)" % version)
 
11775
                 return False
 
11776
@@ -277,7 +274,7 @@
 
11777
                           "Invalid HTTP Version (%s)" % base_version_number)
 
11778
                 return False
 
11779
         elif len(words) == 2:
 
11780
-            [command, path] = words
 
11781
+            command, path = words
 
11782
             self.close_connection = 1
 
11783
             if command != 'GET':
 
11784
                 self.send_error(400,
10771
11785
diff -r 8527427914a2 Lib/ConfigParser.py
10772
11786
--- a/Lib/ConfigParser.py
10773
11787
+++ b/Lib/ConfigParser.py
12203
13217
+        else:
12204
13218
+            name, equals, value = runshared.partition('=')
12205
13219
+            cmd.library_dirs = value.split(os.pathsep)
 
13220
diff -r 8527427914a2 Lib/distutils/tests/test_archive_util.py
 
13221
--- a/Lib/distutils/tests/test_archive_util.py
 
13222
+++ b/Lib/distutils/tests/test_archive_util.py
 
13223
@@ -1,8 +1,10 @@
 
13224
+# -*- coding: utf-8 -*-
 
13225
 """Tests for distutils.archive_util."""
 
13226
 __revision__ = "$Id$"
 
13227
 
 
13228
 import unittest
 
13229
 import os
 
13230
+import sys
 
13231
 import tarfile
 
13232
 from os.path import splitdrive
 
13233
 import warnings
 
13234
@@ -33,6 +35,18 @@
 
13235
 except ImportError:
 
13236
     zlib = None
 
13237
 
 
13238
+def can_fs_encode(filename):
 
13239
+    """
 
13240
+    Return True if the filename can be saved in the file system.
 
13241
+    """
 
13242
+    if os.path.supports_unicode_filenames:
 
13243
+        return True
 
13244
+    try:
 
13245
+        filename.encode(sys.getfilesystemencoding())
 
13246
+    except UnicodeEncodeError:
 
13247
+        return False
 
13248
+    return True
 
13249
+
 
13250
 
 
13251
 class ArchiveUtilTestCase(support.TempdirManager,
 
13252
                           support.LoggingSilencer,
 
13253
@@ -40,6 +54,9 @@
 
13254
 
 
13255
     @unittest.skipUnless(zlib, "requires zlib")
 
13256
     def test_make_tarball(self):
 
13257
+        self._make_tarball('archive')
 
13258
+
 
13259
+    def _make_tarball(self, target_name):
 
13260
         # creating something to tar
 
13261
         tmpdir = self.mkdtemp()
 
13262
         self.write_file([tmpdir, 'file1'], 'xxx')
 
13263
@@ -51,7 +68,7 @@
 
13264
         unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0],
 
13265
                             "source and target should be on same drive")
 
13266
 
 
13267
-        base_name = os.path.join(tmpdir2, 'archive')
 
13268
+        base_name = os.path.join(tmpdir2, target_name)
 
13269
 
 
13270
         # working with relative paths to avoid tar warnings
 
13271
         old_dir = os.getcwd()
 
13272
@@ -66,7 +83,7 @@
 
13273
         self.assertTrue(os.path.exists(tarball))
 
13274
 
 
13275
         # trying an uncompressed one
 
13276
-        base_name = os.path.join(tmpdir2, 'archive')
 
13277
+        base_name = os.path.join(tmpdir2, target_name)
 
13278
         old_dir = os.getcwd()
 
13279
         os.chdir(tmpdir)
 
13280
         try:
 
13281
@@ -277,6 +294,33 @@
 
13282
         finally:
 
13283
             del ARCHIVE_FORMATS['xxx']
 
13284
 
 
13285
+    @unittest.skipUnless(zlib, "requires zlib")
 
13286
+    def test_make_tarball_unicode(self):
 
13287
+        """
 
13288
+        Mirror test_make_tarball, except filename is unicode.
 
13289
+        """
 
13290
+        self._make_tarball(u'archive')
 
13291
+
 
13292
+    @unittest.skipUnless(zlib, "requires zlib")
 
13293
+    @unittest.skipUnless(can_fs_encode(u'årchiv'),
 
13294
+        'File system cannot handle this filename')
 
13295
+    def test_make_tarball_unicode_latin1(self):
 
13296
+        """
 
13297
+        Mirror test_make_tarball, except filename is unicode and contains
 
13298
+        latin characters.
 
13299
+        """
 
13300
+        self._make_tarball(u'årchiv') # note this isn't a real word
 
13301
+
 
13302
+    @unittest.skipUnless(zlib, "requires zlib")
 
13303
+    @unittest.skipUnless(can_fs_encode(u'のアーカイブ'),
 
13304
+        'File system cannot handle this filename')
 
13305
+    def test_make_tarball_unicode_extended(self):
 
13306
+        """
 
13307
+        Mirror test_make_tarball, except filename is unicode and contains
 
13308
+        characters outside the latin charset.
 
13309
+        """
 
13310
+        self._make_tarball(u'のアーカイブ') # japanese for archive
 
13311
+
 
13312
 def test_suite():
 
13313
     return unittest.makeSuite(ArchiveUtilTestCase)
 
13314
 
12206
13315
diff -r 8527427914a2 Lib/distutils/tests/test_bdist.py
12207
13316
--- a/Lib/distutils/tests/test_bdist.py
12208
13317
+++ b/Lib/distutils/tests/test_bdist.py
13450
14559
         return dist, cmd
13451
14560
 
13452
14561
     @unittest.skipUnless(zlib, "requires zlib")
13453
 
@@ -246,7 +240,8 @@
 
14562
@@ -172,6 +166,28 @@
 
14563
         self.assertEqual(result, ['fake-1.0.tar', 'fake-1.0.tar.gz'])
 
14564
 
 
14565
     @unittest.skipUnless(zlib, "requires zlib")
 
14566
+    def test_unicode_metadata_tgz(self):
 
14567
+        """
 
14568
+        Unicode name or version should not break building to tar.gz format.
 
14569
+        Reference issue #11638.
 
14570
+        """
 
14571
+
 
14572
+        # create the sdist command with unicode parameters
 
14573
+        dist, cmd = self.get_cmd({'name': u'fake', 'version': u'1.0'})
 
14574
+
 
14575
+        # create the sdist as gztar and run the command
 
14576
+        cmd.formats = ['gztar']
 
14577
+        cmd.ensure_finalized()
 
14578
+        cmd.run()
 
14579
+
 
14580
+        # The command should have created the .tar.gz file
 
14581
+        dist_folder = join(self.tmp_dir, 'dist')
 
14582
+        result = os.listdir(dist_folder)
 
14583
+        self.assertEqual(result, ['fake-1.0.tar.gz'])
 
14584
+
 
14585
+        os.remove(join(dist_folder, 'fake-1.0.tar.gz'))
 
14586
+
 
14587
+    @unittest.skipUnless(zlib, "requires zlib")
 
14588
     def test_add_defaults(self):
 
14589
 
 
14590
         # http://bugs.python.org/issue2279
 
14591
@@ -246,7 +262,8 @@
13454
14592
         # with the `check` subcommand
13455
14593
         cmd.ensure_finalized()
13456
14594
         cmd.run()
13460
14598
         self.assertEqual(len(warnings), 2)
13461
14599
 
13462
14600
         # trying with a complete set of metadata
13463
 
@@ -255,7 +250,8 @@
 
14601
@@ -255,7 +272,8 @@
13464
14602
         cmd.ensure_finalized()
13465
14603
         cmd.metadata_check = 0
13466
14604
         cmd.run()
13470
14608
         self.assertEqual(len(warnings), 0)
13471
14609
 
13472
14610
     def test_check_metadata_deprecated(self):
13473
 
@@ -277,7 +273,6 @@
 
14611
@@ -277,7 +295,6 @@
13474
14612
         self.assertEqual(len(output), num_formats)
13475
14613
 
13476
14614
     def test_finalize_options(self):
13478
14616
         dist, cmd = self.get_cmd()
13479
14617
         cmd.finalize_options()
13480
14618
 
13481
 
@@ -347,6 +342,32 @@
 
14619
@@ -347,6 +364,32 @@
13482
14620
         finally:
13483
14621
             archive.close()
13484
14622
 
13511
14649
     @unittest.skipUnless(zlib, "requires zlib")
13512
14650
     def test_get_file_list(self):
13513
14651
         # make sure MANIFEST is recalculated
13514
 
@@ -355,6 +376,7 @@
 
14652
@@ -355,6 +398,7 @@
13515
14653
         # filling data_files by pointing files in package_data
13516
14654
         dist.package_data = {'somecode': ['*.txt']}
13517
14655
         self.write_file((self.tmp_dir, 'somecode', 'doc.txt'), '#')
13519
14657
         cmd.ensure_finalized()
13520
14658
         cmd.run()
13521
14659
 
13522
 
@@ -405,13 +427,34 @@
 
14660
@@ -405,13 +449,34 @@
13523
14661
         self.assertEqual(manifest[0],
13524
14662
                          '# file GENERATED by distutils, do NOT edit')
13525
14663
 
13554
14692
 
13555
14693
         f = open(cmd.manifest)
13556
14694
         try:
13557
 
@@ -422,6 +465,15 @@
 
14695
@@ -422,6 +487,15 @@
13558
14696
 
13559
14697
         self.assertEqual(manifest, ['README.manual'])
13560
14698
 
13570
14708
 def test_suite():
13571
14709
     return unittest.makeSuite(SDistTestCase)
13572
14710
 
 
14711
diff -r 8527427914a2 Lib/doctest.py
 
14712
--- a/Lib/doctest.py
 
14713
+++ b/Lib/doctest.py
 
14714
@@ -451,6 +451,25 @@
 
14715
         self.options = options
 
14716
         self.exc_msg = exc_msg
 
14717
 
 
14718
+    def __eq__(self, other):
 
14719
+        if type(self) is not type(other):
 
14720
+            return NotImplemented
 
14721
+
 
14722
+        return self.source == other.source and \
 
14723
+               self.want == other.want and \
 
14724
+               self.lineno == other.lineno and \
 
14725
+               self.indent == other.indent and \
 
14726
+               self.options == other.options and \
 
14727
+               self.exc_msg == other.exc_msg
 
14728
+
 
14729
+    def __ne__(self, other):
 
14730
+        return not self == other
 
14731
+
 
14732
+    def __hash__(self):
 
14733
+        return hash((self.source, self.want, self.lineno, self.indent,
 
14734
+                     self.exc_msg))
 
14735
+
 
14736
+
 
14737
 class DocTest:
 
14738
     """
 
14739
     A collection of doctest examples that should be run in a single
 
14740
@@ -499,6 +518,22 @@
 
14741
         return ('<DocTest %s from %s:%s (%s)>' %
 
14742
                 (self.name, self.filename, self.lineno, examples))
 
14743
 
 
14744
+    def __eq__(self, other):
 
14745
+        if type(self) is not type(other):
 
14746
+            return NotImplemented
 
14747
+
 
14748
+        return self.examples == other.examples and \
 
14749
+               self.docstring == other.docstring and \
 
14750
+               self.globs == other.globs and \
 
14751
+               self.name == other.name and \
 
14752
+               self.filename == other.filename and \
 
14753
+               self.lineno == other.lineno
 
14754
+
 
14755
+    def __ne__(self, other):
 
14756
+        return not self == other
 
14757
+
 
14758
+    def __hash__(self):
 
14759
+        return hash((self.docstring, self.name, self.filename, self.lineno))
 
14760
 
 
14761
     # This lets us sort tests by name:
 
14762
     def __cmp__(self, other):
 
14763
@@ -2252,6 +2287,23 @@
 
14764
     def id(self):
 
14765
         return self._dt_test.name
 
14766
 
 
14767
+    def __eq__(self, other):
 
14768
+        if type(self) is not type(other):
 
14769
+            return NotImplemented
 
14770
+
 
14771
+        return self._dt_test == other._dt_test and \
 
14772
+               self._dt_optionflags == other._dt_optionflags and \
 
14773
+               self._dt_setUp == other._dt_setUp and \
 
14774
+               self._dt_tearDown == other._dt_tearDown and \
 
14775
+               self._dt_checker == other._dt_checker
 
14776
+
 
14777
+    def __ne__(self, other):
 
14778
+        return not self == other
 
14779
+
 
14780
+    def __hash__(self):
 
14781
+        return hash((self._dt_optionflags, self._dt_setUp, self._dt_tearDown,
 
14782
+                     self._dt_checker))
 
14783
+
 
14784
     def __repr__(self):
 
14785
         name = self._dt_test.name.split('.')
 
14786
         return "%s (%s)" % (name[-1], '.'.join(name[:-1]))
13573
14787
diff -r 8527427914a2 Lib/filecmp.py
13574
14788
--- a/Lib/filecmp.py
13575
14789
+++ b/Lib/filecmp.py
13911
15125
diff -r 8527427914a2 Lib/inspect.py
13912
15126
--- a/Lib/inspect.py
13913
15127
+++ b/Lib/inspect.py
13914
 
@@ -524,9 +524,13 @@
 
15128
@@ -247,12 +247,23 @@
 
15129
 def getmembers(object, predicate=None):
 
15130
     """Return all members of an object as (name, value) pairs sorted by name.
 
15131
     Optionally, only return members that satisfy a given predicate."""
 
15132
+    if isclass(object):
 
15133
+        mro = (object,) + getmro(object)
 
15134
+    else:
 
15135
+        mro = ()
 
15136
     results = []
 
15137
     for key in dir(object):
 
15138
-        try:
 
15139
-            value = getattr(object, key)
 
15140
-        except AttributeError:
 
15141
-            continue
 
15142
+        # First try to get the value via __dict__. Some descriptors don't
 
15143
+        # like calling their __get__ (see bug #1785).
 
15144
+        for base in mro:
 
15145
+            if key in base.__dict__:
 
15146
+                value = base.__dict__[key]
 
15147
+                break
 
15148
+        else:
 
15149
+            try:
 
15150
+                value = getattr(object, key)
 
15151
+            except AttributeError:
 
15152
+                continue
 
15153
         if not predicate or predicate(value):
 
15154
             results.append((key, value))
 
15155
     results.sort()
 
15156
@@ -288,30 +299,21 @@
 
15157
     names = dir(cls)
 
15158
     result = []
 
15159
     for name in names:
 
15160
-        # Get the object associated with the name.
 
15161
+        # Get the object associated with the name, and where it was defined.
 
15162
         # Getting an obj from the __dict__ sometimes reveals more than
 
15163
         # using getattr.  Static and class methods are dramatic examples.
 
15164
-        if name in cls.__dict__:
 
15165
-            obj = cls.__dict__[name]
 
15166
+        # Furthermore, some objects may raise an Exception when fetched with
 
15167
+        # getattr(). This is the case with some descriptors (bug #1785).
 
15168
+        # Thus, we only use getattr() as a last resort.
 
15169
+        homecls = None
 
15170
+        for base in (cls,) + mro:
 
15171
+            if name in base.__dict__:
 
15172
+                obj = base.__dict__[name]
 
15173
+                homecls = base
 
15174
+                break
 
15175
         else:
 
15176
             obj = getattr(cls, name)
 
15177
-
 
15178
-        # Figure out where it was defined.
 
15179
-        homecls = getattr(obj, "__objclass__", None)
 
15180
-        if homecls is None:
 
15181
-            # search the dicts.
 
15182
-            for base in mro:
 
15183
-                if name in base.__dict__:
 
15184
-                    homecls = base
 
15185
-                    break
 
15186
-
 
15187
-        # Get the object again, in order to get it from the defining
 
15188
-        # __dict__ instead of via getattr (if possible).
 
15189
-        if homecls is not None and name in homecls.__dict__:
 
15190
-            obj = homecls.__dict__[name]
 
15191
-
 
15192
-        # Also get the object via getattr.
 
15193
-        obj_via_getattr = getattr(cls, name)
 
15194
+            homecls = getattr(obj, "__objclass__", homecls)
 
15195
 
 
15196
         # Classify the object.
 
15197
         if isinstance(obj, staticmethod):
 
15198
@@ -320,11 +322,18 @@
 
15199
             kind = "class method"
 
15200
         elif isinstance(obj, property):
 
15201
             kind = "property"
 
15202
-        elif (ismethod(obj_via_getattr) or
 
15203
-              ismethoddescriptor(obj_via_getattr)):
 
15204
+        elif ismethoddescriptor(obj):
 
15205
             kind = "method"
 
15206
+        elif isdatadescriptor(obj):
 
15207
+            kind = "data"
 
15208
         else:
 
15209
-            kind = "data"
 
15210
+            obj_via_getattr = getattr(cls, name)
 
15211
+            if (ismethod(obj_via_getattr) or
 
15212
+                ismethoddescriptor(obj_via_getattr)):
 
15213
+                kind = "method"
 
15214
+            else:
 
15215
+                kind = "data"
 
15216
+            obj = obj_via_getattr
 
15217
 
 
15218
         result.append(Attribute(name, kind, homecls, obj))
 
15219
 
 
15220
@@ -524,9 +533,13 @@
13915
15221
     or code object.  The source code is returned as a list of all the lines
13916
15222
     in the file and the line number indexes a line in that list.  An IOError
13917
15223
     is raised if the source code cannot be retrieved."""
14535
15841
 
14536
15842
 def _lock_file(f, dotlock=True):
14537
15843
     """Lock file f using lockf and dot locking."""
 
15844
diff -r 8527427914a2 Lib/markupbase.py
 
15845
--- a/Lib/markupbase.py
 
15846
+++ b/Lib/markupbase.py
 
15847
@@ -108,6 +108,10 @@
 
15848
                 if decltype == "doctype":
 
15849
                     self.handle_decl(data)
 
15850
                 else:
 
15851
+                    # According to the HTML5 specs sections "8.2.4.44 Bogus
 
15852
+                    # comment state" and "8.2.4.45 Markup declaration open
 
15853
+                    # state", a comment token should be emitted.
 
15854
+                    # Calling unknown_decl provides more flexibility though.
 
15855
                     self.unknown_decl(data)
 
15856
                 return j + 1
 
15857
             if c in "\"'":
14538
15858
diff -r 8527427914a2 Lib/msilib/schema.py
14539
15859
--- a/Lib/msilib/schema.py
14540
15860
+++ b/Lib/msilib/schema.py
14625
15945
         try:
14626
15946
             size = self._roundup(max(size,1), self._alignment)
14627
15947
             (arena, start, stop) = self._malloc(size)
 
15948
diff -r 8527427914a2 Lib/multiprocessing/managers.py
 
15949
--- a/Lib/multiprocessing/managers.py
 
15950
+++ b/Lib/multiprocessing/managers.py
 
15951
@@ -159,7 +159,7 @@
 
15952
         Listener, Client = listener_client[serializer]
 
15953
 
 
15954
         # do authentication later
 
15955
-        self.listener = Listener(address=address, backlog=5)
 
15956
+        self.listener = Listener(address=address, backlog=16)
 
15957
         self.address = self.listener.address
 
15958
 
 
15959
         self.id_to_obj = {'0': (None, ())}
14628
15960
diff -r 8527427914a2 Lib/multiprocessing/pool.py
14629
15961
--- a/Lib/multiprocessing/pool.py
14630
15962
+++ b/Lib/multiprocessing/pool.py
14859
16191
         info = inspect.getmoduleinfo(filename)
14860
16192
         try:
14861
16193
             file = open(filename)
14862
 
@@ -1454,13 +1454,14 @@
 
16194
@@ -740,8 +740,15 @@
 
16195
                 hr.maybe()
 
16196
                 push(msg)
 
16197
                 for name, kind, homecls, value in ok:
 
16198
-                    push(self.document(getattr(object, name), name, mod,
 
16199
-                                       funcs, classes, mdict, object))
 
16200
+                    try:
 
16201
+                        value = getattr(object, name)
 
16202
+                    except Exception:
 
16203
+                        # Some descriptors may meet a failure in their __get__.
 
16204
+                        # (bug #1785)
 
16205
+                        push(self._docdescriptor(name, value, mod))
 
16206
+                    else:
 
16207
+                        push(self.document(value, name, mod,
 
16208
+                                        funcs, classes, mdict, object))
 
16209
                     push('\n')
 
16210
             return attrs
 
16211
 
 
16212
@@ -781,7 +788,12 @@
 
16213
         mdict = {}
 
16214
         for key, kind, homecls, value in attrs:
 
16215
             mdict[key] = anchor = '#' + name + '-' + key
 
16216
-            value = getattr(object, key)
 
16217
+            try:
 
16218
+                value = getattr(object, name)
 
16219
+            except Exception:
 
16220
+                # Some descriptors may meet a failure in their __get__.
 
16221
+                # (bug #1785)
 
16222
+                pass
 
16223
             try:
 
16224
                 # The value may not be hashable (e.g., a data attr with
 
16225
                 # a dict or list value).
 
16226
@@ -1161,8 +1173,15 @@
 
16227
                 hr.maybe()
 
16228
                 push(msg)
 
16229
                 for name, kind, homecls, value in ok:
 
16230
-                    push(self.document(getattr(object, name),
 
16231
-                                       name, mod, object))
 
16232
+                    try:
 
16233
+                        value = getattr(object, name)
 
16234
+                    except Exception:
 
16235
+                        # Some descriptors may meet a failure in their __get__.
 
16236
+                        # (bug #1785)
 
16237
+                        push(self._docdescriptor(name, value, mod))
 
16238
+                    else:
 
16239
+                        push(self.document(value,
 
16240
+                                        name, mod, object))
 
16241
             return attrs
 
16242
 
 
16243
         def spilldescriptors(msg, attrs, predicate):
 
16244
@@ -1454,13 +1473,14 @@
14863
16245
         else: break
14864
16246
     if module:
14865
16247
         object = module
14880
16262
 
14881
16263
 # --------------------------------------- interactive interpreter interface
14882
16264
 
14883
 
@@ -1967,10 +1968,11 @@
 
16265
@@ -1967,10 +1987,11 @@
14884
16266
         if modname[-9:] == '.__init__':
14885
16267
             modname = modname[:-9] + ' (package)'
14886
16268
         print modname, desc and '- ' + desc
15045
16427
         return self.getreply()
15046
16428
 
15047
16429
     # some useful methods
 
16430
diff -r 8527427914a2 Lib/ssl.py
 
16431
--- a/Lib/ssl.py
 
16432
+++ b/Lib/ssl.py
 
16433
@@ -81,8 +81,9 @@
 
16434
 }
 
16435
 try:
 
16436
     from _ssl import PROTOCOL_SSLv2
 
16437
+    _SSLv2_IF_EXISTS = PROTOCOL_SSLv2
 
16438
 except ImportError:
 
16439
-    pass
 
16440
+    _SSLv2_IF_EXISTS = None
 
16441
 else:
 
16442
     _PROTOCOL_NAMES[PROTOCOL_SSLv2] = "SSLv2"
 
16443
 
 
16444
@@ -91,6 +92,11 @@
 
16445
 import base64        # for DER-to-PEM translation
 
16446
 import errno
 
16447
 
 
16448
+# Disable weak or insecure ciphers by default
 
16449
+# (OpenSSL's default setting is 'DEFAULT:!aNULL:!eNULL')
 
16450
+_DEFAULT_CIPHERS = 'DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2'
 
16451
+
 
16452
+
 
16453
 class SSLSocket(socket):
 
16454
 
 
16455
     """This class implements a subtype of socket.socket that wraps
 
16456
@@ -112,6 +118,9 @@
 
16457
             except AttributeError:
 
16458
                 pass
 
16459
 
 
16460
+        if ciphers is None and ssl_version != _SSLv2_IF_EXISTS:
 
16461
+            ciphers = _DEFAULT_CIPHERS
 
16462
+
 
16463
         if certfile and not keyfile:
 
16464
             keyfile = certfile
 
16465
         # see if it's connected
15048
16466
diff -r 8527427914a2 Lib/stat.py
15049
16467
--- a/Lib/stat.py
15050
16468
+++ b/Lib/stat.py
15189
16607
 # $Source$
15190
16608
 
15191
16609
 version     = "0.9.0"
15192
 
@@ -627,7 +627,7 @@
 
16610
@@ -454,6 +454,8 @@
 
16611
                                             0)
 
16612
         timestamp = struct.pack("<L", long(time.time()))
 
16613
         self.__write("\037\213\010\010%s\002\377" % timestamp)
 
16614
+        if type(self.name) is unicode:
 
16615
+            self.name = self.name.encode("iso-8859-1", "replace")
 
16616
         if self.name.endswith(".gz"):
 
16617
             self.name = self.name[:-3]
 
16618
         self.__write(self.name + NUL)
 
16619
@@ -627,7 +629,7 @@
15193
16620
     def getcomptype(self):
15194
16621
         if self.buf.startswith("\037\213\010"):
15195
16622
             return "gz"
15198
16625
             return "bz2"
15199
16626
         return "tar"
15200
16627
 
15201
 
@@ -2264,17 +2264,11 @@
 
16628
@@ -2264,17 +2266,11 @@
15202
16629
             try:
15203
16630
                 g = grp.getgrnam(tarinfo.gname)[2]
15204
16631
             except KeyError:
16089
17516
 """%(bug1333982.func_code.co_firstlineno + 1,
16090
17517
      bug1333982.func_code.co_firstlineno + 2,
16091
17518
      bug1333982.func_code.co_firstlineno + 3)
 
17519
diff -r 8527427914a2 Lib/test/test_doctest.py
 
17520
--- a/Lib/test/test_doctest.py
 
17521
+++ b/Lib/test/test_doctest.py
 
17522
@@ -258,6 +258,21 @@
 
17523
     >>> e = doctest.Example('raise X()', '', exc_msg)
 
17524
     >>> e.exc_msg
 
17525
     '\n'
 
17526
+
 
17527
+Compare `Example`:
 
17528
+    >>> example = doctest.Example('print 1', '1\n')
 
17529
+    >>> same_example = doctest.Example('print 1', '1\n')
 
17530
+    >>> other_example = doctest.Example('print 42', '42\n')
 
17531
+    >>> example == same_example
 
17532
+    True
 
17533
+    >>> example != same_example
 
17534
+    False
 
17535
+    >>> hash(example) == hash(same_example)
 
17536
+    True
 
17537
+    >>> example == other_example
 
17538
+    False
 
17539
+    >>> example != other_example
 
17540
+    True
 
17541
 """
 
17542
 
 
17543
 def test_DocTest(): r"""
 
17544
@@ -347,6 +362,50 @@
 
17545
     Traceback (most recent call last):
 
17546
     ValueError: line 2 of the docstring for some_test lacks blank after ...: '...print 1'
 
17547
 
 
17548
+Compare `DocTest`:
 
17549
+
 
17550
+    >>> docstring = '''
 
17551
+    ...     >>> print 12
 
17552
+    ...     12
 
17553
+    ... '''
 
17554
+    >>> test = parser.get_doctest(docstring, globs, 'some_test',
 
17555
+    ...                           'some_test', 20)
 
17556
+    >>> same_test = parser.get_doctest(docstring, globs, 'some_test',
 
17557
+    ...                                'some_test', 20)
 
17558
+    >>> test == same_test
 
17559
+    True
 
17560
+    >>> test != same_test
 
17561
+    False
 
17562
+    >>> hash(test) == hash(same_test)
 
17563
+    True
 
17564
+    >>> docstring = '''
 
17565
+    ...     >>> print 42
 
17566
+    ...     42
 
17567
+    ... '''
 
17568
+    >>> other_test = parser.get_doctest(docstring, globs, 'other_test',
 
17569
+    ...                                 'other_file', 10)
 
17570
+    >>> test == other_test
 
17571
+    False
 
17572
+    >>> test != other_test
 
17573
+    True
 
17574
+
 
17575
+Compare `DocTestCase`:
 
17576
+
 
17577
+    >>> DocTestCase = doctest.DocTestCase
 
17578
+    >>> test_case = DocTestCase(test)
 
17579
+    >>> same_test_case = DocTestCase(same_test)
 
17580
+    >>> other_test_case = DocTestCase(other_test)
 
17581
+    >>> test_case == same_test_case
 
17582
+    True
 
17583
+    >>> test_case != same_test_case
 
17584
+    False
 
17585
+    >>> hash(test_case) == hash(same_test_case)
 
17586
+    True
 
17587
+    >>> test == other_test_case
 
17588
+    False
 
17589
+    >>> test != other_test_case
 
17590
+    True
 
17591
+
 
17592
 """
 
17593
 
 
17594
 def test_DocTestFinder(): r"""
 
17595
diff -r 8527427914a2 Lib/test/test_epoll.py
 
17596
--- a/Lib/test/test_epoll.py
 
17597
+++ b/Lib/test/test_epoll.py
 
17598
@@ -36,6 +36,7 @@
 
17599
 except IOError, e:
 
17600
     if e.errno == errno.ENOSYS:
 
17601
         raise unittest.SkipTest("kernel doesn't support epoll()")
 
17602
+    raise
 
17603
 
 
17604
 class TestEPoll(unittest.TestCase):
 
17605
 
16092
17606
diff -r 8527427914a2 Lib/test/test_exceptions.py
16093
17607
--- a/Lib/test/test_exceptions.py
16094
17608
+++ b/Lib/test/test_exceptions.py
16147
17661
     def test_floatasratio(self):
16148
17662
         for f, ratio in [
16149
17663
                 (0.875, (7, 8)),
 
17664
diff -r 8527427914a2 Lib/test/test_ftplib.py
 
17665
--- a/Lib/test/test_ftplib.py
 
17666
+++ b/Lib/test/test_ftplib.py
 
17667
@@ -667,7 +667,7 @@
 
17668
     def setUp(self):
 
17669
         self.evt = threading.Event()
 
17670
         self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 
17671
-        self.sock.settimeout(3)
 
17672
+        self.sock.settimeout(10)
 
17673
         self.port = test_support.bind_port(self.sock)
 
17674
         threading.Thread(target=self.server, args=(self.evt,self.sock)).start()
 
17675
         # Wait for the server to be ready.
 
17676
diff -r 8527427914a2 Lib/test/test_gdb.py
 
17677
--- a/Lib/test/test_gdb.py
 
17678
+++ b/Lib/test/test_gdb.py
 
17679
@@ -32,6 +32,14 @@
 
17680
 if gdbpy_version == '':
 
17681
     raise unittest.SkipTest("gdb not built with embedded python support")
 
17682
 
 
17683
+def python_is_optimized():
 
17684
+    cflags = sysconfig.get_config_vars()['PY_CFLAGS']
 
17685
+    final_opt = ""
 
17686
+    for opt in cflags.split():
 
17687
+        if opt.startswith('-O'):
 
17688
+            final_opt = opt
 
17689
+    return (final_opt and final_opt != '-O0')
 
17690
+
 
17691
 def gdb_has_frame_select():
 
17692
     # Does this build of gdb have gdb.Frame.select ?
 
17693
     cmd = "--eval-command=python print(dir(gdb.Frame))"
 
17694
@@ -543,6 +551,8 @@
 
17695
                                  re.DOTALL),
 
17696
                         'Unexpected gdb representation: %r\n%s' % (gdb_output, gdb_output))
 
17697
 
 
17698
+@unittest.skipIf(python_is_optimized(),
 
17699
+                 "Python was compiled with optimizations")
 
17700
 class PyListTests(DebuggerTests):
 
17701
     def assertListing(self, expected, actual):
 
17702
         self.assertEndsWith(actual, expected)
 
17703
@@ -585,6 +595,8 @@
 
17704
 
 
17705
 class StackNavigationTests(DebuggerTests):
 
17706
     @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
 
17707
+    @unittest.skipIf(python_is_optimized(),
 
17708
+                     "Python was compiled with optimizations")
 
17709
     def test_pyup_command(self):
 
17710
         'Verify that the "py-up" command works'
 
17711
         bt = self.get_stack_trace(script=self.get_sample_script(),
 
17712
@@ -612,6 +624,8 @@
 
17713
                             'Unable to find an older python frame\n')
 
17714
 
 
17715
     @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
 
17716
+    @unittest.skipIf(python_is_optimized(),
 
17717
+                     "Python was compiled with optimizations")
 
17718
     def test_up_then_down(self):
 
17719
         'Verify "py-up" followed by "py-down"'
 
17720
         bt = self.get_stack_trace(script=self.get_sample_script(),
 
17721
@@ -625,6 +639,8 @@
 
17722
 $''')
 
17723
 
 
17724
 class PyBtTests(DebuggerTests):
 
17725
+    @unittest.skipIf(python_is_optimized(),
 
17726
+                     "Python was compiled with optimizations")
 
17727
     def test_basic_command(self):
 
17728
         'Verify that the "py-bt" command works'
 
17729
         bt = self.get_stack_trace(script=self.get_sample_script(),
 
17730
@@ -636,10 +652,12 @@
 
17731
 #[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 4, in foo \(a=1, b=2, c=3\)
 
17732
     bar\(a, b, c\)
 
17733
 #[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 12, in <module> \(\)
 
17734
-foo\(1, 2, 3\)
 
17735
+    foo\(1, 2, 3\)
 
17736
 ''')
 
17737
 
 
17738
 class PyPrintTests(DebuggerTests):
 
17739
+    @unittest.skipIf(python_is_optimized(),
 
17740
+                     "Python was compiled with optimizations")
 
17741
     def test_basic_command(self):
 
17742
         'Verify that the "py-print" command works'
 
17743
         bt = self.get_stack_trace(script=self.get_sample_script(),
 
17744
@@ -648,18 +666,24 @@
 
17745
                                     r".*\nlocal 'args' = \(1, 2, 3\)\n.*")
 
17746
 
 
17747
     @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
 
17748
+    @unittest.skipIf(python_is_optimized(),
 
17749
+                     "Python was compiled with optimizations")
 
17750
     def test_print_after_up(self):
 
17751
         bt = self.get_stack_trace(script=self.get_sample_script(),
 
17752
                                   cmds_after_breakpoint=['py-up', 'py-print c', 'py-print b', 'py-print a'])
 
17753
         self.assertMultilineMatches(bt,
 
17754
                                     r".*\nlocal 'c' = 3\nlocal 'b' = 2\nlocal 'a' = 1\n.*")
 
17755
 
 
17756
+    @unittest.skipIf(python_is_optimized(),
 
17757
+                     "Python was compiled with optimizations")
 
17758
     def test_printing_global(self):
 
17759
         bt = self.get_stack_trace(script=self.get_sample_script(),
 
17760
                                   cmds_after_breakpoint=['py-print __name__'])
 
17761
         self.assertMultilineMatches(bt,
 
17762
                                     r".*\nglobal '__name__' = '__main__'\n.*")
 
17763
 
 
17764
+    @unittest.skipIf(python_is_optimized(),
 
17765
+                     "Python was compiled with optimizations")
 
17766
     def test_printing_builtin(self):
 
17767
         bt = self.get_stack_trace(script=self.get_sample_script(),
 
17768
                                   cmds_after_breakpoint=['py-print len'])
 
17769
@@ -667,6 +691,8 @@
 
17770
                                     r".*\nbuiltin 'len' = <built-in function len>\n.*")
 
17771
 
 
17772
 class PyLocalsTests(DebuggerTests):
 
17773
+    @unittest.skipIf(python_is_optimized(),
 
17774
+                     "Python was compiled with optimizations")
 
17775
     def test_basic_command(self):
 
17776
         bt = self.get_stack_trace(script=self.get_sample_script(),
 
17777
                                   cmds_after_breakpoint=['py-locals'])
 
17778
@@ -674,6 +700,8 @@
 
17779
                                     r".*\nargs = \(1, 2, 3\)\n.*")
 
17780
 
 
17781
     @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
 
17782
+    @unittest.skipIf(python_is_optimized(),
 
17783
+                     "Python was compiled with optimizations")
 
17784
     def test_locals_after_up(self):
 
17785
         bt = self.get_stack_trace(script=self.get_sample_script(),
 
17786
                                   cmds_after_breakpoint=['py-up', 'py-locals'])
 
17787
@@ -681,15 +709,6 @@
 
17788
                                     r".*\na = 1\nb = 2\nc = 3\n.*")
 
17789
 
 
17790
 def test_main():
 
17791
-    cflags = sysconfig.get_config_vars()['PY_CFLAGS']
 
17792
-    final_opt = ""
 
17793
-    for opt in cflags.split():
 
17794
-        if opt.startswith('-O'):
 
17795
-            final_opt = opt
 
17796
-    if final_opt and final_opt != '-O0':
 
17797
-        raise unittest.SkipTest("Python was built with compiler optimizations, "
 
17798
-                                "tests can't reliably succeed")
 
17799
-
 
17800
     run_unittest(PrettyPrintTests,
 
17801
                  PyListTests,
 
17802
                  StackNavigationTests,
16150
17803
diff -r 8527427914a2 Lib/test/test_grammar.py
16151
17804
--- a/Lib/test/test_grammar.py
16152
17805
+++ b/Lib/test/test_grammar.py
16339
17992
 
16340
17993
     def test_malformatted_charref(self):
16341
17994
         self._run_check("<p>&#bad;</p>", [
16342
 
@@ -343,8 +320,138 @@
 
17995
@@ -343,8 +320,180 @@
16343
17996
         self.assertEqual(parser.unescape('&#0038;'),'&')
16344
17997
 
16345
17998
 
16472
18125
+                          [("href", "http://www.example.org/\">;")]),
16473
18126
+                         ("data", "spam"), ("endtag", "a")])
16474
18127
+
 
18128
+    def test_condcoms(self):
 
18129
+        html = ('<!--[if IE & !(lte IE 8)]>aren\'t<![endif]-->'
 
18130
+                '<!--[if IE 8]>condcoms<![endif]-->'
 
18131
+                '<!--[if lte IE 7]>pretty?<![endif]-->')
 
18132
+        expected = [('comment', "[if IE & !(lte IE 8)]>aren't<![endif]"),
 
18133
+                    ('comment', '[if IE 8]>condcoms<![endif]'),
 
18134
+                    ('comment', '[if lte IE 7]>pretty?<![endif]')]
 
18135
+        self._run_check(html, expected)
 
18136
+
 
18137
+    def test_broken_condcoms(self):
 
18138
+        # these condcoms are missing the '--' after '<!' and before the '>'
 
18139
+        html = ('<![if !(IE)]>broken condcom<![endif]>'
 
18140
+                '<![if ! IE]><link href="favicon.tiff"/><![endif]>'
 
18141
+                '<![if !IE 6]><img src="firefox.png" /><![endif]>'
 
18142
+                '<![if !ie 6]><b>foo</b><![endif]>'
 
18143
+                '<![if (!IE)|(lt IE 9)]><img src="mammoth.bmp" /><![endif]>')
 
18144
+        # According to the HTML5 specs sections "8.2.4.44 Bogus comment state"
 
18145
+        # and "8.2.4.45 Markup declaration open state", comment tokens should
 
18146
+        # be emitted instead of 'unknown decl', but calling unknown_decl
 
18147
+        # provides more flexibility.
 
18148
+        # See also Lib/_markupbase.py:parse_declaration
 
18149
+        expected = [
 
18150
+            ('unknown decl', 'if !(IE)'),
 
18151
+            ('data', 'broken condcom'),
 
18152
+            ('unknown decl', 'endif'),
 
18153
+            ('unknown decl', 'if ! IE'),
 
18154
+            ('startendtag', 'link', [('href', 'favicon.tiff')]),
 
18155
+            ('unknown decl', 'endif'),
 
18156
+            ('unknown decl', 'if !IE 6'),
 
18157
+            ('startendtag', 'img', [('src', 'firefox.png')]),
 
18158
+            ('unknown decl', 'endif'),
 
18159
+            ('unknown decl', 'if !ie 6'),
 
18160
+            ('starttag', 'b', []),
 
18161
+            ('data', 'foo'),
 
18162
+            ('endtag', 'b'),
 
18163
+            ('unknown decl', 'endif'),
 
18164
+            ('unknown decl', 'if (!IE)|(lt IE 9)'),
 
18165
+            ('startendtag', 'img', [('src', 'mammoth.bmp')]),
 
18166
+            ('unknown decl', 'endif')
 
18167
+        ]
 
18168
+        self._run_check(html, expected)
 
18169
+
16475
18170
+
16476
18171
 def test_main():
16477
18172
-    test_support.run_unittest(HTMLParserTestCase)
16557
18252
diff -r 8527427914a2 Lib/test/test_import.py
16558
18253
--- a/Lib/test/test_import.py
16559
18254
+++ b/Lib/test/test_import.py
16560
 
@@ -265,6 +265,15 @@
 
18255
@@ -263,7 +263,19 @@
 
18256
                   import imp
 
18257
             sys.argv.insert(0, C())
16561
18258
             """))
16562
 
         script_helper.assert_python_ok(testfn)
16563
 
 
 
18259
-        script_helper.assert_python_ok(testfn)
 
18260
+        try:
 
18261
+            script_helper.assert_python_ok(testfn)
 
18262
+        finally:
 
18263
+            unlink(testfn)
 
18264
+
16564
18265
+    def test_bug7732(self):
16565
18266
+        source = TESTFN + '.py'
16566
18267
+        os.mkdir(source)
16569
18270
+                              imp.find_module, TESTFN, ["."])
16570
18271
+        finally:
16571
18272
+            os.rmdir(source)
16572
 
+
 
18273
 
16573
18274
 
16574
18275
 class PycRewritingTests(unittest.TestCase):
16575
 
     # Test that the `co_filename` attribute on code objects always points
16576
18276
diff -r 8527427914a2 Lib/test/test_inspect.py
16577
18277
--- a/Lib/test/test_inspect.py
16578
18278
+++ b/Lib/test/test_inspect.py
16600
18300
 class TestDecorators(GetSourceBase):
16601
18301
     fodderFile = mod2
16602
18302
 
 
18303
@@ -387,10 +404,37 @@
 
18304
         self.assertEqual(inspect.findsource(co), (lines,0))
 
18305
         self.assertEqual(inspect.getsource(co), lines[0])
 
18306
 
 
18307
+
 
18308
+class _BrokenDataDescriptor(object):
 
18309
+    """
 
18310
+    A broken data descriptor. See bug #1785.
 
18311
+    """
 
18312
+    def __get__(*args):
 
18313
+        raise AssertionError("should not __get__ data descriptors")
 
18314
+
 
18315
+    def __set__(*args):
 
18316
+        raise RuntimeError
 
18317
+
 
18318
+    def __getattr__(*args):
 
18319
+        raise AssertionError("should not __getattr__ data descriptors")
 
18320
+
 
18321
+
 
18322
+class _BrokenMethodDescriptor(object):
 
18323
+    """
 
18324
+    A broken method descriptor. See bug #1785.
 
18325
+    """
 
18326
+    def __get__(*args):
 
18327
+        raise AssertionError("should not __get__ method descriptors")
 
18328
+
 
18329
+    def __getattr__(*args):
 
18330
+        raise AssertionError("should not __getattr__ method descriptors")
 
18331
+
 
18332
+
 
18333
 # Helper for testing classify_class_attrs.
 
18334
 def attrs_wo_objs(cls):
 
18335
     return [t[:3] for t in inspect.classify_class_attrs(cls)]
 
18336
 
 
18337
+
 
18338
 class TestClassesAndFunctions(unittest.TestCase):
 
18339
     def test_classic_mro(self):
 
18340
         # Test classic-class method resolution order.
 
18341
@@ -477,6 +521,9 @@
 
18342
 
 
18343
             datablob = '1'
 
18344
 
 
18345
+            dd = _BrokenDataDescriptor()
 
18346
+            md = _BrokenMethodDescriptor()
 
18347
+
 
18348
         attrs = attrs_wo_objs(A)
 
18349
         self.assertIn(('s', 'static method', A), attrs, 'missing static method')
 
18350
         self.assertIn(('c', 'class method', A), attrs, 'missing class method')
 
18351
@@ -484,6 +531,8 @@
 
18352
         self.assertIn(('m', 'method', A), attrs, 'missing plain method')
 
18353
         self.assertIn(('m1', 'method', A), attrs, 'missing plain method')
 
18354
         self.assertIn(('datablob', 'data', A), attrs, 'missing data')
 
18355
+        self.assertIn(('md', 'method', A), attrs, 'missing method descriptor')
 
18356
+        self.assertIn(('dd', 'data', A), attrs, 'missing data descriptor')
 
18357
 
 
18358
         class B(A):
 
18359
             def m(self): pass
 
18360
@@ -495,6 +544,8 @@
 
18361
         self.assertIn(('m', 'method', B), attrs, 'missing plain method')
 
18362
         self.assertIn(('m1', 'method', A), attrs, 'missing plain method')
 
18363
         self.assertIn(('datablob', 'data', A), attrs, 'missing data')
 
18364
+        self.assertIn(('md', 'method', A), attrs, 'missing method descriptor')
 
18365
+        self.assertIn(('dd', 'data', A), attrs, 'missing data descriptor')
 
18366
 
 
18367
 
 
18368
         class C(A):
 
18369
@@ -508,6 +559,8 @@
 
18370
         self.assertIn(('m', 'method', C), attrs, 'missing plain method')
 
18371
         self.assertIn(('m1', 'method', A), attrs, 'missing plain method')
 
18372
         self.assertIn(('datablob', 'data', A), attrs, 'missing data')
 
18373
+        self.assertIn(('md', 'method', A), attrs, 'missing method descriptor')
 
18374
+        self.assertIn(('dd', 'data', A), attrs, 'missing data descriptor')
 
18375
 
 
18376
         class D(B, C):
 
18377
             def m1(self): pass
 
18378
@@ -522,6 +575,8 @@
 
18379
         self.assertIn(('m', 'method', B), attrs, 'missing plain method')
 
18380
         self.assertIn(('m1', 'method', D), attrs, 'missing plain method')
 
18381
         self.assertIn(('datablob', 'data', A), attrs, 'missing data')
 
18382
+        self.assertIn(('md', 'method', A), attrs, 'missing method descriptor')
 
18383
+        self.assertIn(('dd', 'data', A), attrs, 'missing data descriptor')
 
18384
 
 
18385
 
 
18386
     def test_classify_oldstyle(self):
 
18387
@@ -537,6 +592,64 @@
 
18388
         """
 
18389
         self._classify_test(True)
 
18390
 
 
18391
+    def test_classify_builtin_types(self):
 
18392
+        # Simple sanity check that all built-in types can have their
 
18393
+        # attributes classified.
 
18394
+        for name in dir(__builtin__):
 
18395
+            builtin = getattr(__builtin__, name)
 
18396
+            if isinstance(builtin, type):
 
18397
+                inspect.classify_class_attrs(builtin)
 
18398
+
 
18399
+    def test_getmembers_descriptors(self):
 
18400
+        # Old-style classes
 
18401
+        class A:
 
18402
+            dd = _BrokenDataDescriptor()
 
18403
+            md = _BrokenMethodDescriptor()
 
18404
+
 
18405
+        self.assertEqual(inspect.getmembers(A, inspect.ismethoddescriptor),
 
18406
+            [('md', A.__dict__['md'])])
 
18407
+        self.assertEqual(inspect.getmembers(A, inspect.isdatadescriptor),
 
18408
+            [('dd', A.__dict__['dd'])])
 
18409
+
 
18410
+        class B(A):
 
18411
+            pass
 
18412
+
 
18413
+        self.assertEqual(inspect.getmembers(B, inspect.ismethoddescriptor),
 
18414
+            [('md', A.__dict__['md'])])
 
18415
+        self.assertEqual(inspect.getmembers(B, inspect.isdatadescriptor),
 
18416
+            [('dd', A.__dict__['dd'])])
 
18417
+
 
18418
+        # New-style classes
 
18419
+        class A(object):
 
18420
+            dd = _BrokenDataDescriptor()
 
18421
+            md = _BrokenMethodDescriptor()
 
18422
+
 
18423
+        def pred_wrapper(pred):
 
18424
+            # A quick'n'dirty way to discard standard attributes of new-style
 
18425
+            # classes.
 
18426
+            class Empty(object):
 
18427
+                pass
 
18428
+            def wrapped(x):
 
18429
+                if hasattr(x, '__name__') and hasattr(Empty, x.__name__):
 
18430
+                    return False
 
18431
+                return pred(x)
 
18432
+            return wrapped
 
18433
+
 
18434
+        ismethoddescriptor = pred_wrapper(inspect.ismethoddescriptor)
 
18435
+        isdatadescriptor = pred_wrapper(inspect.isdatadescriptor)
 
18436
+
 
18437
+        self.assertEqual(inspect.getmembers(A, ismethoddescriptor),
 
18438
+            [('md', A.__dict__['md'])])
 
18439
+        self.assertEqual(inspect.getmembers(A, isdatadescriptor),
 
18440
+            [('dd', A.__dict__['dd'])])
 
18441
+
 
18442
+        class B(A):
 
18443
+            pass
 
18444
+
 
18445
+        self.assertEqual(inspect.getmembers(B, ismethoddescriptor),
 
18446
+            [('md', A.__dict__['md'])])
 
18447
+        self.assertEqual(inspect.getmembers(B, isdatadescriptor),
 
18448
+            [('dd', A.__dict__['dd'])])
 
18449
 
 
18450
 
 
18451
 class TestGetcallargsFunctions(unittest.TestCase):
16603
18452
diff -r 8527427914a2 Lib/test/test_io.py
16604
18453
--- a/Lib/test/test_io.py
16605
18454
+++ b/Lib/test/test_io.py
17031
18880
         filename = os.path.join(self._path, 'cur', 'stray-file')
17032
18881
         f = open(filename, 'w')
17033
18882
         f.close()
17034
 
@@ -1670,7 +1704,8 @@
 
18883
@@ -831,26 +865,37 @@
 
18884
             self.assertEqual(contents, f.read())
 
18885
         self._box = self._factory(self._path)
 
18886
 
 
18887
+    @unittest.skipUnless(hasattr(os, 'fork'), "Test needs fork().")
 
18888
+    @unittest.skipUnless(hasattr(socket, 'socketpair'), "Test needs socketpair().")
 
18889
     def test_lock_conflict(self):
 
18890
-        # Fork off a subprocess that will lock the file for 2 seconds,
 
18891
-        # unlock it, and then exit.
 
18892
-        if not hasattr(os, 'fork'):
 
18893
-            return
 
18894
+        # Fork off a child process that will lock the mailbox temporarily,
 
18895
+        # unlock it and exit.
 
18896
+        c, p = socket.socketpair()
 
18897
+        self.addCleanup(c.close)
 
18898
+        self.addCleanup(p.close)
 
18899
+
 
18900
         pid = os.fork()
 
18901
         if pid == 0:
 
18902
-            # In the child, lock the mailbox.
 
18903
-            self._box.lock()
 
18904
-            time.sleep(2)
 
18905
-            self._box.unlock()
 
18906
-            os._exit(0)
 
18907
+            # child
 
18908
+            try:
 
18909
+                # lock the mailbox, and signal the parent it can proceed
 
18910
+                self._box.lock()
 
18911
+                c.send(b'c')
 
18912
 
 
18913
-        # In the parent, sleep a bit to give the child time to acquire
 
18914
-        # the lock.
 
18915
-        time.sleep(0.5)
 
18916
+                # wait until the parent is done, and unlock the mailbox
 
18917
+                c.recv(1)
 
18918
+                self._box.unlock()
 
18919
+            finally:
 
18920
+                os._exit(0)
 
18921
+
 
18922
+        # In the parent, wait until the child signals it locked the mailbox.
 
18923
+        p.recv(1)
 
18924
         try:
 
18925
             self.assertRaises(mailbox.ExternalClashError,
 
18926
                               self._box.lock)
 
18927
         finally:
 
18928
+            # Signal the child it can now release the lock and exit.
 
18929
+            p.send(b'p')
 
18930
             # Wait for child to exit.  Locking should now succeed.
 
18931
             exited_pid, status = os.waitpid(pid, 0)
 
18932
 
 
18933
@@ -1670,7 +1715,8 @@
17035
18934
     def _test_close(self, proxy):
17036
18935
         # Close a file
17037
18936
         proxy.close()
18204
20103
         try:
18205
20104
             test_func()
18206
20105
         except Exception, strerror:
18207
 
@@ -1380,7 +1379,7 @@
 
20106
@@ -707,6 +706,16 @@
 
20107
         srv.listen(0)
 
20108
         srv.close()
 
20109
 
 
20110
+    @unittest.skipUnless(SUPPORTS_IPV6, 'IPv6 required for this test.')
 
20111
+    def test_flowinfo(self):
 
20112
+        self.assertRaises(OverflowError, socket.getnameinfo,
 
20113
+                          ('::1',0, 0xffffffff), 0)
 
20114
+        s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
 
20115
+        try:
 
20116
+            self.assertRaises(OverflowError, s.bind, ('::1', 0, -10))
 
20117
+        finally:
 
20118
+            s.close()
 
20119
+
 
20120
 
 
20121
 @unittest.skipUnless(thread, 'Threading required for this test.')
 
20122
 class BasicTCPTest(SocketConnectedTest):
 
20123
@@ -1380,7 +1389,7 @@
18208
20124
             # no alarm can be pending.  Safe to restore old handler.
18209
20125
             signal.signal(signal.SIGALRM, old_alarm)
18210
20126
 
18265
20181
 
18266
20182
     def test_DER_to_PEM(self):
18267
20183
         with open(SVN_PYTHON_ORG_ROOT_CERT, 'r') as f:
18268
 
@@ -966,6 +983,8 @@
 
20184
@@ -400,10 +417,11 @@
 
20185
                                                    ca_certs=self.server.cacerts,
 
20186
                                                    cert_reqs=self.server.certreqs,
 
20187
                                                    ciphers=self.server.ciphers)
 
20188
-                except ssl.SSLError:
 
20189
+                except ssl.SSLError as e:
 
20190
                     # XXX Various errors can have happened here, for example
 
20191
                     # a mismatching protocol version, an invalid certificate,
 
20192
                     # or a low-level bug. This should be made more discriminating.
 
20193
+                    self.server.conn_errors.append(e)
 
20194
                     if self.server.chatty:
 
20195
                         handle_error("\n server:  bad connection attempt from " +
 
20196
                                      str(self.sock.getpeername()) + ":\n")
 
20197
@@ -512,9 +530,19 @@
 
20198
                     sys.stdout.write(' server:  wrapped server socket as %s\n' % str(self.sock))
 
20199
             self.port = test_support.bind_port(self.sock)
 
20200
             self.active = False
 
20201
+            self.conn_errors = []
 
20202
             threading.Thread.__init__(self)
 
20203
             self.daemon = True
 
20204
 
 
20205
+        def __enter__(self):
 
20206
+            self.start(threading.Event())
 
20207
+            self.flag.wait()
 
20208
+            return self
 
20209
+
 
20210
+        def __exit__(self, *args):
 
20211
+            self.stop()
 
20212
+            self.join()
 
20213
+
 
20214
         def start(self, flag=None):
 
20215
             self.flag = flag
 
20216
             threading.Thread.start(self)
 
20217
@@ -621,6 +649,21 @@
 
20218
         def __str__(self):
 
20219
             return "<%s %s>" % (self.__class__.__name__, self.server)
 
20220
 
 
20221
+        def __enter__(self):
 
20222
+            self.start(threading.Event())
 
20223
+            self.flag.wait()
 
20224
+            return self
 
20225
+
 
20226
+        def __exit__(self, *args):
 
20227
+            if test_support.verbose:
 
20228
+                sys.stdout.write(" cleanup: stopping server.\n")
 
20229
+            self.stop()
 
20230
+            if test_support.verbose:
 
20231
+                sys.stdout.write(" cleanup: joining server thread.\n")
 
20232
+            self.join()
 
20233
+            if test_support.verbose:
 
20234
+                sys.stdout.write(" cleanup: successfully joined.\n")
 
20235
+
 
20236
         def start(self, flag=None):
 
20237
             self.flag = flag
 
20238
             threading.Thread.start(self)
 
20239
@@ -735,12 +778,7 @@
 
20240
         server = ThreadedEchoServer(CERTFILE,
 
20241
                                     certreqs=ssl.CERT_REQUIRED,
 
20242
                                     cacerts=CERTFILE, chatty=False)
 
20243
-        flag = threading.Event()
 
20244
-        server.start(flag)
 
20245
-        # wait for it to start
 
20246
-        flag.wait()
 
20247
-        # try to connect
 
20248
-        try:
 
20249
+        with server:
 
20250
             try:
 
20251
                 s = ssl.wrap_socket(socket.socket(),
 
20252
                                     certfile=certfile,
 
20253
@@ -754,9 +792,6 @@
 
20254
                     sys.stdout.write("\nsocket.error is %s\n" % x[1])
 
20255
             else:
 
20256
                 raise AssertionError("Use of invalid cert should have failed!")
 
20257
-        finally:
 
20258
-            server.stop()
 
20259
-            server.join()
 
20260
 
 
20261
     def server_params_test(certfile, protocol, certreqs, cacertsfile,
 
20262
                            client_certfile, client_protocol=None, indata="FOO\n",
 
20263
@@ -774,14 +809,10 @@
 
20264
                                     chatty=chatty,
 
20265
                                     connectionchatty=connectionchatty,
 
20266
                                     wrap_accepting_socket=wrap_accepting_socket)
 
20267
-        flag = threading.Event()
 
20268
-        server.start(flag)
 
20269
-        # wait for it to start
 
20270
-        flag.wait()
 
20271
-        # try to connect
 
20272
-        if client_protocol is None:
 
20273
-            client_protocol = protocol
 
20274
-        try:
 
20275
+        with server:
 
20276
+            # try to connect
 
20277
+            if client_protocol is None:
 
20278
+                client_protocol = protocol
 
20279
             s = ssl.wrap_socket(socket.socket(),
 
20280
                                 certfile=client_certfile,
 
20281
                                 ca_certs=cacertsfile,
 
20282
@@ -809,9 +840,6 @@
 
20283
                 if test_support.verbose:
 
20284
                     sys.stdout.write(" client:  closing connection.\n")
 
20285
             s.close()
 
20286
-        finally:
 
20287
-            server.stop()
 
20288
-            server.join()
 
20289
 
 
20290
     def try_protocol_combo(server_protocol,
 
20291
                            client_protocol,
 
20292
@@ -913,12 +941,7 @@
 
20293
                                         ssl_version=ssl.PROTOCOL_SSLv23,
 
20294
                                         cacerts=CERTFILE,
 
20295
                                         chatty=False)
 
20296
-            flag = threading.Event()
 
20297
-            server.start(flag)
 
20298
-            # wait for it to start
 
20299
-            flag.wait()
 
20300
-            # try to connect
 
20301
-            try:
 
20302
+            with server:
 
20303
                 s = ssl.wrap_socket(socket.socket(),
 
20304
                                     certfile=CERTFILE,
 
20305
                                     ca_certs=CERTFILE,
 
20306
@@ -940,9 +963,6 @@
 
20307
                         "Missing or invalid 'organizationName' field in certificate subject; "
 
20308
                         "should be 'Python Software Foundation'.")
 
20309
                 s.close()
 
20310
-            finally:
 
20311
-                server.stop()
 
20312
-                server.join()
 
20313
 
 
20314
         def test_empty_cert(self):
 
20315
             """Connecting with an empty cert file"""
 
20316
@@ -966,6 +986,8 @@
18269
20317
             """Connecting to an SSLv2 server with various client options"""
18270
20318
             if test_support.verbose:
18271
20319
                 sys.stdout.write("\n")
18274
20322
             try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True)
18275
20323
             try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_OPTIONAL)
18276
20324
             try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_REQUIRED)
18277
 
@@ -978,14 +997,6 @@
 
20325
@@ -978,14 +1000,6 @@
18278
20326
             """Connecting to an SSLv23 server with various client options"""
18279
20327
             if test_support.verbose:
18280
20328
                 sys.stdout.write("\n")
18289
20337
             try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, True)
18290
20338
             try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True)
18291
20339
             try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True)
18292
 
@@ -1008,7 +1019,6 @@
 
20340
@@ -1008,7 +1022,6 @@
18293
20341
             try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_REQUIRED)
18294
20342
             if hasattr(ssl, 'PROTOCOL_SSLv2'):
18295
20343
                 try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv2, False)
18297
20345
             try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLSv1, False)
18298
20346
 
18299
20347
         @skip_if_broken_ubuntu_ssl
18300
 
@@ -1022,7 +1032,6 @@
 
20348
@@ -1022,7 +1035,6 @@
18301
20349
             if hasattr(ssl, 'PROTOCOL_SSLv2'):
18302
20350
                 try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv2, False)
18303
20351
             try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv3, False)
18305
20353
 
18306
20354
         def test_starttls(self):
18307
20355
             """Switching from clear text to encrypted and back again."""
18308
 
@@ -1329,15 +1338,18 @@
18309
 
 
 
20356
@@ -1033,13 +1045,8 @@
 
20357
                                         starttls_server=True,
 
20358
                                         chatty=True,
 
20359
                                         connectionchatty=True)
 
20360
-            flag = threading.Event()
 
20361
-            server.start(flag)
 
20362
-            # wait for it to start
 
20363
-            flag.wait()
 
20364
-            # try to connect
 
20365
             wrapped = False
 
20366
-            try:
 
20367
+            with server:
 
20368
                 s = socket.socket()
 
20369
                 s.setblocking(1)
 
20370
                 s.connect((HOST, server.port))
 
20371
@@ -1084,9 +1091,6 @@
 
20372
                 else:
 
20373
                     s.send("over\n")
 
20374
                 s.close()
 
20375
-            finally:
 
20376
-                server.stop()
 
20377
-                server.join()
 
20378
 
 
20379
         def test_socketserver(self):
 
20380
             """Using a SocketServer to create and manage SSL connections."""
 
20381
@@ -1136,12 +1140,7 @@
 
20382
             if test_support.verbose:
 
20383
                 sys.stdout.write("\n")
 
20384
             server = AsyncoreEchoServer(CERTFILE)
 
20385
-            flag = threading.Event()
 
20386
-            server.start(flag)
 
20387
-            # wait for it to start
 
20388
-            flag.wait()
 
20389
-            # try to connect
 
20390
-            try:
 
20391
+            with server:
 
20392
                 s = ssl.wrap_socket(socket.socket())
 
20393
                 s.connect(('127.0.0.1', server.port))
 
20394
                 if test_support.verbose:
 
20395
@@ -1160,10 +1159,6 @@
 
20396
                 if test_support.verbose:
 
20397
                     sys.stdout.write(" client:  closing connection.\n")
 
20398
                 s.close()
 
20399
-            finally:
 
20400
-                server.stop()
 
20401
-                # wait for server thread to end
 
20402
-                server.join()
 
20403
 
 
20404
         def test_recv_send(self):
 
20405
             """Test recv(), send() and friends."""
 
20406
@@ -1176,19 +1171,14 @@
 
20407
                                         cacerts=CERTFILE,
 
20408
                                         chatty=True,
 
20409
                                         connectionchatty=False)
 
20410
-            flag = threading.Event()
 
20411
-            server.start(flag)
 
20412
-            # wait for it to start
 
20413
-            flag.wait()
 
20414
-            # try to connect
 
20415
-            s = ssl.wrap_socket(socket.socket(),
 
20416
-                                server_side=False,
 
20417
-                                certfile=CERTFILE,
 
20418
-                                ca_certs=CERTFILE,
 
20419
-                                cert_reqs=ssl.CERT_NONE,
 
20420
-                                ssl_version=ssl.PROTOCOL_TLSv1)
 
20421
-            s.connect((HOST, server.port))
 
20422
-            try:
 
20423
+            with server:
 
20424
+                s = ssl.wrap_socket(socket.socket(),
 
20425
+                                    server_side=False,
 
20426
+                                    certfile=CERTFILE,
 
20427
+                                    ca_certs=CERTFILE,
 
20428
+                                    cert_reqs=ssl.CERT_NONE,
 
20429
+                                    ssl_version=ssl.PROTOCOL_TLSv1)
 
20430
+                s.connect((HOST, server.port))
 
20431
                 # helper methods for standardising recv* method signatures
 
20432
                 def _recv_into():
 
20433
                     b = bytearray("\0"*100)
 
20434
@@ -1276,9 +1266,6 @@
 
20435
 
 
20436
                 s.write("over\n".encode("ASCII", "strict"))
 
20437
                 s.close()
 
20438
-            finally:
 
20439
-                server.stop()
 
20440
-                server.join()
 
20441
 
 
20442
         def test_handshake_timeout(self):
 
20443
             # Issue #5103: SSL handshake must respect the socket timeout
 
20444
@@ -1327,17 +1314,39 @@
 
20445
                 t.join()
 
20446
                 server.close()
 
20447
 
 
20448
+        def test_default_ciphers(self):
 
20449
+            with ThreadedEchoServer(CERTFILE,
 
20450
+                                    ssl_version=ssl.PROTOCOL_SSLv23,
 
20451
+                                    chatty=False) as server:
 
20452
+                sock = socket.socket()
 
20453
+                try:
 
20454
+                    # Force a set of weak ciphers on our client socket
 
20455
+                    try:
 
20456
+                        s = ssl.wrap_socket(sock,
 
20457
+                                            ssl_version=ssl.PROTOCOL_SSLv23,
 
20458
+                                            ciphers="DES")
 
20459
+                    except ssl.SSLError:
 
20460
+                        self.skipTest("no DES cipher available")
 
20461
+                    with self.assertRaises((OSError, ssl.SSLError)):
 
20462
+                        s.connect((HOST, server.port))
 
20463
+                finally:
 
20464
+                    sock.close()
 
20465
+            self.assertIn("no shared cipher", str(server.conn_errors[0]))
 
20466
+
18310
20467
 
18311
20468
 def test_main(verbose=False):
18312
20469
-    global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT
18594
20751
 def captured_stdin():
18595
20752
     return captured_output("stdin")
18596
20753
 
 
20754
diff -r 8527427914a2 Lib/test/test_symtable.py
 
20755
--- a/Lib/test/test_symtable.py
 
20756
+++ b/Lib/test/test_symtable.py
 
20757
@@ -88,10 +88,10 @@
 
20758
 
 
20759
     def test_function_info(self):
 
20760
         func = self.spam
 
20761
-        self.assertEqual(func.get_parameters(), ("a", "b", "kw", "var"))
 
20762
-        self.assertEqual(func.get_locals(),
 
20763
-                         ("a", "b", "internal", "kw", "var", "x"))
 
20764
-        self.assertEqual(func.get_globals(), ("bar", "glob"))
 
20765
+        self.assertEqual(sorted(func.get_parameters()), ["a", "b", "kw", "var"])
 
20766
+        expected = ["a", "b", "internal", "kw", "var", "x"]
 
20767
+        self.assertEqual(sorted(func.get_locals()), expected)
 
20768
+        self.assertEqual(sorted(func.get_globals()), ["bar", "glob"])
 
20769
         self.assertEqual(self.internal.get_frees(), ("x",))
 
20770
 
 
20771
     def test_globals(self):
18597
20772
diff -r 8527427914a2 Lib/test/test_sys.py
18598
20773
--- a/Lib/test/test_sys.py
18599
20774
+++ b/Lib/test/test_sys.py
18698
20873
 
18699
20874
 class MemberReadTest(ReadTest):
18700
20875
 
 
20876
@@ -977,6 +994,13 @@
 
20877
         finally:
 
20878
             os.umask(original_umask)
 
20879
 
 
20880
+    def test_issue13639(self):
 
20881
+        try:
 
20882
+            with tarfile.open(unicode(tmpname, sys.getfilesystemencoding()), self.mode):
 
20883
+                pass
 
20884
+        except UnicodeDecodeError:
 
20885
+            self.fail("_Stream failed to write unicode filename")
 
20886
+
 
20887
 
 
20888
 class GNUWriteTest(unittest.TestCase):
 
20889
     # This testcase checks for correct creation of GNU Longname
18701
20890
diff -r 8527427914a2 Lib/test/test_telnetlib.py
18702
20891
--- a/Lib/test/test_telnetlib.py
18703
20892
+++ b/Lib/test/test_telnetlib.py
18767
20956
         self.assertEqual(telnet.sock.gettimeout(), 30)
18768
20957
         telnet.sock.close()
18769
20958
 
18770
 
@@ -105,11 +100,8 @@
 
20959
@@ -100,16 +95,13 @@
 
20960
     self.evt = threading.Event()
 
20961
     self.dataq = Queue.Queue()
 
20962
     self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 
20963
-    self.sock.settimeout(3)
 
20964
+    self.sock.settimeout(10)
 
20965
     self.port = test_support.bind_port(self.sock)
18771
20966
     self.thread = threading.Thread(target=server, args=(self.evt,self.sock, self.dataq))
18772
20967
     self.thread.start()
18773
20968
     self.evt.wait()
19732
21927
     def tearDown(self):
19733
21928
         unlink(TESTFN)
19734
21929
         unlink(TESTFN2)
 
21930
diff -r 8527427914a2 Lib/threading.py
 
21931
--- a/Lib/threading.py
 
21932
+++ b/Lib/threading.py
 
21933
@@ -878,22 +878,19 @@
 
21934
     current = current_thread()
 
21935
     with _active_limbo_lock:
 
21936
         for thread in _active.itervalues():
 
21937
+            # Any lock/condition variable may be currently locked or in an
 
21938
+            # invalid state, so we reinitialize them.
 
21939
+            if hasattr(thread, '_reset_internal_locks'):
 
21940
+                thread._reset_internal_locks()
 
21941
             if thread is current:
 
21942
                 # There is only one active thread. We reset the ident to
 
21943
                 # its new value since it can have changed.
 
21944
                 ident = _get_ident()
 
21945
                 thread._Thread__ident = ident
 
21946
-                # Any condition variables hanging off of the active thread may
 
21947
-                # be in an invalid state, so we reinitialize them.
 
21948
-                if hasattr(thread, '_reset_internal_locks'):
 
21949
-                    thread._reset_internal_locks()
 
21950
                 new_active[ident] = thread
 
21951
             else:
 
21952
                 # All the others are already stopped.
 
21953
-                # We don't call _Thread__stop() because it tries to acquire
 
21954
-                # thread._Thread__block which could also have been held while
 
21955
-                # we forked.
 
21956
-                thread._Thread__stopped = True
 
21957
+                thread._Thread__stop()
 
21958
 
 
21959
         _limbo.clear()
 
21960
         _active.clear()
19735
21961
diff -r 8527427914a2 Lib/timeit.py
19736
21962
--- a/Lib/timeit.py
19737
21963
+++ b/Lib/timeit.py
19847
22073
                     reporthook(blocknum, bs, size)
19848
22074
                 while 1:
19849
22075
                     block = fp.read(bs)
19850
 
@@ -850,13 +850,16 @@
 
22076
@@ -374,7 +374,6 @@
 
22077
 
 
22078
     def http_error_default(self, url, fp, errcode, errmsg, headers):
 
22079
         """Default error handler: close the connection and raise IOError."""
 
22080
-        void = fp.read()
 
22081
         fp.close()
 
22082
         raise IOError, ('http error', errcode, errmsg, headers)
 
22083
 
 
22084
@@ -640,7 +639,6 @@
 
22085
             newurl = headers['uri']
 
22086
         else:
 
22087
             return
 
22088
-        void = fp.read()
 
22089
         fp.close()
 
22090
         # In case the server sent a relative URL, join with original:
 
22091
         newurl = basejoin(self.type + ":" + url, newurl)
 
22092
@@ -850,13 +848,16 @@
19851
22093
     """Class used by open_ftp() for cache of open FTP connections."""
19852
22094
 
19853
22095
     def __init__(self, user, passwd, host, port, dirs,
19865
22107
         self.init()
19866
22108
 
19867
22109
     def init(self):
19868
 
@@ -883,7 +886,7 @@
 
22110
@@ -883,7 +884,7 @@
19869
22111
             # Try to retrieve as a file
19870
22112
             try:
19871
22113
                 cmd = 'RETR ' + file
19874
22116
             except ftplib.error_perm, reason:
19875
22117
                 if str(reason)[:3] != '550':
19876
22118
                     raise IOError, ('ftp error', reason), sys.exc_info()[2]
19877
 
@@ -903,11 +906,14 @@
 
22119
@@ -903,11 +904,14 @@
19878
22120
                 cmd = 'LIST ' + file
19879
22121
             else:
19880
22122
                 cmd = 'LIST'
19892
22134
     def endtransfer(self):
19893
22135
         if not self.busy:
19894
22136
             return
19895
 
@@ -918,6 +924,17 @@
 
22137
@@ -918,6 +922,17 @@
19896
22138
             pass
19897
22139
 
19898
22140
     def close(self):
19910
22152
         self.endtransfer()
19911
22153
         try:
19912
22154
             self.ftp.close()
19913
 
@@ -1349,7 +1366,8 @@
 
22155
@@ -1349,7 +1364,8 @@
19914
22156
     # strip port off host
19915
22157
     hostonly, port = splitport(host)
19916
22158
     # check if the host ends with any of the DNS suffixes
19920
22162
         if name and (hostonly.endswith(name) or host.endswith(name)):
19921
22163
             return 1
19922
22164
     # otherwise, don't bypass
19923
 
@@ -1581,66 +1599,3 @@
 
22165
@@ -1581,66 +1597,3 @@
19924
22166
     # Report during remote transfers
19925
22167
     print "Block number: %d, Block size: %d, Total size: %d" % (
19926
22168
         blocknum, blocksize, totalsize)
20277
22519
         # Standard values:
20278
22520
         self.compress_type = ZIP_STORED # Type of compression for the file
20279
22521
         self.comment = ""               # Comment for each file
 
22522
diff -r 8527427914a2 Mac/IDLE/Info.plist.in
 
22523
--- a/Mac/IDLE/Info.plist.in
 
22524
+++ b/Mac/IDLE/Info.plist.in
 
22525
@@ -36,7 +36,7 @@
 
22526
        <key>CFBundleExecutable</key>
 
22527
        <string>IDLE</string>
 
22528
        <key>CFBundleGetInfoString</key>
 
22529
-       <string>%VERSION%, © 2001-2011 Python Software Foundation</string>
 
22530
+       <string>%VERSION%, © 2001-2012 Python Software Foundation</string>
 
22531
        <key>CFBundleIconFile</key>
 
22532
        <string>IDLE.icns</string>
 
22533
        <key>CFBundleIdentifier</key>
 
22534
diff -r 8527427914a2 Mac/PythonLauncher/Info.plist.in
 
22535
--- a/Mac/PythonLauncher/Info.plist.in
 
22536
+++ b/Mac/PythonLauncher/Info.plist.in
 
22537
@@ -40,7 +40,7 @@
 
22538
        <key>CFBundleExecutable</key>
 
22539
        <string>PythonLauncher</string>
 
22540
        <key>CFBundleGetInfoString</key>
 
22541
-       <string>%VERSION%, © 2001-2011 Python Software Foundation</string>
 
22542
+       <string>%VERSION%, © 2001-2012 Python Software Foundation</string>
 
22543
        <key>CFBundleIconFile</key>
 
22544
        <string>PythonLauncher.icns</string>
 
22545
        <key>CFBundleIdentifier</key>
 
22546
diff -r 8527427914a2 Mac/Resources/app/Info.plist.in
 
22547
--- a/Mac/Resources/app/Info.plist.in
 
22548
+++ b/Mac/Resources/app/Info.plist.in
 
22549
@@ -20,7 +20,7 @@
 
22550
        <key>CFBundleExecutable</key>
 
22551
        <string>Python</string>
 
22552
        <key>CFBundleGetInfoString</key>
 
22553
-       <string>%version%, (c) 2004-2011 Python Software Foundation.</string>
 
22554
+       <string>%version%, (c) 2004-2012 Python Software Foundation.</string>
 
22555
        <key>CFBundleHelpBookFolder</key>
 
22556
        <array>
 
22557
                <string>Documentation</string>
 
22558
@@ -37,7 +37,7 @@
 
22559
        <key>CFBundleInfoDictionaryVersion</key>
 
22560
        <string>6.0</string>
 
22561
        <key>CFBundleLongVersionString</key>
 
22562
-       <string>%version%, (c) 2004-2011 Python Software Foundation.</string>
 
22563
+       <string>%version%, (c) 2004-2012 Python Software Foundation.</string>
 
22564
        <key>CFBundleName</key>
 
22565
        <string>Python</string>
 
22566
        <key>CFBundlePackageType</key>
 
22567
@@ -55,6 +55,6 @@
 
22568
        <key>NSAppleScriptEnabled</key>
 
22569
        <true/>
 
22570
        <key>NSHumanReadableCopyright</key>
 
22571
-       <string>(c) 2011 Python Software Foundation.</string>
 
22572
+       <string>(c) 2012 Python Software Foundation.</string>
 
22573
 </dict>
 
22574
 </plist>
 
22575
diff -r 8527427914a2 Mac/Resources/framework/Info.plist.in
 
22576
--- a/Mac/Resources/framework/Info.plist.in
 
22577
+++ b/Mac/Resources/framework/Info.plist.in
 
22578
@@ -17,9 +17,9 @@
 
22579
        <key>CFBundlePackageType</key>
 
22580
        <string>FMWK</string>
 
22581
        <key>CFBundleShortVersionString</key>
 
22582
-       <string>%VERSION%, (c) 2004-2011 Python Software Foundation.</string>
 
22583
+       <string>%VERSION%, (c) 2004-2012 Python Software Foundation.</string>
 
22584
        <key>CFBundleLongVersionString</key>
 
22585
-       <string>%VERSION%, (c) 2004-2011 Python Software Foundation.</string>
 
22586
+       <string>%VERSION%, (c) 2004-2012 Python Software Foundation.</string>
 
22587
        <key>CFBundleSignature</key>
 
22588
        <string>????</string>
 
22589
        <key>CFBundleVersion</key>
20280
22590
diff -r 8527427914a2 Makefile.pre.in
20281
22591
--- a/Makefile.pre.in
20282
22592
+++ b/Makefile.pre.in
20312
22622
diff -r 8527427914a2 Misc/ACKS
20313
22623
--- a/Misc/ACKS
20314
22624
+++ b/Misc/ACKS
20315
 
@@ -147,6 +147,7 @@
 
22625
@@ -120,6 +120,7 @@
 
22626
 Lee Busby
 
22627
 Ralph Butler
 
22628
 Jp Calderone
 
22629
+Arnaud Calmettes
 
22630
 Daniel Calvelo
 
22631
 Tony Campbell
 
22632
 Brett Cannon
 
22633
@@ -147,6 +148,7 @@
20316
22634
 Tom Christiansen
20317
22635
 Vadim Chugunov
20318
22636
 David Cinege
20320
22638
 Mike Clarkson
20321
22639
 Andrew Clegg
20322
22640
 Brad Clements
20323
 
@@ -162,6 +163,7 @@
 
22641
@@ -162,6 +164,7 @@
20324
22642
 Juan José Conti
20325
22643
 Matt Conway
20326
22644
 David M. Cooke
20328
22646
 Greg Copeland
20329
22647
 Aldo Cortesi
20330
22648
 David Costanzo
20331
 
@@ -193,6 +195,7 @@
 
22649
@@ -193,6 +196,7 @@
20332
22650
 Vincent Delft
20333
22651
 Arnaud Delobelle
20334
22652
 Erik Demaine
20336
22654
 Roger Dev
20337
22655
 Raghuram Devarakonda
20338
22656
 Catherine Devlin
20339
 
@@ -307,6 +310,7 @@
 
22657
@@ -307,6 +311,7 @@
20340
22658
 Eddy De Greef
20341
22659
 Duncan Grisby
20342
22660
 Fabian Groffen
20344
22662
 Dag Gruneau
20345
22663
 Filip Gruszczyński
20346
22664
 Michael Guravage
20347
 
@@ -399,6 +403,7 @@
 
22665
@@ -399,6 +404,7 @@
20348
22666
 Geert Jansen
20349
22667
 Jack Jansen
20350
22668
 Bill Janssen
20352
22670
 Drew Jenkins
20353
22671
 Flemming Kjær Jensen
20354
22672
 Jiba
20355
 
@@ -431,6 +436,7 @@
 
22673
@@ -431,6 +437,7 @@
20356
22674
 Randall Kern
20357
22675
 Magnus Kessler
20358
22676
 Lawrence Kesteloot
20360
22678
 Vivek Khera
20361
22679
 Akira Kitada
20362
22680
 Mads Kiilerich
20363
 
@@ -443,6 +449,8 @@
 
22681
@@ -443,6 +450,8 @@
20364
22682
 Bastian Kleineidam
20365
22683
 Bob Kline
20366
22684
 Matthias Klose
20369
22687
 Kim Knapp
20370
22688
 Lenny Kneler
20371
22689
 Pat Knight
20372
 
@@ -461,6 +469,7 @@
 
22690
@@ -455,12 +464,14 @@
 
22691
 Holger Krekel
 
22692
 Michael Kremer
 
22693
 Fabian Kreutz
 
22694
+Cédric Krier
 
22695
 Hannu Krosing
 
22696
 Andrej Krpic
 
22697
 Ivan Krstić
20373
22698
 Andrew Kuchling
20374
22699
 Ralf W. Grosse-Kunstleve
20375
22700
 Vladimir Kushnir
20377
22702
 Ross Lagerwall
20378
22703
 Cameron Laird
20379
22704
 Łukasz Langa
20380
 
@@ -502,6 +511,7 @@
 
22705
@@ -502,6 +513,7 @@
20381
22706
 Stephanie Lockwood
20382
22707
 Anne Lord
20383
22708
 Tom Loredo
20385
22710
 Jason Lowe
20386
22711
 Tony Lownds
20387
22712
 Ray Loyzaga
20388
 
@@ -546,6 +556,7 @@
 
22713
@@ -546,6 +558,7 @@
20389
22714
 Ezio Melotti
20390
22715
 Brian Merrell
20391
22716
 Luke Mewburn
20393
22718
 Mike Meyer
20394
22719
 Steven Miale
20395
22720
 Trent Mick
20396
 
@@ -608,6 +619,7 @@
 
22721
@@ -577,6 +590,7 @@
 
22722
 Takahiro Nakayama
 
22723
 Travers Naran
 
22724
 Charles-François Natali
 
22725
+Vilmos Nebehaj
 
22726
 Fredrik Nehr
 
22727
 Trent Nelson
 
22728
 Tony Nelson
 
22729
@@ -608,6 +622,7 @@
20397
22730
 Jason Orendorff
20398
22731
 Douglas Orr
20399
22732
 Michele Orrù
20401
22734
 Denis S. Otkidach
20402
22735
 Michael Otteneder
20403
22736
 R. M. Oudkerk
20404
 
@@ -669,6 +681,7 @@
 
22737
@@ -669,6 +684,7 @@
20405
22738
 Marc Recht
20406
22739
 John Redford
20407
22740
 Terry Reedy
20409
22742
 Steve Reeves
20410
22743
 Lennart Regebro
20411
22744
 Ofir Reichenberg
20412
 
@@ -683,7 +696,9 @@
 
22745
@@ -683,7 +699,9 @@
20413
22746
 Armin Rigo
20414
22747
 Nicholas Riley
20415
22748
 Jean-Claude Rimbault
20419
22752
 Anthony Roach
20420
22753
 Mark Roberts
20421
22754
 Jim Robinson
20422
 
@@ -711,6 +726,7 @@
 
22755
@@ -711,6 +729,7 @@
20423
22756
 Mark Russell
20424
22757
 Nick Russo
20425
22758
 Sébastien Sablé
20427
22760
 Hajime Saitou
20428
22761
 George Sakkis
20429
22762
 Rich Salz
20430
 
@@ -719,6 +735,7 @@
 
22763
@@ -719,6 +738,7 @@
20431
22764
 Mark Sapiro
20432
22765
 Ty Sarna
20433
22766
 Ben Sayer
20435
22768
 Michael Scharf
20436
22769
 Neil Schemenauer
20437
22770
 David Scherer
20438
 
@@ -766,6 +783,7 @@
 
22771
@@ -766,6 +786,7 @@
20439
22772
 Paul Sokolovsky
20440
22773
 Cody Somerville
20441
22774
 Clay Spence
20443
22776
 Per Spilling
20444
22777
 Joshua Spoerri
20445
22778
 Noah Spurrier
20446
 
@@ -803,9 +821,12 @@
 
22779
@@ -803,9 +824,12 @@
20447
22780
 Amy Taylor
20448
22781
 Anatoly Techtonik
20449
22782
 Mikhail Terekhov
20456
22789
 Eric Tiedemann
20457
22790
 Tracy Tims
20458
22791
 Oren Tirosh
20459
 
@@ -904,6 +925,7 @@
 
22792
@@ -904,6 +928,7 @@
20460
22793
 Danny Yoo
20461
22794
 George Yoshida
20462
22795
 Masazumi Yoshikawa
20467
22800
diff -r 8527427914a2 Misc/NEWS
20468
22801
--- a/Misc/NEWS
20469
22802
+++ b/Misc/NEWS
20470
 
@@ -1,6 +1,460 @@
 
22803
@@ -1,6 +1,490 @@
20471
22804
 Python News
20472
22805
 +++++++++++
20473
22806
 
20479
22812
+Core and Builtins
20480
22813
+-----------------
20481
22814
+
 
22815
+- Issue #11638: Unicode strings in 'name' and 'version' no longer cause
 
22816
+  UnicodeDecodeErrors.
 
22817
+
20482
22818
+- Fix the fix for issue #12149: it was incorrect, although it had the side
20483
22819
+  effect of appearing to resolve the issue.  Thanks to Mark Shannon for
20484
22820
+  noticing.
20556
22892
+Library
20557
22893
+-------
20558
22894
+
 
22895
+- Issue #13636: Weak ciphers are now disabled by default in the ssl module
 
22896
+  (except when SSLv2 is explicitly asked for).
 
22897
+
 
22898
+- Issue #12798: Updated the mimetypes documentation.
 
22899
+
 
22900
+- Issue #13639: Accept unicode filenames in tarfile.open(mode="w|gz").
 
22901
+
 
22902
+- Issue #1785: Fix inspect and pydoc with misbehaving descriptors.
 
22903
+
 
22904
+- Issue #7502: Fix equality comparison for DocTestCase instances.  Patch by
 
22905
+  Cédric Krier.
 
22906
+
 
22907
+- Issue #11870: threading: Properly reinitialize threads internal locks and
 
22908
+  condition variables to avoid deadlocks in child processes.
 
22909
+
 
22910
+- Issue #8035: urllib: Fix a bug where the client could remain stuck after a
 
22911
+  redirection or an error.
 
22912
+
20559
22913
+- Issue #4625: If IDLE cannot write to its recent file or breakpoint
20560
22914
+  files, display a message popup and continue rather than crash.
20561
22915
+  (original patch by Roger Serwy)
20820
23174
+Extension Modules
20821
23175
+-----------------
20822
23176
+
 
23177
+- Issue #9975: socket: Fix incorrect use of flowinfo and scope_id. Patch by
 
23178
+  Vilmos Nebehaj.
 
23179
+
20823
23180
+- Issue #13159: FileIO, BZ2File, and the built-in file class now use a
20824
23181
+  linear-time buffer growth strategy instead of a quadratic one.
20825
23182
+
20865
23222
+- Issue #10639: reindent.py no longer converts newlines and will raise
20866
23223
+  an error if attempting to convert a file with mixed newlines.
20867
23224
+
 
23225
+Tools/Demos
 
23226
+-----------
 
23227
+
 
23228
+- Issue #13628: python-gdb.py is now able to retrieve more frames in the Python
 
23229
+  traceback if Python is optimized.
 
23230
+
20868
23231
+Tests
20869
23232
+-----
20870
23233
+
20928
23291
 
20929
23292
 What's New in Python 2.7.2?
20930
23293
 ===========================
20931
 
@@ -106,6 +560,9 @@
 
23294
@@ -106,6 +590,9 @@
20932
23295
 Library
20933
23296
 -------
20934
23297
 
22485
24848
 #endif
22486
24849
 
22487
24850
 static PyObject*
22488
 
@@ -1784,7 +1780,7 @@
 
24851
@@ -1032,10 +1028,10 @@
 
24852
         PyObject *ret = NULL;
 
24853
         if (addrobj) {
 
24854
             a = (struct sockaddr_in6 *)addr;
 
24855
-            ret = Py_BuildValue("Oiii",
 
24856
+            ret = Py_BuildValue("OiII",
 
24857
                                 addrobj,
 
24858
                                 ntohs(a->sin6_port),
 
24859
-                                a->sin6_flowinfo,
 
24860
+                                ntohl(a->sin6_flowinfo),
 
24861
                                 a->sin6_scope_id);
 
24862
             Py_DECREF(addrobj);
 
24863
         }
 
24864
@@ -1286,7 +1282,8 @@
 
24865
     {
 
24866
         struct sockaddr_in6* addr;
 
24867
         char *host;
 
24868
-        int port, flowinfo, scope_id, result;
 
24869
+        int port, result;
 
24870
+        unsigned int flowinfo, scope_id;
 
24871
         flowinfo = scope_id = 0;
 
24872
         if (!PyTuple_Check(args)) {
 
24873
             PyErr_Format(
 
24874
@@ -1296,7 +1293,7 @@
 
24875
                 Py_TYPE(args)->tp_name);
 
24876
             return 0;
 
24877
         }
 
24878
-        if (!PyArg_ParseTuple(args, "eti|ii",
 
24879
+        if (!PyArg_ParseTuple(args, "eti|II",
 
24880
                               "idna", &host, &port, &flowinfo,
 
24881
                               &scope_id)) {
 
24882
             return 0;
 
24883
@@ -1313,9 +1310,15 @@
 
24884
                 "getsockaddrarg: port must be 0-65535.");
 
24885
             return 0;
 
24886
         }
 
24887
+        if (flowinfo < 0 || flowinfo > 0xfffff) {
 
24888
+            PyErr_SetString(
 
24889
+                PyExc_OverflowError,
 
24890
+                "getsockaddrarg: flowinfo must be 0-1048575.");
 
24891
+            return 0;
 
24892
+        }
 
24893
         addr->sin6_family = s->sock_family;
 
24894
         addr->sin6_port = htons((short)port);
 
24895
-        addr->sin6_flowinfo = flowinfo;
 
24896
+        addr->sin6_flowinfo = htonl(flowinfo);
 
24897
         addr->sin6_scope_id = scope_id;
 
24898
         *len_ret = sizeof *addr;
 
24899
         return 1;
 
24900
@@ -1784,7 +1787,7 @@
22489
24901
 PyDoc_STRVAR(gettimeout_doc,
22490
24902
 "gettimeout() -> timeout\n\
22491
24903
 \n\
22494
24906
 operations. A timeout of None indicates that timeouts on socket \n\
22495
24907
 operations are disabled.");
22496
24908
 
22497
 
@@ -4252,7 +4248,7 @@
 
24909
@@ -4160,7 +4163,8 @@
 
24910
     PyObject *sa = (PyObject *)NULL;
 
24911
     int flags;
 
24912
     char *hostp;
 
24913
-    int port, flowinfo, scope_id;
 
24914
+    int port;
 
24915
+    unsigned int flowinfo, scope_id;
 
24916
     char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
 
24917
     struct addrinfo hints, *res = NULL;
 
24918
     int error;
 
24919
@@ -4174,9 +4178,14 @@
 
24920
                         "getnameinfo() argument 1 must be a tuple");
 
24921
         return NULL;
 
24922
     }
 
24923
-    if (!PyArg_ParseTuple(sa, "si|ii",
 
24924
+    if (!PyArg_ParseTuple(sa, "si|II",
 
24925
                           &hostp, &port, &flowinfo, &scope_id))
 
24926
         return NULL;
 
24927
+    if (flowinfo < 0 || flowinfo > 0xfffff) {
 
24928
+        PyErr_SetString(PyExc_OverflowError,
 
24929
+                        "getsockaddrarg: flowinfo must be 0-1048575.");
 
24930
+        return NULL;
 
24931
+    }
 
24932
     PyOS_snprintf(pbuf, sizeof(pbuf), "%d", port);
 
24933
     memset(&hints, 0, sizeof(hints));
 
24934
     hints.ai_family = AF_UNSPEC;
 
24935
@@ -4210,7 +4219,7 @@
 
24936
         {
 
24937
         struct sockaddr_in6 *sin6;
 
24938
         sin6 = (struct sockaddr_in6 *)res->ai_addr;
 
24939
-        sin6->sin6_flowinfo = flowinfo;
 
24940
+        sin6->sin6_flowinfo = htonl(flowinfo);
 
24941
         sin6->sin6_scope_id = scope_id;
 
24942
         break;
 
24943
         }
 
24944
@@ -4252,7 +4261,7 @@
22498
24945
 PyDoc_STRVAR(getdefaulttimeout_doc,
22499
24946
 "getdefaulttimeout() -> timeout\n\
22500
24947
 \n\
22503
24950
 A value of None indicates that new socket objects have no timeout.\n\
22504
24951
 When the socket module is first imported, the default is None.");
22505
24952
 
22506
 
@@ -4282,7 +4278,7 @@
 
24953
@@ -4282,7 +4291,7 @@
22507
24954
 PyDoc_STRVAR(setdefaulttimeout_doc,
22508
24955
 "setdefaulttimeout(timeout)\n\
22509
24956
 \n\
22686
25133
         }
22687
25134
         return d;
22688
25135
     }
 
25136
@@ -2159,9 +2167,9 @@
 
25137
 "D.values() -> list of D's values");
 
25138
 
 
25139
 PyDoc_STRVAR(update__doc__,
 
25140
-"D.update(E, **F) -> None.  Update D from dict/iterable E and F.\n"
 
25141
-"If E has a .keys() method, does:     for k in E: D[k] = E[k]\n\
 
25142
-If E lacks .keys() method, does:     for (k, v) in E: D[k] = v\n\
 
25143
+"D.update([E, ]**F) -> None.  Update D from dict/iterable E and F.\n"
 
25144
+"If E present and has a .keys() method, does:     for k in E: D[k] = E[k]\n\
 
25145
+If E present and lacks .keys() method, does:     for (k, v) in E: D[k] = v\n\
 
25146
 In either case, this is followed by: for k in F: D[k] = F[k]");
 
25147
 
 
25148
 PyDoc_STRVAR(fromkeys__doc__,
22689
25149
diff -r 8527427914a2 Objects/fileobject.c
22690
25150
--- a/Objects/fileobject.c
22691
25151
+++ b/Objects/fileobject.c
23304
25764
         res = PyObject_IsSubclass(err, exc);
23305
25765
         Py_SetRecursionLimit(reclimit);
23306
25766
         /* This function must not fail, so print the error here */
 
25767
diff -r 8527427914a2 Python/getcopyright.c
 
25768
--- a/Python/getcopyright.c
 
25769
+++ b/Python/getcopyright.c
 
25770
@@ -4,7 +4,7 @@
 
25771
 
 
25772
 static char cprt[] = 
 
25773
 "\
 
25774
-Copyright (c) 2001-2011 Python Software Foundation.\n\
 
25775
+Copyright (c) 2001-2012 Python Software Foundation.\n\
 
25776
 All Rights Reserved.\n\
 
25777
 \n\
 
25778
 Copyright (c) 2000 BeOpen.com.\n\
23307
25779
diff -r 8527427914a2 Python/import.c
23308
25780
--- a/Python/import.c
23309
25781
+++ b/Python/import.c
23402
25874
     Py_INCREF(Py_None);
23403
25875
     return Py_None;
23404
25876
 }
 
25877
diff -r 8527427914a2 README
 
25878
--- a/README
 
25879
+++ b/README
 
25880
@@ -1,8 +1,8 @@
 
25881
 This is Python version 2.7.2
 
25882
 ============================
 
25883
 
 
25884
-Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 
25885
-Python Software Foundation.  All rights reserved.
 
25886
+Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
 
25887
+2012 Python Software Foundation.  All rights reserved.
 
25888
 
 
25889
 Copyright (c) 2000 BeOpen.com.
 
25890
 All rights reserved.
 
25891
diff -r 8527427914a2 Tools/gdb/libpython.py
 
25892
--- a/Tools/gdb/libpython.py
 
25893
+++ b/Tools/gdb/libpython.py
 
25894
@@ -47,7 +47,6 @@
 
25895
 _type_char_ptr = gdb.lookup_type('char').pointer() # char*
 
25896
 _type_unsigned_char_ptr = gdb.lookup_type('unsigned char').pointer() # unsigned char*
 
25897
 _type_void_ptr = gdb.lookup_type('void').pointer() # void*
 
25898
-_type_size_t = gdb.lookup_type('size_t')
 
25899
 
 
25900
 SIZEOF_VOID_P = _type_void_ptr.sizeof
 
25901
 
 
25902
@@ -410,11 +409,15 @@
 
25903
                                             self.address)
 
25904
 
 
25905
 def _PyObject_VAR_SIZE(typeobj, nitems):
 
25906
+    if _PyObject_VAR_SIZE._type_size_t is None:
 
25907
+        _PyObject_VAR_SIZE._type_size_t = gdb.lookup_type('size_t')
 
25908
+
 
25909
     return ( ( typeobj.field('tp_basicsize') +
 
25910
                nitems * typeobj.field('tp_itemsize') +
 
25911
                (SIZEOF_VOID_P - 1)
 
25912
              ) & ~(SIZEOF_VOID_P - 1)
 
25913
-           ).cast(_type_size_t)
 
25914
+           ).cast(_PyObject_VAR_SIZE._type_size_t)
 
25915
+_PyObject_VAR_SIZE._type_size_t = None
 
25916
 
 
25917
 class HeapTypeObjectPtr(PyObjectPtr):
 
25918
     _typename = 'PyObject'
 
25919
@@ -786,7 +789,7 @@
 
25920
 class PyFrameObjectPtr(PyObjectPtr):
 
25921
     _typename = 'PyFrameObject'
 
25922
 
 
25923
-    def __init__(self, gdbval, cast_to):
 
25924
+    def __init__(self, gdbval, cast_to=None):
 
25925
         PyObjectPtr.__init__(self, gdbval, cast_to)
 
25926
 
 
25927
         if not self.is_optimized_out():
 
25928
@@ -820,7 +823,7 @@
 
25929
         the global variables of this frame
 
25930
         '''
 
25931
         if self.is_optimized_out():
 
25932
-            return
 
25933
+            return ()
 
25934
 
 
25935
         pyop_globals = self.pyop_field('f_globals')
 
25936
         return pyop_globals.iteritems()
 
25937
@@ -831,7 +834,7 @@
 
25938
         the builtin variables
 
25939
         '''
 
25940
         if self.is_optimized_out():
 
25941
-            return
 
25942
+            return ()
 
25943
 
 
25944
         pyop_builtins = self.pyop_field('f_builtins')
 
25945
         return pyop_builtins.iteritems()
 
25946
@@ -1205,7 +1208,20 @@
 
25947
     def get_pyop(self):
 
25948
         try:
 
25949
             f = self._gdbframe.read_var('f')
 
25950
-            return PyFrameObjectPtr.from_pyobject_ptr(f)
 
25951
+            frame = PyFrameObjectPtr.from_pyobject_ptr(f)
 
25952
+            if not frame.is_optimized_out():
 
25953
+                return frame
 
25954
+            # gdb is unable to get the "f" argument of PyEval_EvalFrameEx()
 
25955
+            # because it was "optimized out". Try to get "f" from the frame
 
25956
+            # of the caller, PyEval_EvalCodeEx().
 
25957
+            orig_frame = frame
 
25958
+            caller = self._gdbframe.older()
 
25959
+            if caller:
 
25960
+                f = caller.read_var('f')
 
25961
+                frame = PyFrameObjectPtr.from_pyobject_ptr(f)
 
25962
+                if not frame.is_optimized_out():
 
25963
+                    return frame
 
25964
+            return orig_frame
 
25965
         except ValueError:
 
25966
             return None
 
25967
 
 
25968
@@ -1235,7 +1251,9 @@
 
25969
             pyop = self.get_pyop()
 
25970
             if pyop:
 
25971
                 sys.stdout.write('#%i %s\n' % (self.get_index(), pyop.get_truncated_repr(MAX_OUTPUT_LEN)))
 
25972
-                sys.stdout.write(pyop.current_line())
 
25973
+                if not pyop.is_optimized_out():
 
25974
+                    line = pyop.current_line()
 
25975
+                    sys.stdout.write('    %s\n' % line.strip())
 
25976
             else:
 
25977
                 sys.stdout.write('#%i (unable to read python frame information)\n' % self.get_index())
 
25978
         else:
 
25979
@@ -1281,7 +1299,7 @@
 
25980
             return
 
25981
 
 
25982
         pyop = frame.get_pyop()
 
25983
-        if not pyop:
 
25984
+        if not pyop or pyop.is_optimized_out():
 
25985
             print 'Unable to read information on python frame'
 
25986
             return
 
25987
 
23405
25988
diff -r 8527427914a2 Tools/iobench/iobench.py
23406
25989
--- a/Tools/iobench/iobench.py
23407
25990
+++ b/Tools/iobench/iobench.py