~milo/+junk/python-linaro

« 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-03-09 23:23:55 UTC
  • mfrom: (36.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20120309232355-syhmsoce7nubjxgl
Tags: 2.7.3~rc1-1ubuntu1
* Merge with Debian; remaining changes:
  - Build-depend on libdb5.1-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# DP: hg updates of the 2.7 release branch (until 2012-02-16).
2
 
 
3
 
# hg diff -r v2.7.2 | filterdiff --exclude=Lib/pstats.py --exclude=Lib/profile.py --exclude=.*ignore --exclude=.hg* --remove-timestamps
4
 
 
5
 
diff -r 8527427914a2 Demo/threads/sync.py
6
 
--- a/Demo/threads/sync.py
7
 
+++ b/Demo/threads/sync.py
8
 
@@ -265,7 +265,7 @@
9
 
 #      intervening.  If there are other threads waiting to write, they
10
 
 #      are allowed to proceed only if the current thread calls
11
 
 #      .read_out; threads waiting to read are only allowed to proceed
12
 
-#      if there are are no threads waiting to write.  (This is a
13
 
+#      if there are no threads waiting to write.  (This is a
14
 
 #      weakness of the interface!)
15
 
 
16
 
 import thread
17
 
diff -r 8527427914a2 Demo/tix/tixwidgets.py
18
 
--- a/Demo/tix/tixwidgets.py
19
 
+++ b/Demo/tix/tixwidgets.py
20
 
@@ -659,7 +659,7 @@
21
 
 I have implemented a new image type called "compound". It allows you
22
 
 to glue together a bunch of bitmaps, images and text strings together
23
 
 to form a bigger image. Then you can use this image with widgets that
24
 
-support the -image option. For example, you can display a text string string
25
 
+support the -image option. For example, you can display a text string
26
 
 together with a bitmap, at the same time, inside a TK button widget.
27
 
 """)
28
 
     list.pack(expand=1, fill=Tix.BOTH, padx=4, pady=6)
29
 
diff -r 8527427914a2 Demo/turtle/about_turtle.txt
30
 
--- a/Demo/turtle/about_turtle.txt
31
 
+++ b/Demo/turtle/about_turtle.txt
32
 
@@ -7,10 +7,10 @@
33
 
 kids. It was part of the original Logo programming language developed
34
 
 by Wally Feurzig and Seymour Papert in 1966.
35
 
 
36
 
-Imagine a robotic turtle starting at (0, 0) in the x-y plane. Give it
37
 
+Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an ``import turtle``, give it
38
 
 the command turtle.forward(15), and it moves (on-screen!) 15 pixels in
39
 
 the direction it is facing, drawing a line as it moves. Give it the
40
 
-command turtle.left(25), and it rotates in-place 25 degrees clockwise.
41
 
+command turtle.right(25), and it rotates in-place 25 degrees clockwise.
42
 
 
43
 
 By combining together these and similar commands, intricate shapes and
44
 
 pictures can easily be drawn.
45
 
diff -r 8527427914a2 Doc/ACKS.txt
46
 
--- a/Doc/ACKS.txt
47
 
+++ b/Doc/ACKS.txt
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 @@
57
 
    * Travis B. Hartwell
58
 
    * Tim Hatch
59
 
    * Janko Hauser
60
 
+   * Ben Hayden
61
 
    * Thomas Heller
62
 
    * Bernhard Herzog
63
 
    * Magnus L. Hetland
64
 
@@ -103,6 +105,7 @@
65
 
    * Robert Kern
66
 
    * Jim Kerr
67
 
    * Jan Kim
68
 
+   * Kamil Kisiel
69
 
    * Greg Kochanski
70
 
    * Guido Kollerie
71
 
    * Peter A. Koren
72
 
@@ -139,7 +142,8 @@
73
 
    * Ross Moore
74
 
    * Sjoerd Mullender
75
 
    * Dale Nagata
76
 
-   * Michal Nowikowski 
77
 
+   * Michal Nowikowski
78
 
+   * Steffen Daode Nurpmeso
79
 
    * Ng Pheng Siong
80
 
    * Koray Oner
81
 
    * Tomas Oppelstrup
82
 
@@ -180,6 +184,7 @@
83
 
    * Joakim Sernbrant
84
 
    * Justin Sheehy
85
 
    * Charlie Shepherd
86
 
+   * Yue Shuaijie
87
 
    * Michael Simcich
88
 
    * Ionel Simionescu
89
 
    * Michael Sloan
90
 
@@ -197,6 +202,7 @@
91
 
    * Kalle Svensson
92
 
    * Jim Tittsler
93
 
    * David Turner
94
 
+   * Sandro Tosi
95
 
    * Ville Vainio
96
 
    * Martijn Vries
97
 
    * Charles G. Waldman
98
 
@@ -214,6 +220,7 @@
99
 
    * Collin Winter
100
 
    * Blake Winton
101
 
    * Dan Wolfe
102
 
+   * Adam Woodbeck
103
 
    * Steven Work
104
 
    * Thomas Wouters
105
 
    * Ka-Ping Yee
106
 
diff -r 8527427914a2 Doc/Makefile
107
 
--- a/Doc/Makefile
108
 
+++ b/Doc/Makefile
109
 
@@ -40,7 +40,7 @@
110
 
 checkout:
111
 
        @if [ ! -d tools/sphinx ]; then \
112
 
          echo "Checking out Sphinx..."; \
113
 
-         svn checkout $(SVNROOT)/external/Sphinx-0.6.7/sphinx tools/sphinx; \
114
 
+         svn checkout $(SVNROOT)/external/Sphinx-1.0.7/sphinx tools/sphinx; \
115
 
        fi
116
 
        @if [ ! -d tools/docutils ]; then \
117
 
          echo "Checking out Docutils..."; \
118
 
diff -r 8527427914a2 Doc/README.txt
119
 
--- a/Doc/README.txt
120
 
+++ b/Doc/README.txt
121
 
@@ -127,7 +127,7 @@
122
 
 as long as you don't change or remove the copyright notice:
123
 
 
124
 
 ----------------------------------------------------------------------
125
 
-Copyright (c) 2000-2008 Python Software Foundation.
126
 
+Copyright (c) 2000-2012 Python Software Foundation.
127
 
 All rights reserved.
128
 
 
129
 
 Copyright (c) 2000 BeOpen.com.
130
 
diff -r 8527427914a2 Doc/bugs.rst
131
 
--- a/Doc/bugs.rst
132
 
+++ b/Doc/bugs.rst
133
 
@@ -57,12 +57,14 @@
134
 
 
135
 
 Each bug report will be assigned to a developer who will determine what needs to
136
 
 be done to correct the problem.  You will receive an update each time action is
137
 
-taken on the bug.  See http://www.python.org/dev/workflow/ for a detailed
138
 
-description of the issue workflow.
139
 
+taken on the bug.
140
 
 
141
 
 
142
 
 .. seealso::
143
 
 
144
 
+   `Python Developer's Guide <http://docs.python.org/devguide/>`_
145
 
+      Detailed description of the issue workflow and developers tools.
146
 
+
147
 
    `How to Report Bugs Effectively <http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>`_
148
 
       Article which goes into some detail about how to create a useful bug report.
149
 
       This describes what kind of information is useful and why it is useful.
150
 
diff -r 8527427914a2 Doc/c-api/abstract.rst
151
 
--- a/Doc/c-api/abstract.rst
152
 
+++ b/Doc/c-api/abstract.rst
153
 
@@ -13,7 +13,7 @@
154
 
 will raise a Python exception.
155
 
 
156
 
 It is not possible to use these functions on objects that are not properly
157
 
-initialized, such as a list object that has been created by :cfunc:`PyList_New`,
158
 
+initialized, such as a list object that has been created by :c:func:`PyList_New`,
159
 
 but whose items have not been set to some non-\ ``NULL`` value yet.
160
 
 
161
 
 .. toctree::
162
 
diff -r 8527427914a2 Doc/c-api/allocation.rst
163
 
--- a/Doc/c-api/allocation.rst
164
 
+++ b/Doc/c-api/allocation.rst
165
 
@@ -6,20 +6,20 @@
166
 
 ==============================
167
 
 
168
 
 
169
 
-.. cfunction:: PyObject* _PyObject_New(PyTypeObject *type)
170
 
+.. c:function:: PyObject* _PyObject_New(PyTypeObject *type)
171
 
 
172
 
 
173
 
-.. cfunction:: PyVarObject* _PyObject_NewVar(PyTypeObject *type, Py_ssize_t size)
174
 
+.. c:function:: PyVarObject* _PyObject_NewVar(PyTypeObject *type, Py_ssize_t size)
175
 
 
176
 
    .. versionchanged:: 2.5
177
 
-      This function used an :ctype:`int` type for *size*. This might require
178
 
+      This function used an :c:type:`int` type for *size*. This might require
179
 
       changes in your code for properly supporting 64-bit systems.
180
 
 
181
 
 
182
 
-.. cfunction:: void _PyObject_Del(PyObject *op)
183
 
+.. c:function:: void _PyObject_Del(PyObject *op)
184
 
 
185
 
 
186
 
-.. cfunction:: PyObject* PyObject_Init(PyObject *op, PyTypeObject *type)
187
 
+.. c:function:: PyObject* PyObject_Init(PyObject *op, PyTypeObject *type)
188
 
 
189
 
    Initialize a newly-allocated object *op* with its type and initial
190
 
    reference.  Returns the initialized object.  If *type* indicates that the
191
 
@@ -28,17 +28,17 @@
192
 
    affected.
193
 
 
194
 
 
195
 
-.. cfunction:: PyVarObject* PyObject_InitVar(PyVarObject *op, PyTypeObject *type, Py_ssize_t size)
196
 
+.. c:function:: PyVarObject* PyObject_InitVar(PyVarObject *op, PyTypeObject *type, Py_ssize_t size)
197
 
 
198
 
-   This does everything :cfunc:`PyObject_Init` does, and also initializes the
199
 
+   This does everything :c:func:`PyObject_Init` does, and also initializes the
200
 
    length information for a variable-size object.
201
 
 
202
 
    .. versionchanged:: 2.5
203
 
-      This function used an :ctype:`int` type for *size*. This might require
204
 
+      This function used an :c:type:`int` type for *size*. This might require
205
 
       changes in your code for properly supporting 64-bit systems.
206
 
 
207
 
 
208
 
-.. cfunction:: TYPE* PyObject_New(TYPE, PyTypeObject *type)
209
 
+.. c:function:: TYPE* PyObject_New(TYPE, PyTypeObject *type)
210
 
 
211
 
    Allocate a new Python object using the C structure type *TYPE* and the
212
 
    Python type object *type*.  Fields not defined by the Python object header
213
 
@@ -47,7 +47,7 @@
214
 
    the type object.
215
 
 
216
 
 
217
 
-.. cfunction:: TYPE* PyObject_NewVar(TYPE, PyTypeObject *type, Py_ssize_t size)
218
 
+.. c:function:: TYPE* PyObject_NewVar(TYPE, PyTypeObject *type, Py_ssize_t size)
219
 
 
220
 
    Allocate a new Python object using the C structure type *TYPE* and the
221
 
    Python type object *type*.  Fields not defined by the Python object header
222
 
@@ -59,20 +59,20 @@
223
 
    improving the memory management efficiency.
224
 
 
225
 
    .. versionchanged:: 2.5
226
 
-      This function used an :ctype:`int` type for *size*. This might require
227
 
+      This function used an :c:type:`int` type for *size*. This might require
228
 
       changes in your code for properly supporting 64-bit systems.
229
 
 
230
 
 
231
 
-.. cfunction:: void PyObject_Del(PyObject *op)
232
 
+.. c:function:: void PyObject_Del(PyObject *op)
233
 
 
234
 
-   Releases memory allocated to an object using :cfunc:`PyObject_New` or
235
 
-   :cfunc:`PyObject_NewVar`.  This is normally called from the
236
 
+   Releases memory allocated to an object using :c:func:`PyObject_New` or
237
 
+   :c:func:`PyObject_NewVar`.  This is normally called from the
238
 
    :attr:`tp_dealloc` handler specified in the object's type.  The fields of
239
 
    the object should not be accessed after this call as the memory is no
240
 
    longer a valid Python object.
241
 
 
242
 
 
243
 
-.. cfunction:: PyObject* Py_InitModule(char *name, PyMethodDef *methods)
244
 
+.. c:function:: PyObject* Py_InitModule(char *name, PyMethodDef *methods)
245
 
 
246
 
    Create a new module object based on a name and table of functions,
247
 
    returning the new module object.
248
 
@@ -82,7 +82,7 @@
249
 
       *methods* argument.
250
 
 
251
 
 
252
 
-.. cfunction:: PyObject* Py_InitModule3(char *name, PyMethodDef *methods, char *doc)
253
 
+.. c:function:: PyObject* Py_InitModule3(char *name, PyMethodDef *methods, char *doc)
254
 
 
255
 
    Create a new module object based on a name and table of functions,
256
 
    returning the new module object.  If *doc* is non-*NULL*, it will be used
257
 
@@ -93,7 +93,7 @@
258
 
       *methods* argument.
259
 
 
260
 
 
261
 
-.. cfunction:: PyObject* Py_InitModule4(char *name, PyMethodDef *methods, char *doc, PyObject *self, int apiver)
262
 
+.. c:function:: PyObject* Py_InitModule4(char *name, PyMethodDef *methods, char *doc, PyObject *self, int apiver)
263
 
 
264
 
    Create a new module object based on a name and table of functions,
265
 
    returning the new module object.  If *doc* is non-*NULL*, it will be used
266
 
@@ -107,7 +107,7 @@
267
 
    .. note::
268
 
 
269
 
       Most uses of this function should probably be using the
270
 
-      :cfunc:`Py_InitModule3` instead; only use this if you are sure you need
271
 
+      :c:func:`Py_InitModule3` instead; only use this if you are sure you need
272
 
       it.
273
 
 
274
 
    .. versionchanged:: 2.3
275
 
@@ -115,7 +115,7 @@
276
 
       *methods* argument.
277
 
 
278
 
 
279
 
-.. cvar:: PyObject _Py_NoneStruct
280
 
+.. c:var:: PyObject _Py_NoneStruct
281
 
 
282
 
    Object which is visible in Python as ``None``.  This should only be
283
 
    accessed using the ``Py_None`` macro, which evaluates to a pointer to this
284
 
diff -r 8527427914a2 Doc/c-api/arg.rst
285
 
--- a/Doc/c-api/arg.rst
286
 
+++ b/Doc/c-api/arg.rst
287
 
@@ -9,8 +9,8 @@
288
 
 methods.  Additional information and examples are available in
289
 
 :ref:`extending-index`.
290
 
 
291
 
-The first three of these functions described, :cfunc:`PyArg_ParseTuple`,
292
 
-:cfunc:`PyArg_ParseTupleAndKeywords`, and :cfunc:`PyArg_Parse`, all use
293
 
+The first three of these functions described, :c:func:`PyArg_ParseTuple`,
294
 
+:c:func:`PyArg_ParseTupleAndKeywords`, and :c:func:`PyArg_Parse`, all use
295
 
 *format strings* which are used to tell the function about the expected
296
 
 arguments.  The format strings use the same syntax for each of these
297
 
 functions.
298
 
@@ -24,6 +24,11 @@
299
 
 that matches the format unit; and the entry in [square] brackets is the type
300
 
 of the C variable(s) whose address should be passed.
301
 
 
302
 
+These formats allow to access an object as a contiguous chunk of memory.
303
 
+You don't have to provide raw storage for the returned unicode or bytes
304
 
+area.  Also, you won't have to release any memory yourself, except with the
305
 
+``es``, ``es#``, ``et`` and ``et#`` formats.
306
 
+
307
 
 ``s`` (string or Unicode) [const char \*]
308
 
    Convert a Python string or Unicode object to a C pointer to a character
309
 
    string.  You must not provide storage for the string itself; a pointer to
310
 
@@ -33,7 +38,7 @@
311
 
    raised. Unicode objects are converted to C strings using the default
312
 
    encoding.  If this conversion fails, a :exc:`UnicodeError` is raised.
313
 
 
314
 
-``s#`` (string, Unicode or any read buffer compatible object) [const char \*, int (or :ctype:`Py_ssize_t`, see below)]
315
 
+``s#`` (string, Unicode or any read buffer compatible object) [const char \*, int (or :c:type:`Py_ssize_t`, see below)]
316
 
    This variant on ``s`` stores into two C variables, the first one a pointer
317
 
    to a character string, the second one its length.  In this case the Python
318
 
    string may contain embedded null bytes.  Unicode objects pass back a
319
 
@@ -42,8 +47,8 @@
320
 
    a reference to the raw internal data representation.
321
 
 
322
 
    Starting with Python 2.5 the type of the length argument can be controlled
323
 
-   by defining the macro :cmacro:`PY_SSIZE_T_CLEAN` before including
324
 
-   :file:`Python.h`.  If the macro is defined, length is a :ctype:`Py_ssize_t`
325
 
+   by defining the macro :c:macro:`PY_SSIZE_T_CLEAN` before including
326
 
+   :file:`Python.h`.  If the macro is defined, length is a :c:type:`Py_ssize_t`
327
 
    rather than an int.
328
 
 
329
 
 ``s*`` (string, Unicode, or any buffer compatible object) [Py_buffer]
330
 
@@ -71,14 +76,14 @@
331
 
    Convert a Python Unicode object to a C pointer to a NUL-terminated buffer
332
 
    of 16-bit Unicode (UTF-16) data.  As with ``s``, there is no need to
333
 
    provide storage for the Unicode data buffer; a pointer to the existing
334
 
-   Unicode data is stored into the :ctype:`Py_UNICODE` pointer variable whose
335
 
+   Unicode data is stored into the :c:type:`Py_UNICODE` pointer variable whose
336
 
    address you pass.
337
 
 
338
 
 ``u#`` (Unicode) [Py_UNICODE \*, int]
339
 
    This variant on ``u`` stores into two C variables, the first one a pointer
340
 
    to a Unicode data buffer, the second one its length. Non-Unicode objects
341
 
    are handled by interpreting their read-buffer pointer as pointer to a
342
 
-   :ctype:`Py_UNICODE` array.
343
 
+   :c:type:`Py_UNICODE` array.
344
 
 
345
 
 ``es`` (string, Unicode or character buffer compatible object) [const char \*encoding, char \*\*buffer]
346
 
    This variant on ``s`` is used for encoding Unicode and objects convertible
347
 
@@ -86,18 +91,18 @@
348
 
    embedded NUL bytes.
349
 
 
350
 
    This format requires two arguments.  The first is only used as input, and
351
 
-   must be a :ctype:`const char\*` which points to the name of an encoding as
352
 
+   must be a :c:type:`const char\*` which points to the name of an encoding as
353
 
    a NUL-terminated string, or *NULL*, in which case the default encoding is
354
 
    used.  An exception is raised if the named encoding is not known to Python.
355
 
-   The second argument must be a :ctype:`char\*\*`; the value of the pointer
356
 
+   The second argument must be a :c:type:`char\*\*`; the value of the pointer
357
 
    it references will be set to a buffer with the contents of the argument
358
 
    text.  The text will be encoded in the encoding specified by the first
359
 
    argument.
360
 
 
361
 
-   :cfunc:`PyArg_ParseTuple` will allocate a buffer of the needed size, copy
362
 
+   :c:func:`PyArg_ParseTuple` will allocate a buffer of the needed size, copy
363
 
    the encoded data into this buffer and adjust *\*buffer* to reference the
364
 
    newly allocated storage.  The caller is responsible for calling
365
 
-   :cfunc:`PyMem_Free` to free the allocated buffer after use.
366
 
+   :c:func:`PyMem_Free` to free the allocated buffer after use.
367
 
 
368
 
 ``et`` (string, Unicode or character buffer compatible object) [const char \*encoding, char \*\*buffer]
369
 
    Same as ``es`` except that 8-bit string objects are passed through without
370
 
@@ -110,10 +115,10 @@
371
 
    allows input data which contains NUL characters.
372
 
 
373
 
    It requires three arguments.  The first is only used as input, and must be
374
 
-   a :ctype:`const char\*` which points to the name of an encoding as a
375
 
+   a :c:type:`const char\*` which points to the name of an encoding as a
376
 
    NUL-terminated string, or *NULL*, in which case the default encoding is
377
 
    used.  An exception is raised if the named encoding is not known to Python.
378
 
-   The second argument must be a :ctype:`char\*\*`; the value of the pointer
379
 
+   The second argument must be a :c:type:`char\*\*`; the value of the pointer
380
 
    it references will be set to a buffer with the contents of the argument
381
 
    text.  The text will be encoded in the encoding specified by the first
382
 
    argument.  The third argument must be a pointer to an integer; the
383
 
@@ -124,11 +129,11 @@
384
 
    If *\*buffer* points a *NULL* pointer, the function will allocate a buffer
385
 
    of the needed size, copy the encoded data into this buffer and set
386
 
    *\*buffer* to reference the newly allocated storage.  The caller is
387
 
-   responsible for calling :cfunc:`PyMem_Free` to free the allocated buffer
388
 
+   responsible for calling :c:func:`PyMem_Free` to free the allocated buffer
389
 
    after usage.
390
 
 
391
 
    If *\*buffer* points to a non-*NULL* pointer (an already allocated buffer),
392
 
-   :cfunc:`PyArg_ParseTuple` will use this location as the buffer and
393
 
+   :c:func:`PyArg_ParseTuple` will use this location as the buffer and
394
 
    interpret the initial value of *\*buffer_length* as the buffer size.  It
395
 
    will then copy the encoded data into the buffer and NUL-terminate it.  If
396
 
    the buffer is not large enough, a :exc:`ValueError` will be set.
397
 
@@ -143,71 +148,71 @@
398
 
 
399
 
 ``b`` (integer) [unsigned char]
400
 
    Convert a nonnegative Python integer to an unsigned tiny int, stored in a C
401
 
-   :ctype:`unsigned char`.
402
 
+   :c:type:`unsigned char`.
403
 
 
404
 
 ``B`` (integer) [unsigned char]
405
 
    Convert a Python integer to a tiny int without overflow checking, stored in
406
 
-   a C :ctype:`unsigned char`.
407
 
+   a C :c:type:`unsigned char`.
408
 
 
409
 
    .. versionadded:: 2.3
410
 
 
411
 
 ``h`` (integer) [short int]
412
 
-   Convert a Python integer to a C :ctype:`short int`.
413
 
+   Convert a Python integer to a C :c:type:`short int`.
414
 
 
415
 
 ``H`` (integer) [unsigned short int]
416
 
-   Convert a Python integer to a C :ctype:`unsigned short int`, without
417
 
+   Convert a Python integer to a C :c:type:`unsigned short int`, without
418
 
    overflow checking.
419
 
 
420
 
    .. versionadded:: 2.3
421
 
 
422
 
 ``i`` (integer) [int]
423
 
-   Convert a Python integer to a plain C :ctype:`int`.
424
 
+   Convert a Python integer to a plain C :c:type:`int`.
425
 
 
426
 
 ``I`` (integer) [unsigned int]
427
 
-   Convert a Python integer to a C :ctype:`unsigned int`, without overflow
428
 
+   Convert a Python integer to a C :c:type:`unsigned int`, without overflow
429
 
    checking.
430
 
 
431
 
    .. versionadded:: 2.3
432
 
 
433
 
 ``l`` (integer) [long int]
434
 
-   Convert a Python integer to a C :ctype:`long int`.
435
 
+   Convert a Python integer to a C :c:type:`long int`.
436
 
 
437
 
 ``k`` (integer) [unsigned long]
438
 
-   Convert a Python integer or long integer to a C :ctype:`unsigned long`
439
 
+   Convert a Python integer or long integer to a C :c:type:`unsigned long`
440
 
    without overflow checking.
441
 
 
442
 
    .. versionadded:: 2.3
443
 
 
444
 
 ``L`` (integer) [PY_LONG_LONG]
445
 
-   Convert a Python integer to a C :ctype:`long long`.  This format is only
446
 
-   available on platforms that support :ctype:`long long` (or :ctype:`_int64`
447
 
+   Convert a Python integer to a C :c:type:`long long`.  This format is only
448
 
+   available on platforms that support :c:type:`long long` (or :c:type:`_int64`
449
 
    on Windows).
450
 
 
451
 
 ``K`` (integer) [unsigned PY_LONG_LONG]
452
 
-   Convert a Python integer or long integer to a C :ctype:`unsigned long long`
453
 
+   Convert a Python integer or long integer to a C :c:type:`unsigned long long`
454
 
    without overflow checking.  This format is only available on platforms that
455
 
-   support :ctype:`unsigned long long` (or :ctype:`unsigned _int64` on
456
 
+   support :c:type:`unsigned long long` (or :c:type:`unsigned _int64` on
457
 
    Windows).
458
 
 
459
 
    .. versionadded:: 2.3
460
 
 
461
 
 ``n`` (integer) [Py_ssize_t]
462
 
-   Convert a Python integer or long integer to a C :ctype:`Py_ssize_t`.
463
 
+   Convert a Python integer or long integer to a C :c:type:`Py_ssize_t`.
464
 
 
465
 
    .. versionadded:: 2.5
466
 
 
467
 
 ``c`` (string of length 1) [char]
468
 
    Convert a Python character, represented as a string of length 1, to a C
469
 
-   :ctype:`char`.
470
 
+   :c:type:`char`.
471
 
 
472
 
 ``f`` (float) [float]
473
 
-   Convert a Python floating point number to a C :ctype:`float`.
474
 
+   Convert a Python floating point number to a C :c:type:`float`.
475
 
 
476
 
 ``d`` (float) [double]
477
 
-   Convert a Python floating point number to a C :ctype:`double`.
478
 
+   Convert a Python floating point number to a C :c:type:`double`.
479
 
 
480
 
 ``D`` (complex) [Py_complex]
481
 
-   Convert a Python complex number to a C :ctype:`Py_complex` structure.
482
 
+   Convert a Python complex number to a C :c:type:`Py_complex` structure.
483
 
 
484
 
 ``O`` (object) [PyObject \*]
485
 
    Store a Python object (without any conversion) in a C object pointer.  The
486
 
@@ -217,20 +222,20 @@
487
 
 ``O!`` (object) [*typeobject*, PyObject \*]
488
 
    Store a Python object in a C object pointer.  This is similar to ``O``, but
489
 
    takes two C arguments: the first is the address of a Python type object,
490
 
-   the second is the address of the C variable (of type :ctype:`PyObject\*`)
491
 
+   the second is the address of the C variable (of type :c:type:`PyObject\*`)
492
 
    into which the object pointer is stored.  If the Python object does not
493
 
    have the required type, :exc:`TypeError` is raised.
494
 
 
495
 
 ``O&`` (object) [*converter*, *anything*]
496
 
    Convert a Python object to a C variable through a *converter* function.
497
 
    This takes two arguments: the first is a function, the second is the
498
 
-   address of a C variable (of arbitrary type), converted to :ctype:`void \*`.
499
 
+   address of a C variable (of arbitrary type), converted to :c:type:`void \*`.
500
 
    The *converter* function in turn is called as follows::
501
 
 
502
 
       status = converter(object, address);
503
 
 
504
 
    where *object* is the Python object to be converted and *address* is the
505
 
-   :ctype:`void\*` argument that was passed to the :cfunc:`PyArg_Parse\*`
506
 
+   :c:type:`void\*` argument that was passed to the :c:func:`PyArg_Parse\*`
507
 
    function.  The returned *status* should be ``1`` for a successful
508
 
    conversion and ``0`` if the conversion has failed.  When the conversion
509
 
    fails, the *converter* function should raise an exception and leave the
510
 
@@ -239,17 +244,17 @@
511
 
 ``S`` (string) [PyStringObject \*]
512
 
    Like ``O`` but requires that the Python object is a string object.  Raises
513
 
    :exc:`TypeError` if the object is not a string object.  The C variable may
514
 
-   also be declared as :ctype:`PyObject\*`.
515
 
+   also be declared as :c:type:`PyObject\*`.
516
 
 
517
 
 ``U`` (Unicode string) [PyUnicodeObject \*]
518
 
    Like ``O`` but requires that the Python object is a Unicode object.  Raises
519
 
    :exc:`TypeError` if the object is not a Unicode object.  The C variable may
520
 
-   also be declared as :ctype:`PyObject\*`.
521
 
+   also be declared as :c:type:`PyObject\*`.
522
 
 
523
 
 ``t#`` (read-only character buffer) [char \*, int]
524
 
    Like ``s#``, but accepts any object which implements the read-only buffer
525
 
-   interface.  The :ctype:`char\*` variable is set to point to the first byte
526
 
-   of the buffer, and the :ctype:`int` is set to the length of the buffer.
527
 
+   interface.  The :c:type:`char\*` variable is set to point to the first byte
528
 
+   of the buffer, and the :c:type:`int` is set to the length of the buffer.
529
 
    Only single-segment buffer objects are accepted; :exc:`TypeError` is raised
530
 
    for all others.
531
 
 
532
 
@@ -261,8 +266,8 @@
533
 
 
534
 
 ``w#`` (read-write character buffer) [char \*, Py_ssize_t]
535
 
    Like ``s#``, but accepts any object which implements the read-write buffer
536
 
-   interface.  The :ctype:`char \*` variable is set to point to the first byte
537
 
-   of the buffer, and the :ctype:`Py_ssize_t` is set to the length of the
538
 
+   interface.  The :c:type:`char \*` variable is set to point to the first byte
539
 
+   of the buffer, and the :c:type:`Py_ssize_t` is set to the length of the
540
 
    buffer.  Only single-segment buffer objects are accepted; :exc:`TypeError`
541
 
    is raised for all others.
542
 
 
543
 
@@ -297,13 +302,13 @@
544
 
    Indicates that the remaining arguments in the Python argument list are
545
 
    optional.  The C variables corresponding to optional arguments should be
546
 
    initialized to their default value --- when an optional argument is not
547
 
-   specified, :cfunc:`PyArg_ParseTuple` does not touch the contents of the
548
 
+   specified, :c:func:`PyArg_ParseTuple` does not touch the contents of the
549
 
    corresponding C variable(s).
550
 
 
551
 
 ``:``
552
 
    The list of format units ends here; the string after the colon is used as
553
 
    the function name in error messages (the "associated value" of the
554
 
-   exception that :cfunc:`PyArg_ParseTuple` raises).
555
 
+   exception that :c:func:`PyArg_ParseTuple` raises).
556
 
 
557
 
 ``;``
558
 
    The list of format units ends here; the string after the semicolon is used
559
 
@@ -320,40 +325,40 @@
560
 
 should match what is specified for the corresponding format unit in that case.
561
 
 
562
 
 For the conversion to succeed, the *arg* object must match the format and the
563
 
-format must be exhausted.  On success, the :cfunc:`PyArg_Parse\*` functions
564
 
+format must be exhausted.  On success, the :c:func:`PyArg_Parse\*` functions
565
 
 return true, otherwise they return false and raise an appropriate exception.
566
 
-When the :cfunc:`PyArg_Parse\*` functions fail due to conversion failure in
567
 
+When the :c:func:`PyArg_Parse\*` functions fail due to conversion failure in
568
 
 one of the format units, the variables at the addresses corresponding to that
569
 
 and the following format units are left untouched.
570
 
 
571
 
 
572
 
-.. cfunction:: int PyArg_ParseTuple(PyObject *args, const char *format, ...)
573
 
+.. c:function:: int PyArg_ParseTuple(PyObject *args, const char *format, ...)
574
 
 
575
 
    Parse the parameters of a function that takes only positional parameters
576
 
    into local variables.  Returns true on success; on failure, it returns
577
 
    false and raises the appropriate exception.
578
 
 
579
 
 
580
 
-.. cfunction:: int PyArg_VaParse(PyObject *args, const char *format, va_list vargs)
581
 
+.. c:function:: int PyArg_VaParse(PyObject *args, const char *format, va_list vargs)
582
 
 
583
 
-   Identical to :cfunc:`PyArg_ParseTuple`, except that it accepts a va_list
584
 
+   Identical to :c:func:`PyArg_ParseTuple`, except that it accepts a va_list
585
 
    rather than a variable number of arguments.
586
 
 
587
 
 
588
 
-.. cfunction:: int PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], ...)
589
 
+.. c:function:: int PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], ...)
590
 
 
591
 
    Parse the parameters of a function that takes both positional and keyword
592
 
    parameters into local variables.  Returns true on success; on failure, it
593
 
    returns false and raises the appropriate exception.
594
 
 
595
 
 
596
 
-.. cfunction:: int PyArg_VaParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], va_list vargs)
597
 
+.. c:function:: int PyArg_VaParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], va_list vargs)
598
 
 
599
 
-   Identical to :cfunc:`PyArg_ParseTupleAndKeywords`, except that it accepts a
600
 
+   Identical to :c:func:`PyArg_ParseTupleAndKeywords`, except that it accepts a
601
 
    va_list rather than a variable number of arguments.
602
 
 
603
 
 
604
 
-.. cfunction:: int PyArg_Parse(PyObject *args, const char *format, ...)
605
 
+.. c:function:: int PyArg_Parse(PyObject *args, const char *format, ...)
606
 
 
607
 
    Function used to deconstruct the argument lists of "old-style" functions
608
 
    --- these are functions which use the :const:`METH_OLDARGS` parameter
609
 
@@ -364,7 +369,7 @@
610
 
    purpose.
611
 
 
612
 
 
613
 
-.. cfunction:: int PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, ...)
614
 
+.. c:function:: int PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, ...)
615
 
 
616
 
    A simpler form of parameter retrieval which does not use a format string to
617
 
    specify the types of the arguments.  Functions which use this method to
618
 
@@ -373,7 +378,7 @@
619
 
    should be passed as *args*; it must actually be a tuple.  The length of the
620
 
    tuple must be at least *min* and no more than *max*; *min* and *max* may be
621
 
    equal.  Additional arguments must be passed to the function, each of which
622
 
-   should be a pointer to a :ctype:`PyObject\*` variable; these will be filled
623
 
+   should be a pointer to a :c:type:`PyObject\*` variable; these will be filled
624
 
    in with the values from *args*; they will contain borrowed references.  The
625
 
    variables which correspond to optional parameters not given by *args* will
626
 
    not be filled in; these should be initialized by the caller. This function
627
 
@@ -396,26 +401,26 @@
628
 
           return result;
629
 
       }
630
 
 
631
 
-   The call to :cfunc:`PyArg_UnpackTuple` in this example is entirely
632
 
-   equivalent to this call to :cfunc:`PyArg_ParseTuple`::
633
 
+   The call to :c:func:`PyArg_UnpackTuple` in this example is entirely
634
 
+   equivalent to this call to :c:func:`PyArg_ParseTuple`::
635
 
 
636
 
       PyArg_ParseTuple(args, "O|O:ref", &object, &callback)
637
 
 
638
 
    .. versionadded:: 2.2
639
 
 
640
 
    .. versionchanged:: 2.5
641
 
-      This function used an :ctype:`int` type for *min* and *max*. This might
642
 
+      This function used an :c:type:`int` type for *min* and *max*. This might
643
 
       require changes in your code for properly supporting 64-bit systems.
644
 
 
645
 
 
646
 
-.. cfunction:: PyObject* Py_BuildValue(const char *format, ...)
647
 
+.. c:function:: PyObject* Py_BuildValue(const char *format, ...)
648
 
 
649
 
    Create a new value based on a format string similar to those accepted by
650
 
-   the :cfunc:`PyArg_Parse\*` family of functions and a sequence of values.
651
 
+   the :c:func:`PyArg_Parse\*` family of functions and a sequence of values.
652
 
    Returns the value or *NULL* in the case of an error; an exception will be
653
 
    raised if *NULL* is returned.
654
 
 
655
 
-   :cfunc:`Py_BuildValue` does not always build a tuple.  It builds a tuple
656
 
+   :c:func:`Py_BuildValue` does not always build a tuple.  It builds a tuple
657
 
    only if its format string contains two or more format units.  If the format
658
 
    string is empty, it returns ``None``; if it contains exactly one format
659
 
    unit, it returns whatever object is described by that format unit.  To
660
 
@@ -425,10 +430,10 @@
661
 
    When memory buffers are passed as parameters to supply data to build
662
 
    objects, as for the ``s`` and ``s#`` formats, the required data is copied.
663
 
    Buffers provided by the caller are never referenced by the objects created
664
 
-   by :cfunc:`Py_BuildValue`.  In other words, if your code invokes
665
 
-   :cfunc:`malloc` and passes the allocated memory to :cfunc:`Py_BuildValue`,
666
 
-   your code is responsible for calling :cfunc:`free` for that memory once
667
 
-   :cfunc:`Py_BuildValue` returns.
668
 
+   by :c:func:`Py_BuildValue`.  In other words, if your code invokes
669
 
+   :c:func:`malloc` and passes the allocated memory to :c:func:`Py_BuildValue`,
670
 
+   your code is responsible for calling :c:func:`free` for that memory once
671
 
+   :c:func:`Py_BuildValue` returns.
672
 
 
673
 
    In the following description, the quoted form is the format unit; the entry
674
 
    in (round) parentheses is the Python object type that the format unit will
675
 
@@ -464,62 +469,62 @@
676
 
       length is ignored and ``None`` is returned.
677
 
 
678
 
    ``i`` (integer) [int]
679
 
-      Convert a plain C :ctype:`int` to a Python integer object.
680
 
+      Convert a plain C :c:type:`int` to a Python integer object.
681
 
 
682
 
    ``b`` (integer) [char]
683
 
-      Convert a plain C :ctype:`char` to a Python integer object.
684
 
+      Convert a plain C :c:type:`char` to a Python integer object.
685
 
 
686
 
    ``h`` (integer) [short int]
687
 
-      Convert a plain C :ctype:`short int` to a Python integer object.
688
 
+      Convert a plain C :c:type:`short int` to a Python integer object.
689
 
 
690
 
    ``l`` (integer) [long int]
691
 
-      Convert a C :ctype:`long int` to a Python integer object.
692
 
+      Convert a C :c:type:`long int` to a Python integer object.
693
 
 
694
 
    ``B`` (integer) [unsigned char]
695
 
-      Convert a C :ctype:`unsigned char` to a Python integer object.
696
 
+      Convert a C :c:type:`unsigned char` to a Python integer object.
697
 
 
698
 
    ``H`` (integer) [unsigned short int]
699
 
-      Convert a C :ctype:`unsigned short int` to a Python integer object.
700
 
+      Convert a C :c:type:`unsigned short int` to a Python integer object.
701
 
 
702
 
    ``I`` (integer/long) [unsigned int]
703
 
-      Convert a C :ctype:`unsigned int` to a Python integer object or a Python
704
 
+      Convert a C :c:type:`unsigned int` to a Python integer object or a Python
705
 
       long integer object, if it is larger than ``sys.maxint``.
706
 
 
707
 
    ``k`` (integer/long) [unsigned long]
708
 
-      Convert a C :ctype:`unsigned long` to a Python integer object or a
709
 
+      Convert a C :c:type:`unsigned long` to a Python integer object or a
710
 
       Python long integer object, if it is larger than ``sys.maxint``.
711
 
 
712
 
    ``L`` (long) [PY_LONG_LONG]
713
 
-      Convert a C :ctype:`long long` to a Python long integer object. Only
714
 
-      available on platforms that support :ctype:`long long`.
715
 
+      Convert a C :c:type:`long long` to a Python long integer object. Only
716
 
+      available on platforms that support :c:type:`long long`.
717
 
 
718
 
    ``K`` (long) [unsigned PY_LONG_LONG]
719
 
-      Convert a C :ctype:`unsigned long long` to a Python long integer object.
720
 
-      Only available on platforms that support :ctype:`unsigned long long`.
721
 
+      Convert a C :c:type:`unsigned long long` to a Python long integer object.
722
 
+      Only available on platforms that support :c:type:`unsigned long long`.
723
 
 
724
 
    ``n`` (int) [Py_ssize_t]
725
 
-      Convert a C :ctype:`Py_ssize_t` to a Python integer or long integer.
726
 
+      Convert a C :c:type:`Py_ssize_t` to a Python integer or long integer.
727
 
 
728
 
       .. versionadded:: 2.5
729
 
 
730
 
    ``c`` (string of length 1) [char]
731
 
-      Convert a C :ctype:`int` representing a character to a Python string of
732
 
+      Convert a C :c:type:`int` representing a character to a Python string of
733
 
       length 1.
734
 
 
735
 
    ``d`` (float) [double]
736
 
-      Convert a C :ctype:`double` to a Python floating point number.
737
 
+      Convert a C :c:type:`double` to a Python floating point number.
738
 
 
739
 
    ``f`` (float) [float]
740
 
       Same as ``d``.
741
 
 
742
 
    ``D`` (complex) [Py_complex \*]
743
 
-      Convert a C :ctype:`Py_complex` structure to a Python complex number.
744
 
+      Convert a C :c:type:`Py_complex` structure to a Python complex number.
745
 
 
746
 
    ``O`` (object) [PyObject \*]
747
 
       Pass a Python object untouched (except for its reference count, which is
748
 
       incremented by one).  If the object passed in is a *NULL* pointer, it is
749
 
       assumed that this was caused because the call producing the argument
750
 
-      found an error and set an exception. Therefore, :cfunc:`Py_BuildValue`
751
 
+      found an error and set an exception. Therefore, :c:func:`Py_BuildValue`
752
 
       will return *NULL* but won't raise an exception.  If no exception has
753
 
       been raised yet, :exc:`SystemError` is set.
754
 
 
755
 
@@ -534,7 +539,7 @@
756
 
    ``O&`` (object) [*converter*, *anything*]
757
 
       Convert *anything* to a Python object through a *converter* function.
758
 
       The function is called with *anything* (which should be compatible with
759
 
-      :ctype:`void \*`) as its argument and should return a "new" Python
760
 
+      :c:type:`void \*`) as its argument and should return a "new" Python
761
 
       object, or *NULL* if an error occurred.
762
 
 
763
 
    ``(items)`` (tuple) [*matching-items*]
764
 
@@ -553,7 +558,7 @@
765
 
    If there is an error in the format string, the :exc:`SystemError` exception
766
 
    is set and *NULL* returned.
767
 
 
768
 
-.. cfunction:: PyObject* Py_VaBuildValue(const char *format, va_list vargs)
769
 
+.. c:function:: PyObject* Py_VaBuildValue(const char *format, va_list vargs)
770
 
 
771
 
-   Identical to :cfunc:`Py_BuildValue`, except that it accepts a va_list
772
 
+   Identical to :c:func:`Py_BuildValue`, except that it accepts a va_list
773
 
    rather than a variable number of arguments.
774
 
diff -r 8527427914a2 Doc/c-api/bool.rst
775
 
--- a/Doc/c-api/bool.rst
776
 
+++ b/Doc/c-api/bool.rst
777
 
@@ -11,26 +11,26 @@
778
 
 are available, however.
779
 
 
780
 
 
781
 
-.. cfunction:: int PyBool_Check(PyObject *o)
782
 
+.. c:function:: int PyBool_Check(PyObject *o)
783
 
 
784
 
-   Return true if *o* is of type :cdata:`PyBool_Type`.
785
 
+   Return true if *o* is of type :c:data:`PyBool_Type`.
786
 
 
787
 
    .. versionadded:: 2.3
788
 
 
789
 
 
790
 
-.. cvar:: PyObject* Py_False
791
 
+.. c:var:: PyObject* Py_False
792
 
 
793
 
    The Python ``False`` object.  This object has no methods.  It needs to be
794
 
    treated just like any other object with respect to reference counts.
795
 
 
796
 
 
797
 
-.. cvar:: PyObject* Py_True
798
 
+.. c:var:: PyObject* Py_True
799
 
 
800
 
    The Python ``True`` object.  This object has no methods.  It needs to be treated
801
 
    just like any other object with respect to reference counts.
802
 
 
803
 
 
804
 
-.. cmacro:: Py_RETURN_FALSE
805
 
+.. c:macro:: Py_RETURN_FALSE
806
 
 
807
 
    Return :const:`Py_False` from a function, properly incrementing its reference
808
 
    count.
809
 
@@ -38,7 +38,7 @@
810
 
    .. versionadded:: 2.4
811
 
 
812
 
 
813
 
-.. cmacro:: Py_RETURN_TRUE
814
 
+.. c:macro:: Py_RETURN_TRUE
815
 
 
816
 
    Return :const:`Py_True` from a function, properly incrementing its reference
817
 
    count.
818
 
@@ -46,7 +46,7 @@
819
 
    .. versionadded:: 2.4
820
 
 
821
 
 
822
 
-.. cfunction:: PyObject* PyBool_FromLong(long v)
823
 
+.. c:function:: PyObject* PyBool_FromLong(long v)
824
 
 
825
 
    Return a new reference to :const:`Py_True` or :const:`Py_False` depending on the
826
 
    truth value of *v*.
827
 
diff -r 8527427914a2 Doc/c-api/buffer.rst
828
 
--- a/Doc/c-api/buffer.rst
829
 
+++ b/Doc/c-api/buffer.rst
830
 
@@ -27,7 +27,7 @@
831
 
 An example user of the buffer interface is the file object's :meth:`write`
832
 
 method. Any object that can export a series of bytes through the buffer
833
 
 interface can be written to a file. There are a number of format codes to
834
 
-:cfunc:`PyArg_ParseTuple` that operate against an object's buffer interface,
835
 
+:c:func:`PyArg_ParseTuple` that operate against an object's buffer interface,
836
 
 returning data from the target object.
837
 
 
838
 
 Starting from version 1.6, Python has been providing Python-level buffer
839
 
@@ -47,49 +47,49 @@
840
 
 ==============================
841
 
 
842
 
 
843
 
-.. ctype:: Py_buffer
844
 
+.. c:type:: Py_buffer
845
 
 
846
 
-   .. cmember:: void *buf
847
 
+   .. c:member:: void *buf
848
 
 
849
 
       A pointer to the start of the memory for the object.
850
 
 
851
 
-   .. cmember:: Py_ssize_t len
852
 
+   .. c:member:: Py_ssize_t len
853
 
       :noindex:
854
 
 
855
 
       The total length of the memory in bytes.
856
 
 
857
 
-   .. cmember:: int readonly
858
 
+   .. c:member:: int readonly
859
 
 
860
 
       An indicator of whether the buffer is read only.
861
 
 
862
 
-   .. cmember:: const char *format
863
 
+   .. c:member:: const char *format
864
 
       :noindex:
865
 
 
866
 
       A *NULL* terminated string in :mod:`struct` module style syntax giving
867
 
       the contents of the elements available through the buffer.  If this is
868
 
       *NULL*, ``"B"`` (unsigned bytes) is assumed.
869
 
 
870
 
-   .. cmember:: int ndim
871
 
+   .. c:member:: int ndim
872
 
 
873
 
       The number of dimensions the memory represents as a multi-dimensional
874
 
-      array.  If it is 0, :cdata:`strides` and :cdata:`suboffsets` must be
875
 
+      array.  If it is 0, :c:data:`strides` and :c:data:`suboffsets` must be
876
 
       *NULL*.
877
 
 
878
 
-   .. cmember:: Py_ssize_t *shape
879
 
+   .. c:member:: Py_ssize_t *shape
880
 
 
881
 
-      An array of :ctype:`Py_ssize_t`\s the length of :cdata:`ndim` giving the
882
 
+      An array of :c:type:`Py_ssize_t`\s the length of :c:data:`ndim` giving the
883
 
       shape of the memory as a multi-dimensional array.  Note that
884
 
       ``((*shape)[0] * ... * (*shape)[ndims-1])*itemsize`` should be equal to
885
 
-      :cdata:`len`.
886
 
+      :c:data:`len`.
887
 
 
888
 
-   .. cmember:: Py_ssize_t *strides
889
 
+   .. c:member:: Py_ssize_t *strides
890
 
 
891
 
-      An array of :ctype:`Py_ssize_t`\s the length of :cdata:`ndim` giving the
892
 
+      An array of :c:type:`Py_ssize_t`\s the length of :c:data:`ndim` giving the
893
 
       number of bytes to skip to get to a new element in each dimension.
894
 
 
895
 
-   .. cmember:: Py_ssize_t *suboffsets
896
 
+   .. c:member:: Py_ssize_t *suboffsets
897
 
 
898
 
-      An array of :ctype:`Py_ssize_t`\s the length of :cdata:`ndim`.  If these
899
 
+      An array of :c:type:`Py_ssize_t`\s the length of :c:data:`ndim`.  If these
900
 
       suboffset numbers are greater than or equal to 0, then the value stored
901
 
       along the indicated dimension is a pointer and the suboffset value
902
 
       dictates how many bytes to add to the pointer after de-referencing. A
903
 
@@ -114,16 +114,16 @@
904
 
            }
905
 
 
906
 
 
907
 
-   .. cmember:: Py_ssize_t itemsize
908
 
+   .. c:member:: Py_ssize_t itemsize
909
 
 
910
 
       This is a storage for the itemsize (in bytes) of each element of the
911
 
       shared memory. It is technically un-necessary as it can be obtained
912
 
-      using :cfunc:`PyBuffer_SizeFromFormat`, however an exporter may know
913
 
+      using :c:func:`PyBuffer_SizeFromFormat`, however an exporter may know
914
 
       this information without parsing the format string and it is necessary
915
 
       to know the itemsize for proper interpretation of striding. Therefore,
916
 
       storing it is more convenient and faster.
917
 
 
918
 
-   .. cmember:: void *internal
919
 
+   .. c:member:: void *internal
920
 
 
921
 
       This is for use internally by the exporting object. For example, this
922
 
       might be re-cast as an integer by the exporter and used to store flags
923
 
@@ -136,14 +136,14 @@
924
 
 ========================
925
 
 
926
 
 
927
 
-.. cfunction:: int PyObject_CheckBuffer(PyObject *obj)
928
 
+.. c:function:: int PyObject_CheckBuffer(PyObject *obj)
929
 
 
930
 
    Return 1 if *obj* supports the buffer interface otherwise 0.
931
 
 
932
 
 
933
 
-.. cfunction:: int PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags)
934
 
+.. c:function:: int PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags)
935
 
 
936
 
-      Export *obj* into a :ctype:`Py_buffer`, *view*.  These arguments must
937
 
+      Export *obj* into a :c:type:`Py_buffer`, *view*.  These arguments must
938
 
       never be *NULL*.  The *flags* argument is a bit field indicating what
939
 
       kind of buffer the caller is prepared to deal with and therefore what
940
 
       kind of buffer the exporter is allowed to return.  The buffer interface
941
 
@@ -156,131 +156,131 @@
942
 
       just not possible. These errors should be a :exc:`BufferError` unless
943
 
       there is another error that is actually causing the problem. The
944
 
       exporter can use flags information to simplify how much of the
945
 
-      :cdata:`Py_buffer` structure is filled in with non-default values and/or
946
 
+      :c:data:`Py_buffer` structure is filled in with non-default values and/or
947
 
       raise an error if the object can't support a simpler view of its memory.
948
 
 
949
 
       0 is returned on success and -1 on error.
950
 
 
951
 
       The following table gives possible values to the *flags* arguments.
952
 
 
953
 
-      +------------------------------+---------------------------------------------------+
954
 
-      | Flag                         | Description                                       |
955
 
-      +==============================+===================================================+
956
 
-      | :cmacro:`PyBUF_SIMPLE`       | This is the default flag state.  The returned     |
957
 
-      |                              | buffer may or may not have writable memory.  The  |
958
 
-      |                              | format of the data will be assumed to be unsigned |
959
 
-      |                              | bytes.  This is a "stand-alone" flag constant. It |
960
 
-      |                              | never needs to be '|'d to the others. The exporter|
961
 
-      |                              | will raise an error if it cannot provide such a   |
962
 
-      |                              | contiguous buffer of bytes.                       |
963
 
-      |                              |                                                   |
964
 
-      +------------------------------+---------------------------------------------------+
965
 
-      | :cmacro:`PyBUF_WRITABLE`     | The returned buffer must be writable.  If it is   |
966
 
-      |                              | not writable, then raise an error.                |
967
 
-      +------------------------------+---------------------------------------------------+
968
 
-      | :cmacro:`PyBUF_STRIDES`      | This implies :cmacro:`PyBUF_ND`. The returned     |
969
 
-      |                              | buffer must provide strides information (i.e. the |
970
 
-      |                              | strides cannot be NULL). This would be used when  |
971
 
-      |                              | the consumer can handle strided, discontiguous    |
972
 
-      |                              | arrays.  Handling strides automatically assumes   |
973
 
-      |                              | you can handle shape.  The exporter can raise an  |
974
 
-      |                              | error if a strided representation of the data is  |
975
 
-      |                              | not possible (i.e. without the suboffsets).       |
976
 
-      |                              |                                                   |
977
 
-      +------------------------------+---------------------------------------------------+
978
 
-      | :cmacro:`PyBUF_ND`           | The returned buffer must provide shape            |
979
 
-      |                              | information. The memory will be assumed C-style   |
980
 
-      |                              | contiguous (last dimension varies the             |
981
 
-      |                              | fastest). The exporter may raise an error if it   |
982
 
-      |                              | cannot provide this kind of contiguous buffer. If |
983
 
-      |                              | this is not given then shape will be *NULL*.      |
984
 
-      |                              |                                                   |
985
 
-      |                              |                                                   |
986
 
-      |                              |                                                   |
987
 
-      +------------------------------+---------------------------------------------------+
988
 
-      |:cmacro:`PyBUF_C_CONTIGUOUS`  | These flags indicate that the contiguity returned |
989
 
-      |:cmacro:`PyBUF_F_CONTIGUOUS`  | buffer must be respectively, C-contiguous (last   |
990
 
-      |:cmacro:`PyBUF_ANY_CONTIGUOUS`| dimension varies the fastest), Fortran contiguous |
991
 
-      |                              | (first dimension varies the fastest) or either    |
992
 
-      |                              | one.  All of these flags imply                    |
993
 
-      |                              | :cmacro:`PyBUF_STRIDES` and guarantee that the    |
994
 
-      |                              | strides buffer info structure will be filled in   |
995
 
-      |                              | correctly.                                        |
996
 
-      |                              |                                                   |
997
 
-      +------------------------------+---------------------------------------------------+
998
 
-      | :cmacro:`PyBUF_INDIRECT`     | This flag indicates the returned buffer must have |
999
 
-      |                              | suboffsets information (which can be NULL if no   |
1000
 
-      |                              | suboffsets are needed).  This can be used when    |
1001
 
-      |                              | the consumer can handle indirect array            |
1002
 
-      |                              | referencing implied by these suboffsets. This     |
1003
 
-      |                              | implies :cmacro:`PyBUF_STRIDES`.                  |
1004
 
-      |                              |                                                   |
1005
 
-      |                              |                                                   |
1006
 
-      |                              |                                                   |
1007
 
-      +------------------------------+---------------------------------------------------+
1008
 
-      | :cmacro:`PyBUF_FORMAT`       | The returned buffer must have true format         |
1009
 
-      |                              | information if this flag is provided. This would  |
1010
 
-      |                              | be used when the consumer is going to be checking |
1011
 
-      |                              | for what 'kind' of data is actually stored. An    |
1012
 
-      |                              | exporter should always be able to provide this    |
1013
 
-      |                              | information if requested. If format is not        |
1014
 
-      |                              | explicitly requested then the format must be      |
1015
 
-      |                              | returned as *NULL* (which means ``'B'``, or       |
1016
 
-      |                              | unsigned bytes)                                   |
1017
 
-      +------------------------------+---------------------------------------------------+
1018
 
-      | :cmacro:`PyBUF_STRIDED`      | This is equivalent to ``(PyBUF_STRIDES |          |
1019
 
-      |                              | PyBUF_WRITABLE)``.                                |
1020
 
-      +------------------------------+---------------------------------------------------+
1021
 
-      | :cmacro:`PyBUF_STRIDED_RO`   | This is equivalent to ``(PyBUF_STRIDES)``.        |
1022
 
-      |                              |                                                   |
1023
 
-      +------------------------------+---------------------------------------------------+
1024
 
-      | :cmacro:`PyBUF_RECORDS`      | This is equivalent to ``(PyBUF_STRIDES |          |
1025
 
-      |                              | PyBUF_FORMAT | PyBUF_WRITABLE)``.                 |
1026
 
-      +------------------------------+---------------------------------------------------+
1027
 
-      | :cmacro:`PyBUF_RECORDS_RO`   | This is equivalent to ``(PyBUF_STRIDES |          |
1028
 
-      |                              | PyBUF_FORMAT)``.                                  |
1029
 
-      +------------------------------+---------------------------------------------------+
1030
 
-      | :cmacro:`PyBUF_FULL`         | This is equivalent to ``(PyBUF_INDIRECT |         |
1031
 
-      |                              | PyBUF_FORMAT | PyBUF_WRITABLE)``.                 |
1032
 
-      +------------------------------+---------------------------------------------------+
1033
 
-      | :cmacro:`PyBUF_FULL_RO`      | This is equivalent to ``(PyBUF_INDIRECT |         |
1034
 
-      |                              | PyBUF_FORMAT)``.                                  |
1035
 
-      +------------------------------+---------------------------------------------------+
1036
 
-      | :cmacro:`PyBUF_CONTIG`       | This is equivalent to ``(PyBUF_ND |               |
1037
 
-      |                              | PyBUF_WRITABLE)``.                                |
1038
 
-      +------------------------------+---------------------------------------------------+
1039
 
-      | :cmacro:`PyBUF_CONTIG_RO`    | This is equivalent to ``(PyBUF_ND)``.             |
1040
 
-      |                              |                                                   |
1041
 
-      +------------------------------+---------------------------------------------------+
1042
 
+      +-------------------------------+---------------------------------------------------+
1043
 
+      | Flag                          | Description                                       |
1044
 
+      +===============================+===================================================+
1045
 
+      | :c:macro:`PyBUF_SIMPLE`       | This is the default flag state.  The returned     |
1046
 
+      |                               | buffer may or may not have writable memory.  The  |
1047
 
+      |                               | format of the data will be assumed to be unsigned |
1048
 
+      |                               | bytes.  This is a "stand-alone" flag constant. It |
1049
 
+      |                               | never needs to be '|'d to the others. The exporter|
1050
 
+      |                               | will raise an error if it cannot provide such a   |
1051
 
+      |                               | contiguous buffer of bytes.                       |
1052
 
+      |                               |                                                   |
1053
 
+      +-------------------------------+---------------------------------------------------+
1054
 
+      | :c:macro:`PyBUF_WRITABLE`     | The returned buffer must be writable.  If it is   |
1055
 
+      |                               | not writable, then raise an error.                |
1056
 
+      +-------------------------------+---------------------------------------------------+
1057
 
+      | :c:macro:`PyBUF_STRIDES`      | This implies :c:macro:`PyBUF_ND`. The returned    |
1058
 
+      |                               | buffer must provide strides information (i.e. the |
1059
 
+      |                               | strides cannot be NULL). This would be used when  |
1060
 
+      |                               | the consumer can handle strided, discontiguous    |
1061
 
+      |                               | arrays.  Handling strides automatically assumes   |
1062
 
+      |                               | you can handle shape.  The exporter can raise an  |
1063
 
+      |                               | error if a strided representation of the data is  |
1064
 
+      |                               | not possible (i.e. without the suboffsets).       |
1065
 
+      |                               |                                                   |
1066
 
+      +-------------------------------+---------------------------------------------------+
1067
 
+      | :c:macro:`PyBUF_ND`           | The returned buffer must provide shape            |
1068
 
+      |                               | information. The memory will be assumed C-style   |
1069
 
+      |                               | contiguous (last dimension varies the             |
1070
 
+      |                               | fastest). The exporter may raise an error if it   |
1071
 
+      |                               | cannot provide this kind of contiguous buffer. If |
1072
 
+      |                               | this is not given then shape will be *NULL*.      |
1073
 
+      |                               |                                                   |
1074
 
+      |                               |                                                   |
1075
 
+      |                               |                                                   |
1076
 
+      +-------------------------------+---------------------------------------------------+
1077
 
+      |:c:macro:`PyBUF_C_CONTIGUOUS`  | These flags indicate that the contiguity returned |
1078
 
+      |:c:macro:`PyBUF_F_CONTIGUOUS`  | buffer must be respectively, C-contiguous (last   |
1079
 
+      |:c:macro:`PyBUF_ANY_CONTIGUOUS`| dimension varies the fastest), Fortran contiguous |
1080
 
+      |                               | (first dimension varies the fastest) or either    |
1081
 
+      |                               | one.  All of these flags imply                    |
1082
 
+      |                               | :c:macro:`PyBUF_STRIDES` and guarantee that the   |
1083
 
+      |                               | strides buffer info structure will be filled in   |
1084
 
+      |                               | correctly.                                        |
1085
 
+      |                               |                                                   |
1086
 
+      +-------------------------------+---------------------------------------------------+
1087
 
+      | :c:macro:`PyBUF_INDIRECT`     | This flag indicates the returned buffer must have |
1088
 
+      |                               | suboffsets information (which can be NULL if no   |
1089
 
+      |                               | suboffsets are needed).  This can be used when    |
1090
 
+      |                               | the consumer can handle indirect array            |
1091
 
+      |                               | referencing implied by these suboffsets. This     |
1092
 
+      |                               | implies :c:macro:`PyBUF_STRIDES`.                 |
1093
 
+      |                               |                                                   |
1094
 
+      |                               |                                                   |
1095
 
+      |                               |                                                   |
1096
 
+      +-------------------------------+---------------------------------------------------+
1097
 
+      | :c:macro:`PyBUF_FORMAT`       | The returned buffer must have true format         |
1098
 
+      |                               | information if this flag is provided. This would  |
1099
 
+      |                               | be used when the consumer is going to be checking |
1100
 
+      |                               | for what 'kind' of data is actually stored. An    |
1101
 
+      |                               | exporter should always be able to provide this    |
1102
 
+      |                               | information if requested. If format is not        |
1103
 
+      |                               | explicitly requested then the format must be      |
1104
 
+      |                               | returned as *NULL* (which means ``'B'``, or       |
1105
 
+      |                               | unsigned bytes)                                   |
1106
 
+      +-------------------------------+---------------------------------------------------+
1107
 
+      | :c:macro:`PyBUF_STRIDED`      | This is equivalent to ``(PyBUF_STRIDES |          |
1108
 
+      |                               | PyBUF_WRITABLE)``.                                |
1109
 
+      +-------------------------------+---------------------------------------------------+
1110
 
+      | :c:macro:`PyBUF_STRIDED_RO`   | This is equivalent to ``(PyBUF_STRIDES)``.        |
1111
 
+      |                               |                                                   |
1112
 
+      +-------------------------------+---------------------------------------------------+
1113
 
+      | :c:macro:`PyBUF_RECORDS`      | This is equivalent to ``(PyBUF_STRIDES |          |
1114
 
+      |                               | PyBUF_FORMAT | PyBUF_WRITABLE)``.                 |
1115
 
+      +-------------------------------+---------------------------------------------------+
1116
 
+      | :c:macro:`PyBUF_RECORDS_RO`   | This is equivalent to ``(PyBUF_STRIDES |          |
1117
 
+      |                               | PyBUF_FORMAT)``.                                  |
1118
 
+      +-------------------------------+---------------------------------------------------+
1119
 
+      | :c:macro:`PyBUF_FULL`         | This is equivalent to ``(PyBUF_INDIRECT |         |
1120
 
+      |                               | PyBUF_FORMAT | PyBUF_WRITABLE)``.                 |
1121
 
+      +-------------------------------+---------------------------------------------------+
1122
 
+      | :c:macro:`PyBUF_FULL_RO`      | This is equivalent to ``(PyBUF_INDIRECT |         |
1123
 
+      |                               | PyBUF_FORMAT)``.                                  |
1124
 
+      +-------------------------------+---------------------------------------------------+
1125
 
+      | :c:macro:`PyBUF_CONTIG`       | This is equivalent to ``(PyBUF_ND |               |
1126
 
+      |                               | PyBUF_WRITABLE)``.                                |
1127
 
+      +-------------------------------+---------------------------------------------------+
1128
 
+      | :c:macro:`PyBUF_CONTIG_RO`    | This is equivalent to ``(PyBUF_ND)``.             |
1129
 
+      |                               |                                                   |
1130
 
+      +-------------------------------+---------------------------------------------------+
1131
 
 
1132
 
 
1133
 
-.. cfunction:: void PyBuffer_Release(Py_buffer *view)
1134
 
+.. c:function:: void PyBuffer_Release(Py_buffer *view)
1135
 
 
1136
 
    Release the buffer *view*.  This should be called when the buffer
1137
 
    is no longer being used as it may free memory from it.
1138
 
 
1139
 
 
1140
 
-.. cfunction:: Py_ssize_t PyBuffer_SizeFromFormat(const char *)
1141
 
+.. c:function:: Py_ssize_t PyBuffer_SizeFromFormat(const char *)
1142
 
 
1143
 
-   Return the implied :cdata:`~Py_buffer.itemsize` from the struct-stype
1144
 
-   :cdata:`~Py_buffer.format`.
1145
 
+   Return the implied :c:data:`~Py_buffer.itemsize` from the struct-stype
1146
 
+   :c:data:`~Py_buffer.format`.
1147
 
 
1148
 
 
1149
 
-.. cfunction:: int PyBuffer_IsContiguous(Py_buffer *view, char fortran)
1150
 
+.. c:function:: int PyBuffer_IsContiguous(Py_buffer *view, char fortran)
1151
 
 
1152
 
    Return 1 if the memory defined by the *view* is C-style (*fortran* is
1153
 
    ``'C'``) or Fortran-style (*fortran* is ``'F'``) contiguous or either one
1154
 
    (*fortran* is ``'A'``).  Return 0 otherwise.
1155
 
 
1156
 
 
1157
 
-.. cfunction:: void PyBuffer_FillContiguousStrides(int ndim, Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t itemsize, char fortran)
1158
 
+.. c:function:: void PyBuffer_FillContiguousStrides(int ndim, Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t itemsize, char fortran)
1159
 
 
1160
 
    Fill the *strides* array with byte-strides of a contiguous (C-style if
1161
 
    *fortran* is ``'C'`` or Fortran-style if *fortran* is ``'F'``) array of the
1162
 
    given shape with the given number of bytes per element.
1163
 
 
1164
 
 
1165
 
-.. cfunction:: int PyBuffer_FillInfo(Py_buffer *view, PyObject *obj, void *buf, Py_ssize_t len, int readonly, int infoflags)
1166
 
+.. c:function:: int PyBuffer_FillInfo(Py_buffer *view, PyObject *obj, void *buf, Py_ssize_t len, int readonly, int infoflags)
1167
 
 
1168
 
    Fill in a buffer-info structure, *view*, correctly for an exporter that can
1169
 
    only share a contiguous chunk of memory of "unsigned bytes" of the given
1170
 
@@ -295,13 +295,13 @@
1171
 
 A :class:`memoryview` object exposes the new C level buffer interface as a
1172
 
 Python object which can then be passed around like any other object.
1173
 
 
1174
 
-.. cfunction:: PyObject *PyMemoryView_FromObject(PyObject *obj)
1175
 
+.. c:function:: PyObject *PyMemoryView_FromObject(PyObject *obj)
1176
 
 
1177
 
    Create a memoryview object from an object that defines the new buffer
1178
 
    interface.
1179
 
 
1180
 
 
1181
 
-.. cfunction:: PyObject *PyMemoryView_FromBuffer(Py_buffer *view)
1182
 
+.. c:function:: PyObject *PyMemoryView_FromBuffer(Py_buffer *view)
1183
 
 
1184
 
    Create a memoryview object wrapping the given buffer-info structure *view*.
1185
 
    The memoryview object then owns the buffer, which means you shouldn't
1186
 
@@ -309,7 +309,7 @@
1187
 
    memoryview object.
1188
 
 
1189
 
 
1190
 
-.. cfunction:: PyObject *PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char order)
1191
 
+.. c:function:: PyObject *PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char order)
1192
 
 
1193
 
    Create a memoryview object to a contiguous chunk of memory (in either
1194
 
    'C' or 'F'ortran *order*) from an object that defines the buffer
1195
 
@@ -318,13 +318,13 @@
1196
 
    new bytes object.
1197
 
 
1198
 
 
1199
 
-.. cfunction:: int PyMemoryView_Check(PyObject *obj)
1200
 
+.. c:function:: int PyMemoryView_Check(PyObject *obj)
1201
 
 
1202
 
    Return true if the object *obj* is a memoryview object.  It is not
1203
 
    currently allowed to create subclasses of :class:`memoryview`.
1204
 
 
1205
 
 
1206
 
-.. cfunction:: Py_buffer *PyMemoryView_GET_BUFFER(PyObject *obj)
1207
 
+.. c:function:: Py_buffer *PyMemoryView_GET_BUFFER(PyObject *obj)
1208
 
 
1209
 
    Return a pointer to the buffer-info structure wrapped by the given
1210
 
    object.  The object **must** be a memoryview instance; this macro doesn't
1211
 
@@ -337,7 +337,7 @@
1212
 
 .. index:: single: PyBufferProcs
1213
 
 
1214
 
 More information on the old buffer interface is provided in the section
1215
 
-:ref:`buffer-structs`, under the description for :ctype:`PyBufferProcs`.
1216
 
+:ref:`buffer-structs`, under the description for :c:type:`PyBufferProcs`.
1217
 
 
1218
 
 A "buffer object" is defined in the :file:`bufferobject.h` header (included by
1219
 
 :file:`Python.h`). These objects look very similar to string objects at the
1220
 
@@ -356,36 +356,36 @@
1221
 
 native, in-memory format.
1222
 
 
1223
 
 
1224
 
-.. ctype:: PyBufferObject
1225
 
+.. c:type:: PyBufferObject
1226
 
 
1227
 
-   This subtype of :ctype:`PyObject` represents a buffer object.
1228
 
+   This subtype of :c:type:`PyObject` represents a buffer object.
1229
 
 
1230
 
 
1231
 
-.. cvar:: PyTypeObject PyBuffer_Type
1232
 
+.. c:var:: PyTypeObject PyBuffer_Type
1233
 
 
1234
 
    .. index:: single: BufferType (in module types)
1235
 
 
1236
 
-   The instance of :ctype:`PyTypeObject` which represents the Python buffer type;
1237
 
+   The instance of :c:type:`PyTypeObject` which represents the Python buffer type;
1238
 
    it is the same object as ``buffer`` and  ``types.BufferType`` in the Python
1239
 
    layer. .
1240
 
 
1241
 
 
1242
 
-.. cvar:: int Py_END_OF_BUFFER
1243
 
+.. c:var:: int Py_END_OF_BUFFER
1244
 
 
1245
 
    This constant may be passed as the *size* parameter to
1246
 
-   :cfunc:`PyBuffer_FromObject` or :cfunc:`PyBuffer_FromReadWriteObject`.  It
1247
 
-   indicates that the new :ctype:`PyBufferObject` should refer to *base*
1248
 
+   :c:func:`PyBuffer_FromObject` or :c:func:`PyBuffer_FromReadWriteObject`.  It
1249
 
+   indicates that the new :c:type:`PyBufferObject` should refer to *base*
1250
 
    object from the specified *offset* to the end of its exported buffer.
1251
 
    Using this enables the caller to avoid querying the *base* object for its
1252
 
    length.
1253
 
 
1254
 
 
1255
 
-.. cfunction:: int PyBuffer_Check(PyObject *p)
1256
 
+.. c:function:: int PyBuffer_Check(PyObject *p)
1257
 
 
1258
 
-   Return true if the argument has type :cdata:`PyBuffer_Type`.
1259
 
+   Return true if the argument has type :c:data:`PyBuffer_Type`.
1260
 
 
1261
 
 
1262
 
-.. cfunction:: PyObject* PyBuffer_FromObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size)
1263
 
+.. c:function:: PyObject* PyBuffer_FromObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size)
1264
 
 
1265
 
    Return a new read-only buffer object.  This raises :exc:`TypeError` if
1266
 
    *base* doesn't support the read-only buffer protocol or doesn't provide
1267
 
@@ -397,24 +397,24 @@
1268
 
    length of the *base* object's exported buffer data.
1269
 
 
1270
 
    .. versionchanged:: 2.5
1271
 
-      This function used an :ctype:`int` type for *offset* and *size*. This
1272
 
+      This function used an :c:type:`int` type for *offset* and *size*. This
1273
 
       might require changes in your code for properly supporting 64-bit
1274
 
       systems.
1275
 
 
1276
 
 
1277
 
-.. cfunction:: PyObject* PyBuffer_FromReadWriteObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size)
1278
 
+.. c:function:: PyObject* PyBuffer_FromReadWriteObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size)
1279
 
 
1280
 
    Return a new writable buffer object.  Parameters and exceptions are similar
1281
 
-   to those for :cfunc:`PyBuffer_FromObject`.  If the *base* object does not
1282
 
+   to those for :c:func:`PyBuffer_FromObject`.  If the *base* object does not
1283
 
    export the writeable buffer protocol, then :exc:`TypeError` is raised.
1284
 
 
1285
 
    .. versionchanged:: 2.5
1286
 
-      This function used an :ctype:`int` type for *offset* and *size*. This
1287
 
+      This function used an :c:type:`int` type for *offset* and *size*. This
1288
 
       might require changes in your code for properly supporting 64-bit
1289
 
       systems.
1290
 
 
1291
 
 
1292
 
-.. cfunction:: PyObject* PyBuffer_FromMemory(void *ptr, Py_ssize_t size)
1293
 
+.. c:function:: PyObject* PyBuffer_FromMemory(void *ptr, Py_ssize_t size)
1294
 
 
1295
 
    Return a new read-only buffer object that reads from a specified location
1296
 
    in memory, with a specified size.  The caller is responsible for ensuring
1297
 
@@ -424,27 +424,27 @@
1298
 
    *size* parameter; :exc:`ValueError` will be raised in that case.
1299
 
 
1300
 
    .. versionchanged:: 2.5
1301
 
-      This function used an :ctype:`int` type for *size*. This might require
1302
 
+      This function used an :c:type:`int` type for *size*. This might require
1303
 
       changes in your code for properly supporting 64-bit systems.
1304
 
 
1305
 
 
1306
 
-.. cfunction:: PyObject* PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size)
1307
 
+.. c:function:: PyObject* PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size)
1308
 
 
1309
 
-   Similar to :cfunc:`PyBuffer_FromMemory`, but the returned buffer is
1310
 
+   Similar to :c:func:`PyBuffer_FromMemory`, but the returned buffer is
1311
 
    writable.
1312
 
 
1313
 
    .. versionchanged:: 2.5
1314
 
-      This function used an :ctype:`int` type for *size*. This might require
1315
 
+      This function used an :c:type:`int` type for *size*. This might require
1316
 
       changes in your code for properly supporting 64-bit systems.
1317
 
 
1318
 
 
1319
 
-.. cfunction:: PyObject* PyBuffer_New(Py_ssize_t size)
1320
 
+.. c:function:: PyObject* PyBuffer_New(Py_ssize_t size)
1321
 
 
1322
 
    Return a new writable buffer object that maintains its own memory buffer of
1323
 
    *size* bytes.  :exc:`ValueError` is returned if *size* is not zero or
1324
 
    positive.  Note that the memory buffer (as returned by
1325
 
-   :cfunc:`PyObject_AsWriteBuffer`) is not specifically aligned.
1326
 
+   :c:func:`PyObject_AsWriteBuffer`) is not specifically aligned.
1327
 
 
1328
 
    .. versionchanged:: 2.5
1329
 
-      This function used an :ctype:`int` type for *size*. This might require
1330
 
+      This function used an :c:type:`int` type for *size*. This might require
1331
 
       changes in your code for properly supporting 64-bit systems.
1332
 
diff -r 8527427914a2 Doc/c-api/bytearray.rst
1333
 
--- a/Doc/c-api/bytearray.rst
1334
 
+++ b/Doc/c-api/bytearray.rst
1335
 
@@ -10,26 +10,26 @@
1336
 
 .. versionadded:: 2.6
1337
 
 
1338
 
 
1339
 
-.. ctype:: PyByteArrayObject
1340
 
+.. c:type:: PyByteArrayObject
1341
 
 
1342
 
-   This subtype of :ctype:`PyObject` represents a Python bytearray object.
1343
 
+   This subtype of :c:type:`PyObject` represents a Python bytearray object.
1344
 
 
1345
 
 
1346
 
-.. cvar:: PyTypeObject PyByteArray_Type
1347
 
+.. c:var:: PyTypeObject PyByteArray_Type
1348
 
 
1349
 
-   This instance of :ctype:`PyTypeObject` represents the Python bytearray type;
1350
 
+   This instance of :c:type:`PyTypeObject` represents the Python bytearray type;
1351
 
    it is the same object as ``bytearray`` in the Python layer.
1352
 
 
1353
 
 Type check macros
1354
 
 ^^^^^^^^^^^^^^^^^
1355
 
 
1356
 
-.. cfunction:: int PyByteArray_Check(PyObject *o)
1357
 
+.. c:function:: int PyByteArray_Check(PyObject *o)
1358
 
 
1359
 
    Return true if the object *o* is a bytearray object or an instance of a
1360
 
    subtype of the bytearray type.
1361
 
 
1362
 
 
1363
 
-.. cfunction:: int PyByteArray_CheckExact(PyObject *o)
1364
 
+.. c:function:: int PyByteArray_CheckExact(PyObject *o)
1365
 
 
1366
 
    Return true if the object *o* is a bytearray object, but not an instance of a
1367
 
    subtype of the bytearray type.
1368
 
@@ -38,7 +38,7 @@
1369
 
 Direct API functions
1370
 
 ^^^^^^^^^^^^^^^^^^^^
1371
 
 
1372
 
-.. cfunction:: PyObject* PyByteArray_FromObject(PyObject *o)
1373
 
+.. c:function:: PyObject* PyByteArray_FromObject(PyObject *o)
1374
 
 
1375
 
    Return a new bytearray object from any object, *o*, that implements the
1376
 
    buffer protocol.
1377
 
@@ -46,29 +46,29 @@
1378
 
    .. XXX expand about the buffer protocol, at least somewhere
1379
 
 
1380
 
 
1381
 
-.. cfunction:: PyObject* PyByteArray_FromStringAndSize(const char *string, Py_ssize_t len)
1382
 
+.. c:function:: PyObject* PyByteArray_FromStringAndSize(const char *string, Py_ssize_t len)
1383
 
 
1384
 
    Create a new bytearray object from *string* and its length, *len*.  On
1385
 
    failure, *NULL* is returned.
1386
 
 
1387
 
 
1388
 
-.. cfunction:: PyObject* PyByteArray_Concat(PyObject *a, PyObject *b)
1389
 
+.. c:function:: PyObject* PyByteArray_Concat(PyObject *a, PyObject *b)
1390
 
 
1391
 
    Concat bytearrays *a* and *b* and return a new bytearray with the result.
1392
 
 
1393
 
 
1394
 
-.. cfunction:: Py_ssize_t PyByteArray_Size(PyObject *bytearray)
1395
 
+.. c:function:: Py_ssize_t PyByteArray_Size(PyObject *bytearray)
1396
 
 
1397
 
    Return the size of *bytearray* after checking for a *NULL* pointer.
1398
 
 
1399
 
 
1400
 
-.. cfunction:: char* PyByteArray_AsString(PyObject *bytearray)
1401
 
+.. c:function:: char* PyByteArray_AsString(PyObject *bytearray)
1402
 
 
1403
 
    Return the contents of *bytearray* as a char array after checking for a
1404
 
    *NULL* pointer.
1405
 
 
1406
 
 
1407
 
-.. cfunction:: int PyByteArray_Resize(PyObject *bytearray, Py_ssize_t len)
1408
 
+.. c:function:: int PyByteArray_Resize(PyObject *bytearray, Py_ssize_t len)
1409
 
 
1410
 
    Resize the internal buffer of *bytearray* to *len*.
1411
 
 
1412
 
@@ -77,11 +77,11 @@
1413
 
 
1414
 
 These macros trade safety for speed and they don't check pointers.
1415
 
 
1416
 
-.. cfunction:: char* PyByteArray_AS_STRING(PyObject *bytearray)
1417
 
+.. c:function:: char* PyByteArray_AS_STRING(PyObject *bytearray)
1418
 
 
1419
 
-   Macro version of :cfunc:`PyByteArray_AsString`.
1420
 
+   Macro version of :c:func:`PyByteArray_AsString`.
1421
 
 
1422
 
 
1423
 
-.. cfunction:: Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray)
1424
 
+.. c:function:: Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray)
1425
 
 
1426
 
-   Macro version of :cfunc:`PyByteArray_Size`.
1427
 
+   Macro version of :c:func:`PyByteArray_Size`.
1428
 
diff -r 8527427914a2 Doc/c-api/capsule.rst
1429
 
--- a/Doc/c-api/capsule.rst
1430
 
+++ b/Doc/c-api/capsule.rst
1431
 
@@ -10,33 +10,33 @@
1432
 
 Refer to :ref:`using-capsules` for more information on using these objects.
1433
 
 
1434
 
 
1435
 
-.. ctype:: PyCapsule
1436
 
+.. c:type:: PyCapsule
1437
 
 
1438
 
-   This subtype of :ctype:`PyObject` represents an opaque value, useful for C
1439
 
-   extension modules who need to pass an opaque value (as a :ctype:`void\*`
1440
 
+   This subtype of :c:type:`PyObject` represents an opaque value, useful for C
1441
 
+   extension modules who need to pass an opaque value (as a :c:type:`void\*`
1442
 
    pointer) through Python code to other C code.  It is often used to make a C
1443
 
    function pointer defined in one module available to other modules, so the
1444
 
    regular import mechanism can be used to access C APIs defined in dynamically
1445
 
    loaded modules.
1446
 
 
1447
 
-.. ctype:: PyCapsule_Destructor
1448
 
+.. c:type:: PyCapsule_Destructor
1449
 
 
1450
 
    The type of a destructor callback for a capsule.  Defined as::
1451
 
 
1452
 
       typedef void (*PyCapsule_Destructor)(PyObject *);
1453
 
 
1454
 
-   See :cfunc:`PyCapsule_New` for the semantics of PyCapsule_Destructor
1455
 
+   See :c:func:`PyCapsule_New` for the semantics of PyCapsule_Destructor
1456
 
    callbacks.
1457
 
 
1458
 
 
1459
 
-.. cfunction:: int PyCapsule_CheckExact(PyObject *p)
1460
 
+.. c:function:: int PyCapsule_CheckExact(PyObject *p)
1461
 
 
1462
 
-   Return true if its argument is a :ctype:`PyCapsule`.
1463
 
+   Return true if its argument is a :c:type:`PyCapsule`.
1464
 
 
1465
 
 
1466
 
-.. cfunction:: PyObject* PyCapsule_New(void *pointer, const char *name, PyCapsule_Destructor destructor)
1467
 
+.. c:function:: PyObject* PyCapsule_New(void *pointer, const char *name, PyCapsule_Destructor destructor)
1468
 
 
1469
 
-   Create a :ctype:`PyCapsule` encapsulating the *pointer*.  The *pointer*
1470
 
+   Create a :c:type:`PyCapsule` encapsulating the *pointer*.  The *pointer*
1471
 
    argument may not be *NULL*.
1472
 
 
1473
 
    On failure, set an exception and return *NULL*.
1474
 
@@ -50,91 +50,91 @@
1475
 
 
1476
 
    If this capsule will be stored as an attribute of a module, the *name* should
1477
 
    be specified as ``modulename.attributename``.  This will enable other modules
1478
 
-   to import the capsule using :cfunc:`PyCapsule_Import`.
1479
 
+   to import the capsule using :c:func:`PyCapsule_Import`.
1480
 
 
1481
 
 
1482
 
-.. cfunction:: void* PyCapsule_GetPointer(PyObject *capsule, const char *name)
1483
 
+.. c:function:: void* PyCapsule_GetPointer(PyObject *capsule, const char *name)
1484
 
 
1485
 
    Retrieve the *pointer* stored in the capsule.  On failure, set an exception
1486
 
    and return *NULL*.
1487
 
 
1488
 
    The *name* parameter must compare exactly to the name stored in the capsule.
1489
 
    If the name stored in the capsule is *NULL*, the *name* passed in must also
1490
 
-   be *NULL*.  Python uses the C function :cfunc:`strcmp` to compare capsule
1491
 
+   be *NULL*.  Python uses the C function :c:func:`strcmp` to compare capsule
1492
 
    names.
1493
 
 
1494
 
 
1495
 
-.. cfunction:: PyCapsule_Destructor PyCapsule_GetDestructor(PyObject *capsule)
1496
 
+.. c:function:: PyCapsule_Destructor PyCapsule_GetDestructor(PyObject *capsule)
1497
 
 
1498
 
    Return the current destructor stored in the capsule.  On failure, set an
1499
 
    exception and return *NULL*.
1500
 
 
1501
 
    It is legal for a capsule to have a *NULL* destructor.  This makes a *NULL*
1502
 
-   return code somewhat ambiguous; use :cfunc:`PyCapsule_IsValid` or
1503
 
-   :cfunc:`PyErr_Occurred` to disambiguate.
1504
 
+   return code somewhat ambiguous; use :c:func:`PyCapsule_IsValid` or
1505
 
+   :c:func:`PyErr_Occurred` to disambiguate.
1506
 
 
1507
 
 
1508
 
-.. cfunction:: void* PyCapsule_GetContext(PyObject *capsule)
1509
 
+.. c:function:: void* PyCapsule_GetContext(PyObject *capsule)
1510
 
 
1511
 
    Return the current context stored in the capsule.  On failure, set an
1512
 
    exception and return *NULL*.
1513
 
 
1514
 
    It is legal for a capsule to have a *NULL* context.  This makes a *NULL*
1515
 
-   return code somewhat ambiguous; use :cfunc:`PyCapsule_IsValid` or
1516
 
-   :cfunc:`PyErr_Occurred` to disambiguate.
1517
 
+   return code somewhat ambiguous; use :c:func:`PyCapsule_IsValid` or
1518
 
+   :c:func:`PyErr_Occurred` to disambiguate.
1519
 
 
1520
 
 
1521
 
-.. cfunction:: const char* PyCapsule_GetName(PyObject *capsule)
1522
 
+.. c:function:: const char* PyCapsule_GetName(PyObject *capsule)
1523
 
 
1524
 
    Return the current name stored in the capsule.  On failure, set an exception
1525
 
    and return *NULL*.
1526
 
 
1527
 
    It is legal for a capsule to have a *NULL* name.  This makes a *NULL* return
1528
 
-   code somewhat ambiguous; use :cfunc:`PyCapsule_IsValid` or
1529
 
-   :cfunc:`PyErr_Occurred` to disambiguate.
1530
 
+   code somewhat ambiguous; use :c:func:`PyCapsule_IsValid` or
1531
 
+   :c:func:`PyErr_Occurred` to disambiguate.
1532
 
 
1533
 
 
1534
 
-.. cfunction:: void* PyCapsule_Import(const char *name, int no_block)
1535
 
+.. c:function:: void* PyCapsule_Import(const char *name, int no_block)
1536
 
 
1537
 
    Import a pointer to a C object from a capsule attribute in a module.  The
1538
 
    *name* parameter should specify the full name to the attribute, as in
1539
 
    ``module.attribute``.  The *name* stored in the capsule must match this
1540
 
    string exactly.  If *no_block* is true, import the module without blocking
1541
 
-   (using :cfunc:`PyImport_ImportModuleNoBlock`).  If *no_block* is false,
1542
 
-   import the module conventionally (using :cfunc:`PyImport_ImportModule`).
1543
 
+   (using :c:func:`PyImport_ImportModuleNoBlock`).  If *no_block* is false,
1544
 
+   import the module conventionally (using :c:func:`PyImport_ImportModule`).
1545
 
 
1546
 
    Return the capsule's internal *pointer* on success.  On failure, set an
1547
 
-   exception and return *NULL*.  However, if :cfunc:`PyCapsule_Import` failed to
1548
 
+   exception and return *NULL*.  However, if :c:func:`PyCapsule_Import` failed to
1549
 
    import the module, and *no_block* was true, no exception is set.
1550
 
 
1551
 
-.. cfunction:: int PyCapsule_IsValid(PyObject *capsule, const char *name)
1552
 
+.. c:function:: int PyCapsule_IsValid(PyObject *capsule, const char *name)
1553
 
 
1554
 
    Determines whether or not *capsule* is a valid capsule.  A valid capsule is
1555
 
-   non-*NULL*, passes :cfunc:`PyCapsule_CheckExact`, has a non-*NULL* pointer
1556
 
+   non-*NULL*, passes :c:func:`PyCapsule_CheckExact`, has a non-*NULL* pointer
1557
 
    stored in it, and its internal name matches the *name* parameter.  (See
1558
 
-   :cfunc:`PyCapsule_GetPointer` for information on how capsule names are
1559
 
+   :c:func:`PyCapsule_GetPointer` for information on how capsule names are
1560
 
    compared.)
1561
 
 
1562
 
-   In other words, if :cfunc:`PyCapsule_IsValid` returns a true value, calls to
1563
 
-   any of the accessors (any function starting with :cfunc:`PyCapsule_Get`) are
1564
 
+   In other words, if :c:func:`PyCapsule_IsValid` returns a true value, calls to
1565
 
+   any of the accessors (any function starting with :c:func:`PyCapsule_Get`) are
1566
 
    guaranteed to succeed.
1567
 
 
1568
 
    Return a nonzero value if the object is valid and matches the name passed in.
1569
 
    Return 0 otherwise.  This function will not fail.
1570
 
 
1571
 
-.. cfunction:: int PyCapsule_SetContext(PyObject *capsule, void *context)
1572
 
+.. c:function:: int PyCapsule_SetContext(PyObject *capsule, void *context)
1573
 
 
1574
 
    Set the context pointer inside *capsule* to *context*.
1575
 
 
1576
 
    Return 0 on success.  Return nonzero and set an exception on failure.
1577
 
 
1578
 
-.. cfunction:: int PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor)
1579
 
+.. c:function:: int PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor)
1580
 
 
1581
 
    Set the destructor inside *capsule* to *destructor*.
1582
 
 
1583
 
    Return 0 on success.  Return nonzero and set an exception on failure.
1584
 
 
1585
 
-.. cfunction:: int PyCapsule_SetName(PyObject *capsule, const char *name)
1586
 
+.. c:function:: int PyCapsule_SetName(PyObject *capsule, const char *name)
1587
 
 
1588
 
    Set the name inside *capsule* to *name*.  If non-*NULL*, the name must
1589
 
    outlive the capsule.  If the previous *name* stored in the capsule was not
1590
 
@@ -142,7 +142,7 @@
1591
 
 
1592
 
    Return 0 on success.  Return nonzero and set an exception on failure.
1593
 
 
1594
 
-.. cfunction:: int PyCapsule_SetPointer(PyObject *capsule, void *pointer)
1595
 
+.. c:function:: int PyCapsule_SetPointer(PyObject *capsule, void *pointer)
1596
 
 
1597
 
    Set the void pointer inside *capsule* to *pointer*.  The pointer may not be
1598
 
    *NULL*.
1599
 
diff -r 8527427914a2 Doc/c-api/cell.rst
1600
 
--- a/Doc/c-api/cell.rst
1601
 
+++ b/Doc/c-api/cell.rst
1602
 
@@ -15,39 +15,39 @@
1603
 
 Cell objects are not likely to be useful elsewhere.
1604
 
 
1605
 
 
1606
 
-.. ctype:: PyCellObject
1607
 
+.. c:type:: PyCellObject
1608
 
 
1609
 
    The C structure used for cell objects.
1610
 
 
1611
 
 
1612
 
-.. cvar:: PyTypeObject PyCell_Type
1613
 
+.. c:var:: PyTypeObject PyCell_Type
1614
 
 
1615
 
    The type object corresponding to cell objects.
1616
 
 
1617
 
 
1618
 
-.. cfunction:: int PyCell_Check(ob)
1619
 
+.. c:function:: int PyCell_Check(ob)
1620
 
 
1621
 
    Return true if *ob* is a cell object; *ob* must not be *NULL*.
1622
 
 
1623
 
 
1624
 
-.. cfunction:: PyObject* PyCell_New(PyObject *ob)
1625
 
+.. c:function:: PyObject* PyCell_New(PyObject *ob)
1626
 
 
1627
 
    Create and return a new cell object containing the value *ob*. The parameter may
1628
 
    be *NULL*.
1629
 
 
1630
 
 
1631
 
-.. cfunction:: PyObject* PyCell_Get(PyObject *cell)
1632
 
+.. c:function:: PyObject* PyCell_Get(PyObject *cell)
1633
 
 
1634
 
    Return the contents of the cell *cell*.
1635
 
 
1636
 
 
1637
 
-.. cfunction:: PyObject* PyCell_GET(PyObject *cell)
1638
 
+.. c:function:: PyObject* PyCell_GET(PyObject *cell)
1639
 
 
1640
 
    Return the contents of the cell *cell*, but without checking that *cell* is
1641
 
    non-*NULL* and a cell object.
1642
 
 
1643
 
 
1644
 
-.. cfunction:: int PyCell_Set(PyObject *cell, PyObject *value)
1645
 
+.. c:function:: int PyCell_Set(PyObject *cell, PyObject *value)
1646
 
 
1647
 
    Set the contents of the cell object *cell* to *value*.  This releases the
1648
 
    reference to any current content of the cell. *value* may be *NULL*.  *cell*
1649
 
@@ -55,7 +55,7 @@
1650
 
    success, ``0`` will be returned.
1651
 
 
1652
 
 
1653
 
-.. cfunction:: void PyCell_SET(PyObject *cell, PyObject *value)
1654
 
+.. c:function:: void PyCell_SET(PyObject *cell, PyObject *value)
1655
 
 
1656
 
    Sets the value of the cell object *cell* to *value*.  No reference counts are
1657
 
    adjusted, and no checks are made for safety; *cell* must be non-*NULL* and must
1658
 
diff -r 8527427914a2 Doc/c-api/class.rst
1659
 
--- a/Doc/c-api/class.rst
1660
 
+++ b/Doc/c-api/class.rst
1661
 
@@ -12,12 +12,12 @@
1662
 
 will want to work with type objects (section :ref:`typeobjects`).
1663
 
 
1664
 
 
1665
 
-.. ctype:: PyClassObject
1666
 
+.. c:type:: PyClassObject
1667
 
 
1668
 
    The C structure of the objects used to describe built-in classes.
1669
 
 
1670
 
 
1671
 
-.. cvar:: PyObject* PyClass_Type
1672
 
+.. c:var:: PyObject* PyClass_Type
1673
 
 
1674
 
    .. index:: single: ClassType (in module types)
1675
 
 
1676
 
@@ -25,13 +25,13 @@
1677
 
    ``types.ClassType`` in the Python layer.
1678
 
 
1679
 
 
1680
 
-.. cfunction:: int PyClass_Check(PyObject *o)
1681
 
+.. c:function:: int PyClass_Check(PyObject *o)
1682
 
 
1683
 
    Return true if the object *o* is a class object, including instances of types
1684
 
    derived from the standard class object.  Return false in all other cases.
1685
 
 
1686
 
 
1687
 
-.. cfunction:: int PyClass_IsSubclass(PyObject *klass, PyObject *base)
1688
 
+.. c:function:: int PyClass_IsSubclass(PyObject *klass, PyObject *base)
1689
 
 
1690
 
    Return true if *klass* is a subclass of *base*. Return false in all other cases.
1691
 
 
1692
 
@@ -41,23 +41,23 @@
1693
 
 There are very few functions specific to instance objects.
1694
 
 
1695
 
 
1696
 
-.. cvar:: PyTypeObject PyInstance_Type
1697
 
+.. c:var:: PyTypeObject PyInstance_Type
1698
 
 
1699
 
    Type object for class instances.
1700
 
 
1701
 
 
1702
 
-.. cfunction:: int PyInstance_Check(PyObject *obj)
1703
 
+.. c:function:: int PyInstance_Check(PyObject *obj)
1704
 
 
1705
 
    Return true if *obj* is an instance.
1706
 
 
1707
 
 
1708
 
-.. cfunction:: PyObject* PyInstance_New(PyObject *class, PyObject *arg, PyObject *kw)
1709
 
+.. c:function:: PyObject* PyInstance_New(PyObject *class, PyObject *arg, PyObject *kw)
1710
 
 
1711
 
    Create a new instance of a specific class.  The parameters *arg* and *kw* are
1712
 
    used as the positional and keyword parameters to the object's constructor.
1713
 
 
1714
 
 
1715
 
-.. cfunction:: PyObject* PyInstance_NewRaw(PyObject *class, PyObject *dict)
1716
 
+.. c:function:: PyObject* PyInstance_NewRaw(PyObject *class, PyObject *dict)
1717
 
 
1718
 
    Create a new instance of a specific class without calling its constructor.
1719
 
    *class* is the class of new object.  The *dict* parameter will be used as the
1720
 
diff -r 8527427914a2 Doc/c-api/cobject.rst
1721
 
--- a/Doc/c-api/cobject.rst
1722
 
+++ b/Doc/c-api/cobject.rst
1723
 
@@ -13,47 +13,47 @@
1724
 
    The CObject API is deprecated as of Python 2.7.  Please switch to the new
1725
 
    :ref:`capsules` API.
1726
 
 
1727
 
-.. ctype:: PyCObject
1728
 
+.. c:type:: PyCObject
1729
 
 
1730
 
-   This subtype of :ctype:`PyObject` represents an opaque value, useful for C
1731
 
-   extension modules who need to pass an opaque value (as a :ctype:`void\*`
1732
 
+   This subtype of :c:type:`PyObject` represents an opaque value, useful for C
1733
 
+   extension modules who need to pass an opaque value (as a :c:type:`void\*`
1734
 
    pointer) through Python code to other C code.  It is often used to make a C
1735
 
    function pointer defined in one module available to other modules, so the
1736
 
    regular import mechanism can be used to access C APIs defined in dynamically
1737
 
    loaded modules.
1738
 
 
1739
 
 
1740
 
-.. cfunction:: int PyCObject_Check(PyObject *p)
1741
 
+.. c:function:: int PyCObject_Check(PyObject *p)
1742
 
 
1743
 
-   Return true if its argument is a :ctype:`PyCObject`.
1744
 
+   Return true if its argument is a :c:type:`PyCObject`.
1745
 
 
1746
 
 
1747
 
-.. cfunction:: PyObject* PyCObject_FromVoidPtr(void* cobj, void (*destr)(void *))
1748
 
+.. c:function:: PyObject* PyCObject_FromVoidPtr(void* cobj, void (*destr)(void *))
1749
 
 
1750
 
-   Create a :ctype:`PyCObject` from the ``void *`` *cobj*.  The *destr* function
1751
 
+   Create a :c:type:`PyCObject` from the ``void *`` *cobj*.  The *destr* function
1752
 
    will be called when the object is reclaimed, unless it is *NULL*.
1753
 
 
1754
 
 
1755
 
-.. cfunction:: PyObject* PyCObject_FromVoidPtrAndDesc(void* cobj, void* desc, void (*destr)(void *, void *))
1756
 
+.. c:function:: PyObject* PyCObject_FromVoidPtrAndDesc(void* cobj, void* desc, void (*destr)(void *, void *))
1757
 
 
1758
 
-   Create a :ctype:`PyCObject` from the :ctype:`void \*` *cobj*.  The *destr*
1759
 
+   Create a :c:type:`PyCObject` from the :c:type:`void \*` *cobj*.  The *destr*
1760
 
    function will be called when the object is reclaimed. The *desc* argument can
1761
 
    be used to pass extra callback data for the destructor function.
1762
 
 
1763
 
 
1764
 
-.. cfunction:: void* PyCObject_AsVoidPtr(PyObject* self)
1765
 
+.. c:function:: void* PyCObject_AsVoidPtr(PyObject* self)
1766
 
 
1767
 
-   Return the object :ctype:`void \*` that the :ctype:`PyCObject` *self* was
1768
 
+   Return the object :c:type:`void \*` that the :c:type:`PyCObject` *self* was
1769
 
    created with.
1770
 
 
1771
 
 
1772
 
-.. cfunction:: void* PyCObject_GetDesc(PyObject* self)
1773
 
+.. c:function:: void* PyCObject_GetDesc(PyObject* self)
1774
 
 
1775
 
-   Return the description :ctype:`void \*` that the :ctype:`PyCObject` *self* was
1776
 
+   Return the description :c:type:`void \*` that the :c:type:`PyCObject` *self* was
1777
 
    created with.
1778
 
 
1779
 
 
1780
 
-.. cfunction:: int PyCObject_SetVoidPtr(PyObject* self, void* cobj)
1781
 
+.. c:function:: int PyCObject_SetVoidPtr(PyObject* self, void* cobj)
1782
 
 
1783
 
-   Set the void pointer inside *self* to *cobj*. The :ctype:`PyCObject` must not
1784
 
+   Set the void pointer inside *self* to *cobj*. The :c:type:`PyCObject` must not
1785
 
    have an associated destructor. Return true on success, false on failure.
1786
 
diff -r 8527427914a2 Doc/c-api/code.rst
1787
 
--- a/Doc/c-api/code.rst
1788
 
+++ b/Doc/c-api/code.rst
1789
 
@@ -15,35 +15,35 @@
1790
 
 Each one represents a chunk of executable code that hasn't yet been
1791
 
 bound into a function.
1792
 
 
1793
 
-.. ctype:: PyCodeObject
1794
 
+.. c:type:: PyCodeObject
1795
 
 
1796
 
    The C structure of the objects used to describe code objects.  The
1797
 
    fields of this type are subject to change at any time.
1798
 
 
1799
 
 
1800
 
-.. cvar:: PyTypeObject PyCode_Type
1801
 
+.. c:var:: PyTypeObject PyCode_Type
1802
 
 
1803
 
-   This is an instance of :ctype:`PyTypeObject` representing the Python
1804
 
+   This is an instance of :c:type:`PyTypeObject` representing the Python
1805
 
    :class:`code` type.
1806
 
 
1807
 
 
1808
 
-.. cfunction:: int PyCode_Check(PyObject *co)
1809
 
+.. c:function:: int PyCode_Check(PyObject *co)
1810
 
 
1811
 
    Return true if *co* is a :class:`code` object
1812
 
 
1813
 
-.. cfunction:: int PyCode_GetNumFree(PyObject *co)
1814
 
+.. c:function:: int PyCode_GetNumFree(PyObject *co)
1815
 
 
1816
 
    Return the number of free variables in *co*.
1817
 
 
1818
 
-.. cfunction:: PyCodeObject *PyCode_New(int argcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *lnotab)
1819
 
+.. c:function:: PyCodeObject *PyCode_New(int argcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *lnotab)
1820
 
 
1821
 
    Return a new code object.  If you need a dummy code object to
1822
 
-   create a frame, use :cfunc:`PyCode_NewEmpty` instead.  Calling
1823
 
-   :cfunc:`PyCode_New` directly can bind you to a precise Python
1824
 
+   create a frame, use :c:func:`PyCode_NewEmpty` instead.  Calling
1825
 
+   :c:func:`PyCode_New` directly can bind you to a precise Python
1826
 
    version since the definition of the bytecode changes often.
1827
 
 
1828
 
 
1829
 
-.. cfunction:: int PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
1830
 
+.. c:function:: int PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
1831
 
 
1832
 
    Return a new empty code object with the specified filename,
1833
 
    function name, and first line number.  It is illegal to
1834
 
diff -r 8527427914a2 Doc/c-api/codec.rst
1835
 
--- a/Doc/c-api/codec.rst
1836
 
+++ b/Doc/c-api/codec.rst
1837
 
@@ -3,19 +3,19 @@
1838
 
 Codec registry and support functions
1839
 
 ====================================
1840
 
 
1841
 
-.. cfunction:: int PyCodec_Register(PyObject *search_function)
1842
 
+.. c:function:: int PyCodec_Register(PyObject *search_function)
1843
 
 
1844
 
    Register a new codec search function.
1845
 
 
1846
 
    As side effect, this tries to load the :mod:`encodings` package, if not yet
1847
 
    done, to make sure that it is always first in the list of search functions.
1848
 
 
1849
 
-.. cfunction:: int PyCodec_KnownEncoding(const char *encoding)
1850
 
+.. c:function:: int PyCodec_KnownEncoding(const char *encoding)
1851
 
 
1852
 
    Return ``1`` or ``0`` depending on whether there is a registered codec for
1853
 
    the given *encoding*.
1854
 
 
1855
 
-.. cfunction:: PyObject* PyCodec_Encode(PyObject *object, const char *encoding, const char *errors)
1856
 
+.. c:function:: PyObject* PyCodec_Encode(PyObject *object, const char *encoding, const char *errors)
1857
 
 
1858
 
    Generic codec based encoding API.
1859
 
 
1860
 
@@ -24,7 +24,7 @@
1861
 
    be *NULL* to use the default method defined for the codec.  Raises a
1862
 
    :exc:`LookupError` if no encoder can be found.
1863
 
 
1864
 
-.. cfunction:: PyObject* PyCodec_Decode(PyObject *object, const char *encoding, const char *errors)
1865
 
+.. c:function:: PyObject* PyCodec_Decode(PyObject *object, const char *encoding, const char *errors)
1866
 
 
1867
 
    Generic codec based decoding API.
1868
 
 
1869
 
@@ -42,27 +42,27 @@
1870
 
 effectively case-insensitive.  If no codec is found, a :exc:`KeyError` is set
1871
 
 and *NULL* returned.
1872
 
 
1873
 
-.. cfunction:: PyObject* PyCodec_Encoder(const char *encoding)
1874
 
+.. c:function:: PyObject* PyCodec_Encoder(const char *encoding)
1875
 
 
1876
 
    Get an encoder function for the given *encoding*.
1877
 
 
1878
 
-.. cfunction:: PyObject* PyCodec_Decoder(const char *encoding)
1879
 
+.. c:function:: PyObject* PyCodec_Decoder(const char *encoding)
1880
 
 
1881
 
    Get a decoder function for the given *encoding*.
1882
 
 
1883
 
-.. cfunction:: PyObject* PyCodec_IncrementalEncoder(const char *encoding, const char *errors)
1884
 
+.. c:function:: PyObject* PyCodec_IncrementalEncoder(const char *encoding, const char *errors)
1885
 
 
1886
 
    Get an :class:`IncrementalEncoder` object for the given *encoding*.
1887
 
 
1888
 
-.. cfunction:: PyObject* PyCodec_IncrementalDecoder(const char *encoding, const char *errors)
1889
 
+.. c:function:: PyObject* PyCodec_IncrementalDecoder(const char *encoding, const char *errors)
1890
 
 
1891
 
    Get an :class:`IncrementalDecoder` object for the given *encoding*.
1892
 
 
1893
 
-.. cfunction:: PyObject* PyCodec_StreamReader(const char *encoding, PyObject *stream, const char *errors)
1894
 
+.. c:function:: PyObject* PyCodec_StreamReader(const char *encoding, PyObject *stream, const char *errors)
1895
 
 
1896
 
    Get a :class:`StreamReader` factory function for the given *encoding*.
1897
 
 
1898
 
-.. cfunction:: PyObject* PyCodec_StreamWriter(const char *encoding, PyObject *stream, const char *errors)
1899
 
+.. c:function:: PyObject* PyCodec_StreamWriter(const char *encoding, PyObject *stream, const char *errors)
1900
 
 
1901
 
    Get a :class:`StreamWriter` factory function for the given *encoding*.
1902
 
 
1903
 
@@ -70,7 +70,7 @@
1904
 
 Registry API for Unicode encoding error handlers
1905
 
 ------------------------------------------------
1906
 
 
1907
 
-.. cfunction:: int PyCodec_RegisterError(const char *name, PyObject *error)
1908
 
+.. c:function:: int PyCodec_RegisterError(const char *name, PyObject *error)
1909
 
 
1910
 
    Register the error handling callback function *error* under the given *name*.
1911
 
    This callback function will be called by a codec when it encounters
1912
 
@@ -89,29 +89,29 @@
1913
 
 
1914
 
    Return ``0`` on success, ``-1`` on error.
1915
 
 
1916
 
-.. cfunction:: PyObject* PyCodec_LookupError(const char *name)
1917
 
+.. c:function:: PyObject* PyCodec_LookupError(const char *name)
1918
 
 
1919
 
    Lookup the error handling callback function registered under *name*.  As a
1920
 
    special case *NULL* can be passed, in which case the error handling callback
1921
 
    for "strict" will be returned.
1922
 
 
1923
 
-.. cfunction:: PyObject* PyCodec_StrictErrors(PyObject *exc)
1924
 
+.. c:function:: PyObject* PyCodec_StrictErrors(PyObject *exc)
1925
 
 
1926
 
    Raise *exc* as an exception.
1927
 
 
1928
 
-.. cfunction:: PyObject* PyCodec_IgnoreErrors(PyObject *exc)
1929
 
+.. c:function:: PyObject* PyCodec_IgnoreErrors(PyObject *exc)
1930
 
 
1931
 
    Ignore the unicode error, skipping the faulty input.
1932
 
 
1933
 
-.. cfunction:: PyObject* PyCodec_ReplaceErrors(PyObject *exc)
1934
 
+.. c:function:: PyObject* PyCodec_ReplaceErrors(PyObject *exc)
1935
 
 
1936
 
    Replace the unicode encode error with ``?`` or ``U+FFFD``.
1937
 
 
1938
 
-.. cfunction:: PyObject* PyCodec_XMLCharRefReplaceErrors(PyObject *exc)
1939
 
+.. c:function:: PyObject* PyCodec_XMLCharRefReplaceErrors(PyObject *exc)
1940
 
 
1941
 
    Replace the unicode encode error with XML character references.
1942
 
 
1943
 
-.. cfunction:: PyObject* PyCodec_BackslashReplaceErrors(PyObject *exc)
1944
 
+.. c:function:: PyObject* PyCodec_BackslashReplaceErrors(PyObject *exc)
1945
 
 
1946
 
    Replace the unicode encode error with backslash escapes (``\x``, ``\u`` and
1947
 
    ``\U``).
1948
 
diff -r 8527427914a2 Doc/c-api/complex.rst
1949
 
--- a/Doc/c-api/complex.rst
1950
 
+++ b/Doc/c-api/complex.rst
1951
 
@@ -21,7 +21,7 @@
1952
 
 pointers.  This is consistent throughout the API.
1953
 
 
1954
 
 
1955
 
-.. ctype:: Py_complex
1956
 
+.. c:type:: Py_complex
1957
 
 
1958
 
    The C structure which corresponds to the value portion of a Python complex
1959
 
    number object.  Most of the functions for dealing with complex number objects
1960
 
@@ -34,97 +34,104 @@
1961
 
       } Py_complex;
1962
 
 
1963
 
 
1964
 
-.. cfunction:: Py_complex _Py_c_sum(Py_complex left, Py_complex right)
1965
 
+.. c:function:: Py_complex _Py_c_sum(Py_complex left, Py_complex right)
1966
 
 
1967
 
-   Return the sum of two complex numbers, using the C :ctype:`Py_complex`
1968
 
+   Return the sum of two complex numbers, using the C :c:type:`Py_complex`
1969
 
    representation.
1970
 
 
1971
 
 
1972
 
-.. cfunction:: Py_complex _Py_c_diff(Py_complex left, Py_complex right)
1973
 
+.. c:function:: Py_complex _Py_c_diff(Py_complex left, Py_complex right)
1974
 
 
1975
 
    Return the difference between two complex numbers, using the C
1976
 
-   :ctype:`Py_complex` representation.
1977
 
+   :c:type:`Py_complex` representation.
1978
 
 
1979
 
 
1980
 
-.. cfunction:: Py_complex _Py_c_neg(Py_complex complex)
1981
 
+.. c:function:: Py_complex _Py_c_neg(Py_complex complex)
1982
 
 
1983
 
    Return the negation of the complex number *complex*, using the C
1984
 
-   :ctype:`Py_complex` representation.
1985
 
+   :c:type:`Py_complex` representation.
1986
 
 
1987
 
 
1988
 
-.. cfunction:: Py_complex _Py_c_prod(Py_complex left, Py_complex right)
1989
 
+.. c:function:: Py_complex _Py_c_prod(Py_complex left, Py_complex right)
1990
 
 
1991
 
-   Return the product of two complex numbers, using the C :ctype:`Py_complex`
1992
 
+   Return the product of two complex numbers, using the C :c:type:`Py_complex`
1993
 
    representation.
1994
 
 
1995
 
 
1996
 
-.. cfunction:: Py_complex _Py_c_quot(Py_complex dividend, Py_complex divisor)
1997
 
+.. c:function:: Py_complex _Py_c_quot(Py_complex dividend, Py_complex divisor)
1998
 
 
1999
 
-   Return the quotient of two complex numbers, using the C :ctype:`Py_complex`
2000
 
+   Return the quotient of two complex numbers, using the C :c:type:`Py_complex`
2001
 
    representation.
2002
 
 
2003
 
+   If *divisor* is null, this method returns zero and sets
2004
 
+   :c:data:`errno` to :c:data:`EDOM`.
2005
 
 
2006
 
-.. cfunction:: Py_complex _Py_c_pow(Py_complex num, Py_complex exp)
2007
 
 
2008
 
-   Return the exponentiation of *num* by *exp*, using the C :ctype:`Py_complex`
2009
 
+.. c:function:: Py_complex _Py_c_pow(Py_complex num, Py_complex exp)
2010
 
+
2011
 
+   Return the exponentiation of *num* by *exp*, using the C :c:type:`Py_complex`
2012
 
    representation.
2013
 
 
2014
 
+   If *num* is null and *exp* is not a positive real number,
2015
 
+   this method returns zero and sets :c:data:`errno` to :c:data:`EDOM`.
2016
 
+
2017
 
 
2018
 
 Complex Numbers as Python Objects
2019
 
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2020
 
 
2021
 
 
2022
 
-.. ctype:: PyComplexObject
2023
 
+.. c:type:: PyComplexObject
2024
 
 
2025
 
-   This subtype of :ctype:`PyObject` represents a Python complex number object.
2026
 
+   This subtype of :c:type:`PyObject` represents a Python complex number object.
2027
 
 
2028
 
 
2029
 
-.. cvar:: PyTypeObject PyComplex_Type
2030
 
+.. c:var:: PyTypeObject PyComplex_Type
2031
 
 
2032
 
-   This instance of :ctype:`PyTypeObject` represents the Python complex number
2033
 
+   This instance of :c:type:`PyTypeObject` represents the Python complex number
2034
 
    type. It is the same object as ``complex`` and ``types.ComplexType``.
2035
 
 
2036
 
 
2037
 
-.. cfunction:: int PyComplex_Check(PyObject *p)
2038
 
+.. c:function:: int PyComplex_Check(PyObject *p)
2039
 
 
2040
 
-   Return true if its argument is a :ctype:`PyComplexObject` or a subtype of
2041
 
-   :ctype:`PyComplexObject`.
2042
 
+   Return true if its argument is a :c:type:`PyComplexObject` or a subtype of
2043
 
+   :c:type:`PyComplexObject`.
2044
 
 
2045
 
    .. versionchanged:: 2.2
2046
 
       Allowed subtypes to be accepted.
2047
 
 
2048
 
 
2049
 
-.. cfunction:: int PyComplex_CheckExact(PyObject *p)
2050
 
+.. c:function:: int PyComplex_CheckExact(PyObject *p)
2051
 
 
2052
 
-   Return true if its argument is a :ctype:`PyComplexObject`, but not a subtype of
2053
 
-   :ctype:`PyComplexObject`.
2054
 
+   Return true if its argument is a :c:type:`PyComplexObject`, but not a subtype of
2055
 
+   :c:type:`PyComplexObject`.
2056
 
 
2057
 
    .. versionadded:: 2.2
2058
 
 
2059
 
 
2060
 
-.. cfunction:: PyObject* PyComplex_FromCComplex(Py_complex v)
2061
 
+.. c:function:: PyObject* PyComplex_FromCComplex(Py_complex v)
2062
 
 
2063
 
-   Create a new Python complex number object from a C :ctype:`Py_complex` value.
2064
 
+   Create a new Python complex number object from a C :c:type:`Py_complex` value.
2065
 
 
2066
 
 
2067
 
-.. cfunction:: PyObject* PyComplex_FromDoubles(double real, double imag)
2068
 
+.. c:function:: PyObject* PyComplex_FromDoubles(double real, double imag)
2069
 
 
2070
 
-   Return a new :ctype:`PyComplexObject` object from *real* and *imag*.
2071
 
+   Return a new :c:type:`PyComplexObject` object from *real* and *imag*.
2072
 
 
2073
 
 
2074
 
-.. cfunction:: double PyComplex_RealAsDouble(PyObject *op)
2075
 
+.. c:function:: double PyComplex_RealAsDouble(PyObject *op)
2076
 
 
2077
 
-   Return the real part of *op* as a C :ctype:`double`.
2078
 
+   Return the real part of *op* as a C :c:type:`double`.
2079
 
 
2080
 
 
2081
 
-.. cfunction:: double PyComplex_ImagAsDouble(PyObject *op)
2082
 
+.. c:function:: double PyComplex_ImagAsDouble(PyObject *op)
2083
 
 
2084
 
-   Return the imaginary part of *op* as a C :ctype:`double`.
2085
 
+   Return the imaginary part of *op* as a C :c:type:`double`.
2086
 
 
2087
 
 
2088
 
-.. cfunction:: Py_complex PyComplex_AsCComplex(PyObject *op)
2089
 
+.. c:function:: Py_complex PyComplex_AsCComplex(PyObject *op)
2090
 
 
2091
 
-   Return the :ctype:`Py_complex` value of the complex number *op*.
2092
 
+   Return the :c:type:`Py_complex` value of the complex number *op*.
2093
 
+   Upon failure, this method returns ``-1.0`` as a real value.
2094
 
 
2095
 
    .. versionchanged:: 2.6
2096
 
       If *op* is not a Python complex number object but has a :meth:`__complex__`
2097
 
diff -r 8527427914a2 Doc/c-api/concrete.rst
2098
 
--- a/Doc/c-api/concrete.rst
2099
 
+++ b/Doc/c-api/concrete.rst
2100
 
@@ -11,7 +11,7 @@
2101
 
 Passing them an object of the wrong type is not a good idea; if you receive an
2102
 
 object from a Python program and you are not sure that it has the right type,
2103
 
 you must perform a type check first; for example, to check that an object is a
2104
 
-dictionary, use :cfunc:`PyDict_Check`.  The chapter is structured like the
2105
 
+dictionary, use :c:func:`PyDict_Check`.  The chapter is structured like the
2106
 
 "family tree" of Python object types.
2107
 
 
2108
 
 .. warning::
2109
 
diff -r 8527427914a2 Doc/c-api/conversion.rst
2110
 
--- a/Doc/c-api/conversion.rst
2111
 
+++ b/Doc/c-api/conversion.rst
2112
 
@@ -8,20 +8,20 @@
2113
 
 Functions for number conversion and formatted string output.
2114
 
 
2115
 
 
2116
 
-.. cfunction:: int PyOS_snprintf(char *str, size_t size,  const char *format, ...)
2117
 
+.. c:function:: int PyOS_snprintf(char *str, size_t size,  const char *format, ...)
2118
 
 
2119
 
    Output not more than *size* bytes to *str* according to the format string
2120
 
    *format* and the extra arguments. See the Unix man page :manpage:`snprintf(2)`.
2121
 
 
2122
 
 
2123
 
-.. cfunction:: int PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va)
2124
 
+.. c:function:: int PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va)
2125
 
 
2126
 
    Output not more than *size* bytes to *str* according to the format string
2127
 
    *format* and the variable argument list *va*. Unix man page
2128
 
    :manpage:`vsnprintf(2)`.
2129
 
 
2130
 
-:cfunc:`PyOS_snprintf` and :cfunc:`PyOS_vsnprintf` wrap the Standard C library
2131
 
-functions :cfunc:`snprintf` and :cfunc:`vsnprintf`. Their purpose is to
2132
 
+:c:func:`PyOS_snprintf` and :c:func:`PyOS_vsnprintf` wrap the Standard C library
2133
 
+functions :c:func:`snprintf` and :c:func:`vsnprintf`. Their purpose is to
2134
 
 guarantee consistent behavior in corner cases, which the Standard C functions do
2135
 
 not.
2136
 
 
2137
 
@@ -30,7 +30,7 @@
2138
 
 Both functions require that ``str != NULL``, ``size > 0`` and ``format !=
2139
 
 NULL``.
2140
 
 
2141
 
-If the platform doesn't have :cfunc:`vsnprintf` and the buffer size needed to
2142
 
+If the platform doesn't have :c:func:`vsnprintf` and the buffer size needed to
2143
 
 avoid truncation exceeds *size* by more than 512 bytes, Python aborts with a
2144
 
 *Py_FatalError*.
2145
 
 
2146
 
@@ -51,9 +51,9 @@
2147
 
 The following functions provide locale-independent string to number conversions.
2148
 
 
2149
 
 
2150
 
-.. cfunction:: double PyOS_string_to_double(const char *s, char **endptr, PyObject *overflow_exception)
2151
 
+.. c:function:: double PyOS_string_to_double(const char *s, char **endptr, PyObject *overflow_exception)
2152
 
 
2153
 
-   Convert a string ``s`` to a :ctype:`double`, raising a Python
2154
 
+   Convert a string ``s`` to a :c:type:`double`, raising a Python
2155
 
    exception on failure.  The set of accepted strings corresponds to
2156
 
    the set of strings accepted by Python's :func:`float` constructor,
2157
 
    except that ``s`` must not have leading or trailing whitespace.
2158
 
@@ -85,13 +85,13 @@
2159
 
    .. versionadded:: 2.7
2160
 
 
2161
 
 
2162
 
-.. cfunction:: double PyOS_ascii_strtod(const char *nptr, char **endptr)
2163
 
+.. c:function:: double PyOS_ascii_strtod(const char *nptr, char **endptr)
2164
 
 
2165
 
-   Convert a string to a :ctype:`double`. This function behaves like the Standard C
2166
 
-   function :cfunc:`strtod` does in the C locale. It does this without changing the
2167
 
+   Convert a string to a :c:type:`double`. This function behaves like the Standard C
2168
 
+   function :c:func:`strtod` does in the C locale. It does this without changing the
2169
 
    current locale, since that would not be thread-safe.
2170
 
 
2171
 
-   :cfunc:`PyOS_ascii_strtod` should typically be used for reading configuration
2172
 
+   :c:func:`PyOS_ascii_strtod` should typically be used for reading configuration
2173
 
    files or other non-user input that should be locale independent.
2174
 
 
2175
 
    See the Unix man page :manpage:`strtod(2)` for details.
2176
 
@@ -99,14 +99,14 @@
2177
 
    .. versionadded:: 2.4
2178
 
 
2179
 
    .. deprecated:: 2.7
2180
 
-      Use :cfunc:`PyOS_string_to_double` instead.
2181
 
+      Use :c:func:`PyOS_string_to_double` instead.
2182
 
 
2183
 
 
2184
 
 
2185
 
-.. cfunction:: char* PyOS_ascii_formatd(char *buffer, size_t buf_len, const char *format, double d)
2186
 
+.. c:function:: char* PyOS_ascii_formatd(char *buffer, size_t buf_len, const char *format, double d)
2187
 
 
2188
 
-   Convert a :ctype:`double` to a string using the ``'.'`` as the decimal
2189
 
-   separator. *format* is a :cfunc:`printf`\ -style format string specifying the
2190
 
+   Convert a :c:type:`double` to a string using the ``'.'`` as the decimal
2191
 
+   separator. *format* is a :c:func:`printf`\ -style format string specifying the
2192
 
    number format. Allowed conversion characters are ``'e'``, ``'E'``, ``'f'``,
2193
 
    ``'F'``, ``'g'`` and ``'G'``.
2194
 
 
2195
 
@@ -119,9 +119,9 @@
2196
 
       instead.
2197
 
 
2198
 
 
2199
 
-.. cfunction:: char* PyOS_double_to_string(double val, char format_code, int precision, int flags, int *ptype)
2200
 
+.. c:function:: char* PyOS_double_to_string(double val, char format_code, int precision, int flags, int *ptype)
2201
 
 
2202
 
-   Convert a :ctype:`double` *val* to a string using supplied
2203
 
+   Convert a :c:type:`double` *val* to a string using supplied
2204
 
    *format_code*, *precision*, and *flags*.
2205
 
 
2206
 
    *format_code* must be one of ``'e'``, ``'E'``, ``'f'``, ``'F'``,
2207
 
@@ -139,7 +139,7 @@
2208
 
      like an integer.
2209
 
 
2210
 
    * *Py_DTSF_ALT* means to apply "alternate" formatting rules.  See the
2211
 
-     documentation for the :cfunc:`PyOS_snprintf` ``'#'`` specifier for
2212
 
+     documentation for the :c:func:`PyOS_snprintf` ``'#'`` specifier for
2213
 
      details.
2214
 
 
2215
 
    If *ptype* is non-NULL, then the value it points to will be set to one of
2216
 
@@ -148,34 +148,34 @@
2217
 
 
2218
 
    The return value is a pointer to *buffer* with the converted string or
2219
 
    *NULL* if the conversion failed. The caller is responsible for freeing the
2220
 
-   returned string by calling :cfunc:`PyMem_Free`.
2221
 
+   returned string by calling :c:func:`PyMem_Free`.
2222
 
 
2223
 
    .. versionadded:: 2.7
2224
 
 
2225
 
 
2226
 
-.. cfunction:: double PyOS_ascii_atof(const char *nptr)
2227
 
+.. c:function:: double PyOS_ascii_atof(const char *nptr)
2228
 
 
2229
 
-   Convert a string to a :ctype:`double` in a locale-independent way.
2230
 
+   Convert a string to a :c:type:`double` in a locale-independent way.
2231
 
 
2232
 
    See the Unix man page :manpage:`atof(2)` for details.
2233
 
 
2234
 
    .. versionadded:: 2.4
2235
 
 
2236
 
    .. deprecated:: 3.1
2237
 
-      Use :cfunc:`PyOS_string_to_double` instead.
2238
 
+      Use :c:func:`PyOS_string_to_double` instead.
2239
 
 
2240
 
 
2241
 
-.. cfunction:: char* PyOS_stricmp(char *s1, char *s2)
2242
 
+.. c:function:: char* PyOS_stricmp(char *s1, char *s2)
2243
 
 
2244
 
    Case insensitive comparison of strings. The function works almost
2245
 
-   identically to :cfunc:`strcmp` except that it ignores the case.
2246
 
+   identically to :c:func:`strcmp` except that it ignores the case.
2247
 
 
2248
 
    .. versionadded:: 2.6
2249
 
 
2250
 
 
2251
 
-.. cfunction:: char* PyOS_strnicmp(char *s1, char *s2, Py_ssize_t  size)
2252
 
+.. c:function:: char* PyOS_strnicmp(char *s1, char *s2, Py_ssize_t  size)
2253
 
 
2254
 
    Case insensitive comparison of strings. The function works almost
2255
 
-   identically to :cfunc:`strncmp` except that it ignores the case.
2256
 
+   identically to :c:func:`strncmp` except that it ignores the case.
2257
 
 
2258
 
    .. versionadded:: 2.6
2259
 
diff -r 8527427914a2 Doc/c-api/datetime.rst
2260
 
--- a/Doc/c-api/datetime.rst
2261
 
+++ b/Doc/c-api/datetime.rst
2262
 
@@ -8,89 +8,89 @@
2263
 
 Various date and time objects are supplied by the :mod:`datetime` module.
2264
 
 Before using any of these functions, the header file :file:`datetime.h` must be
2265
 
 included in your source (note that this is not included by :file:`Python.h`),
2266
 
-and the macro :cmacro:`PyDateTime_IMPORT` must be invoked, usually as part of
2267
 
+and the macro :c:macro:`PyDateTime_IMPORT` must be invoked, usually as part of
2268
 
 the module initialisation function.  The macro puts a pointer to a C structure
2269
 
-into a static variable, :cdata:`PyDateTimeAPI`, that is used by the following
2270
 
+into a static variable, :c:data:`PyDateTimeAPI`, that is used by the following
2271
 
 macros.
2272
 
 
2273
 
 Type-check macros:
2274
 
 
2275
 
 
2276
 
-.. cfunction:: int PyDate_Check(PyObject *ob)
2277
 
+.. c:function:: int PyDate_Check(PyObject *ob)
2278
 
 
2279
 
-   Return true if *ob* is of type :cdata:`PyDateTime_DateType` or a subtype of
2280
 
-   :cdata:`PyDateTime_DateType`.  *ob* must not be *NULL*.
2281
 
+   Return true if *ob* is of type :c:data:`PyDateTime_DateType` or a subtype of
2282
 
+   :c:data:`PyDateTime_DateType`.  *ob* must not be *NULL*.
2283
 
 
2284
 
    .. versionadded:: 2.4
2285
 
 
2286
 
 
2287
 
-.. cfunction:: int PyDate_CheckExact(PyObject *ob)
2288
 
+.. c:function:: int PyDate_CheckExact(PyObject *ob)
2289
 
 
2290
 
-   Return true if *ob* is of type :cdata:`PyDateTime_DateType`. *ob* must not be
2291
 
+   Return true if *ob* is of type :c:data:`PyDateTime_DateType`. *ob* must not be
2292
 
    *NULL*.
2293
 
 
2294
 
    .. versionadded:: 2.4
2295
 
 
2296
 
 
2297
 
-.. cfunction:: int PyDateTime_Check(PyObject *ob)
2298
 
+.. c:function:: int PyDateTime_Check(PyObject *ob)
2299
 
 
2300
 
-   Return true if *ob* is of type :cdata:`PyDateTime_DateTimeType` or a subtype of
2301
 
-   :cdata:`PyDateTime_DateTimeType`.  *ob* must not be *NULL*.
2302
 
+   Return true if *ob* is of type :c:data:`PyDateTime_DateTimeType` or a subtype of
2303
 
+   :c:data:`PyDateTime_DateTimeType`.  *ob* must not be *NULL*.
2304
 
 
2305
 
    .. versionadded:: 2.4
2306
 
 
2307
 
 
2308
 
-.. cfunction:: int PyDateTime_CheckExact(PyObject *ob)
2309
 
+.. c:function:: int PyDateTime_CheckExact(PyObject *ob)
2310
 
 
2311
 
-   Return true if *ob* is of type :cdata:`PyDateTime_DateTimeType`. *ob* must not
2312
 
+   Return true if *ob* is of type :c:data:`PyDateTime_DateTimeType`. *ob* must not
2313
 
    be *NULL*.
2314
 
 
2315
 
    .. versionadded:: 2.4
2316
 
 
2317
 
 
2318
 
-.. cfunction:: int PyTime_Check(PyObject *ob)
2319
 
+.. c:function:: int PyTime_Check(PyObject *ob)
2320
 
 
2321
 
-   Return true if *ob* is of type :cdata:`PyDateTime_TimeType` or a subtype of
2322
 
-   :cdata:`PyDateTime_TimeType`.  *ob* must not be *NULL*.
2323
 
+   Return true if *ob* is of type :c:data:`PyDateTime_TimeType` or a subtype of
2324
 
+   :c:data:`PyDateTime_TimeType`.  *ob* must not be *NULL*.
2325
 
 
2326
 
    .. versionadded:: 2.4
2327
 
 
2328
 
 
2329
 
-.. cfunction:: int PyTime_CheckExact(PyObject *ob)
2330
 
+.. c:function:: int PyTime_CheckExact(PyObject *ob)
2331
 
 
2332
 
-   Return true if *ob* is of type :cdata:`PyDateTime_TimeType`. *ob* must not be
2333
 
+   Return true if *ob* is of type :c:data:`PyDateTime_TimeType`. *ob* must not be
2334
 
    *NULL*.
2335
 
 
2336
 
    .. versionadded:: 2.4
2337
 
 
2338
 
 
2339
 
-.. cfunction:: int PyDelta_Check(PyObject *ob)
2340
 
+.. c:function:: int PyDelta_Check(PyObject *ob)
2341
 
 
2342
 
-   Return true if *ob* is of type :cdata:`PyDateTime_DeltaType` or a subtype of
2343
 
-   :cdata:`PyDateTime_DeltaType`.  *ob* must not be *NULL*.
2344
 
+   Return true if *ob* is of type :c:data:`PyDateTime_DeltaType` or a subtype of
2345
 
+   :c:data:`PyDateTime_DeltaType`.  *ob* must not be *NULL*.
2346
 
 
2347
 
    .. versionadded:: 2.4
2348
 
 
2349
 
 
2350
 
-.. cfunction:: int PyDelta_CheckExact(PyObject *ob)
2351
 
+.. c:function:: int PyDelta_CheckExact(PyObject *ob)
2352
 
 
2353
 
-   Return true if *ob* is of type :cdata:`PyDateTime_DeltaType`. *ob* must not be
2354
 
+   Return true if *ob* is of type :c:data:`PyDateTime_DeltaType`. *ob* must not be
2355
 
    *NULL*.
2356
 
 
2357
 
    .. versionadded:: 2.4
2358
 
 
2359
 
 
2360
 
-.. cfunction:: int PyTZInfo_Check(PyObject *ob)
2361
 
+.. c:function:: int PyTZInfo_Check(PyObject *ob)
2362
 
 
2363
 
-   Return true if *ob* is of type :cdata:`PyDateTime_TZInfoType` or a subtype of
2364
 
-   :cdata:`PyDateTime_TZInfoType`.  *ob* must not be *NULL*.
2365
 
+   Return true if *ob* is of type :c:data:`PyDateTime_TZInfoType` or a subtype of
2366
 
+   :c:data:`PyDateTime_TZInfoType`.  *ob* must not be *NULL*.
2367
 
 
2368
 
    .. versionadded:: 2.4
2369
 
 
2370
 
 
2371
 
-.. cfunction:: int PyTZInfo_CheckExact(PyObject *ob)
2372
 
+.. c:function:: int PyTZInfo_CheckExact(PyObject *ob)
2373
 
 
2374
 
-   Return true if *ob* is of type :cdata:`PyDateTime_TZInfoType`. *ob* must not be
2375
 
+   Return true if *ob* is of type :c:data:`PyDateTime_TZInfoType`. *ob* must not be
2376
 
    *NULL*.
2377
 
 
2378
 
    .. versionadded:: 2.4
2379
 
@@ -98,14 +98,14 @@
2380
 
 Macros to create objects:
2381
 
 
2382
 
 
2383
 
-.. cfunction:: PyObject* PyDate_FromDate(int year, int month, int day)
2384
 
+.. c:function:: PyObject* PyDate_FromDate(int year, int month, int day)
2385
 
 
2386
 
    Return a ``datetime.date`` object with the specified year, month and day.
2387
 
 
2388
 
    .. versionadded:: 2.4
2389
 
 
2390
 
 
2391
 
-.. cfunction:: PyObject* PyDateTime_FromDateAndTime(int year, int month, int day, int hour, int minute, int second, int usecond)
2392
 
+.. c:function:: PyObject* PyDateTime_FromDateAndTime(int year, int month, int day, int hour, int minute, int second, int usecond)
2393
 
 
2394
 
    Return a ``datetime.datetime`` object with the specified year, month, day, hour,
2395
 
    minute, second and microsecond.
2396
 
@@ -113,7 +113,7 @@
2397
 
    .. versionadded:: 2.4
2398
 
 
2399
 
 
2400
 
-.. cfunction:: PyObject* PyTime_FromTime(int hour, int minute, int second, int usecond)
2401
 
+.. c:function:: PyObject* PyTime_FromTime(int hour, int minute, int second, int usecond)
2402
 
 
2403
 
    Return a ``datetime.time`` object with the specified hour, minute, second and
2404
 
    microsecond.
2405
 
@@ -121,7 +121,7 @@
2406
 
    .. versionadded:: 2.4
2407
 
 
2408
 
 
2409
 
-.. cfunction:: PyObject* PyDelta_FromDSU(int days, int seconds, int useconds)
2410
 
+.. c:function:: PyObject* PyDelta_FromDSU(int days, int seconds, int useconds)
2411
 
 
2412
 
    Return a ``datetime.timedelta`` object representing the given number of days,
2413
 
    seconds and microseconds.  Normalization is performed so that the resulting
2414
 
@@ -131,90 +131,90 @@
2415
 
    .. versionadded:: 2.4
2416
 
 
2417
 
 Macros to extract fields from date objects.  The argument must be an instance of
2418
 
-:cdata:`PyDateTime_Date`, including subclasses (such as
2419
 
-:cdata:`PyDateTime_DateTime`).  The argument must not be *NULL*, and the type is
2420
 
+:c:data:`PyDateTime_Date`, including subclasses (such as
2421
 
+:c:data:`PyDateTime_DateTime`).  The argument must not be *NULL*, and the type is
2422
 
 not checked:
2423
 
 
2424
 
 
2425
 
-.. cfunction:: int PyDateTime_GET_YEAR(PyDateTime_Date *o)
2426
 
+.. c:function:: int PyDateTime_GET_YEAR(PyDateTime_Date *o)
2427
 
 
2428
 
    Return the year, as a positive int.
2429
 
 
2430
 
    .. versionadded:: 2.4
2431
 
 
2432
 
 
2433
 
-.. cfunction:: int PyDateTime_GET_MONTH(PyDateTime_Date *o)
2434
 
+.. c:function:: int PyDateTime_GET_MONTH(PyDateTime_Date *o)
2435
 
 
2436
 
    Return the month, as an int from 1 through 12.
2437
 
 
2438
 
    .. versionadded:: 2.4
2439
 
 
2440
 
 
2441
 
-.. cfunction:: int PyDateTime_GET_DAY(PyDateTime_Date *o)
2442
 
+.. c:function:: int PyDateTime_GET_DAY(PyDateTime_Date *o)
2443
 
 
2444
 
    Return the day, as an int from 1 through 31.
2445
 
 
2446
 
    .. versionadded:: 2.4
2447
 
 
2448
 
 Macros to extract fields from datetime objects.  The argument must be an
2449
 
-instance of :cdata:`PyDateTime_DateTime`, including subclasses. The argument
2450
 
+instance of :c:data:`PyDateTime_DateTime`, including subclasses. The argument
2451
 
 must not be *NULL*, and the type is not checked:
2452
 
 
2453
 
 
2454
 
-.. cfunction:: int PyDateTime_DATE_GET_HOUR(PyDateTime_DateTime *o)
2455
 
+.. c:function:: int PyDateTime_DATE_GET_HOUR(PyDateTime_DateTime *o)
2456
 
 
2457
 
    Return the hour, as an int from 0 through 23.
2458
 
 
2459
 
    .. versionadded:: 2.4
2460
 
 
2461
 
 
2462
 
-.. cfunction:: int PyDateTime_DATE_GET_MINUTE(PyDateTime_DateTime *o)
2463
 
+.. c:function:: int PyDateTime_DATE_GET_MINUTE(PyDateTime_DateTime *o)
2464
 
 
2465
 
    Return the minute, as an int from 0 through 59.
2466
 
 
2467
 
    .. versionadded:: 2.4
2468
 
 
2469
 
 
2470
 
-.. cfunction:: int PyDateTime_DATE_GET_SECOND(PyDateTime_DateTime *o)
2471
 
+.. c:function:: int PyDateTime_DATE_GET_SECOND(PyDateTime_DateTime *o)
2472
 
 
2473
 
    Return the second, as an int from 0 through 59.
2474
 
 
2475
 
    .. versionadded:: 2.4
2476
 
 
2477
 
 
2478
 
-.. cfunction:: int PyDateTime_DATE_GET_MICROSECOND(PyDateTime_DateTime *o)
2479
 
+.. c:function:: int PyDateTime_DATE_GET_MICROSECOND(PyDateTime_DateTime *o)
2480
 
 
2481
 
    Return the microsecond, as an int from 0 through 999999.
2482
 
 
2483
 
    .. versionadded:: 2.4
2484
 
 
2485
 
 Macros to extract fields from time objects.  The argument must be an instance of
2486
 
-:cdata:`PyDateTime_Time`, including subclasses. The argument must not be *NULL*,
2487
 
+:c:data:`PyDateTime_Time`, including subclasses. The argument must not be *NULL*,
2488
 
 and the type is not checked:
2489
 
 
2490
 
 
2491
 
-.. cfunction:: int PyDateTime_TIME_GET_HOUR(PyDateTime_Time *o)
2492
 
+.. c:function:: int PyDateTime_TIME_GET_HOUR(PyDateTime_Time *o)
2493
 
 
2494
 
    Return the hour, as an int from 0 through 23.
2495
 
 
2496
 
    .. versionadded:: 2.4
2497
 
 
2498
 
 
2499
 
-.. cfunction:: int PyDateTime_TIME_GET_MINUTE(PyDateTime_Time *o)
2500
 
+.. c:function:: int PyDateTime_TIME_GET_MINUTE(PyDateTime_Time *o)
2501
 
 
2502
 
    Return the minute, as an int from 0 through 59.
2503
 
 
2504
 
    .. versionadded:: 2.4
2505
 
 
2506
 
 
2507
 
-.. cfunction:: int PyDateTime_TIME_GET_SECOND(PyDateTime_Time *o)
2508
 
+.. c:function:: int PyDateTime_TIME_GET_SECOND(PyDateTime_Time *o)
2509
 
 
2510
 
    Return the second, as an int from 0 through 59.
2511
 
 
2512
 
    .. versionadded:: 2.4
2513
 
 
2514
 
 
2515
 
-.. cfunction:: int PyDateTime_TIME_GET_MICROSECOND(PyDateTime_Time *o)
2516
 
+.. c:function:: int PyDateTime_TIME_GET_MICROSECOND(PyDateTime_Time *o)
2517
 
 
2518
 
    Return the microsecond, as an int from 0 through 999999.
2519
 
 
2520
 
@@ -223,7 +223,7 @@
2521
 
 Macros for the convenience of modules implementing the DB API:
2522
 
 
2523
 
 
2524
 
-.. cfunction:: PyObject* PyDateTime_FromTimestamp(PyObject *args)
2525
 
+.. c:function:: PyObject* PyDateTime_FromTimestamp(PyObject *args)
2526
 
 
2527
 
    Create and return a new ``datetime.datetime`` object given an argument tuple
2528
 
    suitable for passing to ``datetime.datetime.fromtimestamp()``.
2529
 
@@ -231,7 +231,7 @@
2530
 
    .. versionadded:: 2.4
2531
 
 
2532
 
 
2533
 
-.. cfunction:: PyObject* PyDate_FromTimestamp(PyObject *args)
2534
 
+.. c:function:: PyObject* PyDate_FromTimestamp(PyObject *args)
2535
 
 
2536
 
    Create and return a new ``datetime.date`` object given an argument tuple
2537
 
    suitable for passing to ``datetime.date.fromtimestamp()``.
2538
 
diff -r 8527427914a2 Doc/c-api/descriptor.rst
2539
 
--- a/Doc/c-api/descriptor.rst
2540
 
+++ b/Doc/c-api/descriptor.rst
2541
 
@@ -9,39 +9,39 @@
2542
 
 found in the dictionary of type objects.
2543
 
 
2544
 
 
2545
 
-.. cvar:: PyTypeObject PyProperty_Type
2546
 
+.. c:var:: PyTypeObject PyProperty_Type
2547
 
 
2548
 
    The type object for the built-in descriptor types.
2549
 
 
2550
 
    .. versionadded:: 2.2
2551
 
 
2552
 
 
2553
 
-.. cfunction:: PyObject* PyDescr_NewGetSet(PyTypeObject *type, struct PyGetSetDef *getset)
2554
 
+.. c:function:: PyObject* PyDescr_NewGetSet(PyTypeObject *type, struct PyGetSetDef *getset)
2555
 
 
2556
 
    .. versionadded:: 2.2
2557
 
 
2558
 
 
2559
 
-.. cfunction:: PyObject* PyDescr_NewMember(PyTypeObject *type, struct PyMemberDef *meth)
2560
 
+.. c:function:: PyObject* PyDescr_NewMember(PyTypeObject *type, struct PyMemberDef *meth)
2561
 
 
2562
 
    .. versionadded:: 2.2
2563
 
 
2564
 
 
2565
 
-.. cfunction:: PyObject* PyDescr_NewMethod(PyTypeObject *type, struct PyMethodDef *meth)
2566
 
+.. c:function:: PyObject* PyDescr_NewMethod(PyTypeObject *type, struct PyMethodDef *meth)
2567
 
 
2568
 
    .. versionadded:: 2.2
2569
 
 
2570
 
 
2571
 
-.. cfunction:: PyObject* PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *wrapper, void *wrapped)
2572
 
+.. c:function:: PyObject* PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *wrapper, void *wrapped)
2573
 
 
2574
 
    .. versionadded:: 2.2
2575
 
 
2576
 
 
2577
 
-.. cfunction:: PyObject* PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method)
2578
 
+.. c:function:: PyObject* PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method)
2579
 
 
2580
 
    .. versionadded:: 2.3
2581
 
 
2582
 
 
2583
 
-.. cfunction:: int PyDescr_IsData(PyObject *descr)
2584
 
+.. c:function:: int PyDescr_IsData(PyObject *descr)
2585
 
 
2586
 
    Return true if the descriptor objects *descr* describes a data attribute, or
2587
 
    false if it describes a method.  *descr* must be a descriptor object; there is
2588
 
@@ -50,6 +50,6 @@
2589
 
    .. versionadded:: 2.2
2590
 
 
2591
 
 
2592
 
-.. cfunction:: PyObject* PyWrapper_New(PyObject *, PyObject *)
2593
 
+.. c:function:: PyObject* PyWrapper_New(PyObject *, PyObject *)
2594
 
 
2595
 
    .. versionadded:: 2.2
2596
 
diff -r 8527427914a2 Doc/c-api/dict.rst
2597
 
--- a/Doc/c-api/dict.rst
2598
 
+++ b/Doc/c-api/dict.rst
2599
 
@@ -8,23 +8,23 @@
2600
 
 .. index:: object: dictionary
2601
 
 
2602
 
 
2603
 
-.. ctype:: PyDictObject
2604
 
+.. c:type:: PyDictObject
2605
 
 
2606
 
-   This subtype of :ctype:`PyObject` represents a Python dictionary object.
2607
 
+   This subtype of :c:type:`PyObject` represents a Python dictionary object.
2608
 
 
2609
 
 
2610
 
-.. cvar:: PyTypeObject PyDict_Type
2611
 
+.. c:var:: PyTypeObject PyDict_Type
2612
 
 
2613
 
    .. index::
2614
 
       single: DictType (in module types)
2615
 
       single: DictionaryType (in module types)
2616
 
 
2617
 
-   This instance of :ctype:`PyTypeObject` represents the Python dictionary
2618
 
+   This instance of :c:type:`PyTypeObject` represents the Python dictionary
2619
 
    type.  This is exposed to Python programs as ``dict`` and
2620
 
    ``types.DictType``.
2621
 
 
2622
 
 
2623
 
-.. cfunction:: int PyDict_Check(PyObject *p)
2624
 
+.. c:function:: int PyDict_Check(PyObject *p)
2625
 
 
2626
 
    Return true if *p* is a dict object or an instance of a subtype of the dict
2627
 
    type.
2628
 
@@ -33,7 +33,7 @@
2629
 
       Allowed subtypes to be accepted.
2630
 
 
2631
 
 
2632
 
-.. cfunction:: int PyDict_CheckExact(PyObject *p)
2633
 
+.. c:function:: int PyDict_CheckExact(PyObject *p)
2634
 
 
2635
 
    Return true if *p* is a dict object, but not an instance of a subtype of
2636
 
    the dict type.
2637
 
@@ -41,12 +41,12 @@
2638
 
    .. versionadded:: 2.4
2639
 
 
2640
 
 
2641
 
-.. cfunction:: PyObject* PyDict_New()
2642
 
+.. c:function:: PyObject* PyDict_New()
2643
 
 
2644
 
    Return a new empty dictionary, or *NULL* on failure.
2645
 
 
2646
 
 
2647
 
-.. cfunction:: PyObject* PyDictProxy_New(PyObject *dict)
2648
 
+.. c:function:: PyObject* PyDictProxy_New(PyObject *dict)
2649
 
 
2650
 
    Return a proxy object for a mapping which enforces read-only behavior.
2651
 
    This is normally used to create a proxy to prevent modification of the
2652
 
@@ -55,12 +55,12 @@
2653
 
    .. versionadded:: 2.2
2654
 
 
2655
 
 
2656
 
-.. cfunction:: void PyDict_Clear(PyObject *p)
2657
 
+.. c:function:: void PyDict_Clear(PyObject *p)
2658
 
 
2659
 
    Empty an existing dictionary of all key-value pairs.
2660
 
 
2661
 
 
2662
 
-.. cfunction:: int PyDict_Contains(PyObject *p, PyObject *key)
2663
 
+.. c:function:: int PyDict_Contains(PyObject *p, PyObject *key)
2664
 
 
2665
 
    Determine if dictionary *p* contains *key*.  If an item in *p* is matches
2666
 
    *key*, return ``1``, otherwise return ``0``.  On error, return ``-1``.
2667
 
@@ -69,74 +69,74 @@
2668
 
    .. versionadded:: 2.4
2669
 
 
2670
 
 
2671
 
-.. cfunction:: PyObject* PyDict_Copy(PyObject *p)
2672
 
+.. c:function:: PyObject* PyDict_Copy(PyObject *p)
2673
 
 
2674
 
    Return a new dictionary that contains the same key-value pairs as *p*.
2675
 
 
2676
 
    .. versionadded:: 1.6
2677
 
 
2678
 
 
2679
 
-.. cfunction:: int PyDict_SetItem(PyObject *p, PyObject *key, PyObject *val)
2680
 
+.. c:function:: int PyDict_SetItem(PyObject *p, PyObject *key, PyObject *val)
2681
 
 
2682
 
    Insert *value* into the dictionary *p* with a key of *key*.  *key* must be
2683
 
    :term:`hashable`; if it isn't, :exc:`TypeError` will be raised. Return
2684
 
    ``0`` on success or ``-1`` on failure.
2685
 
 
2686
 
 
2687
 
-.. cfunction:: int PyDict_SetItemString(PyObject *p, const char *key, PyObject *val)
2688
 
+.. c:function:: int PyDict_SetItemString(PyObject *p, const char *key, PyObject *val)
2689
 
 
2690
 
    .. index:: single: PyString_FromString()
2691
 
 
2692
 
    Insert *value* into the dictionary *p* using *key* as a key. *key* should
2693
 
-   be a :ctype:`char\*`.  The key object is created using
2694
 
+   be a :c:type:`char\*`.  The key object is created using
2695
 
    ``PyString_FromString(key)``.  Return ``0`` on success or ``-1`` on
2696
 
    failure.
2697
 
 
2698
 
 
2699
 
-.. cfunction:: int PyDict_DelItem(PyObject *p, PyObject *key)
2700
 
+.. c:function:: int PyDict_DelItem(PyObject *p, PyObject *key)
2701
 
 
2702
 
    Remove the entry in dictionary *p* with key *key*. *key* must be hashable;
2703
 
    if it isn't, :exc:`TypeError` is raised.  Return ``0`` on success or ``-1``
2704
 
    on failure.
2705
 
 
2706
 
 
2707
 
-.. cfunction:: int PyDict_DelItemString(PyObject *p, char *key)
2708
 
+.. c:function:: int PyDict_DelItemString(PyObject *p, char *key)
2709
 
 
2710
 
    Remove the entry in dictionary *p* which has a key specified by the string
2711
 
    *key*.  Return ``0`` on success or ``-1`` on failure.
2712
 
 
2713
 
 
2714
 
-.. cfunction:: PyObject* PyDict_GetItem(PyObject *p, PyObject *key)
2715
 
+.. c:function:: PyObject* PyDict_GetItem(PyObject *p, PyObject *key)
2716
 
 
2717
 
    Return the object from dictionary *p* which has a key *key*.  Return *NULL*
2718
 
    if the key *key* is not present, but *without* setting an exception.
2719
 
 
2720
 
 
2721
 
-.. cfunction:: PyObject* PyDict_GetItemString(PyObject *p, const char *key)
2722
 
+.. c:function:: PyObject* PyDict_GetItemString(PyObject *p, const char *key)
2723
 
 
2724
 
-   This is the same as :cfunc:`PyDict_GetItem`, but *key* is specified as a
2725
 
-   :ctype:`char\*`, rather than a :ctype:`PyObject\*`.
2726
 
+   This is the same as :c:func:`PyDict_GetItem`, but *key* is specified as a
2727
 
+   :c:type:`char\*`, rather than a :c:type:`PyObject\*`.
2728
 
 
2729
 
 
2730
 
-.. cfunction:: PyObject* PyDict_Items(PyObject *p)
2731
 
+.. c:function:: PyObject* PyDict_Items(PyObject *p)
2732
 
 
2733
 
-   Return a :ctype:`PyListObject` containing all the items from the
2734
 
+   Return a :c:type:`PyListObject` containing all the items from the
2735
 
    dictionary, as in the dictionary method :meth:`dict.items`.
2736
 
 
2737
 
 
2738
 
-.. cfunction:: PyObject* PyDict_Keys(PyObject *p)
2739
 
+.. c:function:: PyObject* PyDict_Keys(PyObject *p)
2740
 
 
2741
 
-   Return a :ctype:`PyListObject` containing all the keys from the dictionary,
2742
 
+   Return a :c:type:`PyListObject` containing all the keys from the dictionary,
2743
 
    as in the dictionary method :meth:`dict.keys`.
2744
 
 
2745
 
 
2746
 
-.. cfunction:: PyObject* PyDict_Values(PyObject *p)
2747
 
+.. c:function:: PyObject* PyDict_Values(PyObject *p)
2748
 
 
2749
 
-   Return a :ctype:`PyListObject` containing all the values from the
2750
 
+   Return a :c:type:`PyListObject` containing all the values from the
2751
 
    dictionary *p*, as in the dictionary method :meth:`dict.values`.
2752
 
 
2753
 
 
2754
 
-.. cfunction:: Py_ssize_t PyDict_Size(PyObject *p)
2755
 
+.. c:function:: Py_ssize_t PyDict_Size(PyObject *p)
2756
 
 
2757
 
    .. index:: builtin: len
2758
 
 
2759
 
@@ -144,18 +144,18 @@
2760
 
    ``len(p)`` on a dictionary.
2761
 
 
2762
 
    .. versionchanged:: 2.5
2763
 
-      This function returned an :ctype:`int` type.  This might require changes
2764
 
+      This function returned an :c:type:`int` type.  This might require changes
2765
 
       in your code for properly supporting 64-bit systems.
2766
 
 
2767
 
 
2768
 
-.. cfunction:: int PyDict_Next(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue)
2769
 
+.. c:function:: int PyDict_Next(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue)
2770
 
 
2771
 
    Iterate over all key-value pairs in the dictionary *p*.  The
2772
 
-   :ctype:`Py_ssize_t` referred to by *ppos* must be initialized to ``0``
2773
 
+   :c:type:`Py_ssize_t` referred to by *ppos* must be initialized to ``0``
2774
 
    prior to the first call to this function to start the iteration; the
2775
 
    function returns true for each pair in the dictionary, and false once all
2776
 
    pairs have been reported.  The parameters *pkey* and *pvalue* should either
2777
 
-   point to :ctype:`PyObject\*` variables that will be filled in with each key
2778
 
+   point to :c:type:`PyObject\*` variables that will be filled in with each key
2779
 
    and value, respectively, or may be *NULL*.  Any references returned through
2780
 
    them are borrowed.  *ppos* should not be altered during iteration. Its
2781
 
    value represents offsets within the internal dictionary structure, and
2782
 
@@ -192,15 +192,15 @@
2783
 
       }
2784
 
 
2785
 
    .. versionchanged:: 2.5
2786
 
-      This function used an :ctype:`int *` type for *ppos*. This might require
2787
 
+      This function used an :c:type:`int *` type for *ppos*. This might require
2788
 
       changes in your code for properly supporting 64-bit systems.
2789
 
 
2790
 
 
2791
 
-.. cfunction:: int PyDict_Merge(PyObject *a, PyObject *b, int override)
2792
 
+.. c:function:: int PyDict_Merge(PyObject *a, PyObject *b, int override)
2793
 
 
2794
 
    Iterate over mapping object *b* adding key-value pairs to dictionary *a*.
2795
 
-   *b* may be a dictionary, or any object supporting :cfunc:`PyMapping_Keys`
2796
 
-   and :cfunc:`PyObject_GetItem`. If *override* is true, existing pairs in *a*
2797
 
+   *b* may be a dictionary, or any object supporting :c:func:`PyMapping_Keys`
2798
 
+   and :c:func:`PyObject_GetItem`. If *override* is true, existing pairs in *a*
2799
 
    will be replaced if a matching key is found in *b*, otherwise pairs will
2800
 
    only be added if there is not a matching key in *a*. Return ``0`` on
2801
 
    success or ``-1`` if an exception was raised.
2802
 
@@ -208,7 +208,7 @@
2803
 
    .. versionadded:: 2.2
2804
 
 
2805
 
 
2806
 
-.. cfunction:: int PyDict_Update(PyObject *a, PyObject *b)
2807
 
+.. c:function:: int PyDict_Update(PyObject *a, PyObject *b)
2808
 
 
2809
 
    This is the same as ``PyDict_Merge(a, b, 1)`` in C, or ``a.update(b)`` in
2810
 
    Python.  Return ``0`` on success or ``-1`` if an exception was raised.
2811
 
@@ -216,7 +216,7 @@
2812
 
    .. versionadded:: 2.2
2813
 
 
2814
 
 
2815
 
-.. cfunction:: int PyDict_MergeFromSeq2(PyObject *a, PyObject *seq2, int override)
2816
 
+.. c:function:: int PyDict_MergeFromSeq2(PyObject *a, PyObject *seq2, int override)
2817
 
 
2818
 
    Update or merge into dictionary *a*, from the key-value pairs in *seq2*.
2819
 
    *seq2* must be an iterable object producing iterable objects of length 2,
2820
 
diff -r 8527427914a2 Doc/c-api/exceptions.rst
2821
 
--- a/Doc/c-api/exceptions.rst
2822
 
+++ b/Doc/c-api/exceptions.rst
2823
 
@@ -9,12 +9,12 @@
2824
 
 
2825
 
 The functions described in this chapter will let you handle and raise Python
2826
 
 exceptions.  It is important to understand some of the basics of Python
2827
 
-exception handling.  It works somewhat like the Unix :cdata:`errno` variable:
2828
 
+exception handling.  It works somewhat like the Unix :c:data:`errno` variable:
2829
 
 there is a global indicator (per thread) of the last error that occurred.  Most
2830
 
 functions don't clear this on success, but will set it to indicate the cause of
2831
 
 the error on failure.  Most functions also return an error indicator, usually
2832
 
 *NULL* if they are supposed to return a pointer, or ``-1`` if they return an
2833
 
-integer (exception: the :cfunc:`PyArg_\*` functions return ``1`` for success and
2834
 
+integer (exception: the :c:func:`PyArg_\*` functions return ``1`` for success and
2835
 
 ``0`` for failure).
2836
 
 
2837
 
 When a function must fail because some function it called failed, it generally
2838
 
@@ -41,7 +41,7 @@
2839
 
    Either alphabetical or some kind of structure.
2840
 
 
2841
 
 
2842
 
-.. cfunction:: void PyErr_PrintEx(int set_sys_last_vars)
2843
 
+.. c:function:: void PyErr_PrintEx(int set_sys_last_vars)
2844
 
 
2845
 
    Print a standard traceback to ``sys.stderr`` and clear the error indicator.
2846
 
    Call this function only when the error indicator is set.  (Otherwise it will
2847
 
@@ -52,35 +52,35 @@
2848
 
    type, value and traceback of the printed exception, respectively.
2849
 
 
2850
 
 
2851
 
-.. cfunction:: void PyErr_Print()
2852
 
+.. c:function:: void PyErr_Print()
2853
 
 
2854
 
    Alias for ``PyErr_PrintEx(1)``.
2855
 
 
2856
 
 
2857
 
-.. cfunction:: PyObject* PyErr_Occurred()
2858
 
+.. c:function:: PyObject* PyErr_Occurred()
2859
 
 
2860
 
    Test whether the error indicator is set.  If set, return the exception *type*
2861
 
-   (the first argument to the last call to one of the :cfunc:`PyErr_Set\*`
2862
 
-   functions or to :cfunc:`PyErr_Restore`).  If not set, return *NULL*.  You do not
2863
 
-   own a reference to the return value, so you do not need to :cfunc:`Py_DECREF`
2864
 
+   (the first argument to the last call to one of the :c:func:`PyErr_Set\*`
2865
 
+   functions or to :c:func:`PyErr_Restore`).  If not set, return *NULL*.  You do not
2866
 
+   own a reference to the return value, so you do not need to :c:func:`Py_DECREF`
2867
 
    it.
2868
 
 
2869
 
    .. note::
2870
 
 
2871
 
       Do not compare the return value to a specific exception; use
2872
 
-      :cfunc:`PyErr_ExceptionMatches` instead, shown below.  (The comparison could
2873
 
+      :c:func:`PyErr_ExceptionMatches` instead, shown below.  (The comparison could
2874
 
       easily fail since the exception may be an instance instead of a class, in the
2875
 
       case of a class exception, or it may the a subclass of the expected exception.)
2876
 
 
2877
 
 
2878
 
-.. cfunction:: int PyErr_ExceptionMatches(PyObject *exc)
2879
 
+.. c:function:: int PyErr_ExceptionMatches(PyObject *exc)
2880
 
 
2881
 
    Equivalent to ``PyErr_GivenExceptionMatches(PyErr_Occurred(), exc)``.  This
2882
 
    should only be called when an exception is actually set; a memory access
2883
 
    violation will occur if no exception has been raised.
2884
 
 
2885
 
 
2886
 
-.. cfunction:: int PyErr_GivenExceptionMatches(PyObject *given, PyObject *exc)
2887
 
+.. c:function:: int PyErr_GivenExceptionMatches(PyObject *given, PyObject *exc)
2888
 
 
2889
 
    Return true if the *given* exception matches the exception in *exc*.  If
2890
 
    *exc* is a class object, this also returns true when *given* is an instance
2891
 
@@ -88,22 +88,22 @@
2892
 
    recursively in subtuples) are searched for a match.
2893
 
 
2894
 
 
2895
 
-.. cfunction:: void PyErr_NormalizeException(PyObject**exc, PyObject**val, PyObject**tb)
2896
 
+.. c:function:: void PyErr_NormalizeException(PyObject**exc, PyObject**val, PyObject**tb)
2897
 
 
2898
 
-   Under certain circumstances, the values returned by :cfunc:`PyErr_Fetch` below
2899
 
+   Under certain circumstances, the values returned by :c:func:`PyErr_Fetch` below
2900
 
    can be "unnormalized", meaning that ``*exc`` is a class object but ``*val`` is
2901
 
    not an instance of the  same class.  This function can be used to instantiate
2902
 
    the class in that case.  If the values are already normalized, nothing happens.
2903
 
    The delayed normalization is implemented to improve performance.
2904
 
 
2905
 
 
2906
 
-.. cfunction:: void PyErr_Clear()
2907
 
+.. c:function:: void PyErr_Clear()
2908
 
 
2909
 
    Clear the error indicator.  If the error indicator is not set, there is no
2910
 
    effect.
2911
 
 
2912
 
 
2913
 
-.. cfunction:: void PyErr_Fetch(PyObject **ptype, PyObject **pvalue, PyObject **ptraceback)
2914
 
+.. c:function:: void PyErr_Fetch(PyObject **ptype, PyObject **pvalue, PyObject **ptraceback)
2915
 
 
2916
 
    Retrieve the error indicator into three variables whose addresses are passed.
2917
 
    If the error indicator is not set, set all three variables to *NULL*.  If it is
2918
 
@@ -116,7 +116,7 @@
2919
 
       by code that needs to save and restore the error indicator temporarily.
2920
 
 
2921
 
 
2922
 
-.. cfunction:: void PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback)
2923
 
+.. c:function:: void PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback)
2924
 
 
2925
 
    Set  the error indicator from the three objects.  If the error indicator is
2926
 
    already set, it is cleared first.  If the objects are *NULL*, the error
2927
 
@@ -131,111 +131,111 @@
2928
 
    .. note::
2929
 
 
2930
 
       This function is normally only used by code that needs to save and restore the
2931
 
-      error indicator temporarily; use :cfunc:`PyErr_Fetch` to save the current
2932
 
+      error indicator temporarily; use :c:func:`PyErr_Fetch` to save the current
2933
 
       exception state.
2934
 
 
2935
 
 
2936
 
-.. cfunction:: void PyErr_SetString(PyObject *type, const char *message)
2937
 
+.. c:function:: void PyErr_SetString(PyObject *type, const char *message)
2938
 
 
2939
 
    This is the most common way to set the error indicator.  The first argument
2940
 
    specifies the exception type; it is normally one of the standard exceptions,
2941
 
-   e.g. :cdata:`PyExc_RuntimeError`.  You need not increment its reference count.
2942
 
+   e.g. :c:data:`PyExc_RuntimeError`.  You need not increment its reference count.
2943
 
    The second argument is an error message; it is converted to a string object.
2944
 
 
2945
 
 
2946
 
-.. cfunction:: void PyErr_SetObject(PyObject *type, PyObject *value)
2947
 
+.. c:function:: void PyErr_SetObject(PyObject *type, PyObject *value)
2948
 
 
2949
 
-   This function is similar to :cfunc:`PyErr_SetString` but lets you specify an
2950
 
+   This function is similar to :c:func:`PyErr_SetString` but lets you specify an
2951
 
    arbitrary Python object for the "value" of the exception.
2952
 
 
2953
 
 
2954
 
-.. cfunction:: PyObject* PyErr_Format(PyObject *exception, const char *format, ...)
2955
 
+.. c:function:: PyObject* PyErr_Format(PyObject *exception, const char *format, ...)
2956
 
 
2957
 
    This function sets the error indicator and returns *NULL*.  *exception*
2958
 
    should be a Python exception class.  The *format* and subsequent
2959
 
    parameters help format the error message; they have the same meaning and
2960
 
-   values as in :cfunc:`PyString_FromFormat`.
2961
 
+   values as in :c:func:`PyString_FromFormat`.
2962
 
 
2963
 
 
2964
 
-.. cfunction:: void PyErr_SetNone(PyObject *type)
2965
 
+.. c:function:: void PyErr_SetNone(PyObject *type)
2966
 
 
2967
 
    This is a shorthand for ``PyErr_SetObject(type, Py_None)``.
2968
 
 
2969
 
 
2970
 
-.. cfunction:: int PyErr_BadArgument()
2971
 
+.. c:function:: int PyErr_BadArgument()
2972
 
 
2973
 
    This is a shorthand for ``PyErr_SetString(PyExc_TypeError, message)``, where
2974
 
    *message* indicates that a built-in operation was invoked with an illegal
2975
 
    argument.  It is mostly for internal use.
2976
 
 
2977
 
 
2978
 
-.. cfunction:: PyObject* PyErr_NoMemory()
2979
 
+.. c:function:: PyObject* PyErr_NoMemory()
2980
 
 
2981
 
    This is a shorthand for ``PyErr_SetNone(PyExc_MemoryError)``; it returns *NULL*
2982
 
    so an object allocation function can write ``return PyErr_NoMemory();`` when it
2983
 
    runs out of memory.
2984
 
 
2985
 
 
2986
 
-.. cfunction:: PyObject* PyErr_SetFromErrno(PyObject *type)
2987
 
+.. c:function:: PyObject* PyErr_SetFromErrno(PyObject *type)
2988
 
 
2989
 
    .. index:: single: strerror()
2990
 
 
2991
 
    This is a convenience function to raise an exception when a C library function
2992
 
-   has returned an error and set the C variable :cdata:`errno`.  It constructs a
2993
 
-   tuple object whose first item is the integer :cdata:`errno` value and whose
2994
 
-   second item is the corresponding error message (gotten from :cfunc:`strerror`),
2995
 
+   has returned an error and set the C variable :c:data:`errno`.  It constructs a
2996
 
+   tuple object whose first item is the integer :c:data:`errno` value and whose
2997
 
+   second item is the corresponding error message (gotten from :c:func:`strerror`),
2998
 
    and then calls ``PyErr_SetObject(type, object)``.  On Unix, when the
2999
 
-   :cdata:`errno` value is :const:`EINTR`, indicating an interrupted system call,
3000
 
-   this calls :cfunc:`PyErr_CheckSignals`, and if that set the error indicator,
3001
 
+   :c:data:`errno` value is :const:`EINTR`, indicating an interrupted system call,
3002
 
+   this calls :c:func:`PyErr_CheckSignals`, and if that set the error indicator,
3003
 
    leaves it set to that.  The function always returns *NULL*, so a wrapper
3004
 
    function around a system call can write ``return PyErr_SetFromErrno(type);``
3005
 
    when the system call returns an error.
3006
 
 
3007
 
 
3008
 
-.. cfunction:: PyObject* PyErr_SetFromErrnoWithFilename(PyObject *type, const char *filename)
3009
 
+.. c:function:: PyObject* PyErr_SetFromErrnoWithFilename(PyObject *type, const char *filename)
3010
 
 
3011
 
-   Similar to :cfunc:`PyErr_SetFromErrno`, with the additional behavior that if
3012
 
+   Similar to :c:func:`PyErr_SetFromErrno`, with the additional behavior that if
3013
 
    *filename* is not *NULL*, it is passed to the constructor of *type* as a third
3014
 
    parameter.  In the case of exceptions such as :exc:`IOError` and :exc:`OSError`,
3015
 
    this is used to define the :attr:`filename` attribute of the exception instance.
3016
 
 
3017
 
 
3018
 
-.. cfunction:: PyObject* PyErr_SetFromWindowsErr(int ierr)
3019
 
+.. c:function:: PyObject* PyErr_SetFromWindowsErr(int ierr)
3020
 
 
3021
 
    This is a convenience function to raise :exc:`WindowsError`. If called with
3022
 
-   *ierr* of :cdata:`0`, the error code returned by a call to :cfunc:`GetLastError`
3023
 
-   is used instead.  It calls the Win32 function :cfunc:`FormatMessage` to retrieve
3024
 
-   the Windows description of error code given by *ierr* or :cfunc:`GetLastError`,
3025
 
+   *ierr* of :c:data:`0`, the error code returned by a call to :c:func:`GetLastError`
3026
 
+   is used instead.  It calls the Win32 function :c:func:`FormatMessage` to retrieve
3027
 
+   the Windows description of error code given by *ierr* or :c:func:`GetLastError`,
3028
 
    then it constructs a tuple object whose first item is the *ierr* value and whose
3029
 
    second item is the corresponding error message (gotten from
3030
 
-   :cfunc:`FormatMessage`), and then calls ``PyErr_SetObject(PyExc_WindowsError,
3031
 
+   :c:func:`FormatMessage`), and then calls ``PyErr_SetObject(PyExc_WindowsError,
3032
 
    object)``. This function always returns *NULL*. Availability: Windows.
3033
 
 
3034
 
 
3035
 
-.. cfunction:: PyObject* PyErr_SetExcFromWindowsErr(PyObject *type, int ierr)
3036
 
+.. c:function:: PyObject* PyErr_SetExcFromWindowsErr(PyObject *type, int ierr)
3037
 
 
3038
 
-   Similar to :cfunc:`PyErr_SetFromWindowsErr`, with an additional parameter
3039
 
+   Similar to :c:func:`PyErr_SetFromWindowsErr`, with an additional parameter
3040
 
    specifying the exception type to be raised. Availability: Windows.
3041
 
 
3042
 
    .. versionadded:: 2.3
3043
 
 
3044
 
 
3045
 
-.. cfunction:: PyObject* PyErr_SetFromWindowsErrWithFilename(int ierr, const char *filename)
3046
 
+.. c:function:: PyObject* PyErr_SetFromWindowsErrWithFilename(int ierr, const char *filename)
3047
 
 
3048
 
-   Similar to :cfunc:`PyErr_SetFromWindowsErr`, with the additional behavior that
3049
 
+   Similar to :c:func:`PyErr_SetFromWindowsErr`, with the additional behavior that
3050
 
    if *filename* is not *NULL*, it is passed to the constructor of
3051
 
    :exc:`WindowsError` as a third parameter. Availability: Windows.
3052
 
 
3053
 
 
3054
 
-.. cfunction:: PyObject* PyErr_SetExcFromWindowsErrWithFilename(PyObject *type, int ierr, char *filename)
3055
 
+.. c:function:: PyObject* PyErr_SetExcFromWindowsErrWithFilename(PyObject *type, int ierr, char *filename)
3056
 
 
3057
 
-   Similar to :cfunc:`PyErr_SetFromWindowsErrWithFilename`, with an additional
3058
 
+   Similar to :c:func:`PyErr_SetFromWindowsErrWithFilename`, with an additional
3059
 
    parameter specifying the exception type to be raised. Availability: Windows.
3060
 
 
3061
 
    .. versionadded:: 2.3
3062
 
 
3063
 
 
3064
 
-.. cfunction:: void PyErr_BadInternalCall()
3065
 
+.. c:function:: void PyErr_BadInternalCall()
3066
 
 
3067
 
    This is a shorthand for ``PyErr_SetString(PyExc_SystemError, message)``,
3068
 
    where *message* indicates that an internal operation (e.g. a Python/C API
3069
 
@@ -243,13 +243,13 @@
3070
 
    use.
3071
 
 
3072
 
 
3073
 
-.. cfunction:: int PyErr_WarnEx(PyObject *category, char *message, int stacklevel)
3074
 
+.. c:function:: int PyErr_WarnEx(PyObject *category, char *message, int stacklevel)
3075
 
 
3076
 
    Issue a warning message.  The *category* argument is a warning category (see
3077
 
    below) or *NULL*; the *message* argument is a message string.  *stacklevel* is a
3078
 
    positive number giving a number of stack frames; the warning will be issued from
3079
 
    the  currently executing line of code in that stack frame.  A *stacklevel* of 1
3080
 
-   is the function calling :cfunc:`PyErr_WarnEx`, 2 is  the function above that,
3081
 
+   is the function calling :c:func:`PyErr_WarnEx`, 2 is  the function above that,
3082
 
    and so forth.
3083
 
 
3084
 
    This function normally prints a warning message to *sys.stderr*; however, it is
3085
 
@@ -261,36 +261,36 @@
3086
 
    is raised.  (It is not possible to determine whether a warning message is
3087
 
    actually printed, nor what the reason is for the exception; this is
3088
 
    intentional.)  If an exception is raised, the caller should do its normal
3089
 
-   exception handling (for example, :cfunc:`Py_DECREF` owned references and return
3090
 
+   exception handling (for example, :c:func:`Py_DECREF` owned references and return
3091
 
    an error value).
3092
 
 
3093
 
-   Warning categories must be subclasses of :cdata:`Warning`; the default warning
3094
 
-   category is :cdata:`RuntimeWarning`.  The standard Python warning categories are
3095
 
+   Warning categories must be subclasses of :c:data:`Warning`; the default warning
3096
 
+   category is :c:data:`RuntimeWarning`.  The standard Python warning categories are
3097
 
    available as global variables whose names are ``PyExc_`` followed by the Python
3098
 
-   exception name. These have the type :ctype:`PyObject\*`; they are all class
3099
 
-   objects. Their names are :cdata:`PyExc_Warning`, :cdata:`PyExc_UserWarning`,
3100
 
-   :cdata:`PyExc_UnicodeWarning`, :cdata:`PyExc_DeprecationWarning`,
3101
 
-   :cdata:`PyExc_SyntaxWarning`, :cdata:`PyExc_RuntimeWarning`, and
3102
 
-   :cdata:`PyExc_FutureWarning`.  :cdata:`PyExc_Warning` is a subclass of
3103
 
-   :cdata:`PyExc_Exception`; the other warning categories are subclasses of
3104
 
-   :cdata:`PyExc_Warning`.
3105
 
+   exception name. These have the type :c:type:`PyObject\*`; they are all class
3106
 
+   objects. Their names are :c:data:`PyExc_Warning`, :c:data:`PyExc_UserWarning`,
3107
 
+   :c:data:`PyExc_UnicodeWarning`, :c:data:`PyExc_DeprecationWarning`,
3108
 
+   :c:data:`PyExc_SyntaxWarning`, :c:data:`PyExc_RuntimeWarning`, and
3109
 
+   :c:data:`PyExc_FutureWarning`.  :c:data:`PyExc_Warning` is a subclass of
3110
 
+   :c:data:`PyExc_Exception`; the other warning categories are subclasses of
3111
 
+   :c:data:`PyExc_Warning`.
3112
 
 
3113
 
    For information about warning control, see the documentation for the
3114
 
    :mod:`warnings` module and the :option:`-W` option in the command line
3115
 
    documentation.  There is no C API for warning control.
3116
 
 
3117
 
 
3118
 
-.. cfunction:: int PyErr_Warn(PyObject *category, char *message)
3119
 
+.. c:function:: int PyErr_Warn(PyObject *category, char *message)
3120
 
 
3121
 
    Issue a warning message.  The *category* argument is a warning category (see
3122
 
    below) or *NULL*; the *message* argument is a message string.  The warning will
3123
 
-   appear to be issued from the function calling :cfunc:`PyErr_Warn`, equivalent to
3124
 
-   calling :cfunc:`PyErr_WarnEx` with a *stacklevel* of 1.
3125
 
+   appear to be issued from the function calling :c:func:`PyErr_Warn`, equivalent to
3126
 
+   calling :c:func:`PyErr_WarnEx` with a *stacklevel* of 1.
3127
 
 
3128
 
-   Deprecated; use :cfunc:`PyErr_WarnEx` instead.
3129
 
+   Deprecated; use :c:func:`PyErr_WarnEx` instead.
3130
 
 
3131
 
 
3132
 
-.. cfunction:: int PyErr_WarnExplicit(PyObject *category, const char *message, const char *filename, int lineno, const char *module, PyObject *registry)
3133
 
+.. c:function:: int PyErr_WarnExplicit(PyObject *category, const char *message, const char *filename, int lineno, const char *module, PyObject *registry)
3134
 
 
3135
 
    Issue a warning message with explicit control over all warning attributes.  This
3136
 
    is a straightforward wrapper around the Python function
3137
 
@@ -299,15 +299,15 @@
3138
 
    described there.
3139
 
 
3140
 
 
3141
 
-.. cfunction:: int PyErr_WarnPy3k(char *message, int stacklevel)
3142
 
+.. c:function:: int PyErr_WarnPy3k(char *message, int stacklevel)
3143
 
 
3144
 
    Issue a :exc:`DeprecationWarning` with the given *message* and *stacklevel*
3145
 
-   if the :cdata:`Py_Py3kWarningFlag` flag is enabled.
3146
 
+   if the :c:data:`Py_Py3kWarningFlag` flag is enabled.
3147
 
 
3148
 
    .. versionadded:: 2.6
3149
 
 
3150
 
 
3151
 
-.. cfunction:: int PyErr_CheckSignals()
3152
 
+.. c:function:: int PyErr_CheckSignals()
3153
 
 
3154
 
    .. index::
3155
 
       module: signal
3156
 
@@ -324,21 +324,21 @@
3157
 
    cleared if it was previously set.
3158
 
 
3159
 
 
3160
 
-.. cfunction:: void PyErr_SetInterrupt()
3161
 
+.. c:function:: void PyErr_SetInterrupt()
3162
 
 
3163
 
    .. index::
3164
 
       single: SIGINT
3165
 
       single: KeyboardInterrupt (built-in exception)
3166
 
 
3167
 
    This function simulates the effect of a :const:`SIGINT` signal arriving --- the
3168
 
-   next time :cfunc:`PyErr_CheckSignals` is called,  :exc:`KeyboardInterrupt` will
3169
 
+   next time :c:func:`PyErr_CheckSignals` is called,  :exc:`KeyboardInterrupt` will
3170
 
    be raised.  It may be called without holding the interpreter lock.
3171
 
 
3172
 
    .. % XXX This was described as obsolete, but is used in
3173
 
    .. % thread.interrupt_main() (used from IDLE), so it's still needed.
3174
 
 
3175
 
 
3176
 
-.. cfunction:: int PySignal_SetWakeupFd(int fd)
3177
 
+.. c:function:: int PySignal_SetWakeupFd(int fd)
3178
 
 
3179
 
    This utility function specifies a file descriptor to which a ``'\0'`` byte will
3180
 
    be written whenever a signal is received.  It returns the previous such file
3181
 
@@ -350,13 +350,13 @@
3182
 
    .. versionadded:: 2.6
3183
 
 
3184
 
 
3185
 
-.. cfunction:: PyObject* PyErr_NewException(char *name, PyObject *base, PyObject *dict)
3186
 
+.. c:function:: PyObject* PyErr_NewException(char *name, PyObject *base, PyObject *dict)
3187
 
 
3188
 
-   This utility function creates and returns a new exception object. The *name*
3189
 
+   This utility function creates and returns a new exception class. The *name*
3190
 
    argument must be the name of the new exception, a C string of the form
3191
 
-   ``module.class``.  The *base* and *dict* arguments are normally *NULL*.  This
3192
 
-   creates a class object derived from :exc:`Exception` (accessible in C as
3193
 
-   :cdata:`PyExc_Exception`).
3194
 
+   ``module.classname``.  The *base* and *dict* arguments are normally *NULL*.
3195
 
+   This creates a class object derived from :exc:`Exception` (accessible in C as
3196
 
+   :c:data:`PyExc_Exception`).
3197
 
 
3198
 
    The :attr:`__module__` attribute of the new class is set to the first part (up
3199
 
    to the last dot) of the *name* argument, and the class name is set to the last
3200
 
@@ -365,16 +365,16 @@
3201
 
    argument can be used to specify a dictionary of class variables and methods.
3202
 
 
3203
 
 
3204
 
-.. cfunction:: PyObject* PyErr_NewExceptionWithDoc(char *name, char *doc, PyObject *base, PyObject *dict)
3205
 
+.. c:function:: PyObject* PyErr_NewExceptionWithDoc(char *name, char *doc, PyObject *base, PyObject *dict)
3206
 
 
3207
 
-   Same as :cfunc:`PyErr_NewException`, except that the new exception class can
3208
 
+   Same as :c:func:`PyErr_NewException`, except that the new exception class can
3209
 
    easily be given a docstring: If *doc* is non-*NULL*, it will be used as the
3210
 
    docstring for the exception class.
3211
 
 
3212
 
    .. versionadded:: 2.7
3213
 
 
3214
 
 
3215
 
-.. cfunction:: void PyErr_WriteUnraisable(PyObject *obj)
3216
 
+.. c:function:: void PyErr_WriteUnraisable(PyObject *obj)
3217
 
 
3218
 
    This utility function prints a warning message to ``sys.stderr`` when an
3219
 
    exception has been set but it is impossible for the interpreter to actually
3220
 
@@ -393,33 +393,33 @@
3221
 
 
3222
 
 The following functions are used to create and modify Unicode exceptions from C.
3223
 
 
3224
 
-.. cfunction:: PyObject* PyUnicodeDecodeError_Create(const char *encoding, const char *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
3225
 
+.. c:function:: PyObject* PyUnicodeDecodeError_Create(const char *encoding, const char *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
3226
 
 
3227
 
    Create a :class:`UnicodeDecodeError` object with the attributes *encoding*,
3228
 
    *object*, *length*, *start*, *end* and *reason*.
3229
 
 
3230
 
-.. cfunction:: PyObject* PyUnicodeEncodeError_Create(const char *encoding, const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
3231
 
+.. c:function:: PyObject* PyUnicodeEncodeError_Create(const char *encoding, const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
3232
 
 
3233
 
    Create a :class:`UnicodeEncodeError` object with the attributes *encoding*,
3234
 
    *object*, *length*, *start*, *end* and *reason*.
3235
 
 
3236
 
-.. cfunction:: PyObject* PyUnicodeTranslateError_Create(const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
3237
 
+.. c:function:: PyObject* PyUnicodeTranslateError_Create(const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
3238
 
 
3239
 
    Create a :class:`UnicodeTranslateError` object with the attributes *object*,
3240
 
    *length*, *start*, *end* and *reason*.
3241
 
 
3242
 
-.. cfunction:: PyObject* PyUnicodeDecodeError_GetEncoding(PyObject *exc)
3243
 
+.. c:function:: PyObject* PyUnicodeDecodeError_GetEncoding(PyObject *exc)
3244
 
                PyObject* PyUnicodeEncodeError_GetEncoding(PyObject *exc)
3245
 
 
3246
 
    Return the *encoding* attribute of the given exception object.
3247
 
 
3248
 
-.. cfunction:: PyObject* PyUnicodeDecodeError_GetObject(PyObject *exc)
3249
 
+.. c:function:: PyObject* PyUnicodeDecodeError_GetObject(PyObject *exc)
3250
 
                PyObject* PyUnicodeEncodeError_GetObject(PyObject *exc)
3251
 
                PyObject* PyUnicodeTranslateError_GetObject(PyObject *exc)
3252
 
 
3253
 
    Return the *object* attribute of the given exception object.
3254
 
 
3255
 
-.. cfunction:: int PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start)
3256
 
+.. c:function:: int PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start)
3257
 
                int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start)
3258
 
                int PyUnicodeTranslateError_GetStart(PyObject *exc, Py_ssize_t *start)
3259
 
 
3260
 
@@ -427,14 +427,14 @@
3261
 
    *\*start*.  *start* must not be *NULL*.  Return ``0`` on success, ``-1`` on
3262
 
    failure.
3263
 
 
3264
 
-.. cfunction:: int PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start)
3265
 
+.. c:function:: int PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start)
3266
 
                int PyUnicodeEncodeError_SetStart(PyObject *exc, Py_ssize_t start)
3267
 
                int PyUnicodeTranslateError_SetStart(PyObject *exc, Py_ssize_t start)
3268
 
 
3269
 
    Set the *start* attribute of the given exception object to *start*.  Return
3270
 
    ``0`` on success, ``-1`` on failure.
3271
 
 
3272
 
-.. cfunction:: int PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
3273
 
+.. c:function:: int PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
3274
 
                int PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
3275
 
                int PyUnicodeTranslateError_GetEnd(PyObject *exc, Py_ssize_t *end)
3276
 
 
3277
 
@@ -442,20 +442,20 @@
3278
 
    *\*end*.  *end* must not be *NULL*.  Return ``0`` on success, ``-1`` on
3279
 
    failure.
3280
 
 
3281
 
-.. cfunction:: int PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end)
3282
 
+.. c:function:: int PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end)
3283
 
                int PyUnicodeEncodeError_SetEnd(PyObject *exc, Py_ssize_t end)
3284
 
                int PyUnicodeTranslateError_SetEnd(PyObject *exc, Py_ssize_t end)
3285
 
 
3286
 
    Set the *end* attribute of the given exception object to *end*.  Return ``0``
3287
 
    on success, ``-1`` on failure.
3288
 
 
3289
 
-.. cfunction:: PyObject* PyUnicodeDecodeError_GetReason(PyObject *exc)
3290
 
+.. c:function:: PyObject* PyUnicodeDecodeError_GetReason(PyObject *exc)
3291
 
                PyObject* PyUnicodeEncodeError_GetReason(PyObject *exc)
3292
 
                PyObject* PyUnicodeTranslateError_GetReason(PyObject *exc)
3293
 
 
3294
 
    Return the *reason* attribute of the given exception object.
3295
 
 
3296
 
-.. cfunction:: int PyUnicodeDecodeError_SetReason(PyObject *exc, const char *reason)
3297
 
+.. c:function:: int PyUnicodeDecodeError_SetReason(PyObject *exc, const char *reason)
3298
 
                int PyUnicodeEncodeError_SetReason(PyObject *exc, const char *reason)
3299
 
                int PyUnicodeTranslateError_SetReason(PyObject *exc, const char *reason)
3300
 
 
3301
 
@@ -471,12 +471,12 @@
3302
 
 recursive code does not necessarily invoke Python code (which tracks its
3303
 
 recursion depth automatically).
3304
 
 
3305
 
-.. cfunction:: int Py_EnterRecursiveCall(char *where)
3306
 
+.. c:function:: int Py_EnterRecursiveCall(char *where)
3307
 
 
3308
 
    Marks a point where a recursive C-level call is about to be performed.
3309
 
 
3310
 
-   If :const:`USE_STACKCHECK` is defined, this function checks if the the OS
3311
 
-   stack overflowed using :cfunc:`PyOS_CheckStack`.  In this is the case, it
3312
 
+   If :const:`USE_STACKCHECK` is defined, this function checks if the OS
3313
 
+   stack overflowed using :c:func:`PyOS_CheckStack`.  In this is the case, it
3314
 
    sets a :exc:`MemoryError` and returns a nonzero value.
3315
 
 
3316
 
    The function then checks if the recursion limit is reached.  If this is the
3317
 
@@ -487,10 +487,10 @@
3318
 
    concatenated to the :exc:`RuntimeError` message caused by the recursion depth
3319
 
    limit.
3320
 
 
3321
 
-.. cfunction:: void Py_LeaveRecursiveCall()
3322
 
+.. c:function:: void Py_LeaveRecursiveCall()
3323
 
 
3324
 
-   Ends a :cfunc:`Py_EnterRecursiveCall`.  Must be called once for each
3325
 
-   *successful* invocation of :cfunc:`Py_EnterRecursiveCall`.
3326
 
+   Ends a :c:func:`Py_EnterRecursiveCall`.  Must be called once for each
3327
 
+   *successful* invocation of :c:func:`Py_EnterRecursiveCall`.
3328
 
 
3329
 
 
3330
 
 .. _standardexceptions:
3331
 
@@ -500,70 +500,70 @@
3332
 
 
3333
 
 All standard Python exceptions are available as global variables whose names are
3334
 
 ``PyExc_`` followed by the Python exception name.  These have the type
3335
 
-:ctype:`PyObject\*`; they are all class objects.  For completeness, here are all
3336
 
+:c:type:`PyObject\*`; they are all class objects.  For completeness, here are all
3337
 
 the variables:
3338
 
 
3339
 
-+------------------------------------+----------------------------+----------+
3340
 
-| C Name                             | Python Name                | Notes    |
3341
 
-+====================================+============================+==========+
3342
 
-| :cdata:`PyExc_BaseException`       | :exc:`BaseException`       | (1), (4) |
3343
 
-+------------------------------------+----------------------------+----------+
3344
 
-| :cdata:`PyExc_Exception`           | :exc:`Exception`           | \(1)     |
3345
 
-+------------------------------------+----------------------------+----------+
3346
 
-| :cdata:`PyExc_StandardError`       | :exc:`StandardError`       | \(1)     |
3347
 
-+------------------------------------+----------------------------+----------+
3348
 
-| :cdata:`PyExc_ArithmeticError`     | :exc:`ArithmeticError`     | \(1)     |
3349
 
-+------------------------------------+----------------------------+----------+
3350
 
-| :cdata:`PyExc_LookupError`         | :exc:`LookupError`         | \(1)     |
3351
 
-+------------------------------------+----------------------------+----------+
3352
 
-| :cdata:`PyExc_AssertionError`      | :exc:`AssertionError`      |          |
3353
 
-+------------------------------------+----------------------------+----------+
3354
 
-| :cdata:`PyExc_AttributeError`      | :exc:`AttributeError`      |          |
3355
 
-+------------------------------------+----------------------------+----------+
3356
 
-| :cdata:`PyExc_EOFError`            | :exc:`EOFError`            |          |
3357
 
-+------------------------------------+----------------------------+----------+
3358
 
-| :cdata:`PyExc_EnvironmentError`    | :exc:`EnvironmentError`    | \(1)     |
3359
 
-+------------------------------------+----------------------------+----------+
3360
 
-| :cdata:`PyExc_FloatingPointError`  | :exc:`FloatingPointError`  |          |
3361
 
-+------------------------------------+----------------------------+----------+
3362
 
-| :cdata:`PyExc_IOError`             | :exc:`IOError`             |          |
3363
 
-+------------------------------------+----------------------------+----------+
3364
 
-| :cdata:`PyExc_ImportError`         | :exc:`ImportError`         |          |
3365
 
-+------------------------------------+----------------------------+----------+
3366
 
-| :cdata:`PyExc_IndexError`          | :exc:`IndexError`          |          |
3367
 
-+------------------------------------+----------------------------+----------+
3368
 
-| :cdata:`PyExc_KeyError`            | :exc:`KeyError`            |          |
3369
 
-+------------------------------------+----------------------------+----------+
3370
 
-| :cdata:`PyExc_KeyboardInterrupt`   | :exc:`KeyboardInterrupt`   |          |
3371
 
-+------------------------------------+----------------------------+----------+
3372
 
-| :cdata:`PyExc_MemoryError`         | :exc:`MemoryError`         |          |
3373
 
-+------------------------------------+----------------------------+----------+
3374
 
-| :cdata:`PyExc_NameError`           | :exc:`NameError`           |          |
3375
 
-+------------------------------------+----------------------------+----------+
3376
 
-| :cdata:`PyExc_NotImplementedError` | :exc:`NotImplementedError` |          |
3377
 
-+------------------------------------+----------------------------+----------+
3378
 
-| :cdata:`PyExc_OSError`             | :exc:`OSError`             |          |
3379
 
-+------------------------------------+----------------------------+----------+
3380
 
-| :cdata:`PyExc_OverflowError`       | :exc:`OverflowError`       |          |
3381
 
-+------------------------------------+----------------------------+----------+
3382
 
-| :cdata:`PyExc_ReferenceError`      | :exc:`ReferenceError`      | \(2)     |
3383
 
-+------------------------------------+----------------------------+----------+
3384
 
-| :cdata:`PyExc_RuntimeError`        | :exc:`RuntimeError`        |          |
3385
 
-+------------------------------------+----------------------------+----------+
3386
 
-| :cdata:`PyExc_SyntaxError`         | :exc:`SyntaxError`         |          |
3387
 
-+------------------------------------+----------------------------+----------+
3388
 
-| :cdata:`PyExc_SystemError`         | :exc:`SystemError`         |          |
3389
 
-+------------------------------------+----------------------------+----------+
3390
 
-| :cdata:`PyExc_SystemExit`          | :exc:`SystemExit`          |          |
3391
 
-+------------------------------------+----------------------------+----------+
3392
 
-| :cdata:`PyExc_TypeError`           | :exc:`TypeError`           |          |
3393
 
-+------------------------------------+----------------------------+----------+
3394
 
-| :cdata:`PyExc_ValueError`          | :exc:`ValueError`          |          |
3395
 
-+------------------------------------+----------------------------+----------+
3396
 
-| :cdata:`PyExc_WindowsError`        | :exc:`WindowsError`        | \(3)     |
3397
 
-+------------------------------------+----------------------------+----------+
3398
 
-| :cdata:`PyExc_ZeroDivisionError`   | :exc:`ZeroDivisionError`   |          |
3399
 
-+------------------------------------+----------------------------+----------+
3400
 
++-------------------------------------+----------------------------+----------+
3401
 
+| C Name                              | Python Name                | Notes    |
3402
 
++=====================================+============================+==========+
3403
 
+| :c:data:`PyExc_BaseException`       | :exc:`BaseException`       | (1), (4) |
3404
 
++-------------------------------------+----------------------------+----------+
3405
 
+| :c:data:`PyExc_Exception`           | :exc:`Exception`           | \(1)     |
3406
 
++-------------------------------------+----------------------------+----------+
3407
 
+| :c:data:`PyExc_StandardError`       | :exc:`StandardError`       | \(1)     |
3408
 
++-------------------------------------+----------------------------+----------+
3409
 
+| :c:data:`PyExc_ArithmeticError`     | :exc:`ArithmeticError`     | \(1)     |
3410
 
++-------------------------------------+----------------------------+----------+
3411
 
+| :c:data:`PyExc_LookupError`         | :exc:`LookupError`         | \(1)     |
3412
 
++-------------------------------------+----------------------------+----------+
3413
 
+| :c:data:`PyExc_AssertionError`      | :exc:`AssertionError`      |          |
3414
 
++-------------------------------------+----------------------------+----------+
3415
 
+| :c:data:`PyExc_AttributeError`      | :exc:`AttributeError`      |          |
3416
 
++-------------------------------------+----------------------------+----------+
3417
 
+| :c:data:`PyExc_EOFError`            | :exc:`EOFError`            |          |
3418
 
++-------------------------------------+----------------------------+----------+
3419
 
+| :c:data:`PyExc_EnvironmentError`    | :exc:`EnvironmentError`    | \(1)     |
3420
 
++-------------------------------------+----------------------------+----------+
3421
 
+| :c:data:`PyExc_FloatingPointError`  | :exc:`FloatingPointError`  |          |
3422
 
++-------------------------------------+----------------------------+----------+
3423
 
+| :c:data:`PyExc_IOError`             | :exc:`IOError`             |          |
3424
 
++-------------------------------------+----------------------------+----------+
3425
 
+| :c:data:`PyExc_ImportError`         | :exc:`ImportError`         |          |
3426
 
++-------------------------------------+----------------------------+----------+
3427
 
+| :c:data:`PyExc_IndexError`          | :exc:`IndexError`          |          |
3428
 
++-------------------------------------+----------------------------+----------+
3429
 
+| :c:data:`PyExc_KeyError`            | :exc:`KeyError`            |          |
3430
 
++-------------------------------------+----------------------------+----------+
3431
 
+| :c:data:`PyExc_KeyboardInterrupt`   | :exc:`KeyboardInterrupt`   |          |
3432
 
++-------------------------------------+----------------------------+----------+
3433
 
+| :c:data:`PyExc_MemoryError`         | :exc:`MemoryError`         |          |
3434
 
++-------------------------------------+----------------------------+----------+
3435
 
+| :c:data:`PyExc_NameError`           | :exc:`NameError`           |          |
3436
 
++-------------------------------------+----------------------------+----------+
3437
 
+| :c:data:`PyExc_NotImplementedError` | :exc:`NotImplementedError` |          |
3438
 
++-------------------------------------+----------------------------+----------+
3439
 
+| :c:data:`PyExc_OSError`             | :exc:`OSError`             |          |
3440
 
++-------------------------------------+----------------------------+----------+
3441
 
+| :c:data:`PyExc_OverflowError`       | :exc:`OverflowError`       |          |
3442
 
++-------------------------------------+----------------------------+----------+
3443
 
+| :c:data:`PyExc_ReferenceError`      | :exc:`ReferenceError`      | \(2)     |
3444
 
++-------------------------------------+----------------------------+----------+
3445
 
+| :c:data:`PyExc_RuntimeError`        | :exc:`RuntimeError`        |          |
3446
 
++-------------------------------------+----------------------------+----------+
3447
 
+| :c:data:`PyExc_SyntaxError`         | :exc:`SyntaxError`         |          |
3448
 
++-------------------------------------+----------------------------+----------+
3449
 
+| :c:data:`PyExc_SystemError`         | :exc:`SystemError`         |          |
3450
 
++-------------------------------------+----------------------------+----------+
3451
 
+| :c:data:`PyExc_SystemExit`          | :exc:`SystemExit`          |          |
3452
 
++-------------------------------------+----------------------------+----------+
3453
 
+| :c:data:`PyExc_TypeError`           | :exc:`TypeError`           |          |
3454
 
++-------------------------------------+----------------------------+----------+
3455
 
+| :c:data:`PyExc_ValueError`          | :exc:`ValueError`          |          |
3456
 
++-------------------------------------+----------------------------+----------+
3457
 
+| :c:data:`PyExc_WindowsError`        | :exc:`WindowsError`        | \(3)     |
3458
 
++-------------------------------------+----------------------------+----------+
3459
 
+| :c:data:`PyExc_ZeroDivisionError`   | :exc:`ZeroDivisionError`   |          |
3460
 
++-------------------------------------+----------------------------+----------+
3461
 
 
3462
 
 .. index::
3463
 
    single: PyExc_BaseException
3464
 
diff -r 8527427914a2 Doc/c-api/file.rst
3465
 
--- a/Doc/c-api/file.rst
3466
 
+++ b/Doc/c-api/file.rst
3467
 
@@ -7,78 +7,79 @@
3468
 
 
3469
 
 .. index:: object: file
3470
 
 
3471
 
-Python's built-in file objects are implemented entirely on the :ctype:`FILE\*`
3472
 
+Python's built-in file objects are implemented entirely on the :c:type:`FILE\*`
3473
 
 support from the C standard library.  This is an implementation detail and may
3474
 
 change in future releases of Python.
3475
 
 
3476
 
 
3477
 
-.. ctype:: PyFileObject
3478
 
+.. c:type:: PyFileObject
3479
 
 
3480
 
-   This subtype of :ctype:`PyObject` represents a Python file object.
3481
 
+   This subtype of :c:type:`PyObject` represents a Python file object.
3482
 
 
3483
 
 
3484
 
-.. cvar:: PyTypeObject PyFile_Type
3485
 
+.. c:var:: PyTypeObject PyFile_Type
3486
 
 
3487
 
    .. index:: single: FileType (in module types)
3488
 
 
3489
 
-   This instance of :ctype:`PyTypeObject` represents the Python file type.  This is
3490
 
+   This instance of :c:type:`PyTypeObject` represents the Python file type.  This is
3491
 
    exposed to Python programs as ``file`` and ``types.FileType``.
3492
 
 
3493
 
 
3494
 
-.. cfunction:: int PyFile_Check(PyObject *p)
3495
 
+.. c:function:: int PyFile_Check(PyObject *p)
3496
 
 
3497
 
-   Return true if its argument is a :ctype:`PyFileObject` or a subtype of
3498
 
-   :ctype:`PyFileObject`.
3499
 
+   Return true if its argument is a :c:type:`PyFileObject` or a subtype of
3500
 
+   :c:type:`PyFileObject`.
3501
 
 
3502
 
    .. versionchanged:: 2.2
3503
 
       Allowed subtypes to be accepted.
3504
 
 
3505
 
 
3506
 
-.. cfunction:: int PyFile_CheckExact(PyObject *p)
3507
 
+.. c:function:: int PyFile_CheckExact(PyObject *p)
3508
 
 
3509
 
-   Return true if its argument is a :ctype:`PyFileObject`, but not a subtype of
3510
 
-   :ctype:`PyFileObject`.
3511
 
+   Return true if its argument is a :c:type:`PyFileObject`, but not a subtype of
3512
 
+   :c:type:`PyFileObject`.
3513
 
 
3514
 
    .. versionadded:: 2.2
3515
 
 
3516
 
 
3517
 
-.. cfunction:: PyObject* PyFile_FromString(char *filename, char *mode)
3518
 
+.. c:function:: PyObject* PyFile_FromString(char *filename, char *mode)
3519
 
 
3520
 
    .. index:: single: fopen()
3521
 
 
3522
 
    On success, return a new file object that is opened on the file given by
3523
 
    *filename*, with a file mode given by *mode*, where *mode* has the same
3524
 
-   semantics as the standard C routine :cfunc:`fopen`.  On failure, return *NULL*.
3525
 
+   semantics as the standard C routine :c:func:`fopen`.  On failure, return *NULL*.
3526
 
 
3527
 
 
3528
 
-.. cfunction:: PyObject* PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE*))
3529
 
+.. c:function:: PyObject* PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE*))
3530
 
 
3531
 
-   Create a new :ctype:`PyFileObject` from the already-open standard C file
3532
 
+   Create a new :c:type:`PyFileObject` from the already-open standard C file
3533
 
    pointer, *fp*.  The function *close* will be called when the file should be
3534
 
-   closed.  Return *NULL* on failure.
3535
 
+   closed.  Return *NULL* and close the file using *close* on failure.
3536
 
+   *close* is optional and can be set to *NULL*.
3537
 
 
3538
 
 
3539
 
-.. cfunction:: FILE* PyFile_AsFile(PyObject \*p)
3540
 
+.. c:function:: FILE* PyFile_AsFile(PyObject \*p)
3541
 
 
3542
 
-   Return the file object associated with *p* as a :ctype:`FILE\*`.
3543
 
+   Return the file object associated with *p* as a :c:type:`FILE\*`.
3544
 
 
3545
 
-   If the caller will ever use the returned :ctype:`FILE\*` object while
3546
 
-   the :term:`GIL` is released it must also call the :cfunc:`PyFile_IncUseCount` and
3547
 
-   :cfunc:`PyFile_DecUseCount` functions described below as appropriate.
3548
 
+   If the caller will ever use the returned :c:type:`FILE\*` object while
3549
 
+   the :term:`GIL` is released it must also call the :c:func:`PyFile_IncUseCount` and
3550
 
+   :c:func:`PyFile_DecUseCount` functions described below as appropriate.
3551
 
 
3552
 
 
3553
 
-.. cfunction:: void PyFile_IncUseCount(PyFileObject \*p)
3554
 
+.. c:function:: void PyFile_IncUseCount(PyFileObject \*p)
3555
 
 
3556
 
    Increments the PyFileObject's internal use count to indicate
3557
 
-   that the underlying :ctype:`FILE\*` is being used.
3558
 
+   that the underlying :c:type:`FILE\*` is being used.
3559
 
    This prevents Python from calling f_close() on it from another thread.
3560
 
-   Callers of this must call :cfunc:`PyFile_DecUseCount` when they are
3561
 
-   finished with the :ctype:`FILE\*`.  Otherwise the file object will
3562
 
+   Callers of this must call :c:func:`PyFile_DecUseCount` when they are
3563
 
+   finished with the :c:type:`FILE\*`.  Otherwise the file object will
3564
 
    never be closed by Python.
3565
 
 
3566
 
    The :term:`GIL` must be held while calling this function.
3567
 
 
3568
 
-   The suggested use is to call this after :cfunc:`PyFile_AsFile` and before
3569
 
+   The suggested use is to call this after :c:func:`PyFile_AsFile` and before
3570
 
    you release the GIL::
3571
 
 
3572
 
       FILE *fp = PyFile_AsFile(p);
3573
 
@@ -93,11 +94,11 @@
3574
 
    .. versionadded:: 2.6
3575
 
 
3576
 
 
3577
 
-.. cfunction:: void PyFile_DecUseCount(PyFileObject \*p)
3578
 
+.. c:function:: void PyFile_DecUseCount(PyFileObject \*p)
3579
 
 
3580
 
    Decrements the PyFileObject's internal unlocked_count member to
3581
 
-   indicate that the caller is done with its own use of the :ctype:`FILE\*`.
3582
 
-   This may only be called to undo a prior call to :cfunc:`PyFile_IncUseCount`.
3583
 
+   indicate that the caller is done with its own use of the :c:type:`FILE\*`.
3584
 
+   This may only be called to undo a prior call to :c:func:`PyFile_IncUseCount`.
3585
 
 
3586
 
    The :term:`GIL` must be held while calling this function (see the example
3587
 
    above).
3588
 
@@ -105,7 +106,7 @@
3589
 
    .. versionadded:: 2.6
3590
 
 
3591
 
 
3592
 
-.. cfunction:: PyObject* PyFile_GetLine(PyObject *p, int n)
3593
 
+.. c:function:: PyObject* PyFile_GetLine(PyObject *p, int n)
3594
 
 
3595
 
    .. index:: single: EOFError (built-in exception)
3596
 
 
3597
 
@@ -119,20 +120,20 @@
3598
 
    raised if the end of the file is reached immediately.
3599
 
 
3600
 
 
3601
 
-.. cfunction:: PyObject* PyFile_Name(PyObject *p)
3602
 
+.. c:function:: PyObject* PyFile_Name(PyObject *p)
3603
 
 
3604
 
    Return the name of the file specified by *p* as a string object.
3605
 
 
3606
 
 
3607
 
-.. cfunction:: void PyFile_SetBufSize(PyFileObject *p, int n)
3608
 
+.. c:function:: void PyFile_SetBufSize(PyFileObject *p, int n)
3609
 
 
3610
 
    .. index:: single: setvbuf()
3611
 
 
3612
 
-   Available on systems with :cfunc:`setvbuf` only.  This should only be called
3613
 
+   Available on systems with :c:func:`setvbuf` only.  This should only be called
3614
 
    immediately after file object creation.
3615
 
 
3616
 
 
3617
 
-.. cfunction:: int PyFile_SetEncoding(PyFileObject *p, const char *enc)
3618
 
+.. c:function:: int PyFile_SetEncoding(PyFileObject *p, const char *enc)
3619
 
 
3620
 
    Set the file's encoding for Unicode output to *enc*. Return 1 on success and 0
3621
 
    on failure.
3622
 
@@ -140,7 +141,7 @@
3623
 
    .. versionadded:: 2.3
3624
 
 
3625
 
 
3626
 
-.. cfunction:: int PyFile_SetEncodingAndErrors(PyFileObject *p, const char *enc, *errors)
3627
 
+.. c:function:: int PyFile_SetEncodingAndErrors(PyFileObject *p, const char *enc, *errors)
3628
 
 
3629
 
    Set the file's encoding for Unicode output to *enc*, and its error
3630
 
    mode to *err*. Return 1 on success and 0 on failure.
3631
 
@@ -148,7 +149,7 @@
3632
 
    .. versionadded:: 2.6
3633
 
 
3634
 
 
3635
 
-.. cfunction:: int PyFile_SoftSpace(PyObject *p, int newflag)
3636
 
+.. c:function:: int PyFile_SoftSpace(PyObject *p, int newflag)
3637
 
 
3638
 
    .. index:: single: softspace (file attribute)
3639
 
 
3640
 
@@ -162,7 +163,7 @@
3641
 
    but doing so should not be needed.
3642
 
 
3643
 
 
3644
 
-.. cfunction:: int PyFile_WriteObject(PyObject *obj, PyObject *p, int flags)
3645
 
+.. c:function:: int PyFile_WriteObject(PyObject *obj, PyObject *p, int flags)
3646
 
 
3647
 
    .. index:: single: Py_PRINT_RAW
3648
 
 
3649
 
@@ -172,7 +173,7 @@
3650
 
    appropriate exception will be set.
3651
 
 
3652
 
 
3653
 
-.. cfunction:: int PyFile_WriteString(const char *s, PyObject *p)
3654
 
+.. c:function:: int PyFile_WriteString(const char *s, PyObject *p)
3655
 
 
3656
 
    Write string *s* to file object *p*.  Return ``0`` on success or ``-1`` on
3657
 
    failure; the appropriate exception will be set.
3658
 
diff -r 8527427914a2 Doc/c-api/float.rst
3659
 
--- a/Doc/c-api/float.rst
3660
 
+++ b/Doc/c-api/float.rst
3661
 
@@ -8,62 +8,64 @@
3662
 
 .. index:: object: floating point
3663
 
 
3664
 
 
3665
 
-.. ctype:: PyFloatObject
3666
 
+.. c:type:: PyFloatObject
3667
 
 
3668
 
-   This subtype of :ctype:`PyObject` represents a Python floating point object.
3669
 
+   This subtype of :c:type:`PyObject` represents a Python floating point object.
3670
 
 
3671
 
 
3672
 
-.. cvar:: PyTypeObject PyFloat_Type
3673
 
+.. c:var:: PyTypeObject PyFloat_Type
3674
 
 
3675
 
    .. index:: single: FloatType (in modules types)
3676
 
 
3677
 
-   This instance of :ctype:`PyTypeObject` represents the Python floating point
3678
 
+   This instance of :c:type:`PyTypeObject` represents the Python floating point
3679
 
    type.  This is the same object as ``float`` and ``types.FloatType``.
3680
 
 
3681
 
 
3682
 
-.. cfunction:: int PyFloat_Check(PyObject *p)
3683
 
+.. c:function:: int PyFloat_Check(PyObject *p)
3684
 
 
3685
 
-   Return true if its argument is a :ctype:`PyFloatObject` or a subtype of
3686
 
-   :ctype:`PyFloatObject`.
3687
 
+   Return true if its argument is a :c:type:`PyFloatObject` or a subtype of
3688
 
+   :c:type:`PyFloatObject`.
3689
 
 
3690
 
    .. versionchanged:: 2.2
3691
 
       Allowed subtypes to be accepted.
3692
 
 
3693
 
 
3694
 
-.. cfunction:: int PyFloat_CheckExact(PyObject *p)
3695
 
+.. c:function:: int PyFloat_CheckExact(PyObject *p)
3696
 
 
3697
 
-   Return true if its argument is a :ctype:`PyFloatObject`, but not a subtype of
3698
 
-   :ctype:`PyFloatObject`.
3699
 
+   Return true if its argument is a :c:type:`PyFloatObject`, but not a subtype of
3700
 
+   :c:type:`PyFloatObject`.
3701
 
 
3702
 
    .. versionadded:: 2.2
3703
 
 
3704
 
 
3705
 
-.. cfunction:: PyObject* PyFloat_FromString(PyObject *str, char **pend)
3706
 
+.. c:function:: PyObject* PyFloat_FromString(PyObject *str, char **pend)
3707
 
 
3708
 
-   Create a :ctype:`PyFloatObject` object based on the string value in *str*, or
3709
 
+   Create a :c:type:`PyFloatObject` object based on the string value in *str*, or
3710
 
    *NULL* on failure.  The *pend* argument is ignored.  It remains only for
3711
 
    backward compatibility.
3712
 
 
3713
 
 
3714
 
-.. cfunction:: PyObject* PyFloat_FromDouble(double v)
3715
 
+.. c:function:: PyObject* PyFloat_FromDouble(double v)
3716
 
 
3717
 
-   Create a :ctype:`PyFloatObject` object from *v*, or *NULL* on failure.
3718
 
+   Create a :c:type:`PyFloatObject` object from *v*, or *NULL* on failure.
3719
 
 
3720
 
 
3721
 
-.. cfunction:: double PyFloat_AsDouble(PyObject *pyfloat)
3722
 
+.. c:function:: double PyFloat_AsDouble(PyObject *pyfloat)
3723
 
 
3724
 
-   Return a C :ctype:`double` representation of the contents of *pyfloat*.  If
3725
 
+   Return a C :c:type:`double` representation of the contents of *pyfloat*.  If
3726
 
    *pyfloat* is not a Python floating point object but has a :meth:`__float__`
3727
 
    method, this method will first be called to convert *pyfloat* into a float.
3728
 
+   This method returns ``-1.0`` upon failure, so one should call
3729
 
+   :c:func:`PyErr_Occurred` to check for errors.
3730
 
 
3731
 
 
3732
 
-.. cfunction:: double PyFloat_AS_DOUBLE(PyObject *pyfloat)
3733
 
+.. c:function:: double PyFloat_AS_DOUBLE(PyObject *pyfloat)
3734
 
 
3735
 
-   Return a C :ctype:`double` representation of the contents of *pyfloat*, but
3736
 
+   Return a C :c:type:`double` representation of the contents of *pyfloat*, but
3737
 
    without error checking.
3738
 
 
3739
 
 
3740
 
-.. cfunction:: PyObject* PyFloat_GetInfo(void)
3741
 
+.. c:function:: PyObject* PyFloat_GetInfo(void)
3742
 
 
3743
 
    Return a structseq instance which contains information about the
3744
 
    precision, minimum and maximum values of a float. It's a thin wrapper
3745
 
@@ -72,21 +74,21 @@
3746
 
    .. versionadded:: 2.6
3747
 
 
3748
 
 
3749
 
-.. cfunction:: double PyFloat_GetMax()
3750
 
+.. c:function:: double PyFloat_GetMax()
3751
 
 
3752
 
-   Return the maximum representable finite float *DBL_MAX* as C :ctype:`double`.
3753
 
+   Return the maximum representable finite float *DBL_MAX* as C :c:type:`double`.
3754
 
 
3755
 
    .. versionadded:: 2.6
3756
 
 
3757
 
 
3758
 
-.. cfunction:: double PyFloat_GetMin()
3759
 
+.. c:function:: double PyFloat_GetMin()
3760
 
 
3761
 
-   Return the minimum normalized positive float *DBL_MIN* as C :ctype:`double`.
3762
 
+   Return the minimum normalized positive float *DBL_MIN* as C :c:type:`double`.
3763
 
 
3764
 
    .. versionadded:: 2.6
3765
 
 
3766
 
 
3767
 
-.. cfunction:: int PyFloat_ClearFreeList()
3768
 
+.. c:function:: int PyFloat_ClearFreeList()
3769
 
 
3770
 
    Clear the float free list. Return the number of items that could not
3771
 
    be freed.
3772
 
@@ -94,7 +96,7 @@
3773
 
    .. versionadded:: 2.6
3774
 
 
3775
 
 
3776
 
-.. cfunction:: void PyFloat_AsString(char *buf, PyFloatObject *v)
3777
 
+.. c:function:: void PyFloat_AsString(char *buf, PyFloatObject *v)
3778
 
 
3779
 
    Convert the argument *v* to a string, using the same rules as
3780
 
    :func:`str`. The length of *buf* should be at least 100.
3781
 
@@ -106,7 +108,7 @@
3782
 
       Use :func:`PyObject_Str` or :func:`PyOS_double_to_string` instead.
3783
 
 
3784
 
 
3785
 
-.. cfunction:: void PyFloat_AsReprString(char *buf, PyFloatObject *v)
3786
 
+.. c:function:: void PyFloat_AsReprString(char *buf, PyFloatObject *v)
3787
 
 
3788
 
    Same as PyFloat_AsString, except uses the same rules as
3789
 
    :func:`repr`.  The length of *buf* should be at least 100.
3790
 
diff -r 8527427914a2 Doc/c-api/function.rst
3791
 
--- a/Doc/c-api/function.rst
3792
 
+++ b/Doc/c-api/function.rst
3793
 
@@ -10,26 +10,26 @@
3794
 
 There are a few functions specific to Python functions.
3795
 
 
3796
 
 
3797
 
-.. ctype:: PyFunctionObject
3798
 
+.. c:type:: PyFunctionObject
3799
 
 
3800
 
    The C structure used for functions.
3801
 
 
3802
 
 
3803
 
-.. cvar:: PyTypeObject PyFunction_Type
3804
 
+.. c:var:: PyTypeObject PyFunction_Type
3805
 
 
3806
 
    .. index:: single: MethodType (in module types)
3807
 
 
3808
 
-   This is an instance of :ctype:`PyTypeObject` and represents the Python function
3809
 
+   This is an instance of :c:type:`PyTypeObject` and represents the Python function
3810
 
    type.  It is exposed to Python programmers as ``types.FunctionType``.
3811
 
 
3812
 
 
3813
 
-.. cfunction:: int PyFunction_Check(PyObject *o)
3814
 
+.. c:function:: int PyFunction_Check(PyObject *o)
3815
 
 
3816
 
-   Return true if *o* is a function object (has type :cdata:`PyFunction_Type`).
3817
 
+   Return true if *o* is a function object (has type :c:data:`PyFunction_Type`).
3818
 
    The parameter must not be *NULL*.
3819
 
 
3820
 
 
3821
 
-.. cfunction:: PyObject* PyFunction_New(PyObject *code, PyObject *globals)
3822
 
+.. c:function:: PyObject* PyFunction_New(PyObject *code, PyObject *globals)
3823
 
 
3824
 
    Return a new function object associated with the code object *code*. *globals*
3825
 
    must be a dictionary with the global variables accessible to the function.
3826
 
@@ -38,30 +38,30 @@
3827
 
    object, the argument defaults and closure are set to *NULL*.
3828
 
 
3829
 
 
3830
 
-.. cfunction:: PyObject* PyFunction_GetCode(PyObject *op)
3831
 
+.. c:function:: PyObject* PyFunction_GetCode(PyObject *op)
3832
 
 
3833
 
    Return the code object associated with the function object *op*.
3834
 
 
3835
 
 
3836
 
-.. cfunction:: PyObject* PyFunction_GetGlobals(PyObject *op)
3837
 
+.. c:function:: PyObject* PyFunction_GetGlobals(PyObject *op)
3838
 
 
3839
 
    Return the globals dictionary associated with the function object *op*.
3840
 
 
3841
 
 
3842
 
-.. cfunction:: PyObject* PyFunction_GetModule(PyObject *op)
3843
 
+.. c:function:: PyObject* PyFunction_GetModule(PyObject *op)
3844
 
 
3845
 
    Return the *__module__* attribute of the function object *op*. This is normally
3846
 
    a string containing the module name, but can be set to any other object by
3847
 
    Python code.
3848
 
 
3849
 
 
3850
 
-.. cfunction:: PyObject* PyFunction_GetDefaults(PyObject *op)
3851
 
+.. c:function:: PyObject* PyFunction_GetDefaults(PyObject *op)
3852
 
 
3853
 
    Return the argument default values of the function object *op*. This can be a
3854
 
    tuple of arguments or *NULL*.
3855
 
 
3856
 
 
3857
 
-.. cfunction:: int PyFunction_SetDefaults(PyObject *op, PyObject *defaults)
3858
 
+.. c:function:: int PyFunction_SetDefaults(PyObject *op, PyObject *defaults)
3859
 
 
3860
 
    Set the argument default values for the function object *op*. *defaults* must be
3861
 
    *Py_None* or a tuple.
3862
 
@@ -69,13 +69,13 @@
3863
 
    Raises :exc:`SystemError` and returns ``-1`` on failure.
3864
 
 
3865
 
 
3866
 
-.. cfunction:: PyObject* PyFunction_GetClosure(PyObject *op)
3867
 
+.. c:function:: PyObject* PyFunction_GetClosure(PyObject *op)
3868
 
 
3869
 
    Return the closure associated with the function object *op*. This can be *NULL*
3870
 
    or a tuple of cell objects.
3871
 
 
3872
 
 
3873
 
-.. cfunction:: int PyFunction_SetClosure(PyObject *op, PyObject *closure)
3874
 
+.. c:function:: int PyFunction_SetClosure(PyObject *op, PyObject *closure)
3875
 
 
3876
 
    Set the closure associated with the function object *op*. *closure* must be
3877
 
    *Py_None* or a tuple of cell objects.
3878
 
diff -r 8527427914a2 Doc/c-api/gcsupport.rst
3879
 
--- a/Doc/c-api/gcsupport.rst
3880
 
+++ b/Doc/c-api/gcsupport.rst
3881
 
@@ -30,40 +30,40 @@
3882
 
 
3883
 
 Constructors for container types must conform to two rules:
3884
 
 
3885
 
-#. The memory for the object must be allocated using :cfunc:`PyObject_GC_New`
3886
 
-   or :cfunc:`PyObject_GC_NewVar`.
3887
 
+#. The memory for the object must be allocated using :c:func:`PyObject_GC_New`
3888
 
+   or :c:func:`PyObject_GC_NewVar`.
3889
 
 
3890
 
 #. Once all the fields which may contain references to other containers are
3891
 
-   initialized, it must call :cfunc:`PyObject_GC_Track`.
3892
 
+   initialized, it must call :c:func:`PyObject_GC_Track`.
3893
 
 
3894
 
 
3895
 
-.. cfunction:: TYPE* PyObject_GC_New(TYPE, PyTypeObject *type)
3896
 
+.. c:function:: TYPE* PyObject_GC_New(TYPE, PyTypeObject *type)
3897
 
 
3898
 
-   Analogous to :cfunc:`PyObject_New` but for container objects with the
3899
 
+   Analogous to :c:func:`PyObject_New` but for container objects with the
3900
 
    :const:`Py_TPFLAGS_HAVE_GC` flag set.
3901
 
 
3902
 
 
3903
 
-.. cfunction:: TYPE* PyObject_GC_NewVar(TYPE, PyTypeObject *type, Py_ssize_t size)
3904
 
+.. c:function:: TYPE* PyObject_GC_NewVar(TYPE, PyTypeObject *type, Py_ssize_t size)
3905
 
 
3906
 
-   Analogous to :cfunc:`PyObject_NewVar` but for container objects with the
3907
 
+   Analogous to :c:func:`PyObject_NewVar` but for container objects with the
3908
 
    :const:`Py_TPFLAGS_HAVE_GC` flag set.
3909
 
 
3910
 
    .. versionchanged:: 2.5
3911
 
-      This function used an :ctype:`int` type for *size*. This might require
3912
 
+      This function used an :c:type:`int` type for *size*. This might require
3913
 
       changes in your code for properly supporting 64-bit systems.
3914
 
 
3915
 
 
3916
 
-.. cfunction:: TYPE* PyObject_GC_Resize(TYPE, PyVarObject *op, Py_ssize_t newsize)
3917
 
+.. c:function:: TYPE* PyObject_GC_Resize(TYPE, PyVarObject *op, Py_ssize_t newsize)
3918
 
 
3919
 
-   Resize an object allocated by :cfunc:`PyObject_NewVar`.  Returns the
3920
 
+   Resize an object allocated by :c:func:`PyObject_NewVar`.  Returns the
3921
 
    resized object or *NULL* on failure.
3922
 
 
3923
 
    .. versionchanged:: 2.5
3924
 
-      This function used an :ctype:`int` type for *newsize*. This might
3925
 
+      This function used an :c:type:`int` type for *newsize*. This might
3926
 
       require changes in your code for properly supporting 64-bit systems.
3927
 
 
3928
 
 
3929
 
-.. cfunction:: void PyObject_GC_Track(PyObject *op)
3930
 
+.. c:function:: void PyObject_GC_Track(PyObject *op)
3931
 
 
3932
 
    Adds the object *op* to the set of container objects tracked by the
3933
 
    collector.  The collector can run at unexpected times so objects must be
3934
 
@@ -72,44 +72,44 @@
3935
 
    end of the constructor.
3936
 
 
3937
 
 
3938
 
-.. cfunction:: void _PyObject_GC_TRACK(PyObject *op)
3939
 
+.. c:function:: void _PyObject_GC_TRACK(PyObject *op)
3940
 
 
3941
 
-   A macro version of :cfunc:`PyObject_GC_Track`.  It should not be used for
3942
 
+   A macro version of :c:func:`PyObject_GC_Track`.  It should not be used for
3943
 
    extension modules.
3944
 
 
3945
 
 Similarly, the deallocator for the object must conform to a similar pair of
3946
 
 rules:
3947
 
 
3948
 
 #. Before fields which refer to other containers are invalidated,
3949
 
-   :cfunc:`PyObject_GC_UnTrack` must be called.
3950
 
+   :c:func:`PyObject_GC_UnTrack` must be called.
3951
 
 
3952
 
-#. The object's memory must be deallocated using :cfunc:`PyObject_GC_Del`.
3953
 
+#. The object's memory must be deallocated using :c:func:`PyObject_GC_Del`.
3954
 
 
3955
 
 
3956
 
-.. cfunction:: void PyObject_GC_Del(void *op)
3957
 
+.. c:function:: void PyObject_GC_Del(void *op)
3958
 
 
3959
 
-   Releases memory allocated to an object using :cfunc:`PyObject_GC_New` or
3960
 
-   :cfunc:`PyObject_GC_NewVar`.
3961
 
+   Releases memory allocated to an object using :c:func:`PyObject_GC_New` or
3962
 
+   :c:func:`PyObject_GC_NewVar`.
3963
 
 
3964
 
 
3965
 
-.. cfunction:: void PyObject_GC_UnTrack(void *op)
3966
 
+.. c:function:: void PyObject_GC_UnTrack(void *op)
3967
 
 
3968
 
    Remove the object *op* from the set of container objects tracked by the
3969
 
-   collector.  Note that :cfunc:`PyObject_GC_Track` can be called again on
3970
 
+   collector.  Note that :c:func:`PyObject_GC_Track` can be called again on
3971
 
    this object to add it back to the set of tracked objects.  The deallocator
3972
 
    (:attr:`tp_dealloc` handler) should call this for the object before any of
3973
 
    the fields used by the :attr:`tp_traverse` handler become invalid.
3974
 
 
3975
 
 
3976
 
-.. cfunction:: void _PyObject_GC_UNTRACK(PyObject *op)
3977
 
+.. c:function:: void _PyObject_GC_UNTRACK(PyObject *op)
3978
 
 
3979
 
-   A macro version of :cfunc:`PyObject_GC_UnTrack`.  It should not be used for
3980
 
+   A macro version of :c:func:`PyObject_GC_UnTrack`.  It should not be used for
3981
 
    extension modules.
3982
 
 
3983
 
 The :attr:`tp_traverse` handler accepts a function parameter of this type:
3984
 
 
3985
 
 
3986
 
-.. ctype:: int (*visitproc)(PyObject *object, void *arg)
3987
 
+.. c:type:: int (*visitproc)(PyObject *object, void *arg)
3988
 
 
3989
 
    Type of the visitor function passed to the :attr:`tp_traverse` handler.
3990
 
    The function should be called with an object to traverse as *object* and
3991
 
@@ -121,7 +121,7 @@
3992
 
 The :attr:`tp_traverse` handler must have the following type:
3993
 
 
3994
 
 
3995
 
-.. ctype:: int (*traverseproc)(PyObject *self, visitproc visit, void *arg)
3996
 
+.. c:type:: int (*traverseproc)(PyObject *self, visitproc visit, void *arg)
3997
 
 
3998
 
    Traversal function for a container object.  Implementations must call the
3999
 
    *visit* function for each object directly contained by *self*, with the
4000
 
@@ -130,12 +130,12 @@
4001
 
    object argument.  If *visit* returns a non-zero value that value should be
4002
 
    returned immediately.
4003
 
 
4004
 
-To simplify writing :attr:`tp_traverse` handlers, a :cfunc:`Py_VISIT` macro is
4005
 
+To simplify writing :attr:`tp_traverse` handlers, a :c:func:`Py_VISIT` macro is
4006
 
 provided.  In order to use this macro, the :attr:`tp_traverse` implementation
4007
 
 must name its arguments exactly *visit* and *arg*:
4008
 
 
4009
 
 
4010
 
-.. cfunction:: void Py_VISIT(PyObject *o)
4011
 
+.. c:function:: void Py_VISIT(PyObject *o)
4012
 
 
4013
 
    Call the *visit* callback, with arguments *o* and *arg*. If *visit* returns
4014
 
    a non-zero value, then return it.  Using this macro, :attr:`tp_traverse`
4015
 
@@ -151,15 +151,15 @@
4016
 
 
4017
 
    .. versionadded:: 2.4
4018
 
 
4019
 
-The :attr:`tp_clear` handler must be of the :ctype:`inquiry` type, or *NULL*
4020
 
+The :attr:`tp_clear` handler must be of the :c:type:`inquiry` type, or *NULL*
4021
 
 if the object is immutable.
4022
 
 
4023
 
 
4024
 
-.. ctype:: int (*inquiry)(PyObject *self)
4025
 
+.. c:type:: int (*inquiry)(PyObject *self)
4026
 
 
4027
 
    Drop references that may have created reference cycles.  Immutable objects
4028
 
    do not have to define this method since they can never directly create
4029
 
    reference cycles.  Note that the object must still be valid after calling
4030
 
-   this method (don't just call :cfunc:`Py_DECREF` on a reference).  The
4031
 
+   this method (don't just call :c:func:`Py_DECREF` on a reference).  The
4032
 
    collector will call this method if it detects that this object is involved
4033
 
    in a reference cycle.
4034
 
diff -r 8527427914a2 Doc/c-api/gen.rst
4035
 
--- a/Doc/c-api/gen.rst
4036
 
+++ b/Doc/c-api/gen.rst
4037
 
@@ -7,31 +7,31 @@
4038
 
 
4039
 
 Generator objects are what Python uses to implement generator iterators. They
4040
 
 are normally created by iterating over a function that yields values, rather
4041
 
-than explicitly calling :cfunc:`PyGen_New`.
4042
 
+than explicitly calling :c:func:`PyGen_New`.
4043
 
 
4044
 
 
4045
 
-.. ctype:: PyGenObject
4046
 
+.. c:type:: PyGenObject
4047
 
 
4048
 
    The C structure used for generator objects.
4049
 
 
4050
 
 
4051
 
-.. cvar:: PyTypeObject PyGen_Type
4052
 
+.. c:var:: PyTypeObject PyGen_Type
4053
 
 
4054
 
    The type object corresponding to generator objects
4055
 
 
4056
 
 
4057
 
-.. cfunction:: int PyGen_Check(ob)
4058
 
+.. c:function:: int PyGen_Check(ob)
4059
 
 
4060
 
    Return true if *ob* is a generator object; *ob* must not be *NULL*.
4061
 
 
4062
 
 
4063
 
-.. cfunction:: int PyGen_CheckExact(ob)
4064
 
+.. c:function:: int PyGen_CheckExact(ob)
4065
 
 
4066
 
    Return true if *ob*'s type is *PyGen_Type* is a generator object; *ob* must not
4067
 
    be *NULL*.
4068
 
 
4069
 
 
4070
 
-.. cfunction:: PyObject* PyGen_New(PyFrameObject *frame)
4071
 
+.. c:function:: PyObject* PyGen_New(PyFrameObject *frame)
4072
 
 
4073
 
    Create and return a new generator object based on the *frame* object. A
4074
 
    reference to *frame* is stolen by this function. The parameter must not be
4075
 
diff -r 8527427914a2 Doc/c-api/import.rst
4076
 
--- a/Doc/c-api/import.rst
4077
 
+++ b/Doc/c-api/import.rst
4078
 
@@ -6,14 +6,14 @@
4079
 
 =================
4080
 
 
4081
 
 
4082
 
-.. cfunction:: PyObject* PyImport_ImportModule(const char *name)
4083
 
+.. c:function:: PyObject* PyImport_ImportModule(const char *name)
4084
 
 
4085
 
    .. index::
4086
 
       single: package variable; __all__
4087
 
       single: __all__ (package variable)
4088
 
       single: modules (in module sys)
4089
 
 
4090
 
-   This is a simplified interface to :cfunc:`PyImport_ImportModuleEx` below,
4091
 
+   This is a simplified interface to :c:func:`PyImport_ImportModuleEx` below,
4092
 
    leaving the *globals* and *locals* arguments set to *NULL* and *level* set
4093
 
    to 0.  When the *name*
4094
 
    argument contains a dot (when it specifies a submodule of a package), the
4095
 
@@ -34,20 +34,20 @@
4096
 
       Always uses absolute imports.
4097
 
 
4098
 
 
4099
 
-.. cfunction:: PyObject* PyImport_ImportModuleNoBlock(const char *name)
4100
 
+.. c:function:: PyObject* PyImport_ImportModuleNoBlock(const char *name)
4101
 
 
4102
 
-   This version of :cfunc:`PyImport_ImportModule` does not block. It's intended
4103
 
+   This version of :c:func:`PyImport_ImportModule` does not block. It's intended
4104
 
    to be used in C functions that import other modules to execute a function.
4105
 
    The import may block if another thread holds the import lock. The function
4106
 
-   :cfunc:`PyImport_ImportModuleNoBlock` never blocks. It first tries to fetch
4107
 
-   the module from sys.modules and falls back to :cfunc:`PyImport_ImportModule`
4108
 
+   :c:func:`PyImport_ImportModuleNoBlock` never blocks. It first tries to fetch
4109
 
+   the module from sys.modules and falls back to :c:func:`PyImport_ImportModule`
4110
 
    unless the lock is held, in which case the function will raise an
4111
 
    :exc:`ImportError`.
4112
 
 
4113
 
    .. versionadded:: 2.6
4114
 
 
4115
 
 
4116
 
-.. cfunction:: PyObject* PyImport_ImportModuleEx(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist)
4117
 
+.. c:function:: PyObject* PyImport_ImportModuleEx(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist)
4118
 
 
4119
 
    .. index:: builtin: __import__
4120
 
 
4121
 
@@ -65,11 +65,11 @@
4122
 
       Failing imports remove incomplete module objects.
4123
 
 
4124
 
    .. versionchanged:: 2.6
4125
 
-      The function is an alias for :cfunc:`PyImport_ImportModuleLevel` with
4126
 
+      The function is an alias for :c:func:`PyImport_ImportModuleLevel` with
4127
 
       -1 as level, meaning relative import.
4128
 
 
4129
 
 
4130
 
-.. cfunction:: PyObject* PyImport_ImportModuleLevel(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist, int level)
4131
 
+.. c:function:: PyObject* PyImport_ImportModuleLevel(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist, int level)
4132
 
 
4133
 
    Import a module.  This is best described by referring to the built-in Python
4134
 
    function :func:`__import__`, as the standard :func:`__import__` function calls
4135
 
@@ -83,7 +83,7 @@
4136
 
    .. versionadded:: 2.5
4137
 
 
4138
 
 
4139
 
-.. cfunction:: PyObject* PyImport_Import(PyObject *name)
4140
 
+.. c:function:: PyObject* PyImport_Import(PyObject *name)
4141
 
 
4142
 
    .. index::
4143
 
       module: rexec
4144
 
@@ -98,7 +98,7 @@
4145
 
       Always uses absolute imports.
4146
 
 
4147
 
 
4148
 
-.. cfunction:: PyObject* PyImport_ReloadModule(PyObject *m)
4149
 
+.. c:function:: PyObject* PyImport_ReloadModule(PyObject *m)
4150
 
 
4151
 
    .. index:: builtin: reload
4152
 
 
4153
 
@@ -108,7 +108,7 @@
4154
 
    with an exception set on failure (the module still exists in this case).
4155
 
 
4156
 
 
4157
 
-.. cfunction:: PyObject* PyImport_AddModule(const char *name)
4158
 
+.. c:function:: PyObject* PyImport_AddModule(const char *name)
4159
 
 
4160
 
    Return the module object corresponding to a module name.  The *name* argument
4161
 
    may be of the form ``package.module``. First check the modules dictionary if
4162
 
@@ -118,12 +118,12 @@
4163
 
    .. note::
4164
 
 
4165
 
       This function does not load or import the module; if the module wasn't already
4166
 
-      loaded, you will get an empty module object. Use :cfunc:`PyImport_ImportModule`
4167
 
+      loaded, you will get an empty module object. Use :c:func:`PyImport_ImportModule`
4168
 
       or one of its variants to import a module.  Package structures implied by a
4169
 
       dotted name for *name* are not created if not already present.
4170
 
 
4171
 
 
4172
 
-.. cfunction:: PyObject* PyImport_ExecCodeModule(char *name, PyObject *co)
4173
 
+.. c:function:: PyObject* PyImport_ExecCodeModule(char *name, PyObject *co)
4174
 
 
4175
 
    .. index:: builtin: compile
4176
 
 
4177
 
@@ -133,16 +133,16 @@
4178
 
    or *NULL* with an exception set if an error occurred.  Before Python 2.4, the
4179
 
    module could still be created in error cases.  Starting with Python 2.4, *name*
4180
 
    is removed from :attr:`sys.modules` in error cases, and even if *name* was already
4181
 
-   in :attr:`sys.modules` on entry to :cfunc:`PyImport_ExecCodeModule`.  Leaving
4182
 
+   in :attr:`sys.modules` on entry to :c:func:`PyImport_ExecCodeModule`.  Leaving
4183
 
    incompletely initialized modules in :attr:`sys.modules` is dangerous, as imports of
4184
 
    such modules have no way to know that the module object is an unknown (and
4185
 
    probably damaged with respect to the module author's intents) state.
4186
 
 
4187
 
    The module's :attr:`__file__` attribute will be set to the code object's
4188
 
-   :cmember:`co_filename`.
4189
 
+   :c:member:`co_filename`.
4190
 
 
4191
 
    This function will reload the module if it was already imported.  See
4192
 
-   :cfunc:`PyImport_ReloadModule` for the intended way to reload a module.
4193
 
+   :c:func:`PyImport_ReloadModule` for the intended way to reload a module.
4194
 
 
4195
 
    If *name* points to a dotted name of the form ``package.module``, any package
4196
 
    structures not already created will still not be created.
4197
 
@@ -151,26 +151,26 @@
4198
 
       *name* is removed from :attr:`sys.modules` in error cases.
4199
 
 
4200
 
 
4201
 
-.. cfunction:: PyObject* PyImport_ExecCodeModuleEx(char *name, PyObject *co, char *pathname)
4202
 
+.. c:function:: PyObject* PyImport_ExecCodeModuleEx(char *name, PyObject *co, char *pathname)
4203
 
 
4204
 
-   Like :cfunc:`PyImport_ExecCodeModule`, but the :attr:`__file__` attribute of
4205
 
+   Like :c:func:`PyImport_ExecCodeModule`, but the :attr:`__file__` attribute of
4206
 
    the module object is set to *pathname* if it is non-``NULL``.
4207
 
 
4208
 
 
4209
 
-.. cfunction:: long PyImport_GetMagicNumber()
4210
 
+.. c:function:: long PyImport_GetMagicNumber()
4211
 
 
4212
 
    Return the magic number for Python bytecode files (a.k.a. :file:`.pyc` and
4213
 
    :file:`.pyo` files).  The magic number should be present in the first four bytes
4214
 
    of the bytecode file, in little-endian byte order.
4215
 
 
4216
 
 
4217
 
-.. cfunction:: PyObject* PyImport_GetModuleDict()
4218
 
+.. c:function:: PyObject* PyImport_GetModuleDict()
4219
 
 
4220
 
    Return the dictionary used for the module administration (a.k.a.
4221
 
    ``sys.modules``).  Note that this is a per-interpreter variable.
4222
 
 
4223
 
 
4224
 
-.. cfunction:: PyObject* PyImport_GetImporter(PyObject *path)
4225
 
+.. c:function:: PyObject* PyImport_GetImporter(PyObject *path)
4226
 
 
4227
 
    Return an importer object for a :data:`sys.path`/:attr:`pkg.__path__` item
4228
 
    *path*, possibly by fetching it from the :data:`sys.path_importer_cache`
4229
 
@@ -183,41 +183,41 @@
4230
 
    .. versionadded:: 2.6
4231
 
 
4232
 
 
4233
 
-.. cfunction:: void _PyImport_Init()
4234
 
+.. c:function:: void _PyImport_Init()
4235
 
 
4236
 
    Initialize the import mechanism.  For internal use only.
4237
 
 
4238
 
 
4239
 
-.. cfunction:: void PyImport_Cleanup()
4240
 
+.. c:function:: void PyImport_Cleanup()
4241
 
 
4242
 
    Empty the module table.  For internal use only.
4243
 
 
4244
 
 
4245
 
-.. cfunction:: void _PyImport_Fini()
4246
 
+.. c:function:: void _PyImport_Fini()
4247
 
 
4248
 
    Finalize the import mechanism.  For internal use only.
4249
 
 
4250
 
 
4251
 
-.. cfunction:: PyObject* _PyImport_FindExtension(char *, char *)
4252
 
+.. c:function:: PyObject* _PyImport_FindExtension(char *, char *)
4253
 
 
4254
 
    For internal use only.
4255
 
 
4256
 
 
4257
 
-.. cfunction:: PyObject* _PyImport_FixupExtension(char *, char *)
4258
 
+.. c:function:: PyObject* _PyImport_FixupExtension(char *, char *)
4259
 
 
4260
 
    For internal use only.
4261
 
 
4262
 
 
4263
 
-.. cfunction:: int PyImport_ImportFrozenModule(char *name)
4264
 
+.. c:function:: int PyImport_ImportFrozenModule(char *name)
4265
 
 
4266
 
    Load a frozen module named *name*.  Return ``1`` for success, ``0`` if the
4267
 
    module is not found, and ``-1`` with an exception set if the initialization
4268
 
    failed.  To access the imported module on a successful load, use
4269
 
-   :cfunc:`PyImport_ImportModule`.  (Note the misnomer --- this function would
4270
 
+   :c:func:`PyImport_ImportModule`.  (Note the misnomer --- this function would
4271
 
    reload the module if it was already imported.)
4272
 
 
4273
 
 
4274
 
-.. ctype:: struct _frozen
4275
 
+.. c:type:: struct _frozen
4276
 
 
4277
 
    .. index:: single: freeze utility
4278
 
 
4279
 
@@ -233,30 +233,30 @@
4280
 
       };
4281
 
 
4282
 
 
4283
 
-.. cvar:: struct _frozen* PyImport_FrozenModules
4284
 
+.. c:var:: struct _frozen* PyImport_FrozenModules
4285
 
 
4286
 
-   This pointer is initialized to point to an array of :ctype:`struct _frozen`
4287
 
+   This pointer is initialized to point to an array of :c:type:`struct _frozen`
4288
 
    records, terminated by one whose members are all *NULL* or zero.  When a frozen
4289
 
    module is imported, it is searched in this table.  Third-party code could play
4290
 
    tricks with this to provide a dynamically created collection of frozen modules.
4291
 
 
4292
 
 
4293
 
-.. cfunction:: int PyImport_AppendInittab(const char *name, void (*initfunc)(void))
4294
 
+.. c:function:: int PyImport_AppendInittab(const char *name, void (*initfunc)(void))
4295
 
 
4296
 
    Add a single module to the existing table of built-in modules.  This is a
4297
 
-   convenience wrapper around :cfunc:`PyImport_ExtendInittab`, returning ``-1`` if
4298
 
+   convenience wrapper around :c:func:`PyImport_ExtendInittab`, returning ``-1`` if
4299
 
    the table could not be extended.  The new module can be imported by the name
4300
 
    *name*, and uses the function *initfunc* as the initialization function called
4301
 
    on the first attempted import.  This should be called before
4302
 
-   :cfunc:`Py_Initialize`.
4303
 
+   :c:func:`Py_Initialize`.
4304
 
 
4305
 
 
4306
 
-.. ctype:: struct _inittab
4307
 
+.. c:type:: struct _inittab
4308
 
 
4309
 
    Structure describing a single entry in the list of built-in modules.  Each of
4310
 
    these structures gives the name and initialization function for a module built
4311
 
    into the interpreter.  Programs which embed Python may use an array of these
4312
 
-   structures in conjunction with :cfunc:`PyImport_ExtendInittab` to provide
4313
 
+   structures in conjunction with :c:func:`PyImport_ExtendInittab` to provide
4314
 
    additional built-in modules.  The structure is defined in
4315
 
    :file:`Include/import.h` as::
4316
 
 
4317
 
@@ -266,11 +266,11 @@
4318
 
       };
4319
 
 
4320
 
 
4321
 
-.. cfunction:: int PyImport_ExtendInittab(struct _inittab *newtab)
4322
 
+.. c:function:: int PyImport_ExtendInittab(struct _inittab *newtab)
4323
 
 
4324
 
    Add a collection of modules to the table of built-in modules.  The *newtab*
4325
 
    array must end with a sentinel entry which contains *NULL* for the :attr:`name`
4326
 
    field; failure to provide the sentinel value can result in a memory fault.
4327
 
    Returns ``0`` on success or ``-1`` if insufficient memory could be allocated to
4328
 
    extend the internal table.  In the event of failure, no modules are added to the
4329
 
-   internal table.  This should be called before :cfunc:`Py_Initialize`.
4330
 
+   internal table.  This should be called before :c:func:`Py_Initialize`.
4331
 
diff -r 8527427914a2 Doc/c-api/init.rst
4332
 
--- a/Doc/c-api/init.rst
4333
 
+++ b/Doc/c-api/init.rst
4334
 
@@ -12,7 +12,7 @@
4335
 
 ===========================================
4336
 
 
4337
 
 
4338
 
-.. cfunction:: void Py_Initialize()
4339
 
+.. c:function:: void Py_Initialize()
4340
 
 
4341
 
    .. index::
4342
 
       single: Py_SetProgramName()
4343
 
@@ -31,40 +31,40 @@
4344
 
 
4345
 
    Initialize the Python interpreter.  In an application embedding  Python, this
4346
 
    should be called before using any other Python/C API functions; with the
4347
 
-   exception of :cfunc:`Py_SetProgramName`, :cfunc:`PyEval_InitThreads`,
4348
 
-   :cfunc:`PyEval_ReleaseLock`, and :cfunc:`PyEval_AcquireLock`. This initializes
4349
 
+   exception of :c:func:`Py_SetProgramName`, :c:func:`Py_SetPythonHome`, :c:func:`PyEval_InitThreads`,
4350
 
+   :c:func:`PyEval_ReleaseLock`, and :c:func:`PyEval_AcquireLock`. This initializes
4351
 
    the table of loaded modules (``sys.modules``), and creates the fundamental
4352
 
    modules :mod:`__builtin__`, :mod:`__main__` and :mod:`sys`.  It also initializes
4353
 
    the module search path (``sys.path``). It does not set ``sys.argv``; use
4354
 
-   :cfunc:`PySys_SetArgvEx` for that.  This is a no-op when called for a second time
4355
 
-   (without calling :cfunc:`Py_Finalize` first).  There is no return value; it is a
4356
 
+   :c:func:`PySys_SetArgvEx` for that.  This is a no-op when called for a second time
4357
 
+   (without calling :c:func:`Py_Finalize` first).  There is no return value; it is a
4358
 
    fatal error if the initialization fails.
4359
 
 
4360
 
 
4361
 
-.. cfunction:: void Py_InitializeEx(int initsigs)
4362
 
+.. c:function:: void Py_InitializeEx(int initsigs)
4363
 
 
4364
 
-   This function works like :cfunc:`Py_Initialize` if *initsigs* is 1. If
4365
 
+   This function works like :c:func:`Py_Initialize` if *initsigs* is 1. If
4366
 
    *initsigs* is 0, it skips initialization registration of signal handlers, which
4367
 
    might be useful when Python is embedded.
4368
 
 
4369
 
    .. versionadded:: 2.4
4370
 
 
4371
 
 
4372
 
-.. cfunction:: int Py_IsInitialized()
4373
 
+.. c:function:: int Py_IsInitialized()
4374
 
 
4375
 
    Return true (nonzero) when the Python interpreter has been initialized, false
4376
 
-   (zero) if not.  After :cfunc:`Py_Finalize` is called, this returns false until
4377
 
-   :cfunc:`Py_Initialize` is called again.
4378
 
+   (zero) if not.  After :c:func:`Py_Finalize` is called, this returns false until
4379
 
+   :c:func:`Py_Initialize` is called again.
4380
 
 
4381
 
 
4382
 
-.. cfunction:: void Py_Finalize()
4383
 
+.. c:function:: void Py_Finalize()
4384
 
 
4385
 
-   Undo all initializations made by :cfunc:`Py_Initialize` and subsequent use of
4386
 
+   Undo all initializations made by :c:func:`Py_Initialize` and subsequent use of
4387
 
    Python/C API functions, and destroy all sub-interpreters (see
4388
 
-   :cfunc:`Py_NewInterpreter` below) that were created and not yet destroyed since
4389
 
-   the last call to :cfunc:`Py_Initialize`.  Ideally, this frees all memory
4390
 
+   :c:func:`Py_NewInterpreter` below) that were created and not yet destroyed since
4391
 
+   the last call to :c:func:`Py_Initialize`.  Ideally, this frees all memory
4392
 
    allocated by the Python interpreter.  This is a no-op when called for a second
4393
 
-   time (without calling :cfunc:`Py_Initialize` again first).  There is no return
4394
 
+   time (without calling :c:func:`Py_Initialize` again first).  There is no return
4395
 
    value; errors during finalization are ignored.
4396
 
 
4397
 
    This function is provided for a number of reasons.  An embedding application
4398
 
@@ -83,25 +83,25 @@
4399
 
    please report it).  Memory tied up in circular references between objects is not
4400
 
    freed.  Some memory allocated by extension modules may not be freed.  Some
4401
 
    extensions may not work properly if their initialization routine is called more
4402
 
-   than once; this can happen if an application calls :cfunc:`Py_Initialize` and
4403
 
-   :cfunc:`Py_Finalize` more than once.
4404
 
+   than once; this can happen if an application calls :c:func:`Py_Initialize` and
4405
 
+   :c:func:`Py_Finalize` more than once.
4406
 
 
4407
 
 
4408
 
 Process-wide parameters
4409
 
 =======================
4410
 
 
4411
 
 
4412
 
-.. cfunction:: void Py_SetProgramName(char *name)
4413
 
+.. c:function:: void Py_SetProgramName(char *name)
4414
 
 
4415
 
    .. index::
4416
 
       single: Py_Initialize()
4417
 
       single: main()
4418
 
       single: Py_GetPath()
4419
 
 
4420
 
-   This function should be called before :cfunc:`Py_Initialize` is called for
4421
 
+   This function should be called before :c:func:`Py_Initialize` is called for
4422
 
    the first time, if it is called at all.  It tells the interpreter the value
4423
 
-   of the ``argv[0]`` argument to the :cfunc:`main` function of the program.
4424
 
-   This is used by :cfunc:`Py_GetPath` and some other functions below to find
4425
 
+   of the ``argv[0]`` argument to the :c:func:`main` function of the program.
4426
 
+   This is used by :c:func:`Py_GetPath` and some other functions below to find
4427
 
    the Python run-time libraries relative to the interpreter executable.  The
4428
 
    default value is ``'python'``.  The argument should point to a
4429
 
    zero-terminated character string in static storage whose contents will not
4430
 
@@ -109,37 +109,37 @@
4431
 
    interpreter will change the contents of this storage.
4432
 
 
4433
 
 
4434
 
-.. cfunction:: char* Py_GetProgramName()
4435
 
+.. c:function:: char* Py_GetProgramName()
4436
 
 
4437
 
    .. index:: single: Py_SetProgramName()
4438
 
 
4439
 
-   Return the program name set with :cfunc:`Py_SetProgramName`, or the default.
4440
 
+   Return the program name set with :c:func:`Py_SetProgramName`, or the default.
4441
 
    The returned string points into static storage; the caller should not modify its
4442
 
    value.
4443
 
 
4444
 
 
4445
 
-.. cfunction:: char* Py_GetPrefix()
4446
 
+.. c:function:: char* Py_GetPrefix()
4447
 
 
4448
 
    Return the *prefix* for installed platform-independent files. This is derived
4449
 
    through a number of complicated rules from the program name set with
4450
 
-   :cfunc:`Py_SetProgramName` and some environment variables; for example, if the
4451
 
+   :c:func:`Py_SetProgramName` and some environment variables; for example, if the
4452
 
    program name is ``'/usr/local/bin/python'``, the prefix is ``'/usr/local'``. The
4453
 
    returned string points into static storage; the caller should not modify its
4454
 
    value.  This corresponds to the :makevar:`prefix` variable in the top-level
4455
 
-   :file:`Makefile` and the :option:`--prefix` argument to the :program:`configure`
4456
 
+   :file:`Makefile` and the ``--prefix`` argument to the :program:`configure`
4457
 
    script at build time.  The value is available to Python code as ``sys.prefix``.
4458
 
    It is only useful on Unix.  See also the next function.
4459
 
 
4460
 
 
4461
 
-.. cfunction:: char* Py_GetExecPrefix()
4462
 
+.. c:function:: char* Py_GetExecPrefix()
4463
 
 
4464
 
    Return the *exec-prefix* for installed platform-*dependent* files.  This is
4465
 
    derived through a number of complicated rules from the program name set with
4466
 
-   :cfunc:`Py_SetProgramName` and some environment variables; for example, if the
4467
 
+   :c:func:`Py_SetProgramName` and some environment variables; for example, if the
4468
 
    program name is ``'/usr/local/bin/python'``, the exec-prefix is
4469
 
    ``'/usr/local'``.  The returned string points into static storage; the caller
4470
 
    should not modify its value.  This corresponds to the :makevar:`exec_prefix`
4471
 
-   variable in the top-level :file:`Makefile` and the :option:`--exec-prefix`
4472
 
+   variable in the top-level :file:`Makefile` and the ``--exec-prefix``
4473
 
    argument to the :program:`configure` script at build  time.  The value is
4474
 
    available to Python code as ``sys.exec_prefix``.  It is only useful on Unix.
4475
 
 
4476
 
@@ -166,7 +166,7 @@
4477
 
    platform.
4478
 
 
4479
 
 
4480
 
-.. cfunction:: char* Py_GetProgramFullPath()
4481
 
+.. c:function:: char* Py_GetProgramFullPath()
4482
 
 
4483
 
    .. index::
4484
 
       single: Py_SetProgramName()
4485
 
@@ -174,19 +174,19 @@
4486
 
 
4487
 
    Return the full program name of the Python executable; this is  computed as a
4488
 
    side-effect of deriving the default module search path  from the program name
4489
 
-   (set by :cfunc:`Py_SetProgramName` above). The returned string points into
4490
 
+   (set by :c:func:`Py_SetProgramName` above). The returned string points into
4491
 
    static storage; the caller should not modify its value.  The value is available
4492
 
    to Python code as ``sys.executable``.
4493
 
 
4494
 
 
4495
 
-.. cfunction:: char* Py_GetPath()
4496
 
+.. c:function:: char* Py_GetPath()
4497
 
 
4498
 
    .. index::
4499
 
       triple: module; search; path
4500
 
       single: path (in module sys)
4501
 
 
4502
 
    Return the default module search path; this is computed from the program name
4503
 
-   (set by :cfunc:`Py_SetProgramName` above) and some environment variables.
4504
 
+   (set by :c:func:`Py_SetProgramName` above) and some environment variables.
4505
 
    The returned string consists of a series of directory names separated by a
4506
 
    platform dependent delimiter character.  The delimiter character is ``':'``
4507
 
    on Unix and Mac OS X, ``';'`` on Windows.  The returned string points into
4508
 
@@ -198,7 +198,7 @@
4509
 
    .. XXX should give the exact rules
4510
 
 
4511
 
 
4512
 
-.. cfunction:: const char* Py_GetVersion()
4513
 
+.. c:function:: const char* Py_GetVersion()
4514
 
 
4515
 
    Return the version of this Python interpreter.  This is a string that looks
4516
 
    something like ::
4517
 
@@ -213,7 +213,7 @@
4518
 
    modify its value.  The value is available to Python code as ``sys.version``.
4519
 
 
4520
 
 
4521
 
-.. cfunction:: const char* Py_GetPlatform()
4522
 
+.. c:function:: const char* Py_GetPlatform()
4523
 
 
4524
 
    .. index:: single: platform (in module sys)
4525
 
 
4526
 
@@ -226,7 +226,7 @@
4527
 
    to Python code as ``sys.platform``.
4528
 
 
4529
 
 
4530
 
-.. cfunction:: const char* Py_GetCopyright()
4531
 
+.. c:function:: const char* Py_GetCopyright()
4532
 
 
4533
 
    Return the official copyright string for the current Python version, for example
4534
 
 
4535
 
@@ -238,7 +238,7 @@
4536
 
    value.  The value is available to Python code as ``sys.copyright``.
4537
 
 
4538
 
 
4539
 
-.. cfunction:: const char* Py_GetCompiler()
4540
 
+.. c:function:: const char* Py_GetCompiler()
4541
 
 
4542
 
    Return an indication of the compiler used to build the current Python version,
4543
 
    in square brackets, for example::
4544
 
@@ -252,7 +252,7 @@
4545
 
    ``sys.version``.
4546
 
 
4547
 
 
4548
 
-.. cfunction:: const char* Py_GetBuildInfo()
4549
 
+.. c:function:: const char* Py_GetBuildInfo()
4550
 
 
4551
 
    Return information about the sequence number and build date and time  of the
4552
 
    current Python interpreter instance, for example ::
4553
 
@@ -266,7 +266,7 @@
4554
 
    ``sys.version``.
4555
 
 
4556
 
 
4557
 
-.. cfunction:: void PySys_SetArgvEx(int argc, char **argv, int updatepath)
4558
 
+.. c:function:: void PySys_SetArgvEx(int argc, char **argv, int updatepath)
4559
 
 
4560
 
    .. index::
4561
 
       single: main()
4562
 
@@ -274,12 +274,12 @@
4563
 
       single: argv (in module sys)
4564
 
 
4565
 
    Set :data:`sys.argv` based on *argc* and *argv*.  These parameters are
4566
 
-   similar to those passed to the program's :cfunc:`main` function with the
4567
 
+   similar to those passed to the program's :c:func:`main` function with the
4568
 
    difference that the first entry should refer to the script file to be
4569
 
    executed rather than the executable hosting the Python interpreter.  If there
4570
 
    isn't a script that will be run, the first entry in *argv* can be an empty
4571
 
    string.  If this function fails to initialize :data:`sys.argv`, a fatal
4572
 
-   condition is signalled using :cfunc:`Py_FatalError`.
4573
 
+   condition is signalled using :c:func:`Py_FatalError`.
4574
 
 
4575
 
    If *updatepath* is zero, this is all the function does.  If *updatepath*
4576
 
    is non-zero, the function also modifies :data:`sys.path` according to the
4577
 
@@ -301,7 +301,7 @@
4578
 
 
4579
 
       On versions before 2.6.6, you can achieve the same effect by manually
4580
 
       popping the first :data:`sys.path` element after having called
4581
 
-      :cfunc:`PySys_SetArgv`, for example using::
4582
 
+      :c:func:`PySys_SetArgv`, for example using::
4583
 
 
4584
 
          PyRun_SimpleString("import sys; sys.path.pop(0)\n");
4585
 
 
4586
 
@@ -311,12 +311,12 @@
4587
 
       check w/ Guido.
4588
 
 
4589
 
 
4590
 
-.. cfunction:: void PySys_SetArgv(int argc, char **argv)
4591
 
+.. c:function:: void PySys_SetArgv(int argc, char **argv)
4592
 
 
4593
 
-   This function works like :cfunc:`PySys_SetArgvEx` with *updatepath* set to 1.
4594
 
+   This function works like :c:func:`PySys_SetArgvEx` with *updatepath* set to 1.
4595
 
 
4596
 
 
4597
 
-.. cfunction:: void Py_SetPythonHome(char *home)
4598
 
+.. c:function:: void Py_SetPythonHome(char *home)
4599
 
 
4600
 
    Set the default "home" directory, that is, the location of the standard
4601
 
    Python libraries.  See :envvar:`PYTHONHOME` for the meaning of the
4602
 
@@ -328,10 +328,10 @@
4603
 
    this storage.
4604
 
 
4605
 
 
4606
 
-.. cfunction:: char* Py_GetPythonHome()
4607
 
+.. c:function:: char* Py_GetPythonHome()
4608
 
 
4609
 
    Return the default "home", that is, the value set by a previous call to
4610
 
-   :cfunc:`Py_SetPythonHome`, or the value of the :envvar:`PYTHONHOME`
4611
 
+   :c:func:`Py_SetPythonHome`, or the value of the :envvar:`PYTHONHOME`
4612
 
    environment variable if it is set.
4613
 
 
4614
 
 
4615
 
@@ -368,9 +368,9 @@
4616
 
    single: PyThreadState
4617
 
 
4618
 
 The Python interpreter keeps some thread-specific bookkeeping information
4619
 
-inside a data structure called :ctype:`PyThreadState`.  There's also one
4620
 
-global variable pointing to the current :ctype:`PyThreadState`: it can
4621
 
-be retrieved using :cfunc:`PyThreadState_Get`.
4622
 
+inside a data structure called :c:type:`PyThreadState`.  There's also one
4623
 
+global variable pointing to the current :c:type:`PyThreadState`: it can
4624
 
+be retrieved using :c:func:`PyThreadState_Get`.
4625
 
 
4626
 
 Releasing the GIL from extension code
4627
 
 -------------------------------------
4628
 
@@ -394,8 +394,8 @@
4629
 
    single: Py_BEGIN_ALLOW_THREADS
4630
 
    single: Py_END_ALLOW_THREADS
4631
 
 
4632
 
-The :cmacro:`Py_BEGIN_ALLOW_THREADS` macro opens a new block and declares a
4633
 
-hidden local variable; the :cmacro:`Py_END_ALLOW_THREADS` macro closes the
4634
 
+The :c:macro:`Py_BEGIN_ALLOW_THREADS` macro opens a new block and declares a
4635
 
+hidden local variable; the :c:macro:`Py_END_ALLOW_THREADS` macro closes the
4636
 
 block.  These two macros are still available when Python is compiled without
4637
 
 thread support (they simply have an empty expansion).
4638
 
 
4639
 
@@ -445,7 +445,7 @@
4640
 
 API.  When you are done, you should reset the thread state pointer, release
4641
 
 the GIL, and finally free the thread state data structure.
4642
 
 
4643
 
-The :cfunc:`PyGILState_Ensure` and :cfunc:`PyGILState_Release` functions do
4644
 
+The :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release` functions do
4645
 
 all of the above automatically.  The typical idiom for calling into Python
4646
 
 from a C thread is::
4647
 
 
4648
 
@@ -459,14 +459,14 @@
4649
 
    /* Release the thread. No Python API allowed beyond this point. */
4650
 
    PyGILState_Release(gstate);
4651
 
 
4652
 
-Note that the :cfunc:`PyGILState_\*` functions assume there is only one global
4653
 
-interpreter (created automatically by :cfunc:`Py_Initialize`).  Python
4654
 
+Note that the :c:func:`PyGILState_\*` functions assume there is only one global
4655
 
+interpreter (created automatically by :c:func:`Py_Initialize`).  Python
4656
 
 supports the creation of additional interpreters (using
4657
 
-:cfunc:`Py_NewInterpreter`), but mixing multiple interpreters and the
4658
 
-:cfunc:`PyGILState_\*` API is unsupported.
4659
 
+:c:func:`Py_NewInterpreter`), but mixing multiple interpreters and the
4660
 
+:c:func:`PyGILState_\*` API is unsupported.
4661
 
 
4662
 
 Another important thing to note about threads is their behaviour in the face
4663
 
-of the C :cfunc:`fork` call. On most systems with :cfunc:`fork`, after a
4664
 
+of the C :c:func:`fork` call. On most systems with :c:func:`fork`, after a
4665
 
 process forks only the thread that issued the fork will exist. That also
4666
 
 means any locks held by other threads will never be released. Python solves
4667
 
 this for :func:`os.fork` by acquiring the locks it uses internally before
4668
 
@@ -474,12 +474,12 @@
4669
 
 :ref:`lock-objects` in the child. When extending or embedding Python, there
4670
 
 is no way to inform Python of additional (non-Python) locks that need to be
4671
 
 acquired before or reset after a fork. OS facilities such as
4672
 
-:cfunc:`pthread_atfork` would need to be used to accomplish the same thing.
4673
 
-Additionally, when extending or embedding Python, calling :cfunc:`fork`
4674
 
+:c:func:`pthread_atfork` would need to be used to accomplish the same thing.
4675
 
+Additionally, when extending or embedding Python, calling :c:func:`fork`
4676
 
 directly rather than through :func:`os.fork` (and returning to or calling
4677
 
 into Python) may result in a deadlock by one of Python's internal locks
4678
 
 being held by a thread that is defunct after the fork.
4679
 
-:cfunc:`PyOS_AfterFork` tries to reset the necessary locks, but is not
4680
 
+:c:func:`PyOS_AfterFork` tries to reset the necessary locks, but is not
4681
 
 always able to.
4682
 
 
4683
 
 
4684
 
@@ -489,7 +489,7 @@
4685
 
 These are the most commonly used types and functions when writing C extension
4686
 
 code, or when embedding the Python interpreter:
4687
 
 
4688
 
-.. ctype:: PyInterpreterState
4689
 
+.. c:type:: PyInterpreterState
4690
 
 
4691
 
    This data structure represents the state shared by a number of cooperating
4692
 
    threads.  Threads belonging to the same interpreter share their module
4693
 
@@ -502,14 +502,14 @@
4694
 
    interpreter they belong.
4695
 
 
4696
 
 
4697
 
-.. ctype:: PyThreadState
4698
 
+.. c:type:: PyThreadState
4699
 
 
4700
 
    This data structure represents the state of a single thread.  The only public
4701
 
-   data member is :ctype:`PyInterpreterState \*`:attr:`interp`, which points to
4702
 
+   data member is :c:type:`PyInterpreterState \*`:attr:`interp`, which points to
4703
 
    this thread's interpreter state.
4704
 
 
4705
 
 
4706
 
-.. cfunction:: void PyEval_InitThreads()
4707
 
+.. c:function:: void PyEval_InitThreads()
4708
 
 
4709
 
    .. index::
4710
 
       single: PyEval_ReleaseLock()
4711
 
@@ -519,14 +519,14 @@
4712
 
 
4713
 
    Initialize and acquire the global interpreter lock.  It should be called in the
4714
 
    main thread before creating a second thread or engaging in any other thread
4715
 
-   operations such as :cfunc:`PyEval_ReleaseLock` or
4716
 
+   operations such as :c:func:`PyEval_ReleaseLock` or
4717
 
    ``PyEval_ReleaseThread(tstate)``. It is not needed before calling
4718
 
-   :cfunc:`PyEval_SaveThread` or :cfunc:`PyEval_RestoreThread`.
4719
 
+   :c:func:`PyEval_SaveThread` or :c:func:`PyEval_RestoreThread`.
4720
 
 
4721
 
    .. index:: single: Py_Initialize()
4722
 
 
4723
 
    This is a no-op when called for a second time.  It is safe to call this function
4724
 
-   before calling :cfunc:`Py_Initialize`.
4725
 
+   before calling :c:func:`Py_Initialize`.
4726
 
 
4727
 
    .. index:: module: thread
4728
 
 
4729
 
@@ -539,7 +539,7 @@
4730
 
       when this function initializes the global interpreter lock, it also acquires
4731
 
       it.  Before the Python :mod:`_thread` module creates a new thread, knowing
4732
 
       that either it has the lock or the lock hasn't been created yet, it calls
4733
 
-      :cfunc:`PyEval_InitThreads`.  When this call returns, it is guaranteed that
4734
 
+      :c:func:`PyEval_InitThreads`.  When this call returns, it is guaranteed that
4735
 
       the lock has been created and that the calling thread has acquired it.
4736
 
 
4737
 
       It is **not** safe to call this function when it is unknown which thread (if
4738
 
@@ -548,9 +548,9 @@
4739
 
       This function is not available when thread support is disabled at compile time.
4740
 
 
4741
 
 
4742
 
-.. cfunction:: int PyEval_ThreadsInitialized()
4743
 
+.. c:function:: int PyEval_ThreadsInitialized()
4744
 
 
4745
 
-   Returns a non-zero value if :cfunc:`PyEval_InitThreads` has been called.  This
4746
 
+   Returns a non-zero value if :c:func:`PyEval_InitThreads` has been called.  This
4747
 
    function can be called without holding the GIL, and therefore can be used to
4748
 
    avoid calls to the locking API when running single-threaded.  This function is
4749
 
    not available when thread support is disabled at compile time.
4750
 
@@ -558,7 +558,7 @@
4751
 
    .. versionadded:: 2.4
4752
 
 
4753
 
 
4754
 
-.. cfunction:: PyThreadState* PyEval_SaveThread()
4755
 
+.. c:function:: PyThreadState* PyEval_SaveThread()
4756
 
 
4757
 
    Release the global interpreter lock (if it has been created and thread
4758
 
    support is enabled) and reset the thread state to *NULL*, returning the
4759
 
@@ -567,7 +567,7 @@
4760
 
    when thread support is disabled at compile time.)
4761
 
 
4762
 
 
4763
 
-.. cfunction:: void PyEval_RestoreThread(PyThreadState *tstate)
4764
 
+.. c:function:: void PyEval_RestoreThread(PyThreadState *tstate)
4765
 
 
4766
 
    Acquire the global interpreter lock (if it has been created and thread
4767
 
    support is enabled) and set the thread state to *tstate*, which must not be
4768
 
@@ -576,23 +576,23 @@
4769
 
    when thread support is disabled at compile time.)
4770
 
 
4771
 
 
4772
 
-.. cfunction:: PyThreadState* PyThreadState_Get()
4773
 
+.. c:function:: PyThreadState* PyThreadState_Get()
4774
 
 
4775
 
    Return the current thread state.  The global interpreter lock must be held.
4776
 
    When the current thread state is *NULL*, this issues a fatal error (so that
4777
 
    the caller needn't check for *NULL*).
4778
 
 
4779
 
 
4780
 
-.. cfunction:: PyThreadState* PyThreadState_Swap(PyThreadState *tstate)
4781
 
+.. c:function:: PyThreadState* PyThreadState_Swap(PyThreadState *tstate)
4782
 
 
4783
 
    Swap the current thread state with the thread state given by the argument
4784
 
    *tstate*, which may be *NULL*.  The global interpreter lock must be held
4785
 
    and is not released.
4786
 
 
4787
 
 
4788
 
-.. cfunction:: void PyEval_ReInitThreads()
4789
 
+.. c:function:: void PyEval_ReInitThreads()
4790
 
 
4791
 
-   This function is called from :cfunc:`PyOS_AfterFork` to ensure that newly
4792
 
+   This function is called from :c:func:`PyOS_AfterFork` to ensure that newly
4793
 
    created child processes don't hold locks referring to threads which
4794
 
    are not running in the child process.
4795
 
 
4796
 
@@ -600,24 +600,24 @@
4797
 
 The following functions use thread-local storage, and are not compatible
4798
 
 with sub-interpreters:
4799
 
 
4800
 
-.. cfunction:: PyGILState_STATE PyGILState_Ensure()
4801
 
+.. c:function:: PyGILState_STATE PyGILState_Ensure()
4802
 
 
4803
 
    Ensure that the current thread is ready to call the Python C API regardless
4804
 
    of the current state of Python, or of the global interpreter lock. This may
4805
 
    be called as many times as desired by a thread as long as each call is
4806
 
-   matched with a call to :cfunc:`PyGILState_Release`. In general, other
4807
 
-   thread-related APIs may be used between :cfunc:`PyGILState_Ensure` and
4808
 
-   :cfunc:`PyGILState_Release` calls as long as the thread state is restored to
4809
 
+   matched with a call to :c:func:`PyGILState_Release`. In general, other
4810
 
+   thread-related APIs may be used between :c:func:`PyGILState_Ensure` and
4811
 
+   :c:func:`PyGILState_Release` calls as long as the thread state is restored to
4812
 
    its previous state before the Release().  For example, normal usage of the
4813
 
-   :cmacro:`Py_BEGIN_ALLOW_THREADS` and :cmacro:`Py_END_ALLOW_THREADS` macros is
4814
 
+   :c:macro:`Py_BEGIN_ALLOW_THREADS` and :c:macro:`Py_END_ALLOW_THREADS` macros is
4815
 
    acceptable.
4816
 
 
4817
 
    The return value is an opaque "handle" to the thread state when
4818
 
-   :cfunc:`PyGILState_Ensure` was called, and must be passed to
4819
 
-   :cfunc:`PyGILState_Release` to ensure Python is left in the same state. Even
4820
 
+   :c:func:`PyGILState_Ensure` was called, and must be passed to
4821
 
+   :c:func:`PyGILState_Release` to ensure Python is left in the same state. Even
4822
 
    though recursive calls are allowed, these handles *cannot* be shared - each
4823
 
-   unique call to :cfunc:`PyGILState_Ensure` must save the handle for its call
4824
 
-   to :cfunc:`PyGILState_Release`.
4825
 
+   unique call to :c:func:`PyGILState_Ensure` must save the handle for its call
4826
 
+   to :c:func:`PyGILState_Release`.
4827
 
 
4828
 
    When the function returns, the current thread will hold the GIL and be able
4829
 
    to call arbitrary Python code.  Failure is a fatal error.
4830
 
@@ -625,15 +625,25 @@
4831
 
    .. versionadded:: 2.3
4832
 
 
4833
 
 
4834
 
-.. cfunction:: void PyGILState_Release(PyGILState_STATE)
4835
 
+.. c:function:: void PyGILState_Release(PyGILState_STATE)
4836
 
 
4837
 
    Release any resources previously acquired.  After this call, Python's state will
4838
 
-   be the same as it was prior to the corresponding :cfunc:`PyGILState_Ensure` call
4839
 
+   be the same as it was prior to the corresponding :c:func:`PyGILState_Ensure` call
4840
 
    (but generally this state will be unknown to the caller, hence the use of the
4841
 
    GILState API).
4842
 
 
4843
 
-   Every call to :cfunc:`PyGILState_Ensure` must be matched by a call to
4844
 
-   :cfunc:`PyGILState_Release` on the same thread.
4845
 
+   Every call to :c:func:`PyGILState_Ensure` must be matched by a call to
4846
 
+   :c:func:`PyGILState_Release` on the same thread.
4847
 
+
4848
 
+   .. versionadded:: 2.3
4849
 
+
4850
 
+
4851
 
+.. c:function:: PyThreadState PyGILState_GetThisThreadState()
4852
 
+
4853
 
+   Get the current thread state for this thread.  May return ``NULL`` if no
4854
 
+   GILState API has been used on the current thread.  Note that the main thread
4855
 
+   always has such a thread-state, even if no auto-thread-state call has been
4856
 
+   made on the main thread.  This is mainly a helper/diagnostic function.
4857
 
 
4858
 
    .. versionadded:: 2.3
4859
 
 
4860
 
@@ -642,33 +652,33 @@
4861
 
 example usage in the Python source distribution.
4862
 
 
4863
 
 
4864
 
-.. cmacro:: Py_BEGIN_ALLOW_THREADS
4865
 
+.. c:macro:: Py_BEGIN_ALLOW_THREADS
4866
 
 
4867
 
    This macro expands to ``{ PyThreadState *_save; _save = PyEval_SaveThread();``.
4868
 
    Note that it contains an opening brace; it must be matched with a following
4869
 
-   :cmacro:`Py_END_ALLOW_THREADS` macro.  See above for further discussion of this
4870
 
+   :c:macro:`Py_END_ALLOW_THREADS` macro.  See above for further discussion of this
4871
 
    macro.  It is a no-op when thread support is disabled at compile time.
4872
 
 
4873
 
 
4874
 
-.. cmacro:: Py_END_ALLOW_THREADS
4875
 
+.. c:macro:: Py_END_ALLOW_THREADS
4876
 
 
4877
 
    This macro expands to ``PyEval_RestoreThread(_save); }``. Note that it contains
4878
 
    a closing brace; it must be matched with an earlier
4879
 
-   :cmacro:`Py_BEGIN_ALLOW_THREADS` macro.  See above for further discussion of
4880
 
+   :c:macro:`Py_BEGIN_ALLOW_THREADS` macro.  See above for further discussion of
4881
 
    this macro.  It is a no-op when thread support is disabled at compile time.
4882
 
 
4883
 
 
4884
 
-.. cmacro:: Py_BLOCK_THREADS
4885
 
+.. c:macro:: Py_BLOCK_THREADS
4886
 
 
4887
 
    This macro expands to ``PyEval_RestoreThread(_save);``: it is equivalent to
4888
 
-   :cmacro:`Py_END_ALLOW_THREADS` without the closing brace.  It is a no-op when
4889
 
+   :c:macro:`Py_END_ALLOW_THREADS` without the closing brace.  It is a no-op when
4890
 
    thread support is disabled at compile time.
4891
 
 
4892
 
 
4893
 
-.. cmacro:: Py_UNBLOCK_THREADS
4894
 
+.. c:macro:: Py_UNBLOCK_THREADS
4895
 
 
4896
 
    This macro expands to ``_save = PyEval_SaveThread();``: it is equivalent to
4897
 
-   :cmacro:`Py_BEGIN_ALLOW_THREADS` without the opening brace and variable
4898
 
+   :c:macro:`Py_BEGIN_ALLOW_THREADS` without the opening brace and variable
4899
 
    declaration.  It is a no-op when thread support is disabled at compile time.
4900
 
 
4901
 
 
4902
 
@@ -680,47 +690,47 @@
4903
 
 been created.
4904
 
 
4905
 
 
4906
 
-.. cfunction:: PyInterpreterState* PyInterpreterState_New()
4907
 
+.. c:function:: PyInterpreterState* PyInterpreterState_New()
4908
 
 
4909
 
    Create a new interpreter state object.  The global interpreter lock need not
4910
 
    be held, but may be held if it is necessary to serialize calls to this
4911
 
    function.
4912
 
 
4913
 
 
4914
 
-.. cfunction:: void PyInterpreterState_Clear(PyInterpreterState *interp)
4915
 
+.. c:function:: void PyInterpreterState_Clear(PyInterpreterState *interp)
4916
 
 
4917
 
    Reset all information in an interpreter state object.  The global interpreter
4918
 
    lock must be held.
4919
 
 
4920
 
 
4921
 
-.. cfunction:: void PyInterpreterState_Delete(PyInterpreterState *interp)
4922
 
+.. c:function:: void PyInterpreterState_Delete(PyInterpreterState *interp)
4923
 
 
4924
 
    Destroy an interpreter state object.  The global interpreter lock need not be
4925
 
    held.  The interpreter state must have been reset with a previous call to
4926
 
-   :cfunc:`PyInterpreterState_Clear`.
4927
 
+   :c:func:`PyInterpreterState_Clear`.
4928
 
 
4929
 
 
4930
 
-.. cfunction:: PyThreadState* PyThreadState_New(PyInterpreterState *interp)
4931
 
+.. c:function:: PyThreadState* PyThreadState_New(PyInterpreterState *interp)
4932
 
 
4933
 
    Create a new thread state object belonging to the given interpreter object.
4934
 
    The global interpreter lock need not be held, but may be held if it is
4935
 
    necessary to serialize calls to this function.
4936
 
 
4937
 
 
4938
 
-.. cfunction:: void PyThreadState_Clear(PyThreadState *tstate)
4939
 
+.. c:function:: void PyThreadState_Clear(PyThreadState *tstate)
4940
 
 
4941
 
    Reset all information in a thread state object.  The global interpreter lock
4942
 
    must be held.
4943
 
 
4944
 
 
4945
 
-.. cfunction:: void PyThreadState_Delete(PyThreadState *tstate)
4946
 
+.. c:function:: void PyThreadState_Delete(PyThreadState *tstate)
4947
 
 
4948
 
    Destroy a thread state object.  The global interpreter lock need not be held.
4949
 
    The thread state must have been reset with a previous call to
4950
 
-   :cfunc:`PyThreadState_Clear`.
4951
 
+   :c:func:`PyThreadState_Clear`.
4952
 
 
4953
 
 
4954
 
-.. cfunction:: PyObject* PyThreadState_GetDict()
4955
 
+.. c:function:: PyObject* PyThreadState_GetDict()
4956
 
 
4957
 
    Return a dictionary in which extensions can store thread-specific state
4958
 
    information.  Each extension should use a unique key to use to store state in
4959
 
@@ -733,7 +743,7 @@
4960
 
       meant that an exception was raised.
4961
 
 
4962
 
 
4963
 
-.. cfunction:: int PyThreadState_SetAsyncExc(long id, PyObject *exc)
4964
 
+.. c:function:: int PyThreadState_SetAsyncExc(long id, PyObject *exc)
4965
 
 
4966
 
    Asynchronously raise an exception in a thread. The *id* argument is the thread
4967
 
    id of the target thread; *exc* is the exception object to be raised. This
4968
 
@@ -746,18 +756,18 @@
4969
 
    .. versionadded:: 2.3
4970
 
 
4971
 
 
4972
 
-.. cfunction:: void PyEval_AcquireThread(PyThreadState *tstate)
4973
 
+.. c:function:: void PyEval_AcquireThread(PyThreadState *tstate)
4974
 
 
4975
 
    Acquire the global interpreter lock and set the current thread state to
4976
 
    *tstate*, which should not be *NULL*.  The lock must have been created earlier.
4977
 
    If this thread already has the lock, deadlock ensues.
4978
 
 
4979
 
-   :cfunc:`PyEval_RestoreThread` is a higher-level function which is always
4980
 
+   :c:func:`PyEval_RestoreThread` is a higher-level function which is always
4981
 
    available (even when thread support isn't enabled or when threads have
4982
 
    not been initialized).
4983
 
 
4984
 
 
4985
 
-.. cfunction:: void PyEval_ReleaseThread(PyThreadState *tstate)
4986
 
+.. c:function:: void PyEval_ReleaseThread(PyThreadState *tstate)
4987
 
 
4988
 
    Reset the current thread state to *NULL* and release the global interpreter
4989
 
    lock.  The lock must have been created earlier and must be held by the current
4990
 
@@ -765,29 +775,29 @@
4991
 
    that it represents the current thread state --- if it isn't, a fatal error is
4992
 
    reported.
4993
 
 
4994
 
-   :cfunc:`PyEval_SaveThread` is a higher-level function which is always
4995
 
+   :c:func:`PyEval_SaveThread` is a higher-level function which is always
4996
 
    available (even when thread support isn't enabled or when threads have
4997
 
    not been initialized).
4998
 
 
4999
 
 
5000
 
-.. cfunction:: void PyEval_AcquireLock()
5001
 
+.. c:function:: void PyEval_AcquireLock()
5002
 
 
5003
 
    Acquire the global interpreter lock.  The lock must have been created earlier.
5004
 
    If this thread already has the lock, a deadlock ensues.
5005
 
 
5006
 
    .. warning::
5007
 
       This function does not change the current thread state.  Please use
5008
 
-      :cfunc:`PyEval_RestoreThread` or :cfunc:`PyEval_AcquireThread`
5009
 
+      :c:func:`PyEval_RestoreThread` or :c:func:`PyEval_AcquireThread`
5010
 
       instead.
5011
 
 
5012
 
 
5013
 
-.. cfunction:: void PyEval_ReleaseLock()
5014
 
+.. c:function:: void PyEval_ReleaseLock()
5015
 
 
5016
 
    Release the global interpreter lock.  The lock must have been created earlier.
5017
 
 
5018
 
    .. warning::
5019
 
       This function does not change the current thread state.  Please use
5020
 
-      :cfunc:`PyEval_SaveThread` or :cfunc:`PyEval_ReleaseThread`
5021
 
+      :c:func:`PyEval_SaveThread` or :c:func:`PyEval_ReleaseThread`
5022
 
       instead.
5023
 
 
5024
 
 
5025
 
@@ -798,11 +808,11 @@
5026
 
 are cases where you need to create several independent interpreters in the
5027
 
 same process and perhaps even in the same thread.  Sub-interpreters allow
5028
 
 you to do that.  You can switch between sub-interpreters using the
5029
 
-:cfunc:`PyThreadState_Swap` function.  You can create and destroy them
5030
 
+:c:func:`PyThreadState_Swap` function.  You can create and destroy them
5031
 
 using the following functions:
5032
 
 
5033
 
 
5034
 
-.. cfunction:: PyThreadState* Py_NewInterpreter()
5035
 
+.. c:function:: PyThreadState* Py_NewInterpreter()
5036
 
 
5037
 
    .. index::
5038
 
       module: builtins
5039
 
@@ -844,13 +854,13 @@
5040
 
    and filled with the contents of this copy; the extension's ``init`` function is
5041
 
    not called.  Note that this is different from what happens when an extension is
5042
 
    imported after the interpreter has been completely re-initialized by calling
5043
 
-   :cfunc:`Py_Finalize` and :cfunc:`Py_Initialize`; in that case, the extension's
5044
 
+   :c:func:`Py_Finalize` and :c:func:`Py_Initialize`; in that case, the extension's
5045
 
    ``initmodule`` function *is* called again.
5046
 
 
5047
 
    .. index:: single: close() (in module os)
5048
 
 
5049
 
 
5050
 
-.. cfunction:: void Py_EndInterpreter(PyThreadState *tstate)
5051
 
+.. c:function:: void Py_EndInterpreter(PyThreadState *tstate)
5052
 
 
5053
 
    .. index:: single: Py_Finalize()
5054
 
 
5055
 
@@ -859,7 +869,7 @@
5056
 
    states below.  When the call returns, the current thread state is *NULL*.  All
5057
 
    thread states associated with this interpreter are destroyed.  (The global
5058
 
    interpreter lock must be held before calling this function and is still held
5059
 
-   when it returns.)  :cfunc:`Py_Finalize` will destroy all sub-interpreters that
5060
 
+   when it returns.)  :c:func:`Py_Finalize` will destroy all sub-interpreters that
5061
 
    haven't been explicitly destroyed at that point.
5062
 
 
5063
 
 
5064
 
@@ -880,11 +890,11 @@
5065
 
 by such objects may affect the wrong (sub-)interpreter's dictionary of loaded
5066
 
 modules.
5067
 
 
5068
 
-Also note that combining this functionality with :cfunc:`PyGILState_\*` APIs
5069
 
+Also note that combining this functionality with :c:func:`PyGILState_\*` APIs
5070
 
 is delicate, because these APIs assume a bijection between Python thread states
5071
 
 and OS-level threads, an assumption broken by the presence of sub-interpreters.
5072
 
 It is highly recommended that you don't switch sub-interpreters between a pair
5073
 
-of matching :cfunc:`PyGILState_Ensure` and :cfunc:`PyGILState_Release` calls.
5074
 
+of matching :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release` calls.
5075
 
 Furthermore, extensions (such as :mod:`ctypes`) using these APIs to allow calling
5076
 
 of Python code from non-Python created threads will probably be broken when using
5077
 
 sub-interpreters.
5078
 
@@ -906,7 +916,7 @@
5079
 
 main thread where it has possession of the global interpreter lock and can
5080
 
 perform any Python API calls.
5081
 
 
5082
 
-.. cfunction:: int Py_AddPendingCall(int (*func)(void *), void *arg)
5083
 
+.. c:function:: int Py_AddPendingCall(int (*func)(void *), void *arg)
5084
 
 
5085
 
    .. index:: single: Py_AddPendingCall()
5086
 
 
5087
 
@@ -954,10 +964,10 @@
5088
 
 in previous versions.
5089
 
 
5090
 
 
5091
 
-.. ctype:: int (*Py_tracefunc)(PyObject *obj, PyFrameObject *frame, int what, PyObject *arg)
5092
 
+.. c:type:: int (*Py_tracefunc)(PyObject *obj, PyFrameObject *frame, int what, PyObject *arg)
5093
 
 
5094
 
-   The type of the trace function registered using :cfunc:`PyEval_SetProfile` and
5095
 
-   :cfunc:`PyEval_SetTrace`. The first parameter is the object passed to the
5096
 
+   The type of the trace function registered using :c:func:`PyEval_SetProfile` and
5097
 
+   :c:func:`PyEval_SetTrace`. The first parameter is the object passed to the
5098
 
    registration function as *obj*, *frame* is the frame object to which the event
5099
 
    pertains, *what* is one of the constants :const:`PyTrace_CALL`,
5100
 
    :const:`PyTrace_EXCEPTION`, :const:`PyTrace_LINE`, :const:`PyTrace_RETURN`,
5101
 
@@ -985,18 +995,18 @@
5102
 
    +------------------------------+--------------------------------------+
5103
 
 
5104
 
 
5105
 
-.. cvar:: int PyTrace_CALL
5106
 
+.. c:var:: int PyTrace_CALL
5107
 
 
5108
 
-   The value of the *what* parameter to a :ctype:`Py_tracefunc` function when a new
5109
 
+   The value of the *what* parameter to a :c:type:`Py_tracefunc` function when a new
5110
 
    call to a function or method is being reported, or a new entry into a generator.
5111
 
    Note that the creation of the iterator for a generator function is not reported
5112
 
    as there is no control transfer to the Python bytecode in the corresponding
5113
 
    frame.
5114
 
 
5115
 
 
5116
 
-.. cvar:: int PyTrace_EXCEPTION
5117
 
+.. c:var:: int PyTrace_EXCEPTION
5118
 
 
5119
 
-   The value of the *what* parameter to a :ctype:`Py_tracefunc` function when an
5120
 
+   The value of the *what* parameter to a :c:type:`Py_tracefunc` function when an
5121
 
    exception has been raised.  The callback function is called with this value for
5122
 
    *what* when after any bytecode is processed after which the exception becomes
5123
 
    set within the frame being executed.  The effect of this is that as exception
5124
 
@@ -1005,37 +1015,37 @@
5125
 
    these events; they are not needed by the profiler.
5126
 
 
5127
 
 
5128
 
-.. cvar:: int PyTrace_LINE
5129
 
+.. c:var:: int PyTrace_LINE
5130
 
 
5131
 
    The value passed as the *what* parameter to a trace function (but not a
5132
 
    profiling function) when a line-number event is being reported.
5133
 
 
5134
 
 
5135
 
-.. cvar:: int PyTrace_RETURN
5136
 
+.. c:var:: int PyTrace_RETURN
5137
 
 
5138
 
-   The value for the *what* parameter to :ctype:`Py_tracefunc` functions when a
5139
 
+   The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a
5140
 
    call is returning without propagating an exception.
5141
 
 
5142
 
 
5143
 
-.. cvar:: int PyTrace_C_CALL
5144
 
+.. c:var:: int PyTrace_C_CALL
5145
 
 
5146
 
-   The value for the *what* parameter to :ctype:`Py_tracefunc` functions when a C
5147
 
+   The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a C
5148
 
    function is about to be called.
5149
 
 
5150
 
 
5151
 
-.. cvar:: int PyTrace_C_EXCEPTION
5152
 
+.. c:var:: int PyTrace_C_EXCEPTION
5153
 
 
5154
 
-   The value for the *what* parameter to :ctype:`Py_tracefunc` functions when a C
5155
 
+   The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a C
5156
 
    function has raised an exception.
5157
 
 
5158
 
 
5159
 
-.. cvar:: int PyTrace_C_RETURN
5160
 
+.. c:var:: int PyTrace_C_RETURN
5161
 
 
5162
 
-   The value for the *what* parameter to :ctype:`Py_tracefunc` functions when a C
5163
 
+   The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a C
5164
 
    function has returned.
5165
 
 
5166
 
 
5167
 
-.. cfunction:: void PyEval_SetProfile(Py_tracefunc func, PyObject *obj)
5168
 
+.. c:function:: void PyEval_SetProfile(Py_tracefunc func, PyObject *obj)
5169
 
 
5170
 
    Set the profiler function to *func*.  The *obj* parameter is passed to the
5171
 
    function as its first parameter, and may be any Python object, or *NULL*.  If
5172
 
@@ -1045,13 +1055,13 @@
5173
 
    events.
5174
 
 
5175
 
 
5176
 
-.. cfunction:: void PyEval_SetTrace(Py_tracefunc func, PyObject *obj)
5177
 
+.. c:function:: void PyEval_SetTrace(Py_tracefunc func, PyObject *obj)
5178
 
 
5179
 
    Set the tracing function to *func*.  This is similar to
5180
 
-   :cfunc:`PyEval_SetProfile`, except the tracing function does receive line-number
5181
 
+   :c:func:`PyEval_SetProfile`, except the tracing function does receive line-number
5182
 
    events.
5183
 
 
5184
 
-.. cfunction:: PyObject* PyEval_GetCallStats(PyObject *self)
5185
 
+.. c:function:: PyObject* PyEval_GetCallStats(PyObject *self)
5186
 
 
5187
 
    Return a tuple of function call counts.  There are constants defined for the
5188
 
    positions within the tuple:
5189
 
@@ -1103,14 +1113,14 @@
5190
 
 These functions are only intended to be used by advanced debugging tools.
5191
 
 
5192
 
 
5193
 
-.. cfunction:: PyInterpreterState* PyInterpreterState_Head()
5194
 
+.. c:function:: PyInterpreterState* PyInterpreterState_Head()
5195
 
 
5196
 
    Return the interpreter state object at the head of the list of all such objects.
5197
 
 
5198
 
    .. versionadded:: 2.2
5199
 
 
5200
 
 
5201
 
-.. cfunction:: PyInterpreterState* PyInterpreterState_Next(PyInterpreterState *interp)
5202
 
+.. c:function:: PyInterpreterState* PyInterpreterState_Next(PyInterpreterState *interp)
5203
 
 
5204
 
    Return the next interpreter state object after *interp* from the list of all
5205
 
    such objects.
5206
 
@@ -1118,18 +1128,18 @@
5207
 
    .. versionadded:: 2.2
5208
 
 
5209
 
 
5210
 
-.. cfunction:: PyThreadState * PyInterpreterState_ThreadHead(PyInterpreterState *interp)
5211
 
+.. c:function:: PyThreadState * PyInterpreterState_ThreadHead(PyInterpreterState *interp)
5212
 
 
5213
 
-   Return the a pointer to the first :ctype:`PyThreadState` object in the list of
5214
 
+   Return the a pointer to the first :c:type:`PyThreadState` object in the list of
5215
 
    threads associated with the interpreter *interp*.
5216
 
 
5217
 
    .. versionadded:: 2.2
5218
 
 
5219
 
 
5220
 
-.. cfunction:: PyThreadState* PyThreadState_Next(PyThreadState *tstate)
5221
 
+.. c:function:: PyThreadState* PyThreadState_Next(PyThreadState *tstate)
5222
 
 
5223
 
    Return the next thread state object after *tstate* from the list of all such
5224
 
-   objects belonging to the same :ctype:`PyInterpreterState` object.
5225
 
+   objects belonging to the same :c:type:`PyInterpreterState` object.
5226
 
 
5227
 
    .. versionadded:: 2.2
5228
 
 
5229
 
diff -r 8527427914a2 Doc/c-api/int.rst
5230
 
--- a/Doc/c-api/int.rst
5231
 
+++ b/Doc/c-api/int.rst
5232
 
@@ -8,39 +8,39 @@
5233
 
 .. index:: object: integer
5234
 
 
5235
 
 
5236
 
-.. ctype:: PyIntObject
5237
 
+.. c:type:: PyIntObject
5238
 
 
5239
 
-   This subtype of :ctype:`PyObject` represents a Python integer object.
5240
 
+   This subtype of :c:type:`PyObject` represents a Python integer object.
5241
 
 
5242
 
 
5243
 
-.. cvar:: PyTypeObject PyInt_Type
5244
 
+.. c:var:: PyTypeObject PyInt_Type
5245
 
 
5246
 
    .. index:: single: IntType (in modules types)
5247
 
 
5248
 
-   This instance of :ctype:`PyTypeObject` represents the Python plain integer type.
5249
 
+   This instance of :c:type:`PyTypeObject` represents the Python plain integer type.
5250
 
    This is the same object as ``int`` and ``types.IntType``.
5251
 
 
5252
 
 
5253
 
-.. cfunction:: int PyInt_Check(PyObject *o)
5254
 
+.. c:function:: int PyInt_Check(PyObject *o)
5255
 
 
5256
 
-   Return true if *o* is of type :cdata:`PyInt_Type` or a subtype of
5257
 
-   :cdata:`PyInt_Type`.
5258
 
+   Return true if *o* is of type :c:data:`PyInt_Type` or a subtype of
5259
 
+   :c:data:`PyInt_Type`.
5260
 
 
5261
 
    .. versionchanged:: 2.2
5262
 
       Allowed subtypes to be accepted.
5263
 
 
5264
 
 
5265
 
-.. cfunction:: int PyInt_CheckExact(PyObject *o)
5266
 
+.. c:function:: int PyInt_CheckExact(PyObject *o)
5267
 
 
5268
 
-   Return true if *o* is of type :cdata:`PyInt_Type`, but not a subtype of
5269
 
-   :cdata:`PyInt_Type`.
5270
 
+   Return true if *o* is of type :c:data:`PyInt_Type`, but not a subtype of
5271
 
+   :c:data:`PyInt_Type`.
5272
 
 
5273
 
    .. versionadded:: 2.2
5274
 
 
5275
 
 
5276
 
-.. cfunction:: PyObject* PyInt_FromString(char *str, char **pend, int base)
5277
 
+.. c:function:: PyObject* PyInt_FromString(char *str, char **pend, int base)
5278
 
 
5279
 
-   Return a new :ctype:`PyIntObject` or :ctype:`PyLongObject` based on the string
5280
 
+   Return a new :c:type:`PyIntObject` or :c:type:`PyLongObject` based on the string
5281
 
    value in *str*, which is interpreted according to the radix in *base*.  If
5282
 
    *pend* is non-*NULL*, ``*pend`` will point to the first character in *str* which
5283
 
    follows the representation of the number.  If *base* is ``0``, the radix will be
5284
 
@@ -49,13 +49,13 @@
5285
 
    8 will be used; otherwise radix 10 will be used.  If *base* is not ``0``, it
5286
 
    must be between ``2`` and ``36``, inclusive.  Leading spaces are ignored.  If
5287
 
    there are no digits, :exc:`ValueError` will be raised.  If the string represents
5288
 
-   a number too large to be contained within the machine's :ctype:`long int` type
5289
 
-   and overflow warnings are being suppressed, a :ctype:`PyLongObject` will be
5290
 
+   a number too large to be contained within the machine's :c:type:`long int` type
5291
 
+   and overflow warnings are being suppressed, a :c:type:`PyLongObject` will be
5292
 
    returned.  If overflow warnings are not being suppressed, *NULL* will be
5293
 
    returned in this case.
5294
 
 
5295
 
 
5296
 
-.. cfunction:: PyObject* PyInt_FromLong(long ival)
5297
 
+.. c:function:: PyObject* PyInt_FromLong(long ival)
5298
 
 
5299
 
    Create a new integer object with a value of *ival*.
5300
 
 
5301
 
@@ -66,7 +66,7 @@
5302
 
    undefined. :-)
5303
 
 
5304
 
 
5305
 
-.. cfunction:: PyObject* PyInt_FromSsize_t(Py_ssize_t ival)
5306
 
+.. c:function:: PyObject* PyInt_FromSsize_t(Py_ssize_t ival)
5307
 
 
5308
 
    Create a new integer object with a value of *ival*. If the value is larger
5309
 
    than ``LONG_MAX`` or smaller than ``LONG_MIN``, a long integer object is
5310
 
@@ -75,7 +75,7 @@
5311
 
    .. versionadded:: 2.5
5312
 
 
5313
 
 
5314
 
-.. cfunction:: PyObject* PyInt_FromSize_t(size_t ival)
5315
 
+.. c:function:: PyObject* PyInt_FromSize_t(size_t ival)
5316
 
 
5317
 
    Create a new integer object with a value of *ival*. If the value exceeds
5318
 
    ``LONG_MAX``, a long integer object is returned.
5319
 
@@ -83,47 +83,47 @@
5320
 
    .. versionadded:: 2.5
5321
 
 
5322
 
 
5323
 
-.. cfunction:: long PyInt_AsLong(PyObject *io)
5324
 
+.. c:function:: long PyInt_AsLong(PyObject *io)
5325
 
 
5326
 
-   Will first attempt to cast the object to a :ctype:`PyIntObject`, if it is not
5327
 
+   Will first attempt to cast the object to a :c:type:`PyIntObject`, if it is not
5328
 
    already one, and then return its value. If there is an error, ``-1`` is
5329
 
    returned, and the caller should check ``PyErr_Occurred()`` to find out whether
5330
 
    there was an error, or whether the value just happened to be -1.
5331
 
 
5332
 
 
5333
 
-.. cfunction:: long PyInt_AS_LONG(PyObject *io)
5334
 
+.. c:function:: long PyInt_AS_LONG(PyObject *io)
5335
 
 
5336
 
    Return the value of the object *io*.  No error checking is performed.
5337
 
 
5338
 
 
5339
 
-.. cfunction:: unsigned long PyInt_AsUnsignedLongMask(PyObject *io)
5340
 
+.. c:function:: unsigned long PyInt_AsUnsignedLongMask(PyObject *io)
5341
 
 
5342
 
-   Will first attempt to cast the object to a :ctype:`PyIntObject` or
5343
 
-   :ctype:`PyLongObject`, if it is not already one, and then return its value as
5344
 
+   Will first attempt to cast the object to a :c:type:`PyIntObject` or
5345
 
+   :c:type:`PyLongObject`, if it is not already one, and then return its value as
5346
 
    unsigned long.  This function does not check for overflow.
5347
 
 
5348
 
    .. versionadded:: 2.3
5349
 
 
5350
 
 
5351
 
-.. cfunction:: unsigned PY_LONG_LONG PyInt_AsUnsignedLongLongMask(PyObject *io)
5352
 
+.. c:function:: unsigned PY_LONG_LONG PyInt_AsUnsignedLongLongMask(PyObject *io)
5353
 
 
5354
 
-   Will first attempt to cast the object to a :ctype:`PyIntObject` or
5355
 
-   :ctype:`PyLongObject`, if it is not already one, and then return its value as
5356
 
+   Will first attempt to cast the object to a :c:type:`PyIntObject` or
5357
 
+   :c:type:`PyLongObject`, if it is not already one, and then return its value as
5358
 
    unsigned long long, without checking for overflow.
5359
 
 
5360
 
    .. versionadded:: 2.3
5361
 
 
5362
 
 
5363
 
-.. cfunction:: Py_ssize_t PyInt_AsSsize_t(PyObject *io)
5364
 
+.. c:function:: Py_ssize_t PyInt_AsSsize_t(PyObject *io)
5365
 
 
5366
 
-   Will first attempt to cast the object to a :ctype:`PyIntObject` or
5367
 
-   :ctype:`PyLongObject`, if it is not already one, and then return its value as
5368
 
-   :ctype:`Py_ssize_t`.
5369
 
+   Will first attempt to cast the object to a :c:type:`PyIntObject` or
5370
 
+   :c:type:`PyLongObject`, if it is not already one, and then return its value as
5371
 
+   :c:type:`Py_ssize_t`.
5372
 
 
5373
 
    .. versionadded:: 2.5
5374
 
 
5375
 
 
5376
 
-.. cfunction:: long PyInt_GetMax()
5377
 
+.. c:function:: long PyInt_GetMax()
5378
 
 
5379
 
    .. index:: single: LONG_MAX
5380
 
 
5381
 
@@ -131,7 +131,7 @@
5382
 
    (:const:`LONG_MAX`, as defined in the system header files).
5383
 
 
5384
 
 
5385
 
-.. cfunction:: int PyInt_ClearFreeList()
5386
 
+.. c:function:: int PyInt_ClearFreeList()
5387
 
 
5388
 
    Clear the integer free list. Return the number of items that could not
5389
 
    be freed.
5390
 
diff -r 8527427914a2 Doc/c-api/intro.rst
5391
 
--- a/Doc/c-api/intro.rst
5392
 
+++ b/Doc/c-api/intro.rst
5393
 
@@ -88,15 +88,15 @@
5394
 
 .. index:: object: type
5395
 
 
5396
 
 Most Python/C API functions have one or more arguments as well as a return value
5397
 
-of type :ctype:`PyObject\*`.  This type is a pointer to an opaque data type
5398
 
+of type :c:type:`PyObject\*`.  This type is a pointer to an opaque data type
5399
 
 representing an arbitrary Python object.  Since all Python object types are
5400
 
 treated the same way by the Python language in most situations (e.g.,
5401
 
 assignments, scope rules, and argument passing), it is only fitting that they
5402
 
 should be represented by a single C type.  Almost all Python objects live on the
5403
 
 heap: you never declare an automatic or static variable of type
5404
 
-:ctype:`PyObject`, only pointer variables of type :ctype:`PyObject\*` can  be
5405
 
+:c:type:`PyObject`, only pointer variables of type :c:type:`PyObject\*` can  be
5406
 
 declared.  The sole exception are the type objects; since these must never be
5407
 
-deallocated, they are typically static :ctype:`PyTypeObject` objects.
5408
 
+deallocated, they are typically static :c:type:`PyTypeObject` objects.
5409
 
 
5410
 
 All Python objects (even Python integers) have a :dfn:`type` and a
5411
 
 :dfn:`reference count`.  An object's type determines what kind of object it is
5412
 
@@ -127,8 +127,8 @@
5413
 
    single: Py_DECREF()
5414
 
 
5415
 
 Reference counts are always manipulated explicitly.  The normal way is  to use
5416
 
-the macro :cfunc:`Py_INCREF` to increment an object's reference count by one,
5417
 
-and :cfunc:`Py_DECREF` to decrement it by   one.  The :cfunc:`Py_DECREF` macro
5418
 
+the macro :c:func:`Py_INCREF` to increment an object's reference count by one,
5419
 
+and :c:func:`Py_DECREF` to decrement it by   one.  The :c:func:`Py_DECREF` macro
5420
 
 is considerably more complex than the incref one, since it must check whether
5421
 
 the reference count becomes zero and then cause the object's deallocator to be
5422
 
 called. The deallocator is a function pointer contained in the object's type
5423
 
@@ -159,13 +159,13 @@
5424
 
 conceivably remove the object from the list, decrementing its reference count
5425
 
 and possible deallocating it. The real danger is that innocent-looking
5426
 
 operations may invoke arbitrary Python code which could do this; there is a code
5427
 
-path which allows control to flow back to the user from a :cfunc:`Py_DECREF`, so
5428
 
+path which allows control to flow back to the user from a :c:func:`Py_DECREF`, so
5429
 
 almost any operation is potentially dangerous.
5430
 
 
5431
 
 A safe approach is to always use the generic operations (functions  whose name
5432
 
 begins with ``PyObject_``, ``PyNumber_``, ``PySequence_`` or ``PyMapping_``).
5433
 
 These operations always increment the reference count of the object they return.
5434
 
-This leaves the caller with the responsibility to call :cfunc:`Py_DECREF` when
5435
 
+This leaves the caller with the responsibility to call :c:func:`Py_DECREF` when
5436
 
 they are done with the result; this soon becomes second nature.
5437
 
 
5438
 
 
5439
 
@@ -180,7 +180,7 @@
5440
 
 reference" means being responsible for calling Py_DECREF on it when the
5441
 
 reference is no longer needed.  Ownership can also be transferred, meaning that
5442
 
 the code that receives ownership of the reference then becomes responsible for
5443
 
-eventually decref'ing it by calling :cfunc:`Py_DECREF` or :cfunc:`Py_XDECREF`
5444
 
+eventually decref'ing it by calling :c:func:`Py_DECREF` or :c:func:`Py_XDECREF`
5445
 
 when it's no longer needed---or passing on this responsibility (usually to its
5446
 
 caller). When a function passes ownership of a reference on to its caller, the
5447
 
 caller is said to receive a *new* reference.  When no ownership is transferred,
5448
 
@@ -198,7 +198,7 @@
5449
 
    single: PyTuple_SetItem()
5450
 
 
5451
 
 Few functions steal references; the two notable exceptions are
5452
 
-:cfunc:`PyList_SetItem` and :cfunc:`PyTuple_SetItem`, which  steal a reference
5453
 
+:c:func:`PyList_SetItem` and :c:func:`PyTuple_SetItem`, which  steal a reference
5454
 
 to the item (but not to the tuple or list into which the item is put!).  These
5455
 
 functions were designed to steal a reference because of a common idiom for
5456
 
 populating a tuple or list with newly created objects; for example, the code to
5457
 
@@ -212,21 +212,21 @@
5458
 
    PyTuple_SetItem(t, 1, PyInt_FromLong(2L));
5459
 
    PyTuple_SetItem(t, 2, PyString_FromString("three"));
5460
 
 
5461
 
-Here, :cfunc:`PyInt_FromLong` returns a new reference which is immediately
5462
 
-stolen by :cfunc:`PyTuple_SetItem`.  When you want to keep using an object
5463
 
-although the reference to it will be stolen, use :cfunc:`Py_INCREF` to grab
5464
 
+Here, :c:func:`PyInt_FromLong` returns a new reference which is immediately
5465
 
+stolen by :c:func:`PyTuple_SetItem`.  When you want to keep using an object
5466
 
+although the reference to it will be stolen, use :c:func:`Py_INCREF` to grab
5467
 
 another reference before calling the reference-stealing function.
5468
 
 
5469
 
-Incidentally, :cfunc:`PyTuple_SetItem` is the *only* way to set tuple items;
5470
 
-:cfunc:`PySequence_SetItem` and :cfunc:`PyObject_SetItem` refuse to do this
5471
 
+Incidentally, :c:func:`PyTuple_SetItem` is the *only* way to set tuple items;
5472
 
+:c:func:`PySequence_SetItem` and :c:func:`PyObject_SetItem` refuse to do this
5473
 
 since tuples are an immutable data type.  You should only use
5474
 
-:cfunc:`PyTuple_SetItem` for tuples that you are creating yourself.
5475
 
+:c:func:`PyTuple_SetItem` for tuples that you are creating yourself.
5476
 
 
5477
 
-Equivalent code for populating a list can be written using :cfunc:`PyList_New`
5478
 
-and :cfunc:`PyList_SetItem`.
5479
 
+Equivalent code for populating a list can be written using :c:func:`PyList_New`
5480
 
+and :c:func:`PyList_SetItem`.
5481
 
 
5482
 
 However, in practice, you will rarely use these ways of creating and populating
5483
 
-a tuple or list.  There's a generic function, :cfunc:`Py_BuildValue`, that can
5484
 
+a tuple or list.  There's a generic function, :c:func:`Py_BuildValue`, that can
5485
 
 create most common objects from C values, directed by a :dfn:`format string`.
5486
 
 For example, the above two blocks of code could be replaced by the following
5487
 
 (which also takes care of the error checking)::
5488
 
@@ -236,7 +236,7 @@
5489
 
    tuple = Py_BuildValue("(iis)", 1, 2, "three");
5490
 
    list = Py_BuildValue("[iis]", 1, 2, "three");
5491
 
 
5492
 
-It is much more common to use :cfunc:`PyObject_SetItem` and friends with items
5493
 
+It is much more common to use :c:func:`PyObject_SetItem` and friends with items
5494
 
 whose references you are only borrowing, like arguments that were passed in to
5495
 
 the function you are writing.  In that case, their behaviour regarding reference
5496
 
 counts is much saner, since you don't have to increment a reference count so you
5497
 
@@ -270,15 +270,15 @@
5498
 
 you ownership of the reference. The reason is simple: in many cases, the
5499
 
 returned object is created  on the fly, and the reference you get is the only
5500
 
 reference to the  object.  Therefore, the generic functions that return object
5501
 
-references, like :cfunc:`PyObject_GetItem` and  :cfunc:`PySequence_GetItem`,
5502
 
+references, like :c:func:`PyObject_GetItem` and  :c:func:`PySequence_GetItem`,
5503
 
 always return a new reference (the caller becomes the owner of the reference).
5504
 
 
5505
 
 It is important to realize that whether you own a reference returned  by a
5506
 
 function depends on which function you call only --- *the plumage* (the type of
5507
 
 the object passed as an argument to the function) *doesn't enter into it!*
5508
 
-Thus, if you  extract an item from a list using :cfunc:`PyList_GetItem`, you
5509
 
+Thus, if you  extract an item from a list using :c:func:`PyList_GetItem`, you
5510
 
 don't own the reference --- but if you obtain the same item from the same list
5511
 
-using :cfunc:`PySequence_GetItem` (which happens to take exactly the same
5512
 
+using :c:func:`PySequence_GetItem` (which happens to take exactly the same
5513
 
 arguments), you do own a reference to the returned object.
5514
 
 
5515
 
 .. index::
5516
 
@@ -286,8 +286,8 @@
5517
 
    single: PySequence_GetItem()
5518
 
 
5519
 
 Here is an example of how you could write a function that computes the sum of
5520
 
-the items in a list of integers; once using  :cfunc:`PyList_GetItem`, and once
5521
 
-using :cfunc:`PySequence_GetItem`. ::
5522
 
+the items in a list of integers; once using  :c:func:`PyList_GetItem`, and once
5523
 
+using :c:func:`PySequence_GetItem`. ::
5524
 
 
5525
 
    long
5526
 
    sum_list(PyObject *list)
5527
 
@@ -340,8 +340,8 @@
5528
 
 -----
5529
 
 
5530
 
 There are few other data types that play a significant role in  the Python/C
5531
 
-API; most are simple C types such as :ctype:`int`,  :ctype:`long`,
5532
 
-:ctype:`double` and :ctype:`char\*`.  A few structure types  are used to
5533
 
+API; most are simple C types such as :c:type:`int`,  :c:type:`long`,
5534
 
+:c:type:`double` and :c:type:`char\*`.  A few structure types  are used to
5535
 
 describe static tables used to list the functions exported  by a module or the
5536
 
 data attributes of a new object type, and another is used to describe the value
5537
 
 of a complex number.  These will  be discussed together with the functions that
5538
 
@@ -370,7 +370,7 @@
5539
 
 A few functions return a Boolean true/false result, with false indicating an
5540
 
 error.  Very few functions return no explicit error indicator or have an
5541
 
 ambiguous return value, and require explicit testing for errors with
5542
 
-:cfunc:`PyErr_Occurred`.  These exceptions are always explicitly documented.
5543
 
+:c:func:`PyErr_Occurred`.  These exceptions are always explicitly documented.
5544
 
 
5545
 
 .. index::
5546
 
    single: PyErr_SetString()
5547
 
@@ -379,11 +379,11 @@
5548
 
 Exception state is maintained in per-thread storage (this is  equivalent to
5549
 
 using global storage in an unthreaded application).  A  thread can be in one of
5550
 
 two states: an exception has occurred, or not. The function
5551
 
-:cfunc:`PyErr_Occurred` can be used to check for this: it returns a borrowed
5552
 
+:c:func:`PyErr_Occurred` can be used to check for this: it returns a borrowed
5553
 
 reference to the exception type object when an exception has occurred, and
5554
 
 *NULL* otherwise.  There are a number of functions to set the exception state:
5555
 
-:cfunc:`PyErr_SetString` is the most common (though not the most general)
5556
 
-function to set the exception state, and :cfunc:`PyErr_Clear` clears the
5557
 
+:c:func:`PyErr_SetString` is the most common (though not the most general)
5558
 
+function to set the exception state, and :c:func:`PyErr_Clear` clears the
5559
 
 exception state.
5560
 
 
5561
 
 .. index::
5562
 
@@ -424,7 +424,7 @@
5563
 
 .. index:: single: sum_sequence()
5564
 
 
5565
 
 A simple example of detecting exceptions and passing them on is shown in the
5566
 
-:cfunc:`sum_sequence` example above.  It so happens that that example doesn't
5567
 
+:c:func:`sum_sequence` example above.  It so happens that that example doesn't
5568
 
 need to clean up any owned references when it detects an error.  The following
5569
 
 example function shows some error cleanup.  First, to remind you why you like
5570
 
 Python, we show the equivalent Python code::
5571
 
@@ -491,10 +491,10 @@
5572
 
    single: Py_XDECREF()
5573
 
 
5574
 
 This example represents an endorsed use of the ``goto`` statement  in C!
5575
 
-It illustrates the use of :cfunc:`PyErr_ExceptionMatches` and
5576
 
-:cfunc:`PyErr_Clear` to handle specific exceptions, and the use of
5577
 
-:cfunc:`Py_XDECREF` to dispose of owned references that may be *NULL* (note the
5578
 
-``'X'`` in the name; :cfunc:`Py_DECREF` would crash when confronted with a
5579
 
+It illustrates the use of :c:func:`PyErr_ExceptionMatches` and
5580
 
+:c:func:`PyErr_Clear` to handle specific exceptions, and the use of
5581
 
+:c:func:`Py_XDECREF` to dispose of owned references that may be *NULL* (note the
5582
 
+``'X'`` in the name; :c:func:`Py_DECREF` would crash when confronted with a
5583
 
 *NULL* reference).  It is important that the variables used to hold owned
5584
 
 references are initialized to *NULL* for this to work; likewise, the proposed
5585
 
 return value is initialized to ``-1`` (failure) and only set to success after
5586
 
@@ -520,20 +520,20 @@
5587
 
    triple: module; search; path
5588
 
    single: path (in module sys)
5589
 
 
5590
 
-The basic initialization function is :cfunc:`Py_Initialize`. This initializes
5591
 
+The basic initialization function is :c:func:`Py_Initialize`. This initializes
5592
 
 the table of loaded modules, and creates the fundamental modules
5593
 
 :mod:`__builtin__`, :mod:`__main__`, :mod:`sys`, and :mod:`exceptions`.  It also
5594
 
 initializes the module search path (``sys.path``).
5595
 
 
5596
 
 .. index:: single: PySys_SetArgvEx()
5597
 
 
5598
 
-:cfunc:`Py_Initialize` does not set the "script argument list"  (``sys.argv``).
5599
 
+:c:func:`Py_Initialize` does not set the "script argument list"  (``sys.argv``).
5600
 
 If this variable is needed by Python code that will be executed later, it must
5601
 
 be set explicitly with a call to  ``PySys_SetArgvEx(argc, argv, updatepath)``
5602
 
-after the call to :cfunc:`Py_Initialize`.
5603
 
+after the call to :c:func:`Py_Initialize`.
5604
 
 
5605
 
 On most systems (in particular, on Unix and Windows, although the details are
5606
 
-slightly different), :cfunc:`Py_Initialize` calculates the module search path
5607
 
+slightly different), :c:func:`Py_Initialize` calculates the module search path
5608
 
 based upon its best guess for the location of the standard Python interpreter
5609
 
 executable, assuming that the Python library is found in a fixed location
5610
 
 relative to the Python interpreter executable.  In particular, it looks for a
5611
 
@@ -557,22 +557,22 @@
5612
 
    single: Py_GetProgramFullPath()
5613
 
 
5614
 
 The embedding application can steer the search by calling
5615
 
-``Py_SetProgramName(file)`` *before* calling  :cfunc:`Py_Initialize`.  Note that
5616
 
+``Py_SetProgramName(file)`` *before* calling  :c:func:`Py_Initialize`.  Note that
5617
 
 :envvar:`PYTHONHOME` still overrides this and :envvar:`PYTHONPATH` is still
5618
 
 inserted in front of the standard path.  An application that requires total
5619
 
-control has to provide its own implementation of :cfunc:`Py_GetPath`,
5620
 
-:cfunc:`Py_GetPrefix`, :cfunc:`Py_GetExecPrefix`, and
5621
 
-:cfunc:`Py_GetProgramFullPath` (all defined in :file:`Modules/getpath.c`).
5622
 
+control has to provide its own implementation of :c:func:`Py_GetPath`,
5623
 
+:c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, and
5624
 
+:c:func:`Py_GetProgramFullPath` (all defined in :file:`Modules/getpath.c`).
5625
 
 
5626
 
 .. index:: single: Py_IsInitialized()
5627
 
 
5628
 
 Sometimes, it is desirable to "uninitialize" Python.  For instance,  the
5629
 
 application may want to start over (make another call to
5630
 
-:cfunc:`Py_Initialize`) or the application is simply done with its  use of
5631
 
+:c:func:`Py_Initialize`) or the application is simply done with its  use of
5632
 
 Python and wants to free memory allocated by Python.  This can be accomplished
5633
 
-by calling :cfunc:`Py_Finalize`.  The function :cfunc:`Py_IsInitialized` returns
5634
 
+by calling :c:func:`Py_Finalize`.  The function :c:func:`Py_IsInitialized` returns
5635
 
 true if Python is currently in the initialized state.  More information about
5636
 
-these functions is given in a later chapter. Notice that :cfunc:`Py_Finalize`
5637
 
+these functions is given in a later chapter. Notice that :c:func:`Py_Finalize`
5638
 
 does *not* free all memory allocated by the Python interpreter, e.g. memory
5639
 
 allocated by extension modules currently cannot be released.
5640
 
 
5641
 
@@ -592,11 +592,11 @@
5642
 
 allocator, or low-level profiling of the main interpreter loop.  Only the most
5643
 
 frequently-used builds will be described in the remainder of this section.
5644
 
 
5645
 
-Compiling the interpreter with the :cmacro:`Py_DEBUG` macro defined produces
5646
 
-what is generally meant by "a debug build" of Python. :cmacro:`Py_DEBUG` is
5647
 
-enabled in the Unix build by adding :option:`--with-pydebug` to the
5648
 
-:file:`configure` command.  It is also implied by the presence of the
5649
 
-not-Python-specific :cmacro:`_DEBUG` macro.  When :cmacro:`Py_DEBUG` is enabled
5650
 
+Compiling the interpreter with the :c:macro:`Py_DEBUG` macro defined produces
5651
 
+what is generally meant by "a debug build" of Python. :c:macro:`Py_DEBUG` is
5652
 
+enabled in the Unix build by adding ``--with-pydebug`` to the
5653
 
+:file:`./configure` command.  It is also implied by the presence of the
5654
 
+not-Python-specific :c:macro:`_DEBUG` macro.  When :c:macro:`Py_DEBUG` is enabled
5655
 
 in the Unix build, compiler optimization is disabled.
5656
 
 
5657
 
 In addition to the reference count debugging described below, the following
5658
 
@@ -625,11 +625,11 @@
5659
 
 
5660
 
 There may be additional checks not mentioned here.
5661
 
 
5662
 
-Defining :cmacro:`Py_TRACE_REFS` enables reference tracing.  When defined, a
5663
 
+Defining :c:macro:`Py_TRACE_REFS` enables reference tracing.  When defined, a
5664
 
 circular doubly linked list of active objects is maintained by adding two extra
5665
 
-fields to every :ctype:`PyObject`.  Total allocations are tracked as well.  Upon
5666
 
+fields to every :c:type:`PyObject`.  Total allocations are tracked as well.  Upon
5667
 
 exit, all existing references are printed.  (In interactive mode this happens
5668
 
-after every statement run by the interpreter.)  Implied by :cmacro:`Py_DEBUG`.
5669
 
+after every statement run by the interpreter.)  Implied by :c:macro:`Py_DEBUG`.
5670
 
 
5671
 
 Please refer to :file:`Misc/SpecialBuilds.txt` in the Python source distribution
5672
 
 for more detailed information.
5673
 
diff -r 8527427914a2 Doc/c-api/iter.rst
5674
 
--- a/Doc/c-api/iter.rst
5675
 
+++ b/Doc/c-api/iter.rst
5676
 
@@ -10,12 +10,12 @@
5677
 
 There are only a couple of functions specifically for working with iterators.
5678
 
 
5679
 
 
5680
 
-.. cfunction:: int PyIter_Check(PyObject *o)
5681
 
+.. c:function:: int PyIter_Check(PyObject *o)
5682
 
 
5683
 
    Return true if the object *o* supports the iterator protocol.
5684
 
 
5685
 
 
5686
 
-.. cfunction:: PyObject* PyIter_Next(PyObject *o)
5687
 
+.. c:function:: PyObject* PyIter_Next(PyObject *o)
5688
 
 
5689
 
    Return the next value from the iteration *o*.  If the object is an iterator,
5690
 
    this retrieves the next value from the iteration, and returns *NULL* with no
5691
 
diff -r 8527427914a2 Doc/c-api/iterator.rst
5692
 
--- a/Doc/c-api/iterator.rst
5693
 
+++ b/Doc/c-api/iterator.rst
5694
 
@@ -12,23 +12,23 @@
5695
 
 sentinel value is returned.
5696
 
 
5697
 
 
5698
 
-.. cvar:: PyTypeObject PySeqIter_Type
5699
 
+.. c:var:: PyTypeObject PySeqIter_Type
5700
 
 
5701
 
-   Type object for iterator objects returned by :cfunc:`PySeqIter_New` and the
5702
 
+   Type object for iterator objects returned by :c:func:`PySeqIter_New` and the
5703
 
    one-argument form of the :func:`iter` built-in function for built-in sequence
5704
 
    types.
5705
 
 
5706
 
    .. versionadded:: 2.2
5707
 
 
5708
 
 
5709
 
-.. cfunction:: int PySeqIter_Check(op)
5710
 
+.. c:function:: int PySeqIter_Check(op)
5711
 
 
5712
 
-   Return true if the type of *op* is :cdata:`PySeqIter_Type`.
5713
 
+   Return true if the type of *op* is :c:data:`PySeqIter_Type`.
5714
 
 
5715
 
    .. versionadded:: 2.2
5716
 
 
5717
 
 
5718
 
-.. cfunction:: PyObject* PySeqIter_New(PyObject *seq)
5719
 
+.. c:function:: PyObject* PySeqIter_New(PyObject *seq)
5720
 
 
5721
 
    Return an iterator that works with a general sequence object, *seq*.  The
5722
 
    iteration ends when the sequence raises :exc:`IndexError` for the subscripting
5723
 
@@ -37,22 +37,22 @@
5724
 
    .. versionadded:: 2.2
5725
 
 
5726
 
 
5727
 
-.. cvar:: PyTypeObject PyCallIter_Type
5728
 
+.. c:var:: PyTypeObject PyCallIter_Type
5729
 
 
5730
 
-   Type object for iterator objects returned by :cfunc:`PyCallIter_New` and the
5731
 
+   Type object for iterator objects returned by :c:func:`PyCallIter_New` and the
5732
 
    two-argument form of the :func:`iter` built-in function.
5733
 
 
5734
 
    .. versionadded:: 2.2
5735
 
 
5736
 
 
5737
 
-.. cfunction:: int PyCallIter_Check(op)
5738
 
+.. c:function:: int PyCallIter_Check(op)
5739
 
 
5740
 
-   Return true if the type of *op* is :cdata:`PyCallIter_Type`.
5741
 
+   Return true if the type of *op* is :c:data:`PyCallIter_Type`.
5742
 
 
5743
 
    .. versionadded:: 2.2
5744
 
 
5745
 
 
5746
 
-.. cfunction:: PyObject* PyCallIter_New(PyObject *callable, PyObject *sentinel)
5747
 
+.. c:function:: PyObject* PyCallIter_New(PyObject *callable, PyObject *sentinel)
5748
 
 
5749
 
    Return a new iterator.  The first parameter, *callable*, can be any Python
5750
 
    callable object that can be called with no parameters; each call to it should
5751
 
diff -r 8527427914a2 Doc/c-api/list.rst
5752
 
--- a/Doc/c-api/list.rst
5753
 
+++ b/Doc/c-api/list.rst
5754
 
@@ -8,18 +8,18 @@
5755
 
 .. index:: object: list
5756
 
 
5757
 
 
5758
 
-.. ctype:: PyListObject
5759
 
+.. c:type:: PyListObject
5760
 
 
5761
 
-   This subtype of :ctype:`PyObject` represents a Python list object.
5762
 
+   This subtype of :c:type:`PyObject` represents a Python list object.
5763
 
 
5764
 
 
5765
 
-.. cvar:: PyTypeObject PyList_Type
5766
 
+.. c:var:: PyTypeObject PyList_Type
5767
 
 
5768
 
-   This instance of :ctype:`PyTypeObject` represents the Python list type.  This
5769
 
+   This instance of :c:type:`PyTypeObject` represents the Python list type.  This
5770
 
    is the same object as ``list`` in the Python layer.
5771
 
 
5772
 
 
5773
 
-.. cfunction:: int PyList_Check(PyObject *p)
5774
 
+.. c:function:: int PyList_Check(PyObject *p)
5775
 
 
5776
 
    Return true if *p* is a list object or an instance of a subtype of the list
5777
 
    type.
5778
 
@@ -28,7 +28,7 @@
5779
 
       Allowed subtypes to be accepted.
5780
 
 
5781
 
 
5782
 
-.. cfunction:: int PyList_CheckExact(PyObject *p)
5783
 
+.. c:function:: int PyList_CheckExact(PyObject *p)
5784
 
 
5785
 
    Return true if *p* is a list object, but not an instance of a subtype of
5786
 
    the list type.
5787
 
@@ -36,7 +36,7 @@
5788
 
    .. versionadded:: 2.2
5789
 
 
5790
 
 
5791
 
-.. cfunction:: PyObject* PyList_New(Py_ssize_t len)
5792
 
+.. c:function:: PyObject* PyList_New(Py_ssize_t len)
5793
 
 
5794
 
    Return a new list of length *len* on success, or *NULL* on failure.
5795
 
 
5796
 
@@ -44,15 +44,15 @@
5797
 
 
5798
 
       If *len* is greater than zero, the returned list object's items are
5799
 
       set to ``NULL``.  Thus you cannot use abstract API functions such as
5800
 
-      :cfunc:`PySequence_SetItem`  or expose the object to Python code before
5801
 
-      setting all items to a real object with :cfunc:`PyList_SetItem`.
5802
 
+      :c:func:`PySequence_SetItem`  or expose the object to Python code before
5803
 
+      setting all items to a real object with :c:func:`PyList_SetItem`.
5804
 
 
5805
 
    .. versionchanged:: 2.5
5806
 
-      This function used an :ctype:`int` for *size*. This might require
5807
 
+      This function used an :c:type:`int` for *size*. This might require
5808
 
       changes in your code for properly supporting 64-bit systems.
5809
 
 
5810
 
 
5811
 
-.. cfunction:: Py_ssize_t PyList_Size(PyObject *list)
5812
 
+.. c:function:: Py_ssize_t PyList_Size(PyObject *list)
5813
 
 
5814
 
    .. index:: builtin: len
5815
 
 
5816
 
@@ -60,20 +60,20 @@
5817
 
    ``len(list)`` on a list object.
5818
 
 
5819
 
    .. versionchanged:: 2.5
5820
 
-      This function returned an :ctype:`int`. This might require changes in
5821
 
+      This function returned an :c:type:`int`. This might require changes in
5822
 
       your code for properly supporting 64-bit systems.
5823
 
 
5824
 
 
5825
 
-.. cfunction:: Py_ssize_t PyList_GET_SIZE(PyObject *list)
5826
 
+.. c:function:: Py_ssize_t PyList_GET_SIZE(PyObject *list)
5827
 
 
5828
 
-   Macro form of :cfunc:`PyList_Size` without error checking.
5829
 
+   Macro form of :c:func:`PyList_Size` without error checking.
5830
 
 
5831
 
    .. versionchanged:: 2.5
5832
 
-      This macro returned an :ctype:`int`. This might require changes in your
5833
 
+      This macro returned an :c:type:`int`. This might require changes in your
5834
 
       code for properly supporting 64-bit systems.
5835
 
 
5836
 
 
5837
 
-.. cfunction:: PyObject* PyList_GetItem(PyObject *list, Py_ssize_t index)
5838
 
+.. c:function:: PyObject* PyList_GetItem(PyObject *list, Py_ssize_t index)
5839
 
 
5840
 
    Return the object at position *index* in the list pointed to by *list*.  The
5841
 
    position must be positive, indexing from the end of the list is not
5842
 
@@ -81,20 +81,20 @@
5843
 
    :exc:`IndexError` exception.
5844
 
 
5845
 
    .. versionchanged:: 2.5
5846
 
-      This function used an :ctype:`int` for *index*. This might require
5847
 
+      This function used an :c:type:`int` for *index*. This might require
5848
 
       changes in your code for properly supporting 64-bit systems.
5849
 
 
5850
 
 
5851
 
-.. cfunction:: PyObject* PyList_GET_ITEM(PyObject *list, Py_ssize_t i)
5852
 
+.. c:function:: PyObject* PyList_GET_ITEM(PyObject *list, Py_ssize_t i)
5853
 
 
5854
 
-   Macro form of :cfunc:`PyList_GetItem` without error checking.
5855
 
+   Macro form of :c:func:`PyList_GetItem` without error checking.
5856
 
 
5857
 
    .. versionchanged:: 2.5
5858
 
-      This macro used an :ctype:`int` for *i*. This might require changes in
5859
 
+      This macro used an :c:type:`int` for *i*. This might require changes in
5860
 
       your code for properly supporting 64-bit systems.
5861
 
 
5862
 
 
5863
 
-.. cfunction:: int PyList_SetItem(PyObject *list, Py_ssize_t index, PyObject *item)
5864
 
+.. c:function:: int PyList_SetItem(PyObject *list, Py_ssize_t index, PyObject *item)
5865
 
 
5866
 
    Set the item at index *index* in list to *item*.  Return ``0`` on success
5867
 
    or ``-1`` on failure.
5868
 
@@ -105,46 +105,46 @@
5869
 
       an item already in the list at the affected position.
5870
 
 
5871
 
    .. versionchanged:: 2.5
5872
 
-      This function used an :ctype:`int` for *index*. This might require
5873
 
+      This function used an :c:type:`int` for *index*. This might require
5874
 
       changes in your code for properly supporting 64-bit systems.
5875
 
 
5876
 
 
5877
 
-.. cfunction:: void PyList_SET_ITEM(PyObject *list, Py_ssize_t i, PyObject *o)
5878
 
+.. c:function:: void PyList_SET_ITEM(PyObject *list, Py_ssize_t i, PyObject *o)
5879
 
 
5880
 
-   Macro form of :cfunc:`PyList_SetItem` without error checking. This is
5881
 
+   Macro form of :c:func:`PyList_SetItem` without error checking. This is
5882
 
    normally only used to fill in new lists where there is no previous content.
5883
 
 
5884
 
    .. note::
5885
 
 
5886
 
       This macro "steals" a reference to *item*, and, unlike
5887
 
-      :cfunc:`PyList_SetItem`, does *not* discard a reference to any item that
5888
 
+      :c:func:`PyList_SetItem`, does *not* discard a reference to any item that
5889
 
       it being replaced; any reference in *list* at position *i* will be
5890
 
       leaked.
5891
 
 
5892
 
    .. versionchanged:: 2.5
5893
 
-      This macro used an :ctype:`int` for *i*. This might require
5894
 
+      This macro used an :c:type:`int` for *i*. This might require
5895
 
       changes in your code for properly supporting 64-bit systems.
5896
 
 
5897
 
 
5898
 
-.. cfunction:: int PyList_Insert(PyObject *list, Py_ssize_t index, PyObject *item)
5899
 
+.. c:function:: int PyList_Insert(PyObject *list, Py_ssize_t index, PyObject *item)
5900
 
 
5901
 
    Insert the item *item* into list *list* in front of index *index*.  Return
5902
 
    ``0`` if successful; return ``-1`` and set an exception if unsuccessful.
5903
 
    Analogous to ``list.insert(index, item)``.
5904
 
 
5905
 
    .. versionchanged:: 2.5
5906
 
-      This function used an :ctype:`int` for *index*. This might require
5907
 
+      This function used an :c:type:`int` for *index*. This might require
5908
 
       changes in your code for properly supporting 64-bit systems.
5909
 
 
5910
 
 
5911
 
-.. cfunction:: int PyList_Append(PyObject *list, PyObject *item)
5912
 
+.. c:function:: int PyList_Append(PyObject *list, PyObject *item)
5913
 
 
5914
 
    Append the object *item* at the end of list *list*. Return ``0`` if
5915
 
    successful; return ``-1`` and set an exception if unsuccessful.  Analogous
5916
 
    to ``list.append(item)``.
5917
 
 
5918
 
 
5919
 
-.. cfunction:: PyObject* PyList_GetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high)
5920
 
+.. c:function:: PyObject* PyList_GetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high)
5921
 
 
5922
 
    Return a list of the objects in *list* containing the objects *between* *low*
5923
 
    and *high*.  Return *NULL* and set an exception if unsuccessful.  Analogous
5924
 
@@ -152,11 +152,11 @@
5925
 
    supported.
5926
 
 
5927
 
    .. versionchanged:: 2.5
5928
 
-      This function used an :ctype:`int` for *low* and *high*. This might
5929
 
+      This function used an :c:type:`int` for *low* and *high*. This might
5930
 
       require changes in your code for properly supporting 64-bit systems.
5931
 
 
5932
 
 
5933
 
-.. cfunction:: int PyList_SetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high, PyObject *itemlist)
5934
 
+.. c:function:: int PyList_SetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high, PyObject *itemlist)
5935
 
 
5936
 
    Set the slice of *list* between *low* and *high* to the contents of
5937
 
    *itemlist*.  Analogous to ``list[low:high] = itemlist``. The *itemlist* may
5938
 
@@ -165,23 +165,23 @@
5939
 
    slicing from Python, are not supported.
5940
 
 
5941
 
    .. versionchanged:: 2.5
5942
 
-      This function used an :ctype:`int` for *low* and *high*. This might
5943
 
+      This function used an :c:type:`int` for *low* and *high*. This might
5944
 
       require changes in your code for properly supporting 64-bit systems.
5945
 
 
5946
 
 
5947
 
-.. cfunction:: int PyList_Sort(PyObject *list)
5948
 
+.. c:function:: int PyList_Sort(PyObject *list)
5949
 
 
5950
 
    Sort the items of *list* in place.  Return ``0`` on success, ``-1`` on
5951
 
    failure.  This is equivalent to ``list.sort()``.
5952
 
 
5953
 
 
5954
 
-.. cfunction:: int PyList_Reverse(PyObject *list)
5955
 
+.. c:function:: int PyList_Reverse(PyObject *list)
5956
 
 
5957
 
    Reverse the items of *list* in place.  Return ``0`` on success, ``-1`` on
5958
 
    failure.  This is the equivalent of ``list.reverse()``.
5959
 
 
5960
 
 
5961
 
-.. cfunction:: PyObject* PyList_AsTuple(PyObject *list)
5962
 
+.. c:function:: PyObject* PyList_AsTuple(PyObject *list)
5963
 
 
5964
 
    .. index:: builtin: tuple
5965
 
 
5966
 
diff -r 8527427914a2 Doc/c-api/long.rst
5967
 
--- a/Doc/c-api/long.rst
5968
 
+++ b/Doc/c-api/long.rst
5969
 
@@ -8,100 +8,100 @@
5970
 
 .. index:: object: long integer
5971
 
 
5972
 
 
5973
 
-.. ctype:: PyLongObject
5974
 
+.. c:type:: PyLongObject
5975
 
 
5976
 
-   This subtype of :ctype:`PyObject` represents a Python long integer object.
5977
 
+   This subtype of :c:type:`PyObject` represents a Python long integer object.
5978
 
 
5979
 
 
5980
 
-.. cvar:: PyTypeObject PyLong_Type
5981
 
+.. c:var:: PyTypeObject PyLong_Type
5982
 
 
5983
 
    .. index:: single: LongType (in modules types)
5984
 
 
5985
 
-   This instance of :ctype:`PyTypeObject` represents the Python long integer type.
5986
 
+   This instance of :c:type:`PyTypeObject` represents the Python long integer type.
5987
 
    This is the same object as ``long`` and ``types.LongType``.
5988
 
 
5989
 
 
5990
 
-.. cfunction:: int PyLong_Check(PyObject *p)
5991
 
+.. c:function:: int PyLong_Check(PyObject *p)
5992
 
 
5993
 
-   Return true if its argument is a :ctype:`PyLongObject` or a subtype of
5994
 
-   :ctype:`PyLongObject`.
5995
 
+   Return true if its argument is a :c:type:`PyLongObject` or a subtype of
5996
 
+   :c:type:`PyLongObject`.
5997
 
 
5998
 
    .. versionchanged:: 2.2
5999
 
       Allowed subtypes to be accepted.
6000
 
 
6001
 
 
6002
 
-.. cfunction:: int PyLong_CheckExact(PyObject *p)
6003
 
+.. c:function:: int PyLong_CheckExact(PyObject *p)
6004
 
 
6005
 
-   Return true if its argument is a :ctype:`PyLongObject`, but not a subtype of
6006
 
-   :ctype:`PyLongObject`.
6007
 
+   Return true if its argument is a :c:type:`PyLongObject`, but not a subtype of
6008
 
+   :c:type:`PyLongObject`.
6009
 
 
6010
 
    .. versionadded:: 2.2
6011
 
 
6012
 
 
6013
 
-.. cfunction:: PyObject* PyLong_FromLong(long v)
6014
 
+.. c:function:: PyObject* PyLong_FromLong(long v)
6015
 
 
6016
 
-   Return a new :ctype:`PyLongObject` object from *v*, or *NULL* on failure.
6017
 
+   Return a new :c:type:`PyLongObject` object from *v*, or *NULL* on failure.
6018
 
 
6019
 
 
6020
 
-.. cfunction:: PyObject* PyLong_FromUnsignedLong(unsigned long v)
6021
 
+.. c:function:: PyObject* PyLong_FromUnsignedLong(unsigned long v)
6022
 
 
6023
 
-   Return a new :ctype:`PyLongObject` object from a C :ctype:`unsigned long`, or
6024
 
+   Return a new :c:type:`PyLongObject` object from a C :c:type:`unsigned long`, or
6025
 
    *NULL* on failure.
6026
 
 
6027
 
 
6028
 
-.. cfunction:: PyObject* PyLong_FromSsize_t(Py_ssize_t v)
6029
 
+.. c:function:: PyObject* PyLong_FromSsize_t(Py_ssize_t v)
6030
 
 
6031
 
-   Return a new :ctype:`PyLongObject` object from a C :ctype:`Py_ssize_t`, or
6032
 
+   Return a new :c:type:`PyLongObject` object from a C :c:type:`Py_ssize_t`, or
6033
 
    *NULL* on failure.
6034
 
 
6035
 
    .. versionadded:: 2.6
6036
 
 
6037
 
 
6038
 
-.. cfunction:: PyObject* PyLong_FromSize_t(size_t v)
6039
 
+.. c:function:: PyObject* PyLong_FromSize_t(size_t v)
6040
 
 
6041
 
-   Return a new :ctype:`PyLongObject` object from a C :ctype:`size_t`, or
6042
 
+   Return a new :c:type:`PyLongObject` object from a C :c:type:`size_t`, or
6043
 
    *NULL* on failure.
6044
 
 
6045
 
    .. versionadded:: 2.6
6046
 
 
6047
 
 
6048
 
-.. cfunction:: PyObject* PyLong_FromSsize_t(Py_ssize_t v)
6049
 
+.. c:function:: PyObject* PyLong_FromSsize_t(Py_ssize_t v)
6050
 
 
6051
 
-   Return a new :ctype:`PyLongObject` object with a value of *v*, or *NULL*
6052
 
+   Return a new :c:type:`PyLongObject` object with a value of *v*, or *NULL*
6053
 
    on failure.
6054
 
 
6055
 
    .. versionadded:: 2.6
6056
 
 
6057
 
 
6058
 
-.. cfunction:: PyObject* PyLong_FromSize_t(size_t v)
6059
 
+.. c:function:: PyObject* PyLong_FromSize_t(size_t v)
6060
 
 
6061
 
-   Return a new :ctype:`PyLongObject` object with a value of *v*, or *NULL*
6062
 
+   Return a new :c:type:`PyLongObject` object with a value of *v*, or *NULL*
6063
 
    on failure.
6064
 
 
6065
 
    .. versionadded:: 2.6
6066
 
 
6067
 
 
6068
 
-.. cfunction:: PyObject* PyLong_FromLongLong(PY_LONG_LONG v)
6069
 
+.. c:function:: PyObject* PyLong_FromLongLong(PY_LONG_LONG v)
6070
 
 
6071
 
-   Return a new :ctype:`PyLongObject` object from a C :ctype:`long long`, or *NULL*
6072
 
+   Return a new :c:type:`PyLongObject` object from a C :c:type:`long long`, or *NULL*
6073
 
    on failure.
6074
 
 
6075
 
 
6076
 
-.. cfunction:: PyObject* PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG v)
6077
 
+.. c:function:: PyObject* PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG v)
6078
 
 
6079
 
-   Return a new :ctype:`PyLongObject` object from a C :ctype:`unsigned long long`,
6080
 
+   Return a new :c:type:`PyLongObject` object from a C :c:type:`unsigned long long`,
6081
 
    or *NULL* on failure.
6082
 
 
6083
 
 
6084
 
-.. cfunction:: PyObject* PyLong_FromDouble(double v)
6085
 
+.. c:function:: PyObject* PyLong_FromDouble(double v)
6086
 
 
6087
 
-   Return a new :ctype:`PyLongObject` object from the integer part of *v*, or
6088
 
+   Return a new :c:type:`PyLongObject` object from the integer part of *v*, or
6089
 
    *NULL* on failure.
6090
 
 
6091
 
 
6092
 
-.. cfunction:: PyObject* PyLong_FromString(char *str, char **pend, int base)
6093
 
+.. c:function:: PyObject* PyLong_FromString(char *str, char **pend, int base)
6094
 
 
6095
 
-   Return a new :ctype:`PyLongObject` based on the string value in *str*, which is
6096
 
+   Return a new :c:type:`PyLongObject` based on the string value in *str*, which is
6097
 
    interpreted according to the radix in *base*.  If *pend* is non-*NULL*,
6098
 
    *\*pend* will point to the first character in *str* which follows the
6099
 
    representation of the number.  If *base* is ``0``, the radix will be determined
6100
 
@@ -112,7 +112,7 @@
6101
 
    no digits, :exc:`ValueError` will be raised.
6102
 
 
6103
 
 
6104
 
-.. cfunction:: PyObject* PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base)
6105
 
+.. c:function:: PyObject* PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base)
6106
 
 
6107
 
    Convert a sequence of Unicode digits to a Python long integer value.  The first
6108
 
    parameter, *u*, points to the first character of the Unicode string, *length*
6109
 
@@ -123,14 +123,14 @@
6110
 
    .. versionadded:: 1.6
6111
 
 
6112
 
    .. versionchanged:: 2.5
6113
 
-      This function used an :ctype:`int` for *length*. This might require
6114
 
+      This function used an :c:type:`int` for *length*. This might require
6115
 
       changes in your code for properly supporting 64-bit systems.
6116
 
 
6117
 
 
6118
 
-.. cfunction:: PyObject* PyLong_FromVoidPtr(void *p)
6119
 
+.. c:function:: PyObject* PyLong_FromVoidPtr(void *p)
6120
 
 
6121
 
    Create a Python integer or long integer from the pointer *p*. The pointer value
6122
 
-   can be retrieved from the resulting value using :cfunc:`PyLong_AsVoidPtr`.
6123
 
+   can be retrieved from the resulting value using :c:func:`PyLong_AsVoidPtr`.
6124
 
 
6125
 
    .. versionadded:: 1.5.2
6126
 
 
6127
 
@@ -138,20 +138,20 @@
6128
 
       If the integer is larger than LONG_MAX, a positive long integer is returned.
6129
 
 
6130
 
 
6131
 
-.. cfunction:: long PyLong_AsLong(PyObject *pylong)
6132
 
+.. c:function:: long PyLong_AsLong(PyObject *pylong)
6133
 
 
6134
 
    .. index::
6135
 
       single: LONG_MAX
6136
 
       single: OverflowError (built-in exception)
6137
 
 
6138
 
-   Return a C :ctype:`long` representation of the contents of *pylong*.  If
6139
 
+   Return a C :c:type:`long` representation of the contents of *pylong*.  If
6140
 
    *pylong* is greater than :const:`LONG_MAX`, an :exc:`OverflowError` is raised
6141
 
    and ``-1`` will be returned.
6142
 
 
6143
 
 
6144
 
-.. cfunction:: long PyLong_AsLongAndOverflow(PyObject *pylong, int *overflow)
6145
 
+.. c:function:: long PyLong_AsLongAndOverflow(PyObject *pylong, int *overflow)
6146
 
 
6147
 
-   Return a C :ctype:`long` representation of the contents of
6148
 
+   Return a C :c:type:`long` representation of the contents of
6149
 
    *pylong*.  If *pylong* is greater than :const:`LONG_MAX` or less
6150
 
    than :const:`LONG_MIN`, set *\*overflow* to ``1`` or ``-1``,
6151
 
    respectively, and return ``-1``; otherwise, set *\*overflow* to
6152
 
@@ -162,9 +162,9 @@
6153
 
    .. versionadded:: 2.7
6154
 
 
6155
 
 
6156
 
-.. cfunction:: PY_LONG_LONG PyLong_AsLongLongAndOverflow(PyObject *pylong, int *overflow)
6157
 
+.. c:function:: PY_LONG_LONG PyLong_AsLongLongAndOverflow(PyObject *pylong, int *overflow)
6158
 
 
6159
 
-   Return a C :ctype:`long long` representation of the contents of
6160
 
+   Return a C :c:type:`long long` representation of the contents of
6161
 
    *pylong*.  If *pylong* is greater than :const:`PY_LLONG_MAX` or less
6162
 
    than :const:`PY_LLONG_MIN`, set *\*overflow* to ``1`` or ``-1``,
6163
 
    respectively, and return ``-1``; otherwise, set *\*overflow* to
6164
 
@@ -175,61 +175,61 @@
6165
 
    .. versionadded:: 2.7
6166
 
 
6167
 
 
6168
 
-.. cfunction:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)
6169
 
+.. c:function:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)
6170
 
 
6171
 
    .. index::
6172
 
       single: PY_SSIZE_T_MAX
6173
 
       single: OverflowError (built-in exception)
6174
 
 
6175
 
-   Return a C :ctype:`Py_ssize_t` representation of the contents of *pylong*.  If
6176
 
+   Return a C :c:type:`Py_ssize_t` representation of the contents of *pylong*.  If
6177
 
    *pylong* is greater than :const:`PY_SSIZE_T_MAX`, an :exc:`OverflowError` is raised
6178
 
    and ``-1`` will be returned.
6179
 
 
6180
 
    .. versionadded:: 2.6
6181
 
 
6182
 
 
6183
 
-.. cfunction:: unsigned long PyLong_AsUnsignedLong(PyObject *pylong)
6184
 
+.. c:function:: unsigned long PyLong_AsUnsignedLong(PyObject *pylong)
6185
 
 
6186
 
    .. index::
6187
 
       single: ULONG_MAX
6188
 
       single: OverflowError (built-in exception)
6189
 
 
6190
 
-   Return a C :ctype:`unsigned long` representation of the contents of *pylong*.
6191
 
+   Return a C :c:type:`unsigned long` representation of the contents of *pylong*.
6192
 
    If *pylong* is greater than :const:`ULONG_MAX`, an :exc:`OverflowError` is
6193
 
    raised.
6194
 
 
6195
 
 
6196
 
-.. cfunction:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)
6197
 
+.. c:function:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)
6198
 
 
6199
 
    .. index::
6200
 
       single: PY_SSIZE_T_MAX
6201
 
 
6202
 
-   Return a :ctype:`Py_ssize_t` representation of the contents of *pylong*.  If
6203
 
+   Return a :c:type:`Py_ssize_t` representation of the contents of *pylong*.  If
6204
 
    *pylong* is greater than :const:`PY_SSIZE_T_MAX`, an :exc:`OverflowError` is
6205
 
    raised.
6206
 
 
6207
 
    .. versionadded:: 2.6
6208
 
 
6209
 
 
6210
 
-.. cfunction:: PY_LONG_LONG PyLong_AsLongLong(PyObject *pylong)
6211
 
+.. c:function:: PY_LONG_LONG PyLong_AsLongLong(PyObject *pylong)
6212
 
 
6213
 
    .. index::
6214
 
       single: OverflowError (built-in exception)
6215
 
 
6216
 
-   Return a C :ctype:`long long` from a Python long integer.  If
6217
 
-   *pylong* cannot be represented as a :ctype:`long long`, an
6218
 
+   Return a C :c:type:`long long` from a Python long integer.  If
6219
 
+   *pylong* cannot be represented as a :c:type:`long long`, an
6220
 
    :exc:`OverflowError` is raised and ``-1`` is returned.
6221
 
 
6222
 
    .. versionadded:: 2.2
6223
 
 
6224
 
 
6225
 
-.. cfunction:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(PyObject *pylong)
6226
 
+.. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(PyObject *pylong)
6227
 
 
6228
 
    .. index::
6229
 
       single: OverflowError (built-in exception)
6230
 
 
6231
 
-   Return a C :ctype:`unsigned long long` from a Python long integer. If
6232
 
-   *pylong* cannot be represented as an :ctype:`unsigned long long`, an
6233
 
+   Return a C :c:type:`unsigned long long` from a Python long integer. If
6234
 
+   *pylong* cannot be represented as an :c:type:`unsigned long long`, an
6235
 
    :exc:`OverflowError` is raised and ``(unsigned long long)-1`` is
6236
 
    returned.
6237
 
 
6238
 
@@ -240,35 +240,35 @@
6239
 
       :exc:`TypeError`.
6240
 
 
6241
 
 
6242
 
-.. cfunction:: unsigned long PyLong_AsUnsignedLongMask(PyObject *io)
6243
 
+.. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *io)
6244
 
 
6245
 
-   Return a C :ctype:`unsigned long` from a Python long integer, without checking
6246
 
+   Return a C :c:type:`unsigned long` from a Python long integer, without checking
6247
 
    for overflow.
6248
 
 
6249
 
    .. versionadded:: 2.3
6250
 
 
6251
 
 
6252
 
-.. cfunction:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *io)
6253
 
+.. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *io)
6254
 
 
6255
 
-   Return a C :ctype:`unsigned long long` from a Python long integer, without
6256
 
+   Return a C :c:type:`unsigned long long` from a Python long integer, without
6257
 
    checking for overflow.
6258
 
 
6259
 
    .. versionadded:: 2.3
6260
 
 
6261
 
 
6262
 
-.. cfunction:: double PyLong_AsDouble(PyObject *pylong)
6263
 
+.. c:function:: double PyLong_AsDouble(PyObject *pylong)
6264
 
 
6265
 
-   Return a C :ctype:`double` representation of the contents of *pylong*.  If
6266
 
-   *pylong* cannot be approximately represented as a :ctype:`double`, an
6267
 
+   Return a C :c:type:`double` representation of the contents of *pylong*.  If
6268
 
+   *pylong* cannot be approximately represented as a :c:type:`double`, an
6269
 
    :exc:`OverflowError` exception is raised and ``-1.0`` will be returned.
6270
 
 
6271
 
 
6272
 
-.. cfunction:: void* PyLong_AsVoidPtr(PyObject *pylong)
6273
 
+.. c:function:: void* PyLong_AsVoidPtr(PyObject *pylong)
6274
 
 
6275
 
-   Convert a Python integer or long integer *pylong* to a C :ctype:`void` pointer.
6276
 
+   Convert a Python integer or long integer *pylong* to a C :c:type:`void` pointer.
6277
 
    If *pylong* cannot be converted, an :exc:`OverflowError` will be raised.  This
6278
 
-   is only assured to produce a usable :ctype:`void` pointer for values created
6279
 
-   with :cfunc:`PyLong_FromVoidPtr`.
6280
 
+   is only assured to produce a usable :c:type:`void` pointer for values created
6281
 
+   with :c:func:`PyLong_FromVoidPtr`.
6282
 
 
6283
 
    .. versionadded:: 1.5.2
6284
 
 
6285
 
diff -r 8527427914a2 Doc/c-api/mapping.rst
6286
 
--- a/Doc/c-api/mapping.rst
6287
 
+++ b/Doc/c-api/mapping.rst
6288
 
@@ -6,13 +6,13 @@
6289
 
 ================
6290
 
 
6291
 
 
6292
 
-.. cfunction:: int PyMapping_Check(PyObject *o)
6293
 
+.. c:function:: int PyMapping_Check(PyObject *o)
6294
 
 
6295
 
    Return ``1`` if the object provides mapping protocol, and ``0`` otherwise.  This
6296
 
    function always succeeds.
6297
 
 
6298
 
 
6299
 
-.. cfunction:: Py_ssize_t PyMapping_Size(PyObject *o)
6300
 
+.. c:function:: Py_ssize_t PyMapping_Size(PyObject *o)
6301
 
                Py_ssize_t PyMapping_Length(PyObject *o)
6302
 
 
6303
 
    .. index:: builtin: len
6304
 
@@ -22,62 +22,62 @@
6305
 
    expression ``len(o)``.
6306
 
 
6307
 
    .. versionchanged:: 2.5
6308
 
-      These functions returned an :ctype:`int` type. This might require
6309
 
+      These functions returned an :c:type:`int` type. This might require
6310
 
       changes in your code for properly supporting 64-bit systems.
6311
 
 
6312
 
 
6313
 
-.. cfunction:: int PyMapping_DelItemString(PyObject *o, char *key)
6314
 
+.. c:function:: int PyMapping_DelItemString(PyObject *o, char *key)
6315
 
 
6316
 
    Remove the mapping for object *key* from the object *o*. Return ``-1`` on
6317
 
    failure.  This is equivalent to the Python statement ``del o[key]``.
6318
 
 
6319
 
 
6320
 
-.. cfunction:: int PyMapping_DelItem(PyObject *o, PyObject *key)
6321
 
+.. c:function:: int PyMapping_DelItem(PyObject *o, PyObject *key)
6322
 
 
6323
 
    Remove the mapping for object *key* from the object *o*. Return ``-1`` on
6324
 
    failure.  This is equivalent to the Python statement ``del o[key]``.
6325
 
 
6326
 
 
6327
 
-.. cfunction:: int PyMapping_HasKeyString(PyObject *o, char *key)
6328
 
+.. c:function:: int PyMapping_HasKeyString(PyObject *o, char *key)
6329
 
 
6330
 
    On success, return ``1`` if the mapping object has the key *key* and ``0``
6331
 
    otherwise.  This is equivalent to ``o[key]``, returning ``True`` on success
6332
 
    and ``False`` on an exception.  This function always succeeds.
6333
 
 
6334
 
 
6335
 
-.. cfunction:: int PyMapping_HasKey(PyObject *o, PyObject *key)
6336
 
+.. c:function:: int PyMapping_HasKey(PyObject *o, PyObject *key)
6337
 
 
6338
 
    Return ``1`` if the mapping object has the key *key* and ``0`` otherwise.
6339
 
    This is equivalent to ``o[key]``, returning ``True`` on success and ``False``
6340
 
    on an exception.  This function always succeeds.
6341
 
 
6342
 
 
6343
 
-.. cfunction:: PyObject* PyMapping_Keys(PyObject *o)
6344
 
+.. c:function:: PyObject* PyMapping_Keys(PyObject *o)
6345
 
 
6346
 
    On success, return a list of the keys in object *o*.  On failure, return *NULL*.
6347
 
    This is equivalent to the Python expression ``o.keys()``.
6348
 
 
6349
 
 
6350
 
-.. cfunction:: PyObject* PyMapping_Values(PyObject *o)
6351
 
+.. c:function:: PyObject* PyMapping_Values(PyObject *o)
6352
 
 
6353
 
    On success, return a list of the values in object *o*.  On failure, return
6354
 
    *NULL*. This is equivalent to the Python expression ``o.values()``.
6355
 
 
6356
 
 
6357
 
-.. cfunction:: PyObject* PyMapping_Items(PyObject *o)
6358
 
+.. c:function:: PyObject* PyMapping_Items(PyObject *o)
6359
 
 
6360
 
    On success, return a list of the items in object *o*, where each item is a tuple
6361
 
    containing a key-value pair.  On failure, return *NULL*. This is equivalent to
6362
 
    the Python expression ``o.items()``.
6363
 
 
6364
 
 
6365
 
-.. cfunction:: PyObject* PyMapping_GetItemString(PyObject *o, char *key)
6366
 
+.. c:function:: PyObject* PyMapping_GetItemString(PyObject *o, char *key)
6367
 
 
6368
 
    Return element of *o* corresponding to the object *key* or *NULL* on failure.
6369
 
    This is the equivalent of the Python expression ``o[key]``.
6370
 
 
6371
 
 
6372
 
-.. cfunction:: int PyMapping_SetItemString(PyObject *o, char *key, PyObject *v)
6373
 
+.. c:function:: int PyMapping_SetItemString(PyObject *o, char *key, PyObject *v)
6374
 
 
6375
 
    Map the object *key* to the value *v* in object *o*. Returns ``-1`` on failure.
6376
 
    This is the equivalent of the Python statement ``o[key] = v``.
6377
 
diff -r 8527427914a2 Doc/c-api/marshal.rst
6378
 
--- a/Doc/c-api/marshal.rst
6379
 
+++ b/Doc/c-api/marshal.rst
6380
 
@@ -20,17 +20,17 @@
6381
 
 file format (currently 2).
6382
 
 
6383
 
 
6384
 
-.. cfunction:: void PyMarshal_WriteLongToFile(long value, FILE *file, int version)
6385
 
+.. c:function:: void PyMarshal_WriteLongToFile(long value, FILE *file, int version)
6386
 
 
6387
 
-   Marshal a :ctype:`long` integer, *value*, to *file*.  This will only write
6388
 
+   Marshal a :c:type:`long` integer, *value*, to *file*.  This will only write
6389
 
    the least-significant 32 bits of *value*; regardless of the size of the
6390
 
-   native :ctype:`long` type.
6391
 
+   native :c:type:`long` type.
6392
 
 
6393
 
    .. versionchanged:: 2.4
6394
 
       *version* indicates the file format.
6395
 
 
6396
 
 
6397
 
-.. cfunction:: void PyMarshal_WriteObjectToFile(PyObject *value, FILE *file, int version)
6398
 
+.. c:function:: void PyMarshal_WriteObjectToFile(PyObject *value, FILE *file, int version)
6399
 
 
6400
 
    Marshal a Python object, *value*, to *file*.
6401
 
 
6402
 
@@ -38,7 +38,7 @@
6403
 
       *version* indicates the file format.
6404
 
 
6405
 
 
6406
 
-.. cfunction:: PyObject* PyMarshal_WriteObjectToString(PyObject *value, int version)
6407
 
+.. c:function:: PyObject* PyMarshal_WriteObjectToString(PyObject *value, int version)
6408
 
 
6409
 
    Return a string object containing the marshalled representation of *value*.
6410
 
 
6411
 
@@ -55,31 +55,31 @@
6412
 
 written using these routines?
6413
 
 
6414
 
 
6415
 
-.. cfunction:: long PyMarshal_ReadLongFromFile(FILE *file)
6416
 
+.. c:function:: long PyMarshal_ReadLongFromFile(FILE *file)
6417
 
 
6418
 
-   Return a C :ctype:`long` from the data stream in a :ctype:`FILE\*` opened
6419
 
+   Return a C :c:type:`long` from the data stream in a :c:type:`FILE\*` opened
6420
 
    for reading.  Only a 32-bit value can be read in using this function,
6421
 
-   regardless of the native size of :ctype:`long`.
6422
 
+   regardless of the native size of :c:type:`long`.
6423
 
 
6424
 
 
6425
 
-.. cfunction:: int PyMarshal_ReadShortFromFile(FILE *file)
6426
 
+.. c:function:: int PyMarshal_ReadShortFromFile(FILE *file)
6427
 
 
6428
 
-   Return a C :ctype:`short` from the data stream in a :ctype:`FILE\*` opened
6429
 
+   Return a C :c:type:`short` from the data stream in a :c:type:`FILE\*` opened
6430
 
    for reading.  Only a 16-bit value can be read in using this function,
6431
 
-   regardless of the native size of :ctype:`short`.
6432
 
+   regardless of the native size of :c:type:`short`.
6433
 
 
6434
 
 
6435
 
-.. cfunction:: PyObject* PyMarshal_ReadObjectFromFile(FILE *file)
6436
 
+.. c:function:: PyObject* PyMarshal_ReadObjectFromFile(FILE *file)
6437
 
 
6438
 
-   Return a Python object from the data stream in a :ctype:`FILE\*` opened for
6439
 
+   Return a Python object from the data stream in a :c:type:`FILE\*` opened for
6440
 
    reading.  On error, sets the appropriate exception (:exc:`EOFError` or
6441
 
    :exc:`TypeError`) and returns *NULL*.
6442
 
 
6443
 
 
6444
 
-.. cfunction:: PyObject* PyMarshal_ReadLastObjectFromFile(FILE *file)
6445
 
+.. c:function:: PyObject* PyMarshal_ReadLastObjectFromFile(FILE *file)
6446
 
 
6447
 
-   Return a Python object from the data stream in a :ctype:`FILE\*` opened for
6448
 
-   reading.  Unlike :cfunc:`PyMarshal_ReadObjectFromFile`, this function
6449
 
+   Return a Python object from the data stream in a :c:type:`FILE\*` opened for
6450
 
+   reading.  Unlike :c:func:`PyMarshal_ReadObjectFromFile`, this function
6451
 
    assumes that no further objects will be read from the file, allowing it to
6452
 
    aggressively load file data into memory so that the de-serialization can
6453
 
    operate from data in memory rather than reading a byte at a time from the
6454
 
@@ -88,7 +88,7 @@
6455
 
    (:exc:`EOFError` or :exc:`TypeError`) and returns *NULL*.
6456
 
 
6457
 
 
6458
 
-.. cfunction:: PyObject* PyMarshal_ReadObjectFromString(char *string, Py_ssize_t len)
6459
 
+.. c:function:: PyObject* PyMarshal_ReadObjectFromString(char *string, Py_ssize_t len)
6460
 
 
6461
 
    Return a Python object from the data stream in a character buffer
6462
 
    containing *len* bytes pointed to by *string*.  On error, sets the
6463
 
@@ -96,5 +96,5 @@
6464
 
    *NULL*.
6465
 
 
6466
 
    .. versionchanged:: 2.5
6467
 
-      This function used an :ctype:`int` type for *len*. This might require
6468
 
+      This function used an :c:type:`int` type for *len*. This might require
6469
 
       changes in your code for properly supporting 64-bit systems.
6470
 
diff -r 8527427914a2 Doc/c-api/memory.rst
6471
 
--- a/Doc/c-api/memory.rst
6472
 
+++ b/Doc/c-api/memory.rst
6473
 
@@ -47,8 +47,8 @@
6474
 
    single: free()
6475
 
 
6476
 
 To avoid memory corruption, extension writers should never try to operate on
6477
 
-Python objects with the functions exported by the C library: :cfunc:`malloc`,
6478
 
-:cfunc:`calloc`, :cfunc:`realloc` and :cfunc:`free`.  This will result in  mixed
6479
 
+Python objects with the functions exported by the C library: :c:func:`malloc`,
6480
 
+:c:func:`calloc`, :c:func:`realloc` and :c:func:`free`.  This will result in  mixed
6481
 
 calls between the C allocator and the Python memory manager with fatal
6482
 
 consequences, because they implement different algorithms and operate on
6483
 
 different heaps.  However, one may safely allocate and release memory blocks
6484
 
@@ -94,65 +94,65 @@
6485
 
 memory from the Python heap:
6486
 
 
6487
 
 
6488
 
-.. cfunction:: void* PyMem_Malloc(size_t n)
6489
 
+.. c:function:: void* PyMem_Malloc(size_t n)
6490
 
 
6491
 
-   Allocates *n* bytes and returns a pointer of type :ctype:`void\*` to the
6492
 
+   Allocates *n* bytes and returns a pointer of type :c:type:`void\*` to the
6493
 
    allocated memory, or *NULL* if the request fails. Requesting zero bytes returns
6494
 
-   a distinct non-*NULL* pointer if possible, as if :cfunc:`PyMem_Malloc(1)` had
6495
 
+   a distinct non-*NULL* pointer if possible, as if :c:func:`PyMem_Malloc(1)` had
6496
 
    been called instead. The memory will not have been initialized in any way.
6497
 
 
6498
 
 
6499
 
-.. cfunction:: void* PyMem_Realloc(void *p, size_t n)
6500
 
+.. c:function:: void* PyMem_Realloc(void *p, size_t n)
6501
 
 
6502
 
    Resizes the memory block pointed to by *p* to *n* bytes. The contents will be
6503
 
    unchanged to the minimum of the old and the new sizes. If *p* is *NULL*, the
6504
 
-   call is equivalent to :cfunc:`PyMem_Malloc(n)`; else if *n* is equal to zero,
6505
 
+   call is equivalent to :c:func:`PyMem_Malloc(n)`; else if *n* is equal to zero,
6506
 
    the memory block is resized but is not freed, and the returned pointer is
6507
 
    non-*NULL*.  Unless *p* is *NULL*, it must have been returned by a previous call
6508
 
-   to :cfunc:`PyMem_Malloc` or :cfunc:`PyMem_Realloc`. If the request fails,
6509
 
-   :cfunc:`PyMem_Realloc` returns *NULL* and *p* remains a valid pointer to the
6510
 
+   to :c:func:`PyMem_Malloc` or :c:func:`PyMem_Realloc`. If the request fails,
6511
 
+   :c:func:`PyMem_Realloc` returns *NULL* and *p* remains a valid pointer to the
6512
 
    previous memory area.
6513
 
 
6514
 
 
6515
 
-.. cfunction:: void PyMem_Free(void *p)
6516
 
+.. c:function:: void PyMem_Free(void *p)
6517
 
 
6518
 
    Frees the memory block pointed to by *p*, which must have been returned by a
6519
 
-   previous call to :cfunc:`PyMem_Malloc` or :cfunc:`PyMem_Realloc`.  Otherwise, or
6520
 
-   if :cfunc:`PyMem_Free(p)` has been called before, undefined behavior occurs. If
6521
 
+   previous call to :c:func:`PyMem_Malloc` or :c:func:`PyMem_Realloc`.  Otherwise, or
6522
 
+   if :c:func:`PyMem_Free(p)` has been called before, undefined behavior occurs. If
6523
 
    *p* is *NULL*, no operation is performed.
6524
 
 
6525
 
 The following type-oriented macros are provided for convenience.  Note  that
6526
 
 *TYPE* refers to any C type.
6527
 
 
6528
 
 
6529
 
-.. cfunction:: TYPE* PyMem_New(TYPE, size_t n)
6530
 
+.. c:function:: TYPE* PyMem_New(TYPE, size_t n)
6531
 
 
6532
 
-   Same as :cfunc:`PyMem_Malloc`, but allocates ``(n * sizeof(TYPE))`` bytes of
6533
 
-   memory.  Returns a pointer cast to :ctype:`TYPE\*`.  The memory will not have
6534
 
+   Same as :c:func:`PyMem_Malloc`, but allocates ``(n * sizeof(TYPE))`` bytes of
6535
 
+   memory.  Returns a pointer cast to :c:type:`TYPE\*`.  The memory will not have
6536
 
    been initialized in any way.
6537
 
 
6538
 
 
6539
 
-.. cfunction:: TYPE* PyMem_Resize(void *p, TYPE, size_t n)
6540
 
+.. c:function:: TYPE* PyMem_Resize(void *p, TYPE, size_t n)
6541
 
 
6542
 
-   Same as :cfunc:`PyMem_Realloc`, but the memory block is resized to ``(n *
6543
 
-   sizeof(TYPE))`` bytes.  Returns a pointer cast to :ctype:`TYPE\*`. On return,
6544
 
+   Same as :c:func:`PyMem_Realloc`, but the memory block is resized to ``(n *
6545
 
+   sizeof(TYPE))`` bytes.  Returns a pointer cast to :c:type:`TYPE\*`. On return,
6546
 
    *p* will be a pointer to the new memory area, or *NULL* in the event of
6547
 
    failure.  This is a C preprocessor macro; p is always reassigned.  Save
6548
 
    the original value of p to avoid losing memory when handling errors.
6549
 
 
6550
 
 
6551
 
-.. cfunction:: void PyMem_Del(void *p)
6552
 
+.. c:function:: void PyMem_Del(void *p)
6553
 
 
6554
 
-   Same as :cfunc:`PyMem_Free`.
6555
 
+   Same as :c:func:`PyMem_Free`.
6556
 
 
6557
 
 In addition, the following macro sets are provided for calling the Python memory
6558
 
 allocator directly, without involving the C API functions listed above. However,
6559
 
 note that their use does not preserve binary compatibility across Python
6560
 
 versions and is therefore deprecated in extension modules.
6561
 
 
6562
 
-:cfunc:`PyMem_MALLOC`, :cfunc:`PyMem_REALLOC`, :cfunc:`PyMem_FREE`.
6563
 
+:c:func:`PyMem_MALLOC`, :c:func:`PyMem_REALLOC`, :c:func:`PyMem_FREE`.
6564
 
 
6565
 
-:cfunc:`PyMem_NEW`, :cfunc:`PyMem_RESIZE`, :cfunc:`PyMem_DEL`.
6566
 
+:c:func:`PyMem_NEW`, :c:func:`PyMem_RESIZE`, :c:func:`PyMem_DEL`.
6567
 
 
6568
 
 
6569
 
 .. _memoryexamples:
6570
 
@@ -201,8 +201,8 @@
6571
 
    free(buf1);       /* Fatal -- should be PyMem_Del()  */
6572
 
 
6573
 
 In addition to the functions aimed at handling raw memory blocks from the Python
6574
 
-heap, objects in Python are allocated and released with :cfunc:`PyObject_New`,
6575
 
-:cfunc:`PyObject_NewVar` and :cfunc:`PyObject_Del`.
6576
 
+heap, objects in Python are allocated and released with :c:func:`PyObject_New`,
6577
 
+:c:func:`PyObject_NewVar` and :c:func:`PyObject_Del`.
6578
 
 
6579
 
 These will be explained in the next chapter on defining and implementing new
6580
 
 object types in C.
6581
 
diff -r 8527427914a2 Doc/c-api/method.rst
6582
 
--- a/Doc/c-api/method.rst
6583
 
+++ b/Doc/c-api/method.rst
6584
 
@@ -10,21 +10,21 @@
6585
 
 There are some useful functions that are useful for working with method objects.
6586
 
 
6587
 
 
6588
 
-.. cvar:: PyTypeObject PyMethod_Type
6589
 
+.. c:var:: PyTypeObject PyMethod_Type
6590
 
 
6591
 
    .. index:: single: MethodType (in module types)
6592
 
 
6593
 
-   This instance of :ctype:`PyTypeObject` represents the Python method type.  This
6594
 
+   This instance of :c:type:`PyTypeObject` represents the Python method type.  This
6595
 
    is exposed to Python programs as ``types.MethodType``.
6596
 
 
6597
 
 
6598
 
-.. cfunction:: int PyMethod_Check(PyObject *o)
6599
 
+.. c:function:: int PyMethod_Check(PyObject *o)
6600
 
 
6601
 
-   Return true if *o* is a method object (has type :cdata:`PyMethod_Type`).  The
6602
 
+   Return true if *o* is a method object (has type :c:data:`PyMethod_Type`).  The
6603
 
    parameter must not be *NULL*.
6604
 
 
6605
 
 
6606
 
-.. cfunction:: PyObject* PyMethod_New(PyObject *func, PyObject *self, PyObject *class)
6607
 
+.. c:function:: PyObject* PyMethod_New(PyObject *func, PyObject *self, PyObject *class)
6608
 
 
6609
 
    Return a new method object, with *func* being any callable object; this is the
6610
 
    function that will be called when the method is called.  If this method should
6611
 
@@ -33,39 +33,39 @@
6612
 
    class which provides the unbound method..
6613
 
 
6614
 
 
6615
 
-.. cfunction:: PyObject* PyMethod_Class(PyObject *meth)
6616
 
+.. c:function:: PyObject* PyMethod_Class(PyObject *meth)
6617
 
 
6618
 
    Return the class object from which the method *meth* was created; if this was
6619
 
    created from an instance, it will be the class of the instance.
6620
 
 
6621
 
 
6622
 
-.. cfunction:: PyObject* PyMethod_GET_CLASS(PyObject *meth)
6623
 
+.. c:function:: PyObject* PyMethod_GET_CLASS(PyObject *meth)
6624
 
 
6625
 
-   Macro version of :cfunc:`PyMethod_Class` which avoids error checking.
6626
 
+   Macro version of :c:func:`PyMethod_Class` which avoids error checking.
6627
 
 
6628
 
 
6629
 
-.. cfunction:: PyObject* PyMethod_Function(PyObject *meth)
6630
 
+.. c:function:: PyObject* PyMethod_Function(PyObject *meth)
6631
 
 
6632
 
    Return the function object associated with the method *meth*.
6633
 
 
6634
 
 
6635
 
-.. cfunction:: PyObject* PyMethod_GET_FUNCTION(PyObject *meth)
6636
 
+.. c:function:: PyObject* PyMethod_GET_FUNCTION(PyObject *meth)
6637
 
 
6638
 
-   Macro version of :cfunc:`PyMethod_Function` which avoids error checking.
6639
 
+   Macro version of :c:func:`PyMethod_Function` which avoids error checking.
6640
 
 
6641
 
 
6642
 
-.. cfunction:: PyObject* PyMethod_Self(PyObject *meth)
6643
 
+.. c:function:: PyObject* PyMethod_Self(PyObject *meth)
6644
 
 
6645
 
    Return the instance associated with the method *meth* if it is bound, otherwise
6646
 
    return *NULL*.
6647
 
 
6648
 
 
6649
 
-.. cfunction:: PyObject* PyMethod_GET_SELF(PyObject *meth)
6650
 
+.. c:function:: PyObject* PyMethod_GET_SELF(PyObject *meth)
6651
 
 
6652
 
-   Macro version of :cfunc:`PyMethod_Self` which avoids error checking.
6653
 
+   Macro version of :c:func:`PyMethod_Self` which avoids error checking.
6654
 
 
6655
 
 
6656
 
-.. cfunction:: int PyMethod_ClearFreeList()
6657
 
+.. c:function:: int PyMethod_ClearFreeList()
6658
 
 
6659
 
    Clear the free list. Return the total number of freed items.
6660
 
 
6661
 
diff -r 8527427914a2 Doc/c-api/module.rst
6662
 
--- a/Doc/c-api/module.rst
6663
 
+++ b/Doc/c-api/module.rst
6664
 
@@ -10,15 +10,15 @@
6665
 
 There are only a few functions special to module objects.
6666
 
 
6667
 
 
6668
 
-.. cvar:: PyTypeObject PyModule_Type
6669
 
+.. c:var:: PyTypeObject PyModule_Type
6670
 
 
6671
 
    .. index:: single: ModuleType (in module types)
6672
 
 
6673
 
-   This instance of :ctype:`PyTypeObject` represents the Python module type.  This
6674
 
+   This instance of :c:type:`PyTypeObject` represents the Python module type.  This
6675
 
    is exposed to Python programs as ``types.ModuleType``.
6676
 
 
6677
 
 
6678
 
-.. cfunction:: int PyModule_Check(PyObject *p)
6679
 
+.. c:function:: int PyModule_Check(PyObject *p)
6680
 
 
6681
 
    Return true if *p* is a module object, or a subtype of a module object.
6682
 
 
6683
 
@@ -26,15 +26,15 @@
6684
 
       Allowed subtypes to be accepted.
6685
 
 
6686
 
 
6687
 
-.. cfunction:: int PyModule_CheckExact(PyObject *p)
6688
 
+.. c:function:: int PyModule_CheckExact(PyObject *p)
6689
 
 
6690
 
    Return true if *p* is a module object, but not a subtype of
6691
 
-   :cdata:`PyModule_Type`.
6692
 
+   :c:data:`PyModule_Type`.
6693
 
 
6694
 
    .. versionadded:: 2.2
6695
 
 
6696
 
 
6697
 
-.. cfunction:: PyObject* PyModule_New(const char *name)
6698
 
+.. c:function:: PyObject* PyModule_New(const char *name)
6699
 
 
6700
 
    .. index::
6701
 
       single: __name__ (module attribute)
6702
 
@@ -46,18 +46,18 @@
6703
 
    the caller is responsible for providing a :attr:`__file__` attribute.
6704
 
 
6705
 
 
6706
 
-.. cfunction:: PyObject* PyModule_GetDict(PyObject *module)
6707
 
+.. c:function:: PyObject* PyModule_GetDict(PyObject *module)
6708
 
 
6709
 
    .. index:: single: __dict__ (module attribute)
6710
 
 
6711
 
    Return the dictionary object that implements *module*'s namespace; this object
6712
 
    is the same as the :attr:`__dict__` attribute of the module object.  This
6713
 
    function never fails.  It is recommended extensions use other
6714
 
-   :cfunc:`PyModule_\*` and :cfunc:`PyObject_\*` functions rather than directly
6715
 
+   :c:func:`PyModule_\*` and :c:func:`PyObject_\*` functions rather than directly
6716
 
    manipulate a module's :attr:`__dict__`.
6717
 
 
6718
 
 
6719
 
-.. cfunction:: char* PyModule_GetName(PyObject *module)
6720
 
+.. c:function:: char* PyModule_GetName(PyObject *module)
6721
 
 
6722
 
    .. index::
6723
 
       single: __name__ (module attribute)
6724
 
@@ -67,7 +67,7 @@
6725
 
    or if it is not a string, :exc:`SystemError` is raised and *NULL* is returned.
6726
 
 
6727
 
 
6728
 
-.. cfunction:: char* PyModule_GetFilename(PyObject *module)
6729
 
+.. c:function:: char* PyModule_GetFilename(PyObject *module)
6730
 
 
6731
 
    .. index::
6732
 
       single: __file__ (module attribute)
6733
 
@@ -78,7 +78,7 @@
6734
 
    raise :exc:`SystemError` and return *NULL*.
6735
 
 
6736
 
 
6737
 
-.. cfunction:: int PyModule_AddObject(PyObject *module, const char *name, PyObject *value)
6738
 
+.. c:function:: int PyModule_AddObject(PyObject *module, const char *name, PyObject *value)
6739
 
 
6740
 
    Add an object to *module* as *name*.  This is a convenience function which can
6741
 
    be used from the module's initialization function.  This steals a reference to
6742
 
@@ -87,7 +87,7 @@
6743
 
    .. versionadded:: 2.0
6744
 
 
6745
 
 
6746
 
-.. cfunction:: int PyModule_AddIntConstant(PyObject *module, const char *name, long value)
6747
 
+.. c:function:: int PyModule_AddIntConstant(PyObject *module, const char *name, long value)
6748
 
 
6749
 
    Add an integer constant to *module* as *name*.  This convenience function can be
6750
 
    used from the module's initialization function. Return ``-1`` on error, ``0`` on
6751
 
@@ -96,7 +96,7 @@
6752
 
    .. versionadded:: 2.0
6753
 
 
6754
 
 
6755
 
-.. cfunction:: int PyModule_AddStringConstant(PyObject *module, const char *name, const char *value)
6756
 
+.. c:function:: int PyModule_AddStringConstant(PyObject *module, const char *name, const char *value)
6757
 
 
6758
 
    Add a string constant to *module* as *name*.  This convenience function can be
6759
 
    used from the module's initialization function.  The string *value* must be
6760
 
@@ -104,7 +104,7 @@
6761
 
 
6762
 
    .. versionadded:: 2.0
6763
 
 
6764
 
-.. cfunction:: int PyModule_AddIntMacro(PyObject *module, macro)
6765
 
+.. c:function:: int PyModule_AddIntMacro(PyObject *module, macro)
6766
 
 
6767
 
    Add an int constant to *module*. The name and the value are taken from
6768
 
    *macro*. For example ``PyModule_AddIntMacro(module, AF_INET)`` adds the int
6769
 
@@ -113,7 +113,7 @@
6770
 
 
6771
 
    .. versionadded:: 2.6
6772
 
 
6773
 
-.. cfunction:: int PyModule_AddStringMacro(PyObject *module, macro)
6774
 
+.. c:function:: int PyModule_AddStringMacro(PyObject *module, macro)
6775
 
 
6776
 
    Add a string constant to *module*.
6777
 
 
6778
 
diff -r 8527427914a2 Doc/c-api/none.rst
6779
 
--- a/Doc/c-api/none.rst
6780
 
+++ b/Doc/c-api/none.rst
6781
 
@@ -7,22 +7,22 @@
6782
 
 
6783
 
 .. index:: object: None
6784
 
 
6785
 
-Note that the :ctype:`PyTypeObject` for ``None`` is not directly exposed in the
6786
 
+Note that the :c:type:`PyTypeObject` for ``None`` is not directly exposed in the
6787
 
 Python/C API.  Since ``None`` is a singleton, testing for object identity (using
6788
 
-``==`` in C) is sufficient. There is no :cfunc:`PyNone_Check` function for the
6789
 
+``==`` in C) is sufficient. There is no :c:func:`PyNone_Check` function for the
6790
 
 same reason.
6791
 
 
6792
 
 
6793
 
-.. cvar:: PyObject* Py_None
6794
 
+.. c:var:: PyObject* Py_None
6795
 
 
6796
 
    The Python ``None`` object, denoting lack of value.  This object has no methods.
6797
 
    It needs to be treated just like any other object with respect to reference
6798
 
    counts.
6799
 
 
6800
 
 
6801
 
-.. cmacro:: Py_RETURN_NONE
6802
 
+.. c:macro:: Py_RETURN_NONE
6803
 
 
6804
 
-   Properly handle returning :cdata:`Py_None` from within a C function.
6805
 
+   Properly handle returning :c:data:`Py_None` from within a C function.
6806
 
 
6807
 
    .. versionadded:: 2.4
6808
 
 
6809
 
diff -r 8527427914a2 Doc/c-api/number.rst
6810
 
--- a/Doc/c-api/number.rst
6811
 
+++ b/Doc/c-api/number.rst
6812
 
@@ -6,37 +6,37 @@
6813
 
 ===============
6814
 
 
6815
 
 
6816
 
-.. cfunction:: int PyNumber_Check(PyObject *o)
6817
 
+.. c:function:: int PyNumber_Check(PyObject *o)
6818
 
 
6819
 
    Returns ``1`` if the object *o* provides numeric protocols, and false otherwise.
6820
 
    This function always succeeds.
6821
 
 
6822
 
 
6823
 
-.. cfunction:: PyObject* PyNumber_Add(PyObject *o1, PyObject *o2)
6824
 
+.. c:function:: PyObject* PyNumber_Add(PyObject *o1, PyObject *o2)
6825
 
 
6826
 
    Returns the result of adding *o1* and *o2*, or *NULL* on failure.  This is the
6827
 
    equivalent of the Python expression ``o1 + o2``.
6828
 
 
6829
 
 
6830
 
-.. cfunction:: PyObject* PyNumber_Subtract(PyObject *o1, PyObject *o2)
6831
 
+.. c:function:: PyObject* PyNumber_Subtract(PyObject *o1, PyObject *o2)
6832
 
 
6833
 
    Returns the result of subtracting *o2* from *o1*, or *NULL* on failure.  This is
6834
 
    the equivalent of the Python expression ``o1 - o2``.
6835
 
 
6836
 
 
6837
 
-.. cfunction:: PyObject* PyNumber_Multiply(PyObject *o1, PyObject *o2)
6838
 
+.. c:function:: PyObject* PyNumber_Multiply(PyObject *o1, PyObject *o2)
6839
 
 
6840
 
    Returns the result of multiplying *o1* and *o2*, or *NULL* on failure.  This is
6841
 
    the equivalent of the Python expression ``o1 * o2``.
6842
 
 
6843
 
 
6844
 
-.. cfunction:: PyObject* PyNumber_Divide(PyObject *o1, PyObject *o2)
6845
 
+.. c:function:: PyObject* PyNumber_Divide(PyObject *o1, PyObject *o2)
6846
 
 
6847
 
    Returns the result of dividing *o1* by *o2*, or *NULL* on failure.  This is the
6848
 
    equivalent of the Python expression ``o1 / o2``.
6849
 
 
6850
 
 
6851
 
-.. cfunction:: PyObject* PyNumber_FloorDivide(PyObject *o1, PyObject *o2)
6852
 
+.. c:function:: PyObject* PyNumber_FloorDivide(PyObject *o1, PyObject *o2)
6853
 
 
6854
 
    Return the floor of *o1* divided by *o2*, or *NULL* on failure.  This is
6855
 
    equivalent to the "classic" division of integers.
6856
 
@@ -44,7 +44,7 @@
6857
 
    .. versionadded:: 2.2
6858
 
 
6859
 
 
6860
 
-.. cfunction:: PyObject* PyNumber_TrueDivide(PyObject *o1, PyObject *o2)
6861
 
+.. c:function:: PyObject* PyNumber_TrueDivide(PyObject *o1, PyObject *o2)
6862
 
 
6863
 
    Return a reasonable approximation for the mathematical value of *o1* divided by
6864
 
    *o2*, or *NULL* on failure.  The return value is "approximate" because binary
6865
 
@@ -55,13 +55,13 @@
6866
 
    .. versionadded:: 2.2
6867
 
 
6868
 
 
6869
 
-.. cfunction:: PyObject* PyNumber_Remainder(PyObject *o1, PyObject *o2)
6870
 
+.. c:function:: PyObject* PyNumber_Remainder(PyObject *o1, PyObject *o2)
6871
 
 
6872
 
    Returns the remainder of dividing *o1* by *o2*, or *NULL* on failure.  This is
6873
 
    the equivalent of the Python expression ``o1 % o2``.
6874
 
 
6875
 
 
6876
 
-.. cfunction:: PyObject* PyNumber_Divmod(PyObject *o1, PyObject *o2)
6877
 
+.. c:function:: PyObject* PyNumber_Divmod(PyObject *o1, PyObject *o2)
6878
 
 
6879
 
    .. index:: builtin: divmod
6880
 
 
6881
 
@@ -69,29 +69,29 @@
6882
 
    the equivalent of the Python expression ``divmod(o1, o2)``.
6883
 
 
6884
 
 
6885
 
-.. cfunction:: PyObject* PyNumber_Power(PyObject *o1, PyObject *o2, PyObject *o3)
6886
 
+.. c:function:: PyObject* PyNumber_Power(PyObject *o1, PyObject *o2, PyObject *o3)
6887
 
 
6888
 
    .. index:: builtin: pow
6889
 
 
6890
 
    See the built-in function :func:`pow`. Returns *NULL* on failure.  This is the
6891
 
    equivalent of the Python expression ``pow(o1, o2, o3)``, where *o3* is optional.
6892
 
-   If *o3* is to be ignored, pass :cdata:`Py_None` in its place (passing *NULL* for
6893
 
+   If *o3* is to be ignored, pass :c:data:`Py_None` in its place (passing *NULL* for
6894
 
    *o3* would cause an illegal memory access).
6895
 
 
6896
 
 
6897
 
-.. cfunction:: PyObject* PyNumber_Negative(PyObject *o)
6898
 
+.. c:function:: PyObject* PyNumber_Negative(PyObject *o)
6899
 
 
6900
 
    Returns the negation of *o* on success, or *NULL* on failure. This is the
6901
 
    equivalent of the Python expression ``-o``.
6902
 
 
6903
 
 
6904
 
-.. cfunction:: PyObject* PyNumber_Positive(PyObject *o)
6905
 
+.. c:function:: PyObject* PyNumber_Positive(PyObject *o)
6906
 
 
6907
 
    Returns *o* on success, or *NULL* on failure.  This is the equivalent of the
6908
 
    Python expression ``+o``.
6909
 
 
6910
 
 
6911
 
-.. cfunction:: PyObject* PyNumber_Absolute(PyObject *o)
6912
 
+.. c:function:: PyObject* PyNumber_Absolute(PyObject *o)
6913
 
 
6914
 
    .. index:: builtin: abs
6915
 
 
6916
 
@@ -99,71 +99,71 @@
6917
 
    of the Python expression ``abs(o)``.
6918
 
 
6919
 
 
6920
 
-.. cfunction:: PyObject* PyNumber_Invert(PyObject *o)
6921
 
+.. c:function:: PyObject* PyNumber_Invert(PyObject *o)
6922
 
 
6923
 
    Returns the bitwise negation of *o* on success, or *NULL* on failure.  This is
6924
 
    the equivalent of the Python expression ``~o``.
6925
 
 
6926
 
 
6927
 
-.. cfunction:: PyObject* PyNumber_Lshift(PyObject *o1, PyObject *o2)
6928
 
+.. c:function:: PyObject* PyNumber_Lshift(PyObject *o1, PyObject *o2)
6929
 
 
6930
 
    Returns the result of left shifting *o1* by *o2* on success, or *NULL* on
6931
 
    failure.  This is the equivalent of the Python expression ``o1 << o2``.
6932
 
 
6933
 
 
6934
 
-.. cfunction:: PyObject* PyNumber_Rshift(PyObject *o1, PyObject *o2)
6935
 
+.. c:function:: PyObject* PyNumber_Rshift(PyObject *o1, PyObject *o2)
6936
 
 
6937
 
    Returns the result of right shifting *o1* by *o2* on success, or *NULL* on
6938
 
    failure.  This is the equivalent of the Python expression ``o1 >> o2``.
6939
 
 
6940
 
 
6941
 
-.. cfunction:: PyObject* PyNumber_And(PyObject *o1, PyObject *o2)
6942
 
+.. c:function:: PyObject* PyNumber_And(PyObject *o1, PyObject *o2)
6943
 
 
6944
 
    Returns the "bitwise and" of *o1* and *o2* on success and *NULL* on failure.
6945
 
    This is the equivalent of the Python expression ``o1 & o2``.
6946
 
 
6947
 
 
6948
 
-.. cfunction:: PyObject* PyNumber_Xor(PyObject *o1, PyObject *o2)
6949
 
+.. c:function:: PyObject* PyNumber_Xor(PyObject *o1, PyObject *o2)
6950
 
 
6951
 
    Returns the "bitwise exclusive or" of *o1* by *o2* on success, or *NULL* on
6952
 
    failure.  This is the equivalent of the Python expression ``o1 ^ o2``.
6953
 
 
6954
 
 
6955
 
-.. cfunction:: PyObject* PyNumber_Or(PyObject *o1, PyObject *o2)
6956
 
+.. c:function:: PyObject* PyNumber_Or(PyObject *o1, PyObject *o2)
6957
 
 
6958
 
    Returns the "bitwise or" of *o1* and *o2* on success, or *NULL* on failure.
6959
 
    This is the equivalent of the Python expression ``o1 | o2``.
6960
 
 
6961
 
 
6962
 
-.. cfunction:: PyObject* PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2)
6963
 
+.. c:function:: PyObject* PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2)
6964
 
 
6965
 
    Returns the result of adding *o1* and *o2*, or *NULL* on failure.  The operation
6966
 
    is done *in-place* when *o1* supports it.  This is the equivalent of the Python
6967
 
    statement ``o1 += o2``.
6968
 
 
6969
 
 
6970
 
-.. cfunction:: PyObject* PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2)
6971
 
+.. c:function:: PyObject* PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2)
6972
 
 
6973
 
    Returns the result of subtracting *o2* from *o1*, or *NULL* on failure.  The
6974
 
    operation is done *in-place* when *o1* supports it.  This is the equivalent of
6975
 
    the Python statement ``o1 -= o2``.
6976
 
 
6977
 
 
6978
 
-.. cfunction:: PyObject* PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2)
6979
 
+.. c:function:: PyObject* PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2)
6980
 
 
6981
 
    Returns the result of multiplying *o1* and *o2*, or *NULL* on failure.  The
6982
 
    operation is done *in-place* when *o1* supports it.  This is the equivalent of
6983
 
    the Python statement ``o1 *= o2``.
6984
 
 
6985
 
 
6986
 
-.. cfunction:: PyObject* PyNumber_InPlaceDivide(PyObject *o1, PyObject *o2)
6987
 
+.. c:function:: PyObject* PyNumber_InPlaceDivide(PyObject *o1, PyObject *o2)
6988
 
 
6989
 
    Returns the result of dividing *o1* by *o2*, or *NULL* on failure.  The
6990
 
    operation is done *in-place* when *o1* supports it. This is the equivalent of
6991
 
    the Python statement ``o1 /= o2``.
6992
 
 
6993
 
 
6994
 
-.. cfunction:: PyObject* PyNumber_InPlaceFloorDivide(PyObject *o1, PyObject *o2)
6995
 
+.. c:function:: PyObject* PyNumber_InPlaceFloorDivide(PyObject *o1, PyObject *o2)
6996
 
 
6997
 
    Returns the mathematical floor of dividing *o1* by *o2*, or *NULL* on failure.
6998
 
    The operation is done *in-place* when *o1* supports it.  This is the equivalent
6999
 
@@ -172,7 +172,7 @@
7000
 
    .. versionadded:: 2.2
7001
 
 
7002
 
 
7003
 
-.. cfunction:: PyObject* PyNumber_InPlaceTrueDivide(PyObject *o1, PyObject *o2)
7004
 
+.. c:function:: PyObject* PyNumber_InPlaceTrueDivide(PyObject *o1, PyObject *o2)
7005
 
 
7006
 
    Return a reasonable approximation for the mathematical value of *o1* divided by
7007
 
    *o2*, or *NULL* on failure.  The return value is "approximate" because binary
7008
 
@@ -183,64 +183,64 @@
7009
 
    .. versionadded:: 2.2
7010
 
 
7011
 
 
7012
 
-.. cfunction:: PyObject* PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2)
7013
 
+.. c:function:: PyObject* PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2)
7014
 
 
7015
 
    Returns the remainder of dividing *o1* by *o2*, or *NULL* on failure.  The
7016
 
    operation is done *in-place* when *o1* supports it.  This is the equivalent of
7017
 
    the Python statement ``o1 %= o2``.
7018
 
 
7019
 
 
7020
 
-.. cfunction:: PyObject* PyNumber_InPlacePower(PyObject *o1, PyObject *o2, PyObject *o3)
7021
 
+.. c:function:: PyObject* PyNumber_InPlacePower(PyObject *o1, PyObject *o2, PyObject *o3)
7022
 
 
7023
 
    .. index:: builtin: pow
7024
 
 
7025
 
    See the built-in function :func:`pow`. Returns *NULL* on failure.  The operation
7026
 
    is done *in-place* when *o1* supports it.  This is the equivalent of the Python
7027
 
-   statement ``o1 **= o2`` when o3 is :cdata:`Py_None`, or an in-place variant of
7028
 
-   ``pow(o1, o2, o3)`` otherwise. If *o3* is to be ignored, pass :cdata:`Py_None`
7029
 
+   statement ``o1 **= o2`` when o3 is :c:data:`Py_None`, or an in-place variant of
7030
 
+   ``pow(o1, o2, o3)`` otherwise. If *o3* is to be ignored, pass :c:data:`Py_None`
7031
 
    in its place (passing *NULL* for *o3* would cause an illegal memory access).
7032
 
 
7033
 
 
7034
 
-.. cfunction:: PyObject* PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2)
7035
 
+.. c:function:: PyObject* PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2)
7036
 
 
7037
 
    Returns the result of left shifting *o1* by *o2* on success, or *NULL* on
7038
 
    failure.  The operation is done *in-place* when *o1* supports it.  This is the
7039
 
    equivalent of the Python statement ``o1 <<= o2``.
7040
 
 
7041
 
 
7042
 
-.. cfunction:: PyObject* PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2)
7043
 
+.. c:function:: PyObject* PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2)
7044
 
 
7045
 
    Returns the result of right shifting *o1* by *o2* on success, or *NULL* on
7046
 
    failure.  The operation is done *in-place* when *o1* supports it.  This is the
7047
 
    equivalent of the Python statement ``o1 >>= o2``.
7048
 
 
7049
 
 
7050
 
-.. cfunction:: PyObject* PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2)
7051
 
+.. c:function:: PyObject* PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2)
7052
 
 
7053
 
    Returns the "bitwise and" of *o1* and *o2* on success and *NULL* on failure. The
7054
 
    operation is done *in-place* when *o1* supports it.  This is the equivalent of
7055
 
    the Python statement ``o1 &= o2``.
7056
 
 
7057
 
 
7058
 
-.. cfunction:: PyObject* PyNumber_InPlaceXor(PyObject *o1, PyObject *o2)
7059
 
+.. c:function:: PyObject* PyNumber_InPlaceXor(PyObject *o1, PyObject *o2)
7060
 
 
7061
 
    Returns the "bitwise exclusive or" of *o1* by *o2* on success, or *NULL* on
7062
 
    failure.  The operation is done *in-place* when *o1* supports it.  This is the
7063
 
    equivalent of the Python statement ``o1 ^= o2``.
7064
 
 
7065
 
 
7066
 
-.. cfunction:: PyObject* PyNumber_InPlaceOr(PyObject *o1, PyObject *o2)
7067
 
+.. c:function:: PyObject* PyNumber_InPlaceOr(PyObject *o1, PyObject *o2)
7068
 
 
7069
 
    Returns the "bitwise or" of *o1* and *o2* on success, or *NULL* on failure.  The
7070
 
    operation is done *in-place* when *o1* supports it.  This is the equivalent of
7071
 
    the Python statement ``o1 |= o2``.
7072
 
 
7073
 
 
7074
 
-.. cfunction:: int PyNumber_Coerce(PyObject **p1, PyObject **p2)
7075
 
+.. c:function:: int PyNumber_Coerce(PyObject **p1, PyObject **p2)
7076
 
 
7077
 
    .. index:: builtin: coerce
7078
 
 
7079
 
-   This function takes the addresses of two variables of type :ctype:`PyObject\*`.
7080
 
+   This function takes the addresses of two variables of type :c:type:`PyObject\*`.
7081
 
    If the objects pointed to by ``*p1`` and ``*p2`` have the same type, increment
7082
 
    their reference count and return ``0`` (success). If the objects can be
7083
 
    converted to a common numeric type, replace ``*p1`` and ``*p2`` by their
7084
 
@@ -250,14 +250,14 @@
7085
 
    &o2)`` is equivalent to the Python statement ``o1, o2 = coerce(o1, o2)``.
7086
 
 
7087
 
 
7088
 
-.. cfunction:: int PyNumber_CoerceEx(PyObject **p1, PyObject **p2)
7089
 
+.. c:function:: int PyNumber_CoerceEx(PyObject **p1, PyObject **p2)
7090
 
 
7091
 
-   This function is similar to :cfunc:`PyNumber_Coerce`, except that it returns
7092
 
+   This function is similar to :c:func:`PyNumber_Coerce`, except that it returns
7093
 
    ``1`` when the conversion is not possible and when no error is raised.
7094
 
    Reference counts are still not increased in this case.
7095
 
 
7096
 
 
7097
 
-.. cfunction:: PyObject* PyNumber_Int(PyObject *o)
7098
 
+.. c:function:: PyObject* PyNumber_Int(PyObject *o)
7099
 
 
7100
 
    .. index:: builtin: int
7101
 
 
7102
 
@@ -266,7 +266,7 @@
7103
 
    instead. This is the equivalent of the Python expression ``int(o)``.
7104
 
 
7105
 
 
7106
 
-.. cfunction:: PyObject* PyNumber_Long(PyObject *o)
7107
 
+.. c:function:: PyObject* PyNumber_Long(PyObject *o)
7108
 
 
7109
 
    .. index:: builtin: long
7110
 
 
7111
 
@@ -274,7 +274,7 @@
7112
 
    failure.  This is the equivalent of the Python expression ``long(o)``.
7113
 
 
7114
 
 
7115
 
-.. cfunction:: PyObject* PyNumber_Float(PyObject *o)
7116
 
+.. c:function:: PyObject* PyNumber_Float(PyObject *o)
7117
 
 
7118
 
    .. index:: builtin: float
7119
 
 
7120
 
@@ -282,7 +282,7 @@
7121
 
    This is the equivalent of the Python expression ``float(o)``.
7122
 
 
7123
 
 
7124
 
-.. cfunction:: PyObject* PyNumber_Index(PyObject *o)
7125
 
+.. c:function:: PyObject* PyNumber_Index(PyObject *o)
7126
 
 
7127
 
    Returns the *o* converted to a Python int or long on success or *NULL* with a
7128
 
    :exc:`TypeError` exception raised on failure.
7129
 
@@ -290,18 +290,18 @@
7130
 
    .. versionadded:: 2.5
7131
 
 
7132
 
 
7133
 
-.. cfunction:: PyObject* PyNumber_ToBase(PyObject *n, int base)
7134
 
+.. c:function:: PyObject* PyNumber_ToBase(PyObject *n, int base)
7135
 
 
7136
 
    Returns the integer *n* converted to *base* as a string with a base
7137
 
    marker of ``'0b'``, ``'0o'``, or ``'0x'`` if applicable.  When
7138
 
    *base* is not 2, 8, 10, or 16, the format is ``'x#num'`` where x is the
7139
 
    base. If *n* is not an int object, it is converted with
7140
 
-   :cfunc:`PyNumber_Index` first.
7141
 
+   :c:func:`PyNumber_Index` first.
7142
 
 
7143
 
    .. versionadded:: 2.6
7144
 
 
7145
 
 
7146
 
-.. cfunction:: Py_ssize_t PyNumber_AsSsize_t(PyObject *o, PyObject *exc)
7147
 
+.. c:function:: Py_ssize_t PyNumber_AsSsize_t(PyObject *o, PyObject *exc)
7148
 
 
7149
 
    Returns *o* converted to a Py_ssize_t value if *o* can be interpreted as an
7150
 
    integer. If *o* can be converted to a Python int or long but the attempt to
7151
 
@@ -314,7 +314,7 @@
7152
 
    .. versionadded:: 2.5
7153
 
 
7154
 
 
7155
 
-.. cfunction:: int PyIndex_Check(PyObject *o)
7156
 
+.. c:function:: int PyIndex_Check(PyObject *o)
7157
 
 
7158
 
    Returns True if *o* is an index integer (has the nb_index slot of  the
7159
 
    tp_as_number structure filled in).
7160
 
diff -r 8527427914a2 Doc/c-api/objbuffer.rst
7161
 
--- a/Doc/c-api/objbuffer.rst
7162
 
+++ b/Doc/c-api/objbuffer.rst
7163
 
@@ -13,7 +13,7 @@
7164
 
 :ref:`bufferobjects` for more information.
7165
 
 
7166
 
 
7167
 
-.. cfunction:: int PyObject_AsCharBuffer(PyObject *obj, const char **buffer, Py_ssize_t *buffer_len)
7168
 
+.. c:function:: int PyObject_AsCharBuffer(PyObject *obj, const char **buffer, Py_ssize_t *buffer_len)
7169
 
 
7170
 
    Returns a pointer to a read-only memory location usable as character-based
7171
 
    input.  The *obj* argument must support the single-segment character buffer
7172
 
@@ -24,11 +24,11 @@
7173
 
    .. versionadded:: 1.6
7174
 
 
7175
 
    .. versionchanged:: 2.5
7176
 
-      This function used an :ctype:`int *` type for *buffer_len*. This might
7177
 
+      This function used an :c:type:`int *` type for *buffer_len*. This might
7178
 
       require changes in your code for properly supporting 64-bit systems.
7179
 
 
7180
 
 
7181
 
-.. cfunction:: int PyObject_AsReadBuffer(PyObject *obj, const void **buffer, Py_ssize_t *buffer_len)
7182
 
+.. c:function:: int PyObject_AsReadBuffer(PyObject *obj, const void **buffer, Py_ssize_t *buffer_len)
7183
 
 
7184
 
    Returns a pointer to a read-only memory location containing arbitrary data.
7185
 
    The *obj* argument must support the single-segment readable buffer
7186
 
@@ -39,11 +39,11 @@
7187
 
    .. versionadded:: 1.6
7188
 
 
7189
 
    .. versionchanged:: 2.5
7190
 
-      This function used an :ctype:`int *` type for *buffer_len*. This might
7191
 
+      This function used an :c:type:`int *` type for *buffer_len*. This might
7192
 
       require changes in your code for properly supporting 64-bit systems.
7193
 
 
7194
 
 
7195
 
-.. cfunction:: int PyObject_CheckReadBuffer(PyObject *o)
7196
 
+.. c:function:: int PyObject_CheckReadBuffer(PyObject *o)
7197
 
 
7198
 
    Returns ``1`` if *o* supports the single-segment readable buffer interface.
7199
 
    Otherwise returns ``0``.
7200
 
@@ -51,7 +51,7 @@
7201
 
    .. versionadded:: 2.2
7202
 
 
7203
 
 
7204
 
-.. cfunction:: int PyObject_AsWriteBuffer(PyObject *obj, void **buffer, Py_ssize_t *buffer_len)
7205
 
+.. c:function:: int PyObject_AsWriteBuffer(PyObject *obj, void **buffer, Py_ssize_t *buffer_len)
7206
 
 
7207
 
    Returns a pointer to a writeable memory location.  The *obj* argument must
7208
 
    support the single-segment, character buffer interface.  On success,
7209
 
@@ -61,6 +61,6 @@
7210
 
    .. versionadded:: 1.6
7211
 
 
7212
 
    .. versionchanged:: 2.5
7213
 
-      This function used an :ctype:`int *` type for *buffer_len*. This might
7214
 
+      This function used an :c:type:`int *` type for *buffer_len*. This might
7215
 
       require changes in your code for properly supporting 64-bit systems.
7216
 
 
7217
 
diff -r 8527427914a2 Doc/c-api/object.rst
7218
 
--- a/Doc/c-api/object.rst
7219
 
+++ b/Doc/c-api/object.rst
7220
 
@@ -6,7 +6,7 @@
7221
 
 ===============
7222
 
 
7223
 
 
7224
 
-.. cfunction:: int PyObject_Print(PyObject *o, FILE *fp, int flags)
7225
 
+.. c:function:: int PyObject_Print(PyObject *o, FILE *fp, int flags)
7226
 
 
7227
 
    Print an object *o*, on file *fp*.  Returns ``-1`` on error.  The flags argument
7228
 
    is used to enable certain printing options.  The only option currently supported
7229
 
@@ -14,35 +14,35 @@
7230
 
    instead of the :func:`repr`.
7231
 
 
7232
 
 
7233
 
-.. cfunction:: int PyObject_HasAttr(PyObject *o, PyObject *attr_name)
7234
 
+.. c:function:: int PyObject_HasAttr(PyObject *o, PyObject *attr_name)
7235
 
 
7236
 
    Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise.  This
7237
 
    is equivalent to the Python expression ``hasattr(o, attr_name)``.  This function
7238
 
    always succeeds.
7239
 
 
7240
 
 
7241
 
-.. cfunction:: int PyObject_HasAttrString(PyObject *o, const char *attr_name)
7242
 
+.. c:function:: int PyObject_HasAttrString(PyObject *o, const char *attr_name)
7243
 
 
7244
 
    Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise.  This
7245
 
    is equivalent to the Python expression ``hasattr(o, attr_name)``.  This function
7246
 
    always succeeds.
7247
 
 
7248
 
 
7249
 
-.. cfunction:: PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name)
7250
 
+.. c:function:: PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name)
7251
 
 
7252
 
    Retrieve an attribute named *attr_name* from object *o*. Returns the attribute
7253
 
    value on success, or *NULL* on failure.  This is the equivalent of the Python
7254
 
    expression ``o.attr_name``.
7255
 
 
7256
 
 
7257
 
-.. cfunction:: PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name)
7258
 
+.. c:function:: PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name)
7259
 
 
7260
 
    Retrieve an attribute named *attr_name* from object *o*. Returns the attribute
7261
 
    value on success, or *NULL* on failure. This is the equivalent of the Python
7262
 
    expression ``o.attr_name``.
7263
 
 
7264
 
 
7265
 
-.. cfunction:: PyObject* PyObject_GenericGetAttr(PyObject *o, PyObject *name)
7266
 
+.. c:function:: PyObject* PyObject_GenericGetAttr(PyObject *o, PyObject *name)
7267
 
 
7268
 
    Generic attribute getter function that is meant to be put into a type
7269
 
    object's ``tp_getattro`` slot.  It looks for a descriptor in the dictionary
7270
 
@@ -52,21 +52,21 @@
7271
 
    descriptors don't.  Otherwise, an :exc:`AttributeError` is raised.
7272
 
 
7273
 
 
7274
 
-.. cfunction:: int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v)
7275
 
+.. c:function:: int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v)
7276
 
 
7277
 
    Set the value of the attribute named *attr_name*, for object *o*, to the value
7278
 
    *v*. Returns ``-1`` on failure.  This is the equivalent of the Python statement
7279
 
    ``o.attr_name = v``.
7280
 
 
7281
 
 
7282
 
-.. cfunction:: int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v)
7283
 
+.. c:function:: int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v)
7284
 
 
7285
 
    Set the value of the attribute named *attr_name*, for object *o*, to the value
7286
 
    *v*. Returns ``-1`` on failure.  This is the equivalent of the Python statement
7287
 
    ``o.attr_name = v``.
7288
 
 
7289
 
 
7290
 
-.. cfunction:: int PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject *value)
7291
 
+.. c:function:: int PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject *value)
7292
 
 
7293
 
    Generic attribute setter function that is meant to be put into a type
7294
 
    object's ``tp_setattro`` slot.  It looks for a data descriptor in the
7295
 
@@ -76,19 +76,19 @@
7296
 
    an :exc:`AttributeError` is raised and ``-1`` is returned.
7297
 
 
7298
 
 
7299
 
-.. cfunction:: int PyObject_DelAttr(PyObject *o, PyObject *attr_name)
7300
 
+.. c:function:: int PyObject_DelAttr(PyObject *o, PyObject *attr_name)
7301
 
 
7302
 
    Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on failure.
7303
 
    This is the equivalent of the Python statement ``del o.attr_name``.
7304
 
 
7305
 
 
7306
 
-.. cfunction:: int PyObject_DelAttrString(PyObject *o, const char *attr_name)
7307
 
+.. c:function:: int PyObject_DelAttrString(PyObject *o, const char *attr_name)
7308
 
 
7309
 
    Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on failure.
7310
 
    This is the equivalent of the Python statement ``del o.attr_name``.
7311
 
 
7312
 
 
7313
 
-.. cfunction:: PyObject* PyObject_RichCompare(PyObject *o1, PyObject *o2, int opid)
7314
 
+.. c:function:: PyObject* PyObject_RichCompare(PyObject *o1, PyObject *o2, int opid)
7315
 
 
7316
 
    Compare the values of *o1* and *o2* using the operation specified by *opid*,
7317
 
    which must be one of :const:`Py_LT`, :const:`Py_LE`, :const:`Py_EQ`,
7318
 
@@ -98,7 +98,7 @@
7319
 
    to *opid*. Returns the value of the comparison on success, or *NULL* on failure.
7320
 
 
7321
 
 
7322
 
-.. cfunction:: int PyObject_RichCompareBool(PyObject *o1, PyObject *o2, int opid)
7323
 
+.. c:function:: int PyObject_RichCompareBool(PyObject *o1, PyObject *o2, int opid)
7324
 
 
7325
 
    Compare the values of *o1* and *o2* using the operation specified by *opid*,
7326
 
    which must be one of :const:`Py_LT`, :const:`Py_LE`, :const:`Py_EQ`,
7327
 
@@ -109,10 +109,10 @@
7328
 
    *opid*.
7329
 
 
7330
 
 .. note::
7331
 
-   If *o1* and *o2* are the same object, :cfunc:`PyObject_RichCompareBool`
7332
 
+   If *o1* and *o2* are the same object, :c:func:`PyObject_RichCompareBool`
7333
 
    will always return ``1`` for :const:`Py_EQ` and ``0`` for :const:`Py_NE`.
7334
 
 
7335
 
-.. cfunction:: int PyObject_Cmp(PyObject *o1, PyObject *o2, int *result)
7336
 
+.. c:function:: int PyObject_Cmp(PyObject *o1, PyObject *o2, int *result)
7337
 
 
7338
 
    .. index:: builtin: cmp
7339
 
 
7340
 
@@ -122,18 +122,18 @@
7341
 
    the Python statement ``result = cmp(o1, o2)``.
7342
 
 
7343
 
 
7344
 
-.. cfunction:: int PyObject_Compare(PyObject *o1, PyObject *o2)
7345
 
+.. c:function:: int PyObject_Compare(PyObject *o1, PyObject *o2)
7346
 
 
7347
 
    .. index:: builtin: cmp
7348
 
 
7349
 
    Compare the values of *o1* and *o2* using a routine provided by *o1*, if one
7350
 
    exists, otherwise with a routine provided by *o2*.  Returns the result of the
7351
 
    comparison on success.  On error, the value returned is undefined; use
7352
 
-   :cfunc:`PyErr_Occurred` to detect an error.  This is equivalent to the Python
7353
 
+   :c:func:`PyErr_Occurred` to detect an error.  This is equivalent to the Python
7354
 
    expression ``cmp(o1, o2)``.
7355
 
 
7356
 
 
7357
 
-.. cfunction:: PyObject* PyObject_Repr(PyObject *o)
7358
 
+.. c:function:: PyObject* PyObject_Repr(PyObject *o)
7359
 
 
7360
 
    .. index:: builtin: repr
7361
 
 
7362
 
@@ -143,7 +143,7 @@
7363
 
    by reverse quotes.
7364
 
 
7365
 
 
7366
 
-.. cfunction:: PyObject* PyObject_Str(PyObject *o)
7367
 
+.. c:function:: PyObject* PyObject_Str(PyObject *o)
7368
 
 
7369
 
    .. index:: builtin: str
7370
 
 
7371
 
@@ -153,15 +153,15 @@
7372
 
    by the :keyword:`print` statement.
7373
 
 
7374
 
 
7375
 
-.. cfunction:: PyObject* PyObject_Bytes(PyObject *o)
7376
 
+.. c:function:: PyObject* PyObject_Bytes(PyObject *o)
7377
 
 
7378
 
    .. index:: builtin: bytes
7379
 
 
7380
 
    Compute a bytes representation of object *o*.  In 2.x, this is just a alias
7381
 
-   for :cfunc:`PyObject_Str`.
7382
 
+   for :c:func:`PyObject_Str`.
7383
 
 
7384
 
 
7385
 
-.. cfunction:: PyObject* PyObject_Unicode(PyObject *o)
7386
 
+.. c:function:: PyObject* PyObject_Unicode(PyObject *o)
7387
 
 
7388
 
    .. index:: builtin: unicode
7389
 
 
7390
 
@@ -171,11 +171,11 @@
7391
 
    function.
7392
 
 
7393
 
 
7394
 
-.. cfunction:: int PyObject_IsInstance(PyObject *inst, PyObject *cls)
7395
 
+.. c:function:: int PyObject_IsInstance(PyObject *inst, PyObject *cls)
7396
 
 
7397
 
    Returns ``1`` if *inst* is an instance of the class *cls* or a subclass of
7398
 
    *cls*, or ``0`` if not.  On error, returns ``-1`` and sets an exception.  If
7399
 
-   *cls* is a type object rather than a class object, :cfunc:`PyObject_IsInstance`
7400
 
+   *cls* is a type object rather than a class object, :c:func:`PyObject_IsInstance`
7401
 
    returns ``1`` if *inst* is of type *cls*.  If *cls* is a tuple, the check will
7402
 
    be done against every entry in *cls*. The result will be ``1`` when at least one
7403
 
    of the checks returns ``1``, otherwise it will be ``0``. If *inst* is not a
7404
 
@@ -195,13 +195,13 @@
7405
 
 :class:`A` if it inherits from :class:`A` either directly or indirectly.  If
7406
 
 either is not a class object, a more general mechanism is used to determine the
7407
 
 class relationship of the two objects.  When testing if *B* is a subclass of
7408
 
-*A*, if *A* is *B*, :cfunc:`PyObject_IsSubclass` returns true.  If *A* and *B*
7409
 
+*A*, if *A* is *B*, :c:func:`PyObject_IsSubclass` returns true.  If *A* and *B*
7410
 
 are different objects, *B*'s :attr:`__bases__` attribute is searched in a
7411
 
 depth-first fashion for *A* --- the presence of the :attr:`__bases__` attribute
7412
 
 is considered sufficient for this determination.
7413
 
 
7414
 
 
7415
 
-.. cfunction:: int PyObject_IsSubclass(PyObject *derived, PyObject *cls)
7416
 
+.. c:function:: int PyObject_IsSubclass(PyObject *derived, PyObject *cls)
7417
 
 
7418
 
    Returns ``1`` if the class *derived* is identical to or derived from the class
7419
 
    *cls*, otherwise returns ``0``.  In case of an error, returns ``-1``. If *cls*
7420
 
@@ -216,13 +216,13 @@
7421
 
       Older versions of Python did not support a tuple as the second argument.
7422
 
 
7423
 
 
7424
 
-.. cfunction:: int PyCallable_Check(PyObject *o)
7425
 
+.. c:function:: int PyCallable_Check(PyObject *o)
7426
 
 
7427
 
    Determine if the object *o* is callable.  Return ``1`` if the object is callable
7428
 
    and ``0`` otherwise.  This function always succeeds.
7429
 
 
7430
 
 
7431
 
-.. cfunction:: PyObject* PyObject_Call(PyObject *callable_object, PyObject *args, PyObject *kw)
7432
 
+.. c:function:: PyObject* PyObject_Call(PyObject *callable_object, PyObject *args, PyObject *kw)
7433
 
 
7434
 
    .. index:: builtin: apply
7435
 
 
7436
 
@@ -236,7 +236,7 @@
7437
 
    .. versionadded:: 2.2
7438
 
 
7439
 
 
7440
 
-.. cfunction:: PyObject* PyObject_CallObject(PyObject *callable_object, PyObject *args)
7441
 
+.. c:function:: PyObject* PyObject_CallObject(PyObject *callable_object, PyObject *args)
7442
 
 
7443
 
    .. index:: builtin: apply
7444
 
 
7445
 
@@ -247,52 +247,52 @@
7446
 
    ``callable_object(*args)``.
7447
 
 
7448
 
 
7449
 
-.. cfunction:: PyObject* PyObject_CallFunction(PyObject *callable, char *format, ...)
7450
 
+.. c:function:: PyObject* PyObject_CallFunction(PyObject *callable, char *format, ...)
7451
 
 
7452
 
    .. index:: builtin: apply
7453
 
 
7454
 
    Call a callable Python object *callable*, with a variable number of C arguments.
7455
 
-   The C arguments are described using a :cfunc:`Py_BuildValue` style format
7456
 
+   The C arguments are described using a :c:func:`Py_BuildValue` style format
7457
 
    string.  The format may be *NULL*, indicating that no arguments are provided.
7458
 
    Returns the result of the call on success, or *NULL* on failure.  This is the
7459
 
    equivalent of the Python expression ``apply(callable, args)`` or
7460
 
-   ``callable(*args)``. Note that if you only pass :ctype:`PyObject \*` args,
7461
 
-   :cfunc:`PyObject_CallFunctionObjArgs` is a faster alternative.
7462
 
+   ``callable(*args)``. Note that if you only pass :c:type:`PyObject \*` args,
7463
 
+   :c:func:`PyObject_CallFunctionObjArgs` is a faster alternative.
7464
 
 
7465
 
 
7466
 
-.. cfunction:: PyObject* PyObject_CallMethod(PyObject *o, char *method, char *format, ...)
7467
 
+.. c:function:: PyObject* PyObject_CallMethod(PyObject *o, char *method, char *format, ...)
7468
 
 
7469
 
    Call the method named *method* of object *o* with a variable number of C
7470
 
-   arguments.  The C arguments are described by a :cfunc:`Py_BuildValue` format
7471
 
+   arguments.  The C arguments are described by a :c:func:`Py_BuildValue` format
7472
 
    string that should  produce a tuple.  The format may be *NULL*, indicating that
7473
 
    no arguments are provided. Returns the result of the call on success, or *NULL*
7474
 
    on failure.  This is the equivalent of the Python expression ``o.method(args)``.
7475
 
-   Note that if you only pass :ctype:`PyObject \*` args,
7476
 
-   :cfunc:`PyObject_CallMethodObjArgs` is a faster alternative.
7477
 
+   Note that if you only pass :c:type:`PyObject \*` args,
7478
 
+   :c:func:`PyObject_CallMethodObjArgs` is a faster alternative.
7479
 
 
7480
 
 
7481
 
-.. cfunction:: PyObject* PyObject_CallFunctionObjArgs(PyObject *callable, ..., NULL)
7482
 
+.. c:function:: PyObject* PyObject_CallFunctionObjArgs(PyObject *callable, ..., NULL)
7483
 
 
7484
 
    Call a callable Python object *callable*, with a variable number of
7485
 
-   :ctype:`PyObject\*` arguments.  The arguments are provided as a variable number
7486
 
+   :c:type:`PyObject\*` arguments.  The arguments are provided as a variable number
7487
 
    of parameters followed by *NULL*. Returns the result of the call on success, or
7488
 
    *NULL* on failure.
7489
 
 
7490
 
    .. versionadded:: 2.2
7491
 
 
7492
 
 
7493
 
-.. cfunction:: PyObject* PyObject_CallMethodObjArgs(PyObject *o, PyObject *name, ..., NULL)
7494
 
+.. c:function:: PyObject* PyObject_CallMethodObjArgs(PyObject *o, PyObject *name, ..., NULL)
7495
 
 
7496
 
    Calls a method of the object *o*, where the name of the method is given as a
7497
 
    Python string object in *name*.  It is called with a variable number of
7498
 
-   :ctype:`PyObject\*` arguments.  The arguments are provided as a variable number
7499
 
+   :c:type:`PyObject\*` arguments.  The arguments are provided as a variable number
7500
 
    of parameters followed by *NULL*. Returns the result of the call on success, or
7501
 
    *NULL* on failure.
7502
 
 
7503
 
    .. versionadded:: 2.2
7504
 
 
7505
 
 
7506
 
-.. cfunction:: long PyObject_Hash(PyObject *o)
7507
 
+.. c:function:: long PyObject_Hash(PyObject *o)
7508
 
 
7509
 
    .. index:: builtin: hash
7510
 
 
7511
 
@@ -300,7 +300,7 @@
7512
 
    This is the equivalent of the Python expression ``hash(o)``.
7513
 
 
7514
 
 
7515
 
-.. cfunction:: long PyObject_HashNotImplemented(PyObject *o)
7516
 
+.. c:function:: long PyObject_HashNotImplemented(PyObject *o)
7517
 
 
7518
 
    Set a :exc:`TypeError` indicating that ``type(o)`` is not hashable and return ``-1``.
7519
 
    This function receives special treatment when stored in a ``tp_hash`` slot,
7520
 
@@ -310,21 +310,21 @@
7521
 
    .. versionadded:: 2.6
7522
 
 
7523
 
 
7524
 
-.. cfunction:: int PyObject_IsTrue(PyObject *o)
7525
 
+.. c:function:: int PyObject_IsTrue(PyObject *o)
7526
 
 
7527
 
    Returns ``1`` if the object *o* is considered to be true, and ``0`` otherwise.
7528
 
    This is equivalent to the Python expression ``not not o``.  On failure, return
7529
 
    ``-1``.
7530
 
 
7531
 
 
7532
 
-.. cfunction:: int PyObject_Not(PyObject *o)
7533
 
+.. c:function:: int PyObject_Not(PyObject *o)
7534
 
 
7535
 
    Returns ``0`` if the object *o* is considered to be true, and ``1`` otherwise.
7536
 
    This is equivalent to the Python expression ``not o``.  On failure, return
7537
 
    ``-1``.
7538
 
 
7539
 
 
7540
 
-.. cfunction:: PyObject* PyObject_Type(PyObject *o)
7541
 
+.. c:function:: PyObject* PyObject_Type(PyObject *o)
7542
 
 
7543
 
    .. index:: builtin: type
7544
 
 
7545
 
@@ -333,11 +333,11 @@
7546
 
    is equivalent to the Python expression ``type(o)``. This function increments the
7547
 
    reference count of the return value. There's really no reason to use this
7548
 
    function instead of the common expression ``o->ob_type``, which returns a
7549
 
-   pointer of type :ctype:`PyTypeObject\*`, except when the incremented reference
7550
 
+   pointer of type :c:type:`PyTypeObject\*`, except when the incremented reference
7551
 
    count is needed.
7552
 
 
7553
 
 
7554
 
-.. cfunction:: int PyObject_TypeCheck(PyObject *o, PyTypeObject *type)
7555
 
+.. c:function:: int PyObject_TypeCheck(PyObject *o, PyTypeObject *type)
7556
 
 
7557
 
    Return true if the object *o* is of type *type* or a subtype of *type*.  Both
7558
 
    parameters must be non-*NULL*.
7559
 
@@ -345,7 +345,7 @@
7560
 
    .. versionadded:: 2.2
7561
 
 
7562
 
 
7563
 
-.. cfunction:: Py_ssize_t PyObject_Length(PyObject *o)
7564
 
+.. c:function:: Py_ssize_t PyObject_Length(PyObject *o)
7565
 
                Py_ssize_t PyObject_Size(PyObject *o)
7566
 
 
7567
 
    .. index:: builtin: len
7568
 
@@ -355,29 +355,29 @@
7569
 
    returned.  This is the equivalent to the Python expression ``len(o)``.
7570
 
 
7571
 
    .. versionchanged:: 2.5
7572
 
-      These functions returned an :ctype:`int` type. This might require
7573
 
+      These functions returned an :c:type:`int` type. This might require
7574
 
       changes in your code for properly supporting 64-bit systems.
7575
 
 
7576
 
 
7577
 
-.. cfunction:: PyObject* PyObject_GetItem(PyObject *o, PyObject *key)
7578
 
+.. c:function:: PyObject* PyObject_GetItem(PyObject *o, PyObject *key)
7579
 
 
7580
 
    Return element of *o* corresponding to the object *key* or *NULL* on failure.
7581
 
    This is the equivalent of the Python expression ``o[key]``.
7582
 
 
7583
 
 
7584
 
-.. cfunction:: int PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v)
7585
 
+.. c:function:: int PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v)
7586
 
 
7587
 
    Map the object *key* to the value *v*.  Returns ``-1`` on failure.  This is the
7588
 
    equivalent of the Python statement ``o[key] = v``.
7589
 
 
7590
 
 
7591
 
-.. cfunction:: int PyObject_DelItem(PyObject *o, PyObject *key)
7592
 
+.. c:function:: int PyObject_DelItem(PyObject *o, PyObject *key)
7593
 
 
7594
 
    Delete the mapping for *key* from *o*.  Returns ``-1`` on failure. This is the
7595
 
    equivalent of the Python statement ``del o[key]``.
7596
 
 
7597
 
 
7598
 
-.. cfunction:: int PyObject_AsFileDescriptor(PyObject *o)
7599
 
+.. c:function:: int PyObject_AsFileDescriptor(PyObject *o)
7600
 
 
7601
 
    Derives a file descriptor from a Python object.  If the object is an integer or
7602
 
    long integer, its value is returned.  If not, the object's :meth:`fileno` method
7603
 
@@ -385,16 +385,16 @@
7604
 
    is returned as the file descriptor value.  Returns ``-1`` on failure.
7605
 
 
7606
 
 
7607
 
-.. cfunction:: PyObject* PyObject_Dir(PyObject *o)
7608
 
+.. c:function:: PyObject* PyObject_Dir(PyObject *o)
7609
 
 
7610
 
    This is equivalent to the Python expression ``dir(o)``, returning a (possibly
7611
 
    empty) list of strings appropriate for the object argument, or *NULL* if there
7612
 
    was an error.  If the argument is *NULL*, this is like the Python ``dir()``,
7613
 
    returning the names of the current locals; in this case, if no execution frame
7614
 
-   is active then *NULL* is returned but :cfunc:`PyErr_Occurred` will return false.
7615
 
+   is active then *NULL* is returned but :c:func:`PyErr_Occurred` will return false.
7616
 
 
7617
 
 
7618
 
-.. cfunction:: PyObject* PyObject_GetIter(PyObject *o)
7619
 
+.. c:function:: PyObject* PyObject_GetIter(PyObject *o)
7620
 
 
7621
 
    This is equivalent to the Python expression ``iter(o)``. It returns a new
7622
 
    iterator for the object argument, or the object  itself if the object is already
7623
 
diff -r 8527427914a2 Doc/c-api/refcounting.rst
7624
 
--- a/Doc/c-api/refcounting.rst
7625
 
+++ b/Doc/c-api/refcounting.rst
7626
 
@@ -11,22 +11,22 @@
7627
 
 objects.
7628
 
 
7629
 
 
7630
 
-.. cfunction:: void Py_INCREF(PyObject *o)
7631
 
+.. c:function:: void Py_INCREF(PyObject *o)
7632
 
 
7633
 
    Increment the reference count for object *o*.  The object must not be *NULL*; if
7634
 
-   you aren't sure that it isn't *NULL*, use :cfunc:`Py_XINCREF`.
7635
 
+   you aren't sure that it isn't *NULL*, use :c:func:`Py_XINCREF`.
7636
 
 
7637
 
 
7638
 
-.. cfunction:: void Py_XINCREF(PyObject *o)
7639
 
+.. c:function:: void Py_XINCREF(PyObject *o)
7640
 
 
7641
 
    Increment the reference count for object *o*.  The object may be *NULL*, in
7642
 
    which case the macro has no effect.
7643
 
 
7644
 
 
7645
 
-.. cfunction:: void Py_DECREF(PyObject *o)
7646
 
+.. c:function:: void Py_DECREF(PyObject *o)
7647
 
 
7648
 
    Decrement the reference count for object *o*.  The object must not be *NULL*; if
7649
 
-   you aren't sure that it isn't *NULL*, use :cfunc:`Py_XDECREF`.  If the reference
7650
 
+   you aren't sure that it isn't *NULL*, use :c:func:`Py_XDECREF`.  If the reference
7651
 
    count reaches zero, the object's type's deallocation function (which must not be
7652
 
    *NULL*) is invoked.
7653
 
 
7654
 
@@ -36,25 +36,25 @@
7655
 
       when a class instance with a :meth:`__del__` method is deallocated).  While
7656
 
       exceptions in such code are not propagated, the executed code has free access to
7657
 
       all Python global variables.  This means that any object that is reachable from
7658
 
-      a global variable should be in a consistent state before :cfunc:`Py_DECREF` is
7659
 
+      a global variable should be in a consistent state before :c:func:`Py_DECREF` is
7660
 
       invoked.  For example, code to delete an object from a list should copy a
7661
 
       reference to the deleted object in a temporary variable, update the list data
7662
 
-      structure, and then call :cfunc:`Py_DECREF` for the temporary variable.
7663
 
+      structure, and then call :c:func:`Py_DECREF` for the temporary variable.
7664
 
 
7665
 
 
7666
 
-.. cfunction:: void Py_XDECREF(PyObject *o)
7667
 
+.. c:function:: void Py_XDECREF(PyObject *o)
7668
 
 
7669
 
    Decrement the reference count for object *o*.  The object may be *NULL*, in
7670
 
    which case the macro has no effect; otherwise the effect is the same as for
7671
 
-   :cfunc:`Py_DECREF`, and the same warning applies.
7672
 
+   :c:func:`Py_DECREF`, and the same warning applies.
7673
 
 
7674
 
 
7675
 
-.. cfunction:: void Py_CLEAR(PyObject *o)
7676
 
+.. c:function:: void Py_CLEAR(PyObject *o)
7677
 
 
7678
 
    Decrement the reference count for object *o*.  The object may be *NULL*, in
7679
 
    which case the macro has no effect; otherwise the effect is the same as for
7680
 
-   :cfunc:`Py_DECREF`, except that the argument is also set to *NULL*.  The warning
7681
 
-   for :cfunc:`Py_DECREF` does not apply with respect to the object passed because
7682
 
+   :c:func:`Py_DECREF`, except that the argument is also set to *NULL*.  The warning
7683
 
+   for :c:func:`Py_DECREF` does not apply with respect to the object passed because
7684
 
    the macro carefully uses a temporary variable and sets the argument to *NULL*
7685
 
    before decrementing its reference count.
7686
 
 
7687
 
@@ -65,10 +65,10 @@
7688
 
 
7689
 
 The following functions are for runtime dynamic embedding of Python:
7690
 
 ``Py_IncRef(PyObject *o)``, ``Py_DecRef(PyObject *o)``. They are
7691
 
-simply exported function versions of :cfunc:`Py_XINCREF` and
7692
 
-:cfunc:`Py_XDECREF`, respectively.
7693
 
+simply exported function versions of :c:func:`Py_XINCREF` and
7694
 
+:c:func:`Py_XDECREF`, respectively.
7695
 
 
7696
 
 The following functions or macros are only for use within the interpreter core:
7697
 
-:cfunc:`_Py_Dealloc`, :cfunc:`_Py_ForgetReference`, :cfunc:`_Py_NewReference`,
7698
 
-as well as the global variable :cdata:`_Py_RefTotal`.
7699
 
+:c:func:`_Py_Dealloc`, :c:func:`_Py_ForgetReference`, :c:func:`_Py_NewReference`,
7700
 
+as well as the global variable :c:data:`_Py_RefTotal`.
7701
 
 
7702
 
diff -r 8527427914a2 Doc/c-api/reflection.rst
7703
 
--- a/Doc/c-api/reflection.rst
7704
 
+++ b/Doc/c-api/reflection.rst
7705
 
@@ -5,51 +5,51 @@
7706
 
 Reflection
7707
 
 ==========
7708
 
 
7709
 
-.. cfunction:: PyObject* PyEval_GetBuiltins()
7710
 
+.. c:function:: PyObject* PyEval_GetBuiltins()
7711
 
 
7712
 
    Return a dictionary of the builtins in the current execution frame,
7713
 
    or the interpreter of the thread state if no frame is currently executing.
7714
 
 
7715
 
 
7716
 
-.. cfunction:: PyObject* PyEval_GetLocals()
7717
 
+.. c:function:: PyObject* PyEval_GetLocals()
7718
 
 
7719
 
    Return a dictionary of the local variables in the current execution frame,
7720
 
    or *NULL* if no frame is currently executing.
7721
 
 
7722
 
 
7723
 
-.. cfunction:: PyObject* PyEval_GetGlobals()
7724
 
+.. c:function:: PyObject* PyEval_GetGlobals()
7725
 
 
7726
 
    Return a dictionary of the global variables in the current execution frame,
7727
 
    or *NULL* if no frame is currently executing.
7728
 
 
7729
 
 
7730
 
-.. cfunction:: PyFrameObject* PyEval_GetFrame()
7731
 
+.. c:function:: PyFrameObject* PyEval_GetFrame()
7732
 
 
7733
 
    Return the current thread state's frame, which is *NULL* if no frame is
7734
 
    currently executing.
7735
 
 
7736
 
 
7737
 
-.. cfunction:: int PyFrame_GetLineNumber(PyFrameObject *frame)
7738
 
+.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)
7739
 
 
7740
 
    Return the line number that *frame* is currently executing.
7741
 
 
7742
 
 
7743
 
-.. cfunction:: int PyEval_GetRestricted()
7744
 
+.. c:function:: int PyEval_GetRestricted()
7745
 
 
7746
 
    If there is a current frame and it is executing in restricted mode, return true,
7747
 
    otherwise false.
7748
 
 
7749
 
 
7750
 
-.. cfunction:: const char* PyEval_GetFuncName(PyObject *func)
7751
 
+.. c:function:: const char* PyEval_GetFuncName(PyObject *func)
7752
 
 
7753
 
    Return the name of *func* if it is a function, class or instance object, else the
7754
 
    name of *func*\s type.
7755
 
 
7756
 
 
7757
 
-.. cfunction:: const char* PyEval_GetFuncDesc(PyObject *func)
7758
 
+.. c:function:: const char* PyEval_GetFuncDesc(PyObject *func)
7759
 
 
7760
 
    Return a description string, depending on the type of *func*.
7761
 
    Return values include "()" for functions and methods, " constructor",
7762
 
    " instance", and " object".  Concatenated with the result of
7763
 
-   :cfunc:`PyEval_GetFuncName`, the result will be a description of
7764
 
+   :c:func:`PyEval_GetFuncName`, the result will be a description of
7765
 
    *func*.
7766
 
diff -r 8527427914a2 Doc/c-api/sequence.rst
7767
 
--- a/Doc/c-api/sequence.rst
7768
 
+++ b/Doc/c-api/sequence.rst
7769
 
@@ -6,13 +6,13 @@
7770
 
 =================
7771
 
 
7772
 
 
7773
 
-.. cfunction:: int PySequence_Check(PyObject *o)
7774
 
+.. c:function:: int PySequence_Check(PyObject *o)
7775
 
 
7776
 
    Return ``1`` if the object provides sequence protocol, and ``0`` otherwise.
7777
 
    This function always succeeds.
7778
 
 
7779
 
 
7780
 
-.. cfunction:: Py_ssize_t PySequence_Size(PyObject *o)
7781
 
+.. c:function:: Py_ssize_t PySequence_Size(PyObject *o)
7782
 
                Py_ssize_t PySequence_Length(PyObject *o)
7783
 
 
7784
 
    .. index:: builtin: len
7785
 
@@ -22,140 +22,140 @@
7786
 
    Python expression ``len(o)``.
7787
 
 
7788
 
    .. versionchanged:: 2.5
7789
 
-      These functions returned an :ctype:`int` type. This might require
7790
 
+      These functions returned an :c:type:`int` type. This might require
7791
 
       changes in your code for properly supporting 64-bit systems.
7792
 
 
7793
 
 
7794
 
-.. cfunction:: PyObject* PySequence_Concat(PyObject *o1, PyObject *o2)
7795
 
+.. c:function:: PyObject* PySequence_Concat(PyObject *o1, PyObject *o2)
7796
 
 
7797
 
    Return the concatenation of *o1* and *o2* on success, and *NULL* on failure.
7798
 
    This is the equivalent of the Python expression ``o1 + o2``.
7799
 
 
7800
 
 
7801
 
-.. cfunction:: PyObject* PySequence_Repeat(PyObject *o, Py_ssize_t count)
7802
 
+.. c:function:: PyObject* PySequence_Repeat(PyObject *o, Py_ssize_t count)
7803
 
 
7804
 
    Return the result of repeating sequence object *o* *count* times, or *NULL* on
7805
 
    failure.  This is the equivalent of the Python expression ``o * count``.
7806
 
 
7807
 
    .. versionchanged:: 2.5
7808
 
-      This function used an :ctype:`int` type for *count*. This might require
7809
 
+      This function used an :c:type:`int` type for *count*. This might require
7810
 
       changes in your code for properly supporting 64-bit systems.
7811
 
 
7812
 
 
7813
 
-.. cfunction:: PyObject* PySequence_InPlaceConcat(PyObject *o1, PyObject *o2)
7814
 
+.. c:function:: PyObject* PySequence_InPlaceConcat(PyObject *o1, PyObject *o2)
7815
 
 
7816
 
    Return the concatenation of *o1* and *o2* on success, and *NULL* on failure.
7817
 
    The operation is done *in-place* when *o1* supports it.  This is the equivalent
7818
 
    of the Python expression ``o1 += o2``.
7819
 
 
7820
 
 
7821
 
-.. cfunction:: PyObject* PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count)
7822
 
+.. c:function:: PyObject* PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count)
7823
 
 
7824
 
    Return the result of repeating sequence object *o* *count* times, or *NULL* on
7825
 
    failure.  The operation is done *in-place* when *o* supports it.  This is the
7826
 
    equivalent of the Python expression ``o *= count``.
7827
 
 
7828
 
    .. versionchanged:: 2.5
7829
 
-      This function used an :ctype:`int` type for *count*. This might require
7830
 
+      This function used an :c:type:`int` type for *count*. This might require
7831
 
       changes in your code for properly supporting 64-bit systems.
7832
 
 
7833
 
 
7834
 
-.. cfunction:: PyObject* PySequence_GetItem(PyObject *o, Py_ssize_t i)
7835
 
+.. c:function:: PyObject* PySequence_GetItem(PyObject *o, Py_ssize_t i)
7836
 
 
7837
 
    Return the *i*\ th element of *o*, or *NULL* on failure. This is the equivalent of
7838
 
    the Python expression ``o[i]``.
7839
 
 
7840
 
    .. versionchanged:: 2.5
7841
 
-      This function used an :ctype:`int` type for *i*. This might require
7842
 
+      This function used an :c:type:`int` type for *i*. This might require
7843
 
       changes in your code for properly supporting 64-bit systems.
7844
 
 
7845
 
 
7846
 
-.. cfunction:: PyObject* PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2)
7847
 
+.. c:function:: PyObject* PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2)
7848
 
 
7849
 
    Return the slice of sequence object *o* between *i1* and *i2*, or *NULL* on
7850
 
    failure. This is the equivalent of the Python expression ``o[i1:i2]``.
7851
 
 
7852
 
    .. versionchanged:: 2.5
7853
 
-      This function used an :ctype:`int` type for *i1* and *i2*. This might
7854
 
+      This function used an :c:type:`int` type for *i1* and *i2*. This might
7855
 
       require changes in your code for properly supporting 64-bit systems.
7856
 
 
7857
 
 
7858
 
-.. cfunction:: int PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v)
7859
 
+.. c:function:: int PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v)
7860
 
 
7861
 
    Assign object *v* to the *i*\ th element of *o*.  Returns ``-1`` on failure.  This
7862
 
    is the equivalent of the Python statement ``o[i] = v``.  This function *does
7863
 
    not* steal a reference to *v*.
7864
 
 
7865
 
    .. versionchanged:: 2.5
7866
 
-      This function used an :ctype:`int` type for *i*. This might require
7867
 
+      This function used an :c:type:`int` type for *i*. This might require
7868
 
       changes in your code for properly supporting 64-bit systems.
7869
 
 
7870
 
 
7871
 
-.. cfunction:: int PySequence_DelItem(PyObject *o, Py_ssize_t i)
7872
 
+.. c:function:: int PySequence_DelItem(PyObject *o, Py_ssize_t i)
7873
 
 
7874
 
    Delete the *i*\ th element of object *o*.  Returns ``-1`` on failure.  This is the
7875
 
    equivalent of the Python statement ``del o[i]``.
7876
 
 
7877
 
    .. versionchanged:: 2.5
7878
 
-      This function used an :ctype:`int` type for *i*. This might require
7879
 
+      This function used an :c:type:`int` type for *i*. This might require
7880
 
       changes in your code for properly supporting 64-bit systems.
7881
 
 
7882
 
 
7883
 
-.. cfunction:: int PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2, PyObject *v)
7884
 
+.. c:function:: int PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2, PyObject *v)
7885
 
 
7886
 
    Assign the sequence object *v* to the slice in sequence object *o* from *i1* to
7887
 
    *i2*.  This is the equivalent of the Python statement ``o[i1:i2] = v``.
7888
 
 
7889
 
    .. versionchanged:: 2.5
7890
 
-      This function used an :ctype:`int` type for *i1* and *i2*. This might
7891
 
+      This function used an :c:type:`int` type for *i1* and *i2*. This might
7892
 
       require changes in your code for properly supporting 64-bit systems.
7893
 
 
7894
 
 
7895
 
-.. cfunction:: int PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2)
7896
 
+.. c:function:: int PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2)
7897
 
 
7898
 
    Delete the slice in sequence object *o* from *i1* to *i2*.  Returns ``-1`` on
7899
 
    failure.  This is the equivalent of the Python statement ``del o[i1:i2]``.
7900
 
 
7901
 
    .. versionchanged:: 2.5
7902
 
-      This function used an :ctype:`int` type for *i1* and *i2*. This might
7903
 
+      This function used an :c:type:`int` type for *i1* and *i2*. This might
7904
 
       require changes in your code for properly supporting 64-bit systems.
7905
 
 
7906
 
 
7907
 
-.. cfunction:: Py_ssize_t PySequence_Count(PyObject *o, PyObject *value)
7908
 
+.. c:function:: Py_ssize_t PySequence_Count(PyObject *o, PyObject *value)
7909
 
 
7910
 
    Return the number of occurrences of *value* in *o*, that is, return the number
7911
 
    of keys for which ``o[key] == value``.  On failure, return ``-1``.  This is
7912
 
    equivalent to the Python expression ``o.count(value)``.
7913
 
 
7914
 
    .. versionchanged:: 2.5
7915
 
-      This function returned an :ctype:`int` type. This might require changes
7916
 
+      This function returned an :c:type:`int` type. This might require changes
7917
 
       in your code for properly supporting 64-bit systems.
7918
 
 
7919
 
 
7920
 
-.. cfunction:: int PySequence_Contains(PyObject *o, PyObject *value)
7921
 
+.. c:function:: int PySequence_Contains(PyObject *o, PyObject *value)
7922
 
 
7923
 
    Determine if *o* contains *value*.  If an item in *o* is equal to *value*,
7924
 
    return ``1``, otherwise return ``0``. On error, return ``-1``.  This is
7925
 
    equivalent to the Python expression ``value in o``.
7926
 
 
7927
 
 
7928
 
-.. cfunction:: Py_ssize_t PySequence_Index(PyObject *o, PyObject *value)
7929
 
+.. c:function:: Py_ssize_t PySequence_Index(PyObject *o, PyObject *value)
7930
 
 
7931
 
    Return the first index *i* for which ``o[i] == value``.  On error, return
7932
 
    ``-1``.    This is equivalent to the Python expression ``o.index(value)``.
7933
 
 
7934
 
    .. versionchanged:: 2.5
7935
 
-      This function returned an :ctype:`int` type. This might require changes
7936
 
+      This function returned an :c:type:`int` type. This might require changes
7937
 
       in your code for properly supporting 64-bit systems.
7938
 
 
7939
 
 
7940
 
-.. cfunction:: PyObject* PySequence_List(PyObject *o)
7941
 
+.. c:function:: PyObject* PySequence_List(PyObject *o)
7942
 
 
7943
 
    Return a list object with the same contents as the arbitrary sequence *o*.  The
7944
 
    returned list is guaranteed to be new.
7945
 
 
7946
 
 
7947
 
-.. cfunction:: PyObject* PySequence_Tuple(PyObject *o)
7948
 
+.. c:function:: PyObject* PySequence_Tuple(PyObject *o)
7949
 
 
7950
 
    .. index:: builtin: tuple
7951
 
 
7952
 
@@ -165,28 +165,28 @@
7953
 
    equivalent to the Python expression ``tuple(o)``.
7954
 
 
7955
 
 
7956
 
-.. cfunction:: PyObject* PySequence_Fast(PyObject *o, const char *m)
7957
 
+.. c:function:: PyObject* PySequence_Fast(PyObject *o, const char *m)
7958
 
 
7959
 
    Returns the sequence *o* as a tuple, unless it is already a tuple or list, in
7960
 
-   which case *o* is returned.  Use :cfunc:`PySequence_Fast_GET_ITEM` to access the
7961
 
+   which case *o* is returned.  Use :c:func:`PySequence_Fast_GET_ITEM` to access the
7962
 
    members of the result.  Returns *NULL* on failure.  If the object is not a
7963
 
    sequence, raises :exc:`TypeError` with *m* as the message text.
7964
 
 
7965
 
 
7966
 
-.. cfunction:: PyObject* PySequence_Fast_GET_ITEM(PyObject *o, Py_ssize_t i)
7967
 
+.. c:function:: PyObject* PySequence_Fast_GET_ITEM(PyObject *o, Py_ssize_t i)
7968
 
 
7969
 
    Return the *i*\ th element of *o*, assuming that *o* was returned by
7970
 
-   :cfunc:`PySequence_Fast`, *o* is not *NULL*, and that *i* is within bounds.
7971
 
+   :c:func:`PySequence_Fast`, *o* is not *NULL*, and that *i* is within bounds.
7972
 
 
7973
 
    .. versionchanged:: 2.5
7974
 
-      This function used an :ctype:`int` type for *i*. This might require
7975
 
+      This function used an :c:type:`int` type for *i*. This might require
7976
 
       changes in your code for properly supporting 64-bit systems.
7977
 
 
7978
 
 
7979
 
-.. cfunction:: PyObject** PySequence_Fast_ITEMS(PyObject *o)
7980
 
+.. c:function:: PyObject** PySequence_Fast_ITEMS(PyObject *o)
7981
 
 
7982
 
    Return the underlying array of PyObject pointers.  Assumes that *o* was returned
7983
 
-   by :cfunc:`PySequence_Fast` and *o* is not *NULL*.
7984
 
+   by :c:func:`PySequence_Fast` and *o* is not *NULL*.
7985
 
 
7986
 
    Note, if a list gets resized, the reallocation may relocate the items array.
7987
 
    So, only use the underlying array pointer in contexts where the sequence
7988
 
@@ -195,24 +195,24 @@
7989
 
    .. versionadded:: 2.4
7990
 
 
7991
 
 
7992
 
-.. cfunction:: PyObject* PySequence_ITEM(PyObject *o, Py_ssize_t i)
7993
 
+.. c:function:: PyObject* PySequence_ITEM(PyObject *o, Py_ssize_t i)
7994
 
 
7995
 
    Return the *i*\ th element of *o* or *NULL* on failure. Macro form of
7996
 
-   :cfunc:`PySequence_GetItem` but without checking that
7997
 
-   :cfunc:`PySequence_Check(o)` is true and without adjustment for negative
7998
 
+   :c:func:`PySequence_GetItem` but without checking that
7999
 
+   :c:func:`PySequence_Check` on *o* is true and without adjustment for negative
8000
 
    indices.
8001
 
 
8002
 
    .. versionadded:: 2.3
8003
 
 
8004
 
    .. versionchanged:: 2.5
8005
 
-      This function used an :ctype:`int` type for *i*. This might require
8006
 
+      This function used an :c:type:`int` type for *i*. This might require
8007
 
       changes in your code for properly supporting 64-bit systems.
8008
 
 
8009
 
 
8010
 
-.. cfunction:: Py_ssize_t PySequence_Fast_GET_SIZE(PyObject *o)
8011
 
+.. c:function:: Py_ssize_t PySequence_Fast_GET_SIZE(PyObject *o)
8012
 
 
8013
 
    Returns the length of *o*, assuming that *o* was returned by
8014
 
-   :cfunc:`PySequence_Fast` and that *o* is not *NULL*.  The size can also be
8015
 
-   gotten by calling :cfunc:`PySequence_Size` on *o*, but
8016
 
-   :cfunc:`PySequence_Fast_GET_SIZE` is faster because it can assume *o* is a list
8017
 
+   :c:func:`PySequence_Fast` and that *o* is not *NULL*.  The size can also be
8018
 
+   gotten by calling :c:func:`PySequence_Size` on *o*, but
8019
 
+   :c:func:`PySequence_Fast_GET_SIZE` is faster because it can assume *o* is a list
8020
 
    or tuple.
8021
 
diff -r 8527427914a2 Doc/c-api/set.rst
8022
 
--- a/Doc/c-api/set.rst
8023
 
+++ b/Doc/c-api/set.rst
8024
 
@@ -16,20 +16,20 @@
8025
 
 
8026
 
 This section details the public API for :class:`set` and :class:`frozenset`
8027
 
 objects.  Any functionality not listed below is best accessed using the either
8028
 
-the abstract object protocol (including :cfunc:`PyObject_CallMethod`,
8029
 
-:cfunc:`PyObject_RichCompareBool`, :cfunc:`PyObject_Hash`,
8030
 
-:cfunc:`PyObject_Repr`, :cfunc:`PyObject_IsTrue`, :cfunc:`PyObject_Print`, and
8031
 
-:cfunc:`PyObject_GetIter`) or the abstract number protocol (including
8032
 
-:cfunc:`PyNumber_And`, :cfunc:`PyNumber_Subtract`, :cfunc:`PyNumber_Or`,
8033
 
-:cfunc:`PyNumber_Xor`, :cfunc:`PyNumber_InPlaceAnd`,
8034
 
-:cfunc:`PyNumber_InPlaceSubtract`, :cfunc:`PyNumber_InPlaceOr`, and
8035
 
-:cfunc:`PyNumber_InPlaceXor`).
8036
 
+the abstract object protocol (including :c:func:`PyObject_CallMethod`,
8037
 
+:c:func:`PyObject_RichCompareBool`, :c:func:`PyObject_Hash`,
8038
 
+:c:func:`PyObject_Repr`, :c:func:`PyObject_IsTrue`, :c:func:`PyObject_Print`, and
8039
 
+:c:func:`PyObject_GetIter`) or the abstract number protocol (including
8040
 
+:c:func:`PyNumber_And`, :c:func:`PyNumber_Subtract`, :c:func:`PyNumber_Or`,
8041
 
+:c:func:`PyNumber_Xor`, :c:func:`PyNumber_InPlaceAnd`,
8042
 
+:c:func:`PyNumber_InPlaceSubtract`, :c:func:`PyNumber_InPlaceOr`, and
8043
 
+:c:func:`PyNumber_InPlaceXor`).
8044
 
 
8045
 
 
8046
 
-.. ctype:: PySetObject
8047
 
+.. c:type:: PySetObject
8048
 
 
8049
 
-   This subtype of :ctype:`PyObject` is used to hold the internal data for both
8050
 
-   :class:`set` and :class:`frozenset` objects.  It is like a :ctype:`PyDictObject`
8051
 
+   This subtype of :c:type:`PyObject` is used to hold the internal data for both
8052
 
+   :class:`set` and :class:`frozenset` objects.  It is like a :c:type:`PyDictObject`
8053
 
    in that it is a fixed size for small sets (much like tuple storage) and will
8054
 
    point to a separate, variable sized block of memory for medium and large sized
8055
 
    sets (much like list storage). None of the fields of this structure should be
8056
 
@@ -37,53 +37,53 @@
8057
 
    the documented API rather than by manipulating the values in the structure.
8058
 
 
8059
 
 
8060
 
-.. cvar:: PyTypeObject PySet_Type
8061
 
+.. c:var:: PyTypeObject PySet_Type
8062
 
 
8063
 
-   This is an instance of :ctype:`PyTypeObject` representing the Python
8064
 
+   This is an instance of :c:type:`PyTypeObject` representing the Python
8065
 
    :class:`set` type.
8066
 
 
8067
 
 
8068
 
-.. cvar:: PyTypeObject PyFrozenSet_Type
8069
 
+.. c:var:: PyTypeObject PyFrozenSet_Type
8070
 
 
8071
 
-   This is an instance of :ctype:`PyTypeObject` representing the Python
8072
 
+   This is an instance of :c:type:`PyTypeObject` representing the Python
8073
 
    :class:`frozenset` type.
8074
 
 
8075
 
 The following type check macros work on pointers to any Python object. Likewise,
8076
 
 the constructor functions work with any iterable Python object.
8077
 
 
8078
 
 
8079
 
-.. cfunction:: int PySet_Check(PyObject *p)
8080
 
+.. c:function:: int PySet_Check(PyObject *p)
8081
 
 
8082
 
    Return true if *p* is a :class:`set` object or an instance of a subtype.
8083
 
 
8084
 
    .. versionadded:: 2.6
8085
 
 
8086
 
-.. cfunction:: int PyFrozenSet_Check(PyObject *p)
8087
 
+.. c:function:: int PyFrozenSet_Check(PyObject *p)
8088
 
 
8089
 
    Return true if *p* is a :class:`frozenset` object or an instance of a
8090
 
    subtype.
8091
 
 
8092
 
    .. versionadded:: 2.6
8093
 
 
8094
 
-.. cfunction:: int PyAnySet_Check(PyObject *p)
8095
 
+.. c:function:: int PyAnySet_Check(PyObject *p)
8096
 
 
8097
 
    Return true if *p* is a :class:`set` object, a :class:`frozenset` object, or an
8098
 
    instance of a subtype.
8099
 
 
8100
 
 
8101
 
-.. cfunction:: int PyAnySet_CheckExact(PyObject *p)
8102
 
+.. c:function:: int PyAnySet_CheckExact(PyObject *p)
8103
 
 
8104
 
    Return true if *p* is a :class:`set` object or a :class:`frozenset` object but
8105
 
    not an instance of a subtype.
8106
 
 
8107
 
 
8108
 
-.. cfunction:: int PyFrozenSet_CheckExact(PyObject *p)
8109
 
+.. c:function:: int PyFrozenSet_CheckExact(PyObject *p)
8110
 
 
8111
 
    Return true if *p* is a :class:`frozenset` object but not an instance of a
8112
 
    subtype.
8113
 
 
8114
 
 
8115
 
-.. cfunction:: PyObject* PySet_New(PyObject *iterable)
8116
 
+.. c:function:: PyObject* PySet_New(PyObject *iterable)
8117
 
 
8118
 
    Return a new :class:`set` containing objects returned by the *iterable*.  The
8119
 
    *iterable* may be *NULL* to create a new empty set.  Return the new set on
8120
 
@@ -92,7 +92,7 @@
8121
 
    (``c=set(s)``).
8122
 
 
8123
 
 
8124
 
-.. cfunction:: PyObject* PyFrozenSet_New(PyObject *iterable)
8125
 
+.. c:function:: PyObject* PyFrozenSet_New(PyObject *iterable)
8126
 
 
8127
 
    Return a new :class:`frozenset` containing objects returned by the *iterable*.
8128
 
    The *iterable* may be *NULL* to create a new empty frozenset.  Return the new
8129
 
@@ -108,7 +108,7 @@
8130
 
 or :class:`frozenset` or instances of their subtypes.
8131
 
 
8132
 
 
8133
 
-.. cfunction:: Py_ssize_t PySet_Size(PyObject *anyset)
8134
 
+.. c:function:: Py_ssize_t PySet_Size(PyObject *anyset)
8135
 
 
8136
 
    .. index:: builtin: len
8137
 
 
8138
 
@@ -117,16 +117,16 @@
8139
 
    :class:`set`, :class:`frozenset`, or an instance of a subtype.
8140
 
 
8141
 
    .. versionchanged:: 2.5
8142
 
-      This function returned an :ctype:`int`. This might require changes in
8143
 
+      This function returned an :c:type:`int`. This might require changes in
8144
 
       your code for properly supporting 64-bit systems.
8145
 
 
8146
 
 
8147
 
-.. cfunction:: Py_ssize_t PySet_GET_SIZE(PyObject *anyset)
8148
 
+.. c:function:: Py_ssize_t PySet_GET_SIZE(PyObject *anyset)
8149
 
 
8150
 
-   Macro form of :cfunc:`PySet_Size` without error checking.
8151
 
+   Macro form of :c:func:`PySet_Size` without error checking.
8152
 
 
8153
 
 
8154
 
-.. cfunction:: int PySet_Contains(PyObject *anyset, PyObject *key)
8155
 
+.. c:function:: int PySet_Contains(PyObject *anyset, PyObject *key)
8156
 
 
8157
 
    Return 1 if found, 0 if not found, and -1 if an error is encountered.  Unlike
8158
 
    the Python :meth:`__contains__` method, this function does not automatically
8159
 
@@ -135,7 +135,7 @@
8160
 
    :class:`set`, :class:`frozenset`, or an instance of a subtype.
8161
 
 
8162
 
 
8163
 
-.. cfunction:: int PySet_Add(PyObject *set, PyObject *key)
8164
 
+.. c:function:: int PySet_Add(PyObject *set, PyObject *key)
8165
 
 
8166
 
    Add *key* to a :class:`set` instance.  Does not apply to :class:`frozenset`
8167
 
    instances.  Return 0 on success or -1 on failure. Raise a :exc:`TypeError` if
8168
 
@@ -145,14 +145,14 @@
8169
 
 
8170
 
    .. versionchanged:: 2.6
8171
 
       Now works with instances of :class:`frozenset` or its subtypes.
8172
 
-      Like :cfunc:`PyTuple_SetItem` in that it can be used to fill-in the
8173
 
+      Like :c:func:`PyTuple_SetItem` in that it can be used to fill-in the
8174
 
       values of brand new frozensets before they are exposed to other code.
8175
 
 
8176
 
 The following functions are available for instances of :class:`set` or its
8177
 
 subtypes but not for instances of :class:`frozenset` or its subtypes.
8178
 
 
8179
 
 
8180
 
-.. cfunction:: int PySet_Discard(PyObject *set, PyObject *key)
8181
 
+.. c:function:: int PySet_Discard(PyObject *set, PyObject *key)
8182
 
 
8183
 
    Return 1 if found and removed, 0 if not found (no action taken), and -1 if an
8184
 
    error is encountered.  Does not raise :exc:`KeyError` for missing keys.  Raise a
8185
 
@@ -162,7 +162,7 @@
8186
 
    instance of :class:`set` or its subtype.
8187
 
 
8188
 
 
8189
 
-.. cfunction:: PyObject* PySet_Pop(PyObject *set)
8190
 
+.. c:function:: PyObject* PySet_Pop(PyObject *set)
8191
 
 
8192
 
    Return a new reference to an arbitrary object in the *set*, and removes the
8193
 
    object from the *set*.  Return *NULL* on failure.  Raise :exc:`KeyError` if the
8194
 
@@ -170,6 +170,6 @@
8195
 
    :class:`set` or its subtype.
8196
 
 
8197
 
 
8198
 
-.. cfunction:: int PySet_Clear(PyObject *set)
8199
 
+.. c:function:: int PySet_Clear(PyObject *set)
8200
 
 
8201
 
    Empty an existing set of all elements.
8202
 
diff -r 8527427914a2 Doc/c-api/slice.rst
8203
 
--- a/Doc/c-api/slice.rst
8204
 
+++ b/Doc/c-api/slice.rst
8205
 
@@ -6,7 +6,7 @@
8206
 
 -------------
8207
 
 
8208
 
 
8209
 
-.. cvar:: PyTypeObject PySlice_Type
8210
 
+.. c:var:: PyTypeObject PySlice_Type
8211
 
 
8212
 
    .. index:: single: SliceType (in module types)
8213
 
 
8214
 
@@ -14,12 +14,12 @@
8215
 
    ``types.SliceType``.
8216
 
 
8217
 
 
8218
 
-.. cfunction:: int PySlice_Check(PyObject *ob)
8219
 
+.. c:function:: int PySlice_Check(PyObject *ob)
8220
 
 
8221
 
    Return true if *ob* is a slice object; *ob* must not be *NULL*.
8222
 
 
8223
 
 
8224
 
-.. cfunction:: PyObject* PySlice_New(PyObject *start, PyObject *stop, PyObject *step)
8225
 
+.. c:function:: PyObject* PySlice_New(PyObject *start, PyObject *stop, PyObject *step)
8226
 
 
8227
 
    Return a new slice object with the given values.  The *start*, *stop*, and
8228
 
    *step* parameters are used as the values of the slice object attributes of
8229
 
@@ -28,7 +28,7 @@
8230
 
    the new object could not be allocated.
8231
 
 
8232
 
 
8233
 
-.. cfunction:: int PySlice_GetIndices(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step)
8234
 
+.. c:function:: int PySlice_GetIndices(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step)
8235
 
 
8236
 
    Retrieve the start, stop and step indices from the slice object *slice*,
8237
 
    assuming a sequence of length *length*. Treats indices greater than
8238
 
@@ -40,18 +40,18 @@
8239
 
 
8240
 
    You probably do not want to use this function.  If you want to use slice
8241
 
    objects in versions of Python prior to 2.3, you would probably do well to
8242
 
-   incorporate the source of :cfunc:`PySlice_GetIndicesEx`, suitably renamed,
8243
 
+   incorporate the source of :c:func:`PySlice_GetIndicesEx`, suitably renamed,
8244
 
    in the source of your extension.
8245
 
 
8246
 
    .. versionchanged:: 2.5
8247
 
-      This function used an :ctype:`int` type for *length* and an
8248
 
-      :ctype:`int *` type for *start*, *stop*, and *step*. This might require
8249
 
+      This function used an :c:type:`int` type for *length* and an
8250
 
+      :c:type:`int *` type for *start*, *stop*, and *step*. This might require
8251
 
       changes in your code for properly supporting 64-bit systems.
8252
 
 
8253
 
 
8254
 
-.. cfunction:: int PySlice_GetIndicesEx(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, Py_ssize_t *slicelength)
8255
 
+.. c:function:: int PySlice_GetIndicesEx(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, Py_ssize_t *slicelength)
8256
 
 
8257
 
-   Usable replacement for :cfunc:`PySlice_GetIndices`.  Retrieve the start,
8258
 
+   Usable replacement for :c:func:`PySlice_GetIndices`.  Retrieve the start,
8259
 
    stop, and step indices from the slice object *slice* assuming a sequence of
8260
 
    length *length*, and store the length of the slice in *slicelength*.  Out
8261
 
    of bounds indices are clipped in a manner consistent with the handling of
8262
 
@@ -62,7 +62,7 @@
8263
 
    .. versionadded:: 2.3
8264
 
 
8265
 
    .. versionchanged:: 2.5
8266
 
-      This function used an :ctype:`int` type for *length* and an
8267
 
-      :ctype:`int *` type for *start*, *stop*, *step*, and *slicelength*. This
8268
 
+      This function used an :c:type:`int` type for *length* and an
8269
 
+      :c:type:`int *` type for *start*, *stop*, *step*, and *slicelength*. This
8270
 
       might require changes in your code for properly supporting 64-bit
8271
 
       systems.
8272
 
diff -r 8527427914a2 Doc/c-api/string.rst
8273
 
--- a/Doc/c-api/string.rst
8274
 
+++ b/Doc/c-api/string.rst
8275
 
@@ -17,20 +17,20 @@
8276
 
 .. index:: object: string
8277
 
 
8278
 
 
8279
 
-.. ctype:: PyStringObject
8280
 
+.. c:type:: PyStringObject
8281
 
 
8282
 
-   This subtype of :ctype:`PyObject` represents a Python string object.
8283
 
+   This subtype of :c:type:`PyObject` represents a Python string object.
8284
 
 
8285
 
 
8286
 
-.. cvar:: PyTypeObject PyString_Type
8287
 
+.. c:var:: PyTypeObject PyString_Type
8288
 
 
8289
 
    .. index:: single: StringType (in module types)
8290
 
 
8291
 
-   This instance of :ctype:`PyTypeObject` represents the Python string type; it is
8292
 
+   This instance of :c:type:`PyTypeObject` represents the Python string type; it is
8293
 
    the same object as ``str`` and ``types.StringType`` in the Python layer. .
8294
 
 
8295
 
 
8296
 
-.. cfunction:: int PyString_Check(PyObject *o)
8297
 
+.. c:function:: int PyString_Check(PyObject *o)
8298
 
 
8299
 
    Return true if the object *o* is a string object or an instance of a subtype of
8300
 
    the string type.
8301
 
@@ -39,7 +39,7 @@
8302
 
       Allowed subtypes to be accepted.
8303
 
 
8304
 
 
8305
 
-.. cfunction:: int PyString_CheckExact(PyObject *o)
8306
 
+.. c:function:: int PyString_CheckExact(PyObject *o)
8307
 
 
8308
 
    Return true if the object *o* is a string object, but not an instance of a
8309
 
    subtype of the string type.
8310
 
@@ -47,27 +47,27 @@
8311
 
    .. versionadded:: 2.2
8312
 
 
8313
 
 
8314
 
-.. cfunction:: PyObject* PyString_FromString(const char *v)
8315
 
+.. c:function:: PyObject* PyString_FromString(const char *v)
8316
 
 
8317
 
    Return a new string object with a copy of the string *v* as value on success,
8318
 
    and *NULL* on failure.  The parameter *v* must not be *NULL*; it will not be
8319
 
    checked.
8320
 
 
8321
 
 
8322
 
-.. cfunction:: PyObject* PyString_FromStringAndSize(const char *v, Py_ssize_t len)
8323
 
+.. c:function:: PyObject* PyString_FromStringAndSize(const char *v, Py_ssize_t len)
8324
 
 
8325
 
    Return a new string object with a copy of the string *v* as value and length
8326
 
    *len* on success, and *NULL* on failure.  If *v* is *NULL*, the contents of the
8327
 
    string are uninitialized.
8328
 
 
8329
 
    .. versionchanged:: 2.5
8330
 
-      This function used an :ctype:`int` type for *len*. This might require
8331
 
+      This function used an :c:type:`int` type for *len*. This might require
8332
 
       changes in your code for properly supporting 64-bit systems.
8333
 
 
8334
 
 
8335
 
-.. cfunction:: PyObject* PyString_FromFormat(const char *format, ...)
8336
 
+.. c:function:: PyObject* PyString_FromFormat(const char *format, ...)
8337
 
 
8338
 
-   Take a C :cfunc:`printf`\ -style *format* string and a variable number of
8339
 
+   Take a C :c:func:`printf`\ -style *format* string and a variable number of
8340
 
    arguments, calculate the size of the resulting Python string and return a string
8341
 
    with the values formatted into it.  The variable arguments must be C types and
8342
 
    must correspond exactly to the format characters in the *format* string.  The
8343
 
@@ -144,31 +144,31 @@
8344
 
       Support for `"%lld"` and `"%llu"` added.
8345
 
 
8346
 
 
8347
 
-.. cfunction:: PyObject* PyString_FromFormatV(const char *format, va_list vargs)
8348
 
+.. c:function:: PyObject* PyString_FromFormatV(const char *format, va_list vargs)
8349
 
 
8350
 
-   Identical to :cfunc:`PyString_FromFormat` except that it takes exactly two
8351
 
+   Identical to :c:func:`PyString_FromFormat` except that it takes exactly two
8352
 
    arguments.
8353
 
 
8354
 
 
8355
 
-.. cfunction:: Py_ssize_t PyString_Size(PyObject *string)
8356
 
+.. c:function:: Py_ssize_t PyString_Size(PyObject *string)
8357
 
 
8358
 
    Return the length of the string in string object *string*.
8359
 
 
8360
 
    .. versionchanged:: 2.5
8361
 
-      This function returned an :ctype:`int` type. This might require changes
8362
 
+      This function returned an :c:type:`int` type. This might require changes
8363
 
       in your code for properly supporting 64-bit systems.
8364
 
 
8365
 
 
8366
 
-.. cfunction:: Py_ssize_t PyString_GET_SIZE(PyObject *string)
8367
 
+.. c:function:: Py_ssize_t PyString_GET_SIZE(PyObject *string)
8368
 
 
8369
 
-   Macro form of :cfunc:`PyString_Size` but without error checking.
8370
 
+   Macro form of :c:func:`PyString_Size` but without error checking.
8371
 
 
8372
 
    .. versionchanged:: 2.5
8373
 
-      This macro returned an :ctype:`int` type. This might require changes in
8374
 
+      This macro returned an :c:type:`int` type. This might require changes in
8375
 
       your code for properly supporting 64-bit systems.
8376
 
 
8377
 
 
8378
 
-.. cfunction:: char* PyString_AsString(PyObject *string)
8379
 
+.. c:function:: char* PyString_AsString(PyObject *string)
8380
 
 
8381
 
    Return a NUL-terminated representation of the contents of *string*.  The pointer
8382
 
    refers to the internal buffer of *string*, not a copy.  The data must not be
8383
 
@@ -176,16 +176,16 @@
8384
 
    ``PyString_FromStringAndSize(NULL, size)``. It must not be deallocated.  If
8385
 
    *string* is a Unicode object, this function computes the default encoding of
8386
 
    *string* and operates on that.  If *string* is not a string object at all,
8387
 
-   :cfunc:`PyString_AsString` returns *NULL* and raises :exc:`TypeError`.
8388
 
+   :c:func:`PyString_AsString` returns *NULL* and raises :exc:`TypeError`.
8389
 
 
8390
 
 
8391
 
-.. cfunction:: char* PyString_AS_STRING(PyObject *string)
8392
 
+.. c:function:: char* PyString_AS_STRING(PyObject *string)
8393
 
 
8394
 
-   Macro form of :cfunc:`PyString_AsString` but without error checking.  Only
8395
 
+   Macro form of :c:func:`PyString_AsString` but without error checking.  Only
8396
 
    string objects are supported; no Unicode objects should be passed.
8397
 
 
8398
 
 
8399
 
-.. cfunction:: int PyString_AsStringAndSize(PyObject *obj, char **buffer, Py_ssize_t *length)
8400
 
+.. c:function:: int PyString_AsStringAndSize(PyObject *obj, char **buffer, Py_ssize_t *length)
8401
 
 
8402
 
    Return a NUL-terminated representation of the contents of the object *obj*
8403
 
    through the output variables *buffer* and *length*.
8404
 
@@ -200,14 +200,14 @@
8405
 
    ``PyString_FromStringAndSize(NULL, size)``.  It must not be deallocated.  If
8406
 
    *string* is a Unicode object, this function computes the default encoding of
8407
 
    *string* and operates on that.  If *string* is not a string object at all,
8408
 
-   :cfunc:`PyString_AsStringAndSize` returns ``-1`` and raises :exc:`TypeError`.
8409
 
+   :c:func:`PyString_AsStringAndSize` returns ``-1`` and raises :exc:`TypeError`.
8410
 
 
8411
 
    .. versionchanged:: 2.5
8412
 
-      This function used an :ctype:`int *` type for *length*. This might
8413
 
+      This function used an :c:type:`int *` type for *length*. This might
8414
 
       require changes in your code for properly supporting 64-bit systems.
8415
 
 
8416
 
 
8417
 
-.. cfunction:: void PyString_Concat(PyObject **string, PyObject *newpart)
8418
 
+.. c:function:: void PyString_Concat(PyObject **string, PyObject *newpart)
8419
 
 
8420
 
    Create a new string object in *\*string* containing the contents of *newpart*
8421
 
    appended to *string*; the caller will own the new reference.  The reference to
8422
 
@@ -216,13 +216,13 @@
8423
 
    *\*string* will be set to *NULL*; the appropriate exception will be set.
8424
 
 
8425
 
 
8426
 
-.. cfunction:: void PyString_ConcatAndDel(PyObject **string, PyObject *newpart)
8427
 
+.. c:function:: void PyString_ConcatAndDel(PyObject **string, PyObject *newpart)
8428
 
 
8429
 
    Create a new string object in *\*string* containing the contents of *newpart*
8430
 
    appended to *string*.  This version decrements the reference count of *newpart*.
8431
 
 
8432
 
 
8433
 
-.. cfunction:: int _PyString_Resize(PyObject **string, Py_ssize_t newsize)
8434
 
+.. c:function:: int _PyString_Resize(PyObject **string, Py_ssize_t newsize)
8435
 
 
8436
 
    A way to resize a string object even though it is "immutable". Only use this to
8437
 
    build up a brand new string object; don't use this if the string may already be
8438
 
@@ -235,16 +235,16 @@
8439
 
    set to *NULL*, a memory exception is set, and ``-1`` is returned.
8440
 
 
8441
 
    .. versionchanged:: 2.5
8442
 
-      This function used an :ctype:`int` type for *newsize*. This might
8443
 
+      This function used an :c:type:`int` type for *newsize*. This might
8444
 
       require changes in your code for properly supporting 64-bit systems.
8445
 
 
8446
 
-.. cfunction:: PyObject* PyString_Format(PyObject *format, PyObject *args)
8447
 
+.. c:function:: PyObject* PyString_Format(PyObject *format, PyObject *args)
8448
 
 
8449
 
    Return a new string object from *format* and *args*. Analogous to ``format %
8450
 
    args``.  The *args* argument must be a tuple.
8451
 
 
8452
 
 
8453
 
-.. cfunction:: void PyString_InternInPlace(PyObject **string)
8454
 
+.. c:function:: void PyString_InternInPlace(PyObject **string)
8455
 
 
8456
 
    Intern the argument *\*string* in place.  The argument must be the address of a
8457
 
    pointer variable pointing to a Python string object.  If there is an existing
8458
 
@@ -261,10 +261,10 @@
8459
 
       This function is not available in 3.x and does not have a PyBytes alias.
8460
 
 
8461
 
 
8462
 
-.. cfunction:: PyObject* PyString_InternFromString(const char *v)
8463
 
+.. c:function:: PyObject* PyString_InternFromString(const char *v)
8464
 
 
8465
 
-   A combination of :cfunc:`PyString_FromString` and
8466
 
-   :cfunc:`PyString_InternInPlace`, returning either a new string object that has
8467
 
+   A combination of :c:func:`PyString_FromString` and
8468
 
+   :c:func:`PyString_InternInPlace`, returning either a new string object that has
8469
 
    been interned, or a new ("owned") reference to an earlier interned string object
8470
 
    with the same value.
8471
 
 
8472
 
@@ -273,7 +273,7 @@
8473
 
       This function is not available in 3.x and does not have a PyBytes alias.
8474
 
 
8475
 
 
8476
 
-.. cfunction:: PyObject* PyString_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors)
8477
 
+.. c:function:: PyObject* PyString_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors)
8478
 
 
8479
 
    Create an object by decoding *size* bytes of the encoded buffer *s* using the
8480
 
    codec registered for *encoding*.  *encoding* and *errors* have the same meaning
8481
 
@@ -286,11 +286,11 @@
8482
 
       This function is not available in 3.x and does not have a PyBytes alias.
8483
 
 
8484
 
    .. versionchanged:: 2.5
8485
 
-      This function used an :ctype:`int` type for *size*. This might require
8486
 
+      This function used an :c:type:`int` type for *size*. This might require
8487
 
       changes in your code for properly supporting 64-bit systems.
8488
 
 
8489
 
 
8490
 
-.. cfunction:: PyObject* PyString_AsDecodedObject(PyObject *str, const char *encoding, const char *errors)
8491
 
+.. c:function:: PyObject* PyString_AsDecodedObject(PyObject *str, const char *encoding, const char *errors)
8492
 
 
8493
 
    Decode a string object by passing it to the codec registered for *encoding* and
8494
 
    return the result as Python object. *encoding* and *errors* have the same
8495
 
@@ -303,9 +303,9 @@
8496
 
       This function is not available in 3.x and does not have a PyBytes alias.
8497
 
 
8498
 
 
8499
 
-.. cfunction:: PyObject* PyString_Encode(const char *s, Py_ssize_t size, const char *encoding, const char *errors)
8500
 
+.. c:function:: PyObject* PyString_Encode(const char *s, Py_ssize_t size, const char *encoding, const char *errors)
8501
 
 
8502
 
-   Encode the :ctype:`char` buffer of the given size by passing it to the codec
8503
 
+   Encode the :c:type:`char` buffer of the given size by passing it to the codec
8504
 
    registered for *encoding* and return a Python object. *encoding* and *errors*
8505
 
    have the same meaning as the parameters of the same name in the string
8506
 
    :meth:`encode` method. The codec to be used is looked up using the Python codec
8507
 
@@ -316,11 +316,11 @@
8508
 
       This function is not available in 3.x and does not have a PyBytes alias.
8509
 
 
8510
 
    .. versionchanged:: 2.5
8511
 
-      This function used an :ctype:`int` type for *size*. This might require
8512
 
+      This function used an :c:type:`int` type for *size*. This might require
8513
 
       changes in your code for properly supporting 64-bit systems.
8514
 
 
8515
 
 
8516
 
-.. cfunction:: PyObject* PyString_AsEncodedObject(PyObject *str, const char *encoding, const char *errors)
8517
 
+.. c:function:: PyObject* PyString_AsEncodedObject(PyObject *str, const char *encoding, const char *errors)
8518
 
 
8519
 
    Encode a string object using the codec registered for *encoding* and return the
8520
 
    result as Python object. *encoding* and *errors* have the same meaning as the
8521
 
diff -r 8527427914a2 Doc/c-api/structures.rst
8522
 
--- a/Doc/c-api/structures.rst
8523
 
+++ b/Doc/c-api/structures.rst
8524
 
@@ -11,12 +11,12 @@
8525
 
 
8526
 
 All Python objects ultimately share a small number of fields at the beginning
8527
 
 of the object's representation in memory.  These are represented by the
8528
 
-:ctype:`PyObject` and :ctype:`PyVarObject` types, which are defined, in turn,
8529
 
+:c:type:`PyObject` and :c:type:`PyVarObject` types, which are defined, in turn,
8530
 
 by the expansions of some macros also used, whether directly or indirectly, in
8531
 
 the definition of all other Python objects.
8532
 
 
8533
 
 
8534
 
-.. ctype:: PyObject
8535
 
+.. c:type:: PyObject
8536
 
 
8537
 
    All object types are extensions of this type.  This is a type which
8538
 
    contains the information Python needs to treat a pointer to an object as an
8539
 
@@ -26,79 +26,79 @@
8540
 
    macro.
8541
 
 
8542
 
 
8543
 
-.. ctype:: PyVarObject
8544
 
+.. c:type:: PyVarObject
8545
 
 
8546
 
-   This is an extension of :ctype:`PyObject` that adds the :attr:`ob_size`
8547
 
+   This is an extension of :c:type:`PyObject` that adds the :attr:`ob_size`
8548
 
    field.  This is only used for objects that have some notion of *length*.
8549
 
    This type does not often appear in the Python/C API.  It corresponds to the
8550
 
    fields defined by the expansion of the ``PyObject_VAR_HEAD`` macro.
8551
 
 
8552
 
-These macros are used in the definition of :ctype:`PyObject` and
8553
 
-:ctype:`PyVarObject`:
8554
 
+These macros are used in the definition of :c:type:`PyObject` and
8555
 
+:c:type:`PyVarObject`:
8556
 
 
8557
 
 
8558
 
-.. cmacro:: PyObject_HEAD
8559
 
+.. c:macro:: PyObject_HEAD
8560
 
 
8561
 
    This is a macro which expands to the declarations of the fields of the
8562
 
-   :ctype:`PyObject` type; it is used when declaring new types which represent
8563
 
+   :c:type:`PyObject` type; it is used when declaring new types which represent
8564
 
    objects without a varying length.  The specific fields it expands to depend
8565
 
-   on the definition of :cmacro:`Py_TRACE_REFS`.  By default, that macro is
8566
 
-   not defined, and :cmacro:`PyObject_HEAD` expands to::
8567
 
+   on the definition of :c:macro:`Py_TRACE_REFS`.  By default, that macro is
8568
 
+   not defined, and :c:macro:`PyObject_HEAD` expands to::
8569
 
 
8570
 
       Py_ssize_t ob_refcnt;
8571
 
       PyTypeObject *ob_type;
8572
 
 
8573
 
-   When :cmacro:`Py_TRACE_REFS` is defined, it expands to::
8574
 
+   When :c:macro:`Py_TRACE_REFS` is defined, it expands to::
8575
 
 
8576
 
       PyObject *_ob_next, *_ob_prev;
8577
 
       Py_ssize_t ob_refcnt;
8578
 
       PyTypeObject *ob_type;
8579
 
 
8580
 
 
8581
 
-.. cmacro:: PyObject_VAR_HEAD
8582
 
+.. c:macro:: PyObject_VAR_HEAD
8583
 
 
8584
 
    This is a macro which expands to the declarations of the fields of the
8585
 
-   :ctype:`PyVarObject` type; it is used when declaring new types which
8586
 
+   :c:type:`PyVarObject` type; it is used when declaring new types which
8587
 
    represent objects with a length that varies from instance to instance.
8588
 
    This macro always expands to::
8589
 
 
8590
 
       PyObject_HEAD
8591
 
       Py_ssize_t ob_size;
8592
 
 
8593
 
-   Note that :cmacro:`PyObject_HEAD` is part of the expansion, and that its own
8594
 
-   expansion varies depending on the definition of :cmacro:`Py_TRACE_REFS`.
8595
 
+   Note that :c:macro:`PyObject_HEAD` is part of the expansion, and that its own
8596
 
+   expansion varies depending on the definition of :c:macro:`Py_TRACE_REFS`.
8597
 
 
8598
 
 
8599
 
-.. cmacro:: PyObject_HEAD_INIT(type)
8600
 
+.. c:macro:: PyObject_HEAD_INIT(type)
8601
 
 
8602
 
    This is a macro which expands to initialization values for a new
8603
 
-   :ctype:`PyObject` type.  This macro expands to::
8604
 
+   :c:type:`PyObject` type.  This macro expands to::
8605
 
 
8606
 
       _PyObject_EXTRA_INIT
8607
 
       1, type,
8608
 
 
8609
 
 
8610
 
-.. cmacro:: PyVarObject_HEAD_INIT(type, size)
8611
 
+.. c:macro:: PyVarObject_HEAD_INIT(type, size)
8612
 
 
8613
 
    This is a macro which expands to initialization values for a new
8614
 
-   :ctype:`PyVarObject` type, including the :attr:`ob_size` field.
8615
 
+   :c:type:`PyVarObject` type, including the :attr:`ob_size` field.
8616
 
    This macro expands to::
8617
 
 
8618
 
       _PyObject_EXTRA_INIT
8619
 
       1, type, size,
8620
 
 
8621
 
 
8622
 
-.. ctype:: PyCFunction
8623
 
+.. c:type:: PyCFunction
8624
 
 
8625
 
    Type of the functions used to implement most Python callables in C.
8626
 
-   Functions of this type take two :ctype:`PyObject\*` parameters and return
8627
 
+   Functions of this type take two :c:type:`PyObject\*` parameters and return
8628
 
    one such value.  If the return value is *NULL*, an exception shall have
8629
 
    been set.  If not *NULL*, the return value is interpreted as the return
8630
 
    value of the function as exposed in Python.  The function must return a new
8631
 
    reference.
8632
 
 
8633
 
 
8634
 
-.. ctype:: PyMethodDef
8635
 
+.. c:type:: PyMethodDef
8636
 
 
8637
 
    Structure used to describe a method of an extension type.  This structure has
8638
 
    four fields:
8639
 
@@ -119,10 +119,10 @@
8640
 
    +------------------+-------------+-------------------------------+
8641
 
 
8642
 
 The :attr:`ml_meth` is a C function pointer.  The functions may be of different
8643
 
-types, but they always return :ctype:`PyObject\*`.  If the function is not of
8644
 
-the :ctype:`PyCFunction`, the compiler will require a cast in the method table.
8645
 
-Even though :ctype:`PyCFunction` defines the first parameter as
8646
 
-:ctype:`PyObject\*`, it is common that the method implementation uses a the
8647
 
+types, but they always return :c:type:`PyObject\*`.  If the function is not of
8648
 
+the :c:type:`PyCFunction`, the compiler will require a cast in the method table.
8649
 
+Even though :c:type:`PyCFunction` defines the first parameter as
8650
 
+:c:type:`PyObject\*`, it is common that the method implementation uses a the
8651
 
 specific C type of the *self* object.
8652
 
 
8653
 
 The :attr:`ml_flags` field is a bitfield which can include the following flags.
8654
 
@@ -136,27 +136,27 @@
8655
 
 .. data:: METH_VARARGS
8656
 
 
8657
 
    This is the typical calling convention, where the methods have the type
8658
 
-   :ctype:`PyCFunction`. The function expects two :ctype:`PyObject\*` values.
8659
 
+   :c:type:`PyCFunction`. The function expects two :c:type:`PyObject\*` values.
8660
 
    The first one is the *self* object for methods; for module functions, it is
8661
 
    the module object.  The second parameter (often called *args*) is a tuple
8662
 
    object representing all arguments.  This parameter is typically processed
8663
 
-   using :cfunc:`PyArg_ParseTuple` or :cfunc:`PyArg_UnpackTuple`.
8664
 
+   using :c:func:`PyArg_ParseTuple` or :c:func:`PyArg_UnpackTuple`.
8665
 
 
8666
 
 
8667
 
 .. data:: METH_KEYWORDS
8668
 
 
8669
 
-   Methods with these flags must be of type :ctype:`PyCFunctionWithKeywords`.
8670
 
+   Methods with these flags must be of type :c:type:`PyCFunctionWithKeywords`.
8671
 
    The function expects three parameters: *self*, *args*, and a dictionary of
8672
 
    all the keyword arguments.  The flag is typically combined with
8673
 
    :const:`METH_VARARGS`, and the parameters are typically processed using
8674
 
-   :cfunc:`PyArg_ParseTupleAndKeywords`.
8675
 
+   :c:func:`PyArg_ParseTupleAndKeywords`.
8676
 
 
8677
 
 
8678
 
 .. data:: METH_NOARGS
8679
 
 
8680
 
    Methods without parameters don't need to check whether arguments are given if
8681
 
    they are listed with the :const:`METH_NOARGS` flag.  They need to be of type
8682
 
-   :ctype:`PyCFunction`.  The first parameter is typically named ``self`` and
8683
 
+   :c:type:`PyCFunction`.  The first parameter is typically named ``self`` and
8684
 
    will hold a reference to the module or object instance.  In all cases the
8685
 
    second parameter will be *NULL*.
8686
 
 
8687
 
@@ -164,15 +164,15 @@
8688
 
 .. data:: METH_O
8689
 
 
8690
 
    Methods with a single object argument can be listed with the :const:`METH_O`
8691
 
-   flag, instead of invoking :cfunc:`PyArg_ParseTuple` with a ``"O"`` argument.
8692
 
-   They have the type :ctype:`PyCFunction`, with the *self* parameter, and a
8693
 
-   :ctype:`PyObject\*` parameter representing the single argument.
8694
 
+   flag, instead of invoking :c:func:`PyArg_ParseTuple` with a ``"O"`` argument.
8695
 
+   They have the type :c:type:`PyCFunction`, with the *self* parameter, and a
8696
 
+   :c:type:`PyObject\*` parameter representing the single argument.
8697
 
 
8698
 
 
8699
 
 .. data:: METH_OLDARGS
8700
 
 
8701
 
    This calling convention is deprecated.  The method must be of type
8702
 
-   :ctype:`PyCFunction`.  The second argument is *NULL* if no arguments are
8703
 
+   :c:type:`PyCFunction`.  The second argument is *NULL* if no arguments are
8704
 
    given, a single object if exactly one argument is given, and a tuple of
8705
 
    objects if more than one argument is given.  There is no way for a function
8706
 
    using this convention to distinguish between a call with multiple arguments
8707
 
@@ -225,7 +225,7 @@
8708
 
    .. versionadded:: 2.4
8709
 
 
8710
 
 
8711
 
-.. ctype:: PyMemberDef
8712
 
+.. c:type:: PyMemberDef
8713
 
 
8714
 
    Structure which describes an attribute of a type which corresponds to a C
8715
 
    struct member.  Its fields are:
8716
 
@@ -277,22 +277,22 @@
8717
 
    T_PYSSIZET      Py_ssize_t
8718
 
    =============== ==================
8719
 
 
8720
 
-   :cmacro:`T_OBJECT` and :cmacro:`T_OBJECT_EX` differ in that
8721
 
-   :cmacro:`T_OBJECT` returns ``None`` if the member is *NULL* and
8722
 
-   :cmacro:`T_OBJECT_EX` raises an :exc:`AttributeError`.  Try to use
8723
 
-   :cmacro:`T_OBJECT_EX` over :cmacro:`T_OBJECT` because :cmacro:`T_OBJECT_EX`
8724
 
+   :c:macro:`T_OBJECT` and :c:macro:`T_OBJECT_EX` differ in that
8725
 
+   :c:macro:`T_OBJECT` returns ``None`` if the member is *NULL* and
8726
 
+   :c:macro:`T_OBJECT_EX` raises an :exc:`AttributeError`.  Try to use
8727
 
+   :c:macro:`T_OBJECT_EX` over :c:macro:`T_OBJECT` because :c:macro:`T_OBJECT_EX`
8728
 
    handles use of the :keyword:`del` statement on that attribute more correctly
8729
 
-   than :cmacro:`T_OBJECT`.
8730
 
+   than :c:macro:`T_OBJECT`.
8731
 
 
8732
 
-   :attr:`flags` can be 0 for write and read access or :cmacro:`READONLY` for
8733
 
-   read-only access.  Using :cmacro:`T_STRING` for :attr:`type` implies
8734
 
-   :cmacro:`READONLY`.  Only :cmacro:`T_OBJECT` and :cmacro:`T_OBJECT_EX`
8735
 
+   :attr:`flags` can be 0 for write and read access or :c:macro:`READONLY` for
8736
 
+   read-only access.  Using :c:macro:`T_STRING` for :attr:`type` implies
8737
 
+   :c:macro:`READONLY`.  Only :c:macro:`T_OBJECT` and :c:macro:`T_OBJECT_EX`
8738
 
    members can be deleted.  (They are set to *NULL*).
8739
 
 
8740
 
 
8741
 
-.. cfunction:: PyObject* Py_FindMethod(PyMethodDef table[], PyObject *ob, char *name)
8742
 
+.. c:function:: PyObject* Py_FindMethod(PyMethodDef table[], PyObject *ob, char *name)
8743
 
 
8744
 
    Return a bound method object for an extension type implemented in C.  This
8745
 
    can be useful in the implementation of a :attr:`tp_getattro` or
8746
 
    :attr:`tp_getattr` handler that does not use the
8747
 
-   :cfunc:`PyObject_GenericGetAttr` function.
8748
 
+   :c:func:`PyObject_GenericGetAttr` function.
8749
 
diff -r 8527427914a2 Doc/c-api/sys.rst
8750
 
--- a/Doc/c-api/sys.rst
8751
 
+++ b/Doc/c-api/sys.rst
8752
 
@@ -6,16 +6,16 @@
8753
 
 ==========================
8754
 
 
8755
 
 
8756
 
-.. cfunction:: int Py_FdIsInteractive(FILE *fp, const char *filename)
8757
 
+.. c:function:: int Py_FdIsInteractive(FILE *fp, const char *filename)
8758
 
 
8759
 
    Return true (nonzero) if the standard I/O file *fp* with name *filename* is
8760
 
    deemed interactive.  This is the case for files for which ``isatty(fileno(fp))``
8761
 
-   is true.  If the global flag :cdata:`Py_InteractiveFlag` is true, this function
8762
 
+   is true.  If the global flag :c:data:`Py_InteractiveFlag` is true, this function
8763
 
    also returns true if the *filename* pointer is *NULL* or if the name is equal to
8764
 
    one of the strings ``'<stdin>'`` or ``'???'``.
8765
 
 
8766
 
 
8767
 
-.. cfunction:: void PyOS_AfterFork()
8768
 
+.. c:function:: void PyOS_AfterFork()
8769
 
 
8770
 
    Function to update some internal state after a process fork; this should be
8771
 
    called in the new process if the Python interpreter will continue to be used.
8772
 
@@ -23,7 +23,7 @@
8773
 
    to be called.
8774
 
 
8775
 
 
8776
 
-.. cfunction:: int PyOS_CheckStack()
8777
 
+.. c:function:: int PyOS_CheckStack()
8778
 
 
8779
 
    Return true when the interpreter runs out of stack space.  This is a reliable
8780
 
    check, but is only available when :const:`USE_STACKCHECK` is defined (currently
8781
 
@@ -32,20 +32,20 @@
8782
 
    own code.
8783
 
 
8784
 
 
8785
 
-.. cfunction:: PyOS_sighandler_t PyOS_getsig(int i)
8786
 
+.. c:function:: PyOS_sighandler_t PyOS_getsig(int i)
8787
 
 
8788
 
    Return the current signal handler for signal *i*.  This is a thin wrapper around
8789
 
-   either :cfunc:`sigaction` or :cfunc:`signal`.  Do not call those functions
8790
 
-   directly! :ctype:`PyOS_sighandler_t` is a typedef alias for :ctype:`void
8791
 
+   either :c:func:`sigaction` or :c:func:`signal`.  Do not call those functions
8792
 
+   directly! :c:type:`PyOS_sighandler_t` is a typedef alias for :c:type:`void
8793
 
    (\*)(int)`.
8794
 
 
8795
 
 
8796
 
-.. cfunction:: PyOS_sighandler_t PyOS_setsig(int i, PyOS_sighandler_t h)
8797
 
+.. c:function:: PyOS_sighandler_t PyOS_setsig(int i, PyOS_sighandler_t h)
8798
 
 
8799
 
    Set the signal handler for signal *i* to be *h*; return the old signal handler.
8800
 
-   This is a thin wrapper around either :cfunc:`sigaction` or :cfunc:`signal`.  Do
8801
 
-   not call those functions directly!  :ctype:`PyOS_sighandler_t` is a typedef
8802
 
-   alias for :ctype:`void (\*)(int)`.
8803
 
+   This is a thin wrapper around either :c:func:`sigaction` or :c:func:`signal`.  Do
8804
 
+   not call those functions directly!  :c:type:`PyOS_sighandler_t` is a typedef
8805
 
+   alias for :c:type:`void (\*)(int)`.
8806
 
 
8807
 
 .. _systemfunctions:
8808
 
 
8809
 
@@ -56,38 +56,38 @@
8810
 
 accessible to C code.  They all work with the current interpreter thread's
8811
 
 :mod:`sys` module's dict, which is contained in the internal thread state structure.
8812
 
 
8813
 
-.. cfunction:: PyObject *PySys_GetObject(char *name)
8814
 
+.. c:function:: PyObject *PySys_GetObject(char *name)
8815
 
 
8816
 
    Return the object *name* from the :mod:`sys` module or *NULL* if it does
8817
 
    not exist, without setting an exception.
8818
 
 
8819
 
-.. cfunction:: FILE *PySys_GetFile(char *name, FILE *def)
8820
 
+.. c:function:: FILE *PySys_GetFile(char *name, FILE *def)
8821
 
 
8822
 
-   Return the :ctype:`FILE*` associated with the object *name* in the
8823
 
+   Return the :c:type:`FILE*` associated with the object *name* in the
8824
 
    :mod:`sys` module, or *def* if *name* is not in the module or is not associated
8825
 
-   with a :ctype:`FILE*`.
8826
 
+   with a :c:type:`FILE*`.
8827
 
 
8828
 
-.. cfunction:: int PySys_SetObject(char *name, PyObject *v)
8829
 
+.. c:function:: int PySys_SetObject(char *name, PyObject *v)
8830
 
 
8831
 
    Set *name* in the :mod:`sys` module to *v* unless *v* is *NULL*, in which
8832
 
    case *name* is deleted from the sys module. Returns ``0`` on success, ``-1``
8833
 
    on error.
8834
 
 
8835
 
-.. cfunction:: void PySys_ResetWarnOptions()
8836
 
+.. c:function:: void PySys_ResetWarnOptions()
8837
 
 
8838
 
    Reset :data:`sys.warnoptions` to an empty list.
8839
 
 
8840
 
-.. cfunction:: void PySys_AddWarnOption(char *s)
8841
 
+.. c:function:: void PySys_AddWarnOption(char *s)
8842
 
 
8843
 
    Append *s* to :data:`sys.warnoptions`.
8844
 
 
8845
 
-.. cfunction:: void PySys_SetPath(char *path)
8846
 
+.. c:function:: void PySys_SetPath(char *path)
8847
 
 
8848
 
    Set :data:`sys.path` to a list object of paths found in *path* which should
8849
 
    be a list of paths separated with the platform's search path delimiter
8850
 
    (``:`` on Unix, ``;`` on Windows).
8851
 
 
8852
 
-.. cfunction:: void PySys_WriteStdout(const char *format, ...)
8853
 
+.. c:function:: void PySys_WriteStdout(const char *format, ...)
8854
 
 
8855
 
    Write the output string described by *format* to :data:`sys.stdout`.  No
8856
 
    exceptions are raised, even if truncation occurs (see below).
8857
 
@@ -103,7 +103,7 @@
8858
 
    If a problem occurs, or :data:`sys.stdout` is unset, the formatted message
8859
 
    is written to the real (C level) *stdout*.
8860
 
 
8861
 
-.. cfunction:: void PySys_WriteStderr(const char *format, ...)
8862
 
+.. c:function:: void PySys_WriteStderr(const char *format, ...)
8863
 
 
8864
 
    As above, but write to :data:`sys.stderr` or *stderr* instead.
8865
 
 
8866
 
@@ -114,7 +114,7 @@
8867
 
 ===============
8868
 
 
8869
 
 
8870
 
-.. cfunction:: void Py_FatalError(const char *message)
8871
 
+.. c:function:: void Py_FatalError(const char *message)
8872
 
 
8873
 
    .. index:: single: abort()
8874
 
 
8875
 
@@ -122,30 +122,30 @@
8876
 
    This function should only be invoked when a condition is detected that would
8877
 
    make it dangerous to continue using the Python interpreter; e.g., when the
8878
 
    object administration appears to be corrupted.  On Unix, the standard C library
8879
 
-   function :cfunc:`abort` is called which will attempt to produce a :file:`core`
8880
 
+   function :c:func:`abort` is called which will attempt to produce a :file:`core`
8881
 
    file.
8882
 
 
8883
 
 
8884
 
-.. cfunction:: void Py_Exit(int status)
8885
 
+.. c:function:: void Py_Exit(int status)
8886
 
 
8887
 
    .. index::
8888
 
       single: Py_Finalize()
8889
 
       single: exit()
8890
 
 
8891
 
-   Exit the current process.  This calls :cfunc:`Py_Finalize` and then calls the
8892
 
+   Exit the current process.  This calls :c:func:`Py_Finalize` and then calls the
8893
 
    standard C library function ``exit(status)``.
8894
 
 
8895
 
 
8896
 
-.. cfunction:: int Py_AtExit(void (*func) ())
8897
 
+.. c:function:: int Py_AtExit(void (*func) ())
8898
 
 
8899
 
    .. index::
8900
 
       single: Py_Finalize()
8901
 
       single: cleanup functions
8902
 
 
8903
 
-   Register a cleanup function to be called by :cfunc:`Py_Finalize`.  The cleanup
8904
 
+   Register a cleanup function to be called by :c:func:`Py_Finalize`.  The cleanup
8905
 
    function will be called with no arguments and should return no value.  At most
8906
 
    32 cleanup functions can be registered.  When the registration is successful,
8907
 
-   :cfunc:`Py_AtExit` returns ``0``; on failure, it returns ``-1``.  The cleanup
8908
 
+   :c:func:`Py_AtExit` returns ``0``; on failure, it returns ``-1``.  The cleanup
8909
 
    function registered last is called first. Each cleanup function will be called
8910
 
    at most once.  Since Python's internal finalization will have completed before
8911
 
    the cleanup function, no Python APIs should be called by *func*.
8912
 
diff -r 8527427914a2 Doc/c-api/tuple.rst
8913
 
--- a/Doc/c-api/tuple.rst
8914
 
+++ b/Doc/c-api/tuple.rst
8915
 
@@ -8,20 +8,20 @@
8916
 
 .. index:: object: tuple
8917
 
 
8918
 
 
8919
 
-.. ctype:: PyTupleObject
8920
 
+.. c:type:: PyTupleObject
8921
 
 
8922
 
-   This subtype of :ctype:`PyObject` represents a Python tuple object.
8923
 
+   This subtype of :c:type:`PyObject` represents a Python tuple object.
8924
 
 
8925
 
 
8926
 
-.. cvar:: PyTypeObject PyTuple_Type
8927
 
+.. c:var:: PyTypeObject PyTuple_Type
8928
 
 
8929
 
    .. index:: single: TupleType (in module types)
8930
 
 
8931
 
-   This instance of :ctype:`PyTypeObject` represents the Python tuple type; it is
8932
 
+   This instance of :c:type:`PyTypeObject` represents the Python tuple type; it is
8933
 
    the same object as ``tuple`` and ``types.TupleType`` in the Python layer..
8934
 
 
8935
 
 
8936
 
-.. cfunction:: int PyTuple_Check(PyObject *p)
8937
 
+.. c:function:: int PyTuple_Check(PyObject *p)
8938
 
 
8939
 
    Return true if *p* is a tuple object or an instance of a subtype of the tuple
8940
 
    type.
8941
 
@@ -30,7 +30,7 @@
8942
 
       Allowed subtypes to be accepted.
8943
 
 
8944
 
 
8945
 
-.. cfunction:: int PyTuple_CheckExact(PyObject *p)
8946
 
+.. c:function:: int PyTuple_CheckExact(PyObject *p)
8947
 
 
8948
 
    Return true if *p* is a tuple object, but not an instance of a subtype of the
8949
 
    tuple type.
8950
 
@@ -38,16 +38,16 @@
8951
 
    .. versionadded:: 2.2
8952
 
 
8953
 
 
8954
 
-.. cfunction:: PyObject* PyTuple_New(Py_ssize_t len)
8955
 
+.. c:function:: PyObject* PyTuple_New(Py_ssize_t len)
8956
 
 
8957
 
    Return a new tuple object of size *len*, or *NULL* on failure.
8958
 
 
8959
 
    .. versionchanged:: 2.5
8960
 
-      This function used an :ctype:`int` type for *len*. This might require
8961
 
+      This function used an :c:type:`int` type for *len*. This might require
8962
 
       changes in your code for properly supporting 64-bit systems.
8963
 
 
8964
 
 
8965
 
-.. cfunction:: PyObject* PyTuple_Pack(Py_ssize_t n, ...)
8966
 
+.. c:function:: PyObject* PyTuple_Pack(Py_ssize_t n, ...)
8967
 
 
8968
 
    Return a new tuple object of size *n*, or *NULL* on failure. The tuple values
8969
 
    are initialized to the subsequent *n* C arguments pointing to Python objects.
8970
 
@@ -56,59 +56,59 @@
8971
 
    .. versionadded:: 2.4
8972
 
 
8973
 
    .. versionchanged:: 2.5
8974
 
-      This function used an :ctype:`int` type for *n*. This might require
8975
 
+      This function used an :c:type:`int` type for *n*. This might require
8976
 
       changes in your code for properly supporting 64-bit systems.
8977
 
 
8978
 
 
8979
 
-.. cfunction:: Py_ssize_t PyTuple_Size(PyObject *p)
8980
 
+.. c:function:: Py_ssize_t PyTuple_Size(PyObject *p)
8981
 
 
8982
 
    Take a pointer to a tuple object, and return the size of that tuple.
8983
 
 
8984
 
    .. versionchanged:: 2.5
8985
 
-      This function returned an :ctype:`int` type. This might require changes
8986
 
+      This function returned an :c:type:`int` type. This might require changes
8987
 
       in your code for properly supporting 64-bit systems.
8988
 
 
8989
 
 
8990
 
-.. cfunction:: Py_ssize_t PyTuple_GET_SIZE(PyObject *p)
8991
 
+.. c:function:: Py_ssize_t PyTuple_GET_SIZE(PyObject *p)
8992
 
 
8993
 
    Return the size of the tuple *p*, which must be non-*NULL* and point to a tuple;
8994
 
    no error checking is performed.
8995
 
 
8996
 
    .. versionchanged:: 2.5
8997
 
-      This function returned an :ctype:`int` type. This might require changes
8998
 
+      This function returned an :c:type:`int` type. This might require changes
8999
 
       in your code for properly supporting 64-bit systems.
9000
 
 
9001
 
 
9002
 
-.. cfunction:: PyObject* PyTuple_GetItem(PyObject *p, Py_ssize_t pos)
9003
 
+.. c:function:: PyObject* PyTuple_GetItem(PyObject *p, Py_ssize_t pos)
9004
 
 
9005
 
    Return the object at position *pos* in the tuple pointed to by *p*.  If *pos* is
9006
 
    out of bounds, return *NULL* and sets an :exc:`IndexError` exception.
9007
 
 
9008
 
    .. versionchanged:: 2.5
9009
 
-      This function used an :ctype:`int` type for *pos*. This might require
9010
 
+      This function used an :c:type:`int` type for *pos*. This might require
9011
 
       changes in your code for properly supporting 64-bit systems.
9012
 
 
9013
 
 
9014
 
-.. cfunction:: PyObject* PyTuple_GET_ITEM(PyObject *p, Py_ssize_t pos)
9015
 
+.. c:function:: PyObject* PyTuple_GET_ITEM(PyObject *p, Py_ssize_t pos)
9016
 
 
9017
 
-   Like :cfunc:`PyTuple_GetItem`, but does no checking of its arguments.
9018
 
+   Like :c:func:`PyTuple_GetItem`, but does no checking of its arguments.
9019
 
 
9020
 
    .. versionchanged:: 2.5
9021
 
-      This function used an :ctype:`int` type for *pos*. This might require
9022
 
+      This function used an :c:type:`int` type for *pos*. This might require
9023
 
       changes in your code for properly supporting 64-bit systems.
9024
 
 
9025
 
 
9026
 
-.. cfunction:: PyObject* PyTuple_GetSlice(PyObject *p, Py_ssize_t low, Py_ssize_t high)
9027
 
+.. c:function:: PyObject* PyTuple_GetSlice(PyObject *p, Py_ssize_t low, Py_ssize_t high)
9028
 
 
9029
 
    Take a slice of the tuple pointed to by *p* from *low* to *high* and return it
9030
 
    as a new tuple.
9031
 
 
9032
 
    .. versionchanged:: 2.5
9033
 
-      This function used an :ctype:`int` type for *low* and *high*. This might
9034
 
+      This function used an :c:type:`int` type for *low* and *high*. This might
9035
 
       require changes in your code for properly supporting 64-bit systems.
9036
 
 
9037
 
 
9038
 
-.. cfunction:: int PyTuple_SetItem(PyObject *p, Py_ssize_t pos, PyObject *o)
9039
 
+.. c:function:: int PyTuple_SetItem(PyObject *p, Py_ssize_t pos, PyObject *o)
9040
 
 
9041
 
    Insert a reference to object *o* at position *pos* of the tuple pointed to by
9042
 
    *p*. Return ``0`` on success.
9043
 
@@ -118,13 +118,13 @@
9044
 
       This function "steals" a reference to *o*.
9045
 
 
9046
 
    .. versionchanged:: 2.5
9047
 
-      This function used an :ctype:`int` type for *pos*. This might require
9048
 
+      This function used an :c:type:`int` type for *pos*. This might require
9049
 
       changes in your code for properly supporting 64-bit systems.
9050
 
 
9051
 
 
9052
 
-.. cfunction:: void PyTuple_SET_ITEM(PyObject *p, Py_ssize_t pos, PyObject *o)
9053
 
+.. c:function:: void PyTuple_SET_ITEM(PyObject *p, Py_ssize_t pos, PyObject *o)
9054
 
 
9055
 
-   Like :cfunc:`PyTuple_SetItem`, but does no error checking, and should *only* be
9056
 
+   Like :c:func:`PyTuple_SetItem`, but does no error checking, and should *only* be
9057
 
    used to fill in brand new tuples.
9058
 
 
9059
 
    .. note::
9060
 
@@ -132,11 +132,11 @@
9061
 
       This function "steals" a reference to *o*.
9062
 
 
9063
 
    .. versionchanged:: 2.5
9064
 
-      This function used an :ctype:`int` type for *pos*. This might require
9065
 
+      This function used an :c:type:`int` type for *pos*. This might require
9066
 
       changes in your code for properly supporting 64-bit systems.
9067
 
 
9068
 
 
9069
 
-.. cfunction:: int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize)
9070
 
+.. c:function:: int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize)
9071
 
 
9072
 
    Can be used to resize a tuple.  *newsize* will be the new length of the tuple.
9073
 
    Because tuples are *supposed* to be immutable, this should only be used if there
9074
 
@@ -153,11 +153,11 @@
9075
 
       Removed unused third parameter, *last_is_sticky*.
9076
 
 
9077
 
    .. versionchanged:: 2.5
9078
 
-      This function used an :ctype:`int` type for *newsize*. This might
9079
 
+      This function used an :c:type:`int` type for *newsize*. This might
9080
 
       require changes in your code for properly supporting 64-bit systems.
9081
 
 
9082
 
 
9083
 
-.. cfunction:: int PyTuple_ClearFreeList()
9084
 
+.. c:function:: int PyTuple_ClearFreeList()
9085
 
 
9086
 
    Clear the free list. Return the total number of freed items.
9087
 
 
9088
 
diff -r 8527427914a2 Doc/c-api/type.rst
9089
 
--- a/Doc/c-api/type.rst
9090
 
+++ b/Doc/c-api/type.rst
9091
 
@@ -8,12 +8,12 @@
9092
 
 .. index:: object: type
9093
 
 
9094
 
 
9095
 
-.. ctype:: PyTypeObject
9096
 
+.. c:type:: PyTypeObject
9097
 
 
9098
 
    The C structure of the objects used to describe built-in types.
9099
 
 
9100
 
 
9101
 
-.. cvar:: PyObject* PyType_Type
9102
 
+.. c:var:: PyObject* PyType_Type
9103
 
 
9104
 
    .. index:: single: TypeType (in module types)
9105
 
 
9106
 
@@ -21,13 +21,13 @@
9107
 
    ``types.TypeType`` in the Python layer.
9108
 
 
9109
 
 
9110
 
-.. cfunction:: int PyType_Check(PyObject *o)
9111
 
+.. c:function:: int PyType_Check(PyObject *o)
9112
 
 
9113
 
    Return true if the object *o* is a type object, including instances of types
9114
 
    derived from the standard type object.  Return false in all other cases.
9115
 
 
9116
 
 
9117
 
-.. cfunction:: int PyType_CheckExact(PyObject *o)
9118
 
+.. c:function:: int PyType_CheckExact(PyObject *o)
9119
 
 
9120
 
    Return true if the object *o* is a type object, but not a subtype of the
9121
 
    standard type object.  Return false in all other cases.
9122
 
@@ -35,14 +35,14 @@
9123
 
    .. versionadded:: 2.2
9124
 
 
9125
 
 
9126
 
-.. cfunction:: unsigned int PyType_ClearCache()
9127
 
+.. c:function:: unsigned int PyType_ClearCache()
9128
 
 
9129
 
    Clear the internal lookup cache. Return the current version tag.
9130
 
 
9131
 
    .. versionadded:: 2.6
9132
 
 
9133
 
 
9134
 
-.. cfunction:: void PyType_Modified(PyTypeObject *type)
9135
 
+.. c:function:: void PyType_Modified(PyTypeObject *type)
9136
 
 
9137
 
    Invalidate the internal lookup cache for the type and all of its
9138
 
    subtypes.  This function must be called after any manual
9139
 
@@ -51,13 +51,13 @@
9140
 
    .. versionadded:: 2.6
9141
 
 
9142
 
 
9143
 
-.. cfunction:: int PyType_HasFeature(PyObject *o, int feature)
9144
 
+.. c:function:: int PyType_HasFeature(PyObject *o, int feature)
9145
 
 
9146
 
    Return true if the type object *o* sets the feature *feature*.  Type features
9147
 
    are denoted by single bit flags.
9148
 
 
9149
 
 
9150
 
-.. cfunction:: int PyType_IS_GC(PyObject *o)
9151
 
+.. c:function:: int PyType_IS_GC(PyObject *o)
9152
 
 
9153
 
    Return true if the type object includes support for the cycle detector; this
9154
 
    tests the type flag :const:`Py_TPFLAGS_HAVE_GC`.
9155
 
@@ -65,28 +65,28 @@
9156
 
    .. versionadded:: 2.0
9157
 
 
9158
 
 
9159
 
-.. cfunction:: int PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b)
9160
 
+.. c:function:: int PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b)
9161
 
 
9162
 
    Return true if *a* is a subtype of *b*.
9163
 
 
9164
 
    .. versionadded:: 2.2
9165
 
 
9166
 
 
9167
 
-.. cfunction:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
9168
 
+.. c:function:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
9169
 
 
9170
 
    .. versionadded:: 2.2
9171
 
 
9172
 
    .. versionchanged:: 2.5
9173
 
-      This function used an :ctype:`int` type for *nitems*. This might require
9174
 
+      This function used an :c:type:`int` type for *nitems*. This might require
9175
 
       changes in your code for properly supporting 64-bit systems.
9176
 
 
9177
 
 
9178
 
-.. cfunction:: PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds)
9179
 
+.. c:function:: PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds)
9180
 
 
9181
 
    .. versionadded:: 2.2
9182
 
 
9183
 
 
9184
 
-.. cfunction:: int PyType_Ready(PyTypeObject *type)
9185
 
+.. c:function:: int PyType_Ready(PyTypeObject *type)
9186
 
 
9187
 
    Finalize a type object.  This should be called on all type objects to finish
9188
 
    their initialization.  This function is responsible for adding inherited slots
9189
 
diff -r 8527427914a2 Doc/c-api/typeobj.rst
9190
 
--- a/Doc/c-api/typeobj.rst
9191
 
+++ b/Doc/c-api/typeobj.rst
9192
 
@@ -6,9 +6,9 @@
9193
 
 ============
9194
 
 
9195
 
 Perhaps one of the most important structures of the Python object system is the
9196
 
-structure that defines a new type: the :ctype:`PyTypeObject` structure.  Type
9197
 
-objects can be handled using any of the :cfunc:`PyObject_\*` or
9198
 
-:cfunc:`PyType_\*` functions, but do not offer much that's interesting to most
9199
 
+structure that defines a new type: the :c:type:`PyTypeObject` structure.  Type
9200
 
+objects can be handled using any of the :c:func:`PyObject_\*` or
9201
 
+:c:func:`PyType_\*` functions, but do not offer much that's interesting to most
9202
 
 Python applications. These objects are fundamental to how objects behave, so
9203
 
 they are very important to the interpreter itself and to any extension module
9204
 
 that implements new types.
9205
 
@@ -25,21 +25,21 @@
9206
 
 freefunc, printfunc, getattrfunc, getattrofunc, setattrfunc, setattrofunc,
9207
 
 cmpfunc, reprfunc, hashfunc
9208
 
 
9209
 
-The structure definition for :ctype:`PyTypeObject` can be found in
9210
 
+The structure definition for :c:type:`PyTypeObject` can be found in
9211
 
 :file:`Include/object.h`.  For convenience of reference, this repeats the
9212
 
 definition found there:
9213
 
 
9214
 
 .. literalinclude:: ../includes/typestruct.h
9215
 
 
9216
 
 
9217
 
-The type object structure extends the :ctype:`PyVarObject` structure. The
9218
 
+The type object structure extends the :c:type:`PyVarObject` structure. The
9219
 
 :attr:`ob_size` field is used for dynamic types (created by  :func:`type_new`,
9220
 
-usually called from a class statement). Note that :cdata:`PyType_Type` (the
9221
 
+usually called from a class statement). Note that :c:data:`PyType_Type` (the
9222
 
 metatype) initializes :attr:`tp_itemsize`, which means that its instances (i.e.
9223
 
 type objects) *must* have the :attr:`ob_size` field.
9224
 
 
9225
 
 
9226
 
-.. cmember:: PyObject* PyObject._ob_next
9227
 
+.. c:member:: PyObject* PyObject._ob_next
9228
 
              PyObject* PyObject._ob_prev
9229
 
 
9230
 
    These fields are only present when the macro ``Py_TRACE_REFS`` is defined.
9231
 
@@ -54,7 +54,7 @@
9232
 
    These fields are not inherited by subtypes.
9233
 
 
9234
 
 
9235
 
-.. cmember:: Py_ssize_t PyObject.ob_refcnt
9236
 
+.. c:member:: Py_ssize_t PyObject.ob_refcnt
9237
 
 
9238
 
    This is the type object's reference count, initialized to ``1`` by the
9239
 
    ``PyObject_HEAD_INIT`` macro.  Note that for statically allocated type objects,
9240
 
@@ -65,11 +65,11 @@
9241
 
    This field is not inherited by subtypes.
9242
 
 
9243
 
    .. versionchanged:: 2.5
9244
 
-      This field used to be an :ctype:`int` type. This might require changes
9245
 
+      This field used to be an :c:type:`int` type. This might require changes
9246
 
       in your code for properly supporting 64-bit systems.
9247
 
 
9248
 
 
9249
 
-.. cmember:: PyTypeObject* PyObject.ob_type
9250
 
+.. c:member:: PyTypeObject* PyObject.ob_type
9251
 
 
9252
 
    This is the type's type, in other words its metatype.  It is initialized by the
9253
 
    argument to the ``PyObject_HEAD_INIT`` macro, and its value should normally be
9254
 
@@ -83,16 +83,16 @@
9255
 
       Foo_Type.ob_type = &PyType_Type;
9256
 
 
9257
 
    This should be done before any instances of the type are created.
9258
 
-   :cfunc:`PyType_Ready` checks if :attr:`ob_type` is *NULL*, and if so,
9259
 
+   :c:func:`PyType_Ready` checks if :attr:`ob_type` is *NULL*, and if so,
9260
 
    initializes it: in Python 2.2, it is set to ``&PyType_Type``; in Python 2.2.1
9261
 
    and later it is initialized to the :attr:`ob_type` field of the base class.
9262
 
-   :cfunc:`PyType_Ready` will not change this field if it is non-zero.
9263
 
+   :c:func:`PyType_Ready` will not change this field if it is non-zero.
9264
 
 
9265
 
    In Python 2.2, this field is not inherited by subtypes.  In 2.2.1, and in 2.3
9266
 
    and beyond, it is inherited by subtypes.
9267
 
 
9268
 
 
9269
 
-.. cmember:: Py_ssize_t PyVarObject.ob_size
9270
 
+.. c:member:: Py_ssize_t PyVarObject.ob_size
9271
 
 
9272
 
    For statically allocated type objects, this should be initialized to zero.  For
9273
 
    dynamically allocated type objects, this field has a special internal meaning.
9274
 
@@ -100,7 +100,7 @@
9275
 
    This field is not inherited by subtypes.
9276
 
 
9277
 
 
9278
 
-.. cmember:: char* PyTypeObject.tp_name
9279
 
+.. c:member:: char* PyTypeObject.tp_name
9280
 
 
9281
 
    Pointer to a NUL-terminated string containing the name of the type. For types
9282
 
    that are accessible as module globals, the string should be the full module
9283
 
@@ -127,7 +127,7 @@
9284
 
    This field is not inherited by subtypes.
9285
 
 
9286
 
 
9287
 
-.. cmember:: Py_ssize_t PyTypeObject.tp_basicsize
9288
 
+.. c:member:: Py_ssize_t PyTypeObject.tp_basicsize
9289
 
              Py_ssize_t PyTypeObject.tp_itemsize
9290
 
 
9291
 
    These fields allow calculating the size in bytes of instances of the type.
9292
 
@@ -149,7 +149,7 @@
9293
 
    field).
9294
 
 
9295
 
    The basic size includes the fields in the instance declared by the macro
9296
 
-   :cmacro:`PyObject_HEAD` or :cmacro:`PyObject_VAR_HEAD` (whichever is used to
9297
 
+   :c:macro:`PyObject_HEAD` or :c:macro:`PyObject_VAR_HEAD` (whichever is used to
9298
 
    declare the instance struct) and this in turn includes the :attr:`_ob_prev` and
9299
 
    :attr:`_ob_next` fields if they are present.  This means that the only correct
9300
 
    way to get an initializer for the :attr:`tp_basicsize` is to use the
9301
 
@@ -170,14 +170,14 @@
9302
 
    alignment requirement for ``double``).
9303
 
 
9304
 
 
9305
 
-.. cmember:: destructor PyTypeObject.tp_dealloc
9306
 
+.. c:member:: destructor PyTypeObject.tp_dealloc
9307
 
 
9308
 
    A pointer to the instance destructor function.  This function must be defined
9309
 
    unless the type guarantees that its instances will never be deallocated (as is
9310
 
    the case for the singletons ``None`` and ``Ellipsis``).
9311
 
 
9312
 
-   The destructor function is called by the :cfunc:`Py_DECREF` and
9313
 
-   :cfunc:`Py_XDECREF` macros when the new reference count is zero.  At this point,
9314
 
+   The destructor function is called by the :c:func:`Py_DECREF` and
9315
 
+   :c:func:`Py_XDECREF` macros when the new reference count is zero.  At this point,
9316
 
    the instance is still in existence, but there are no references to it.  The
9317
 
    destructor function should free all references which the instance owns, free all
9318
 
    memory buffers owned by the instance (using the freeing function corresponding
9319
 
@@ -186,15 +186,15 @@
9320
 
    subtypable (doesn't have the :const:`Py_TPFLAGS_BASETYPE` flag bit set), it is
9321
 
    permissible to call the object deallocator directly instead of via
9322
 
    :attr:`tp_free`.  The object deallocator should be the one used to allocate the
9323
 
-   instance; this is normally :cfunc:`PyObject_Del` if the instance was allocated
9324
 
-   using :cfunc:`PyObject_New` or :cfunc:`PyObject_VarNew`, or
9325
 
-   :cfunc:`PyObject_GC_Del` if the instance was allocated using
9326
 
-   :cfunc:`PyObject_GC_New` or :cfunc:`PyObject_GC_NewVar`.
9327
 
+   instance; this is normally :c:func:`PyObject_Del` if the instance was allocated
9328
 
+   using :c:func:`PyObject_New` or :c:func:`PyObject_VarNew`, or
9329
 
+   :c:func:`PyObject_GC_Del` if the instance was allocated using
9330
 
+   :c:func:`PyObject_GC_New` or :c:func:`PyObject_GC_NewVar`.
9331
 
 
9332
 
    This field is inherited by subtypes.
9333
 
 
9334
 
 
9335
 
-.. cmember:: printfunc PyTypeObject.tp_print
9336
 
+.. c:member:: printfunc PyTypeObject.tp_print
9337
 
 
9338
 
    An optional pointer to the instance print function.
9339
 
 
9340
 
@@ -205,7 +205,7 @@
9341
 
    *NULL*.  A type should never implement :attr:`tp_print` in a way that produces
9342
 
    different output than :attr:`tp_repr` or :attr:`tp_str` would.
9343
 
 
9344
 
-   The print function is called with the same signature as :cfunc:`PyObject_Print`:
9345
 
+   The print function is called with the same signature as :c:func:`PyObject_Print`:
9346
 
    ``int tp_print(PyObject *self, FILE *file, int flags)``.  The *self* argument is
9347
 
    the instance to be printed.  The *file* argument is the stdio file to which it
9348
 
    is to be printed.  The *flags* argument is composed of flag bits. The only flag
9349
 
@@ -223,39 +223,39 @@
9350
 
    This field is inherited by subtypes.
9351
 
 
9352
 
 
9353
 
-.. cmember:: getattrfunc PyTypeObject.tp_getattr
9354
 
+.. c:member:: getattrfunc PyTypeObject.tp_getattr
9355
 
 
9356
 
    An optional pointer to the get-attribute-string function.
9357
 
 
9358
 
    This field is deprecated.  When it is defined, it should point to a function
9359
 
    that acts the same as the :attr:`tp_getattro` function, but taking a C string
9360
 
    instead of a Python string object to give the attribute name.  The signature is
9361
 
-   the same as for :cfunc:`PyObject_GetAttrString`.
9362
 
+   the same as for :c:func:`PyObject_GetAttrString`.
9363
 
 
9364
 
    This field is inherited by subtypes together with :attr:`tp_getattro`: a subtype
9365
 
    inherits both :attr:`tp_getattr` and :attr:`tp_getattro` from its base type when
9366
 
    the subtype's :attr:`tp_getattr` and :attr:`tp_getattro` are both *NULL*.
9367
 
 
9368
 
 
9369
 
-.. cmember:: setattrfunc PyTypeObject.tp_setattr
9370
 
+.. c:member:: setattrfunc PyTypeObject.tp_setattr
9371
 
 
9372
 
    An optional pointer to the set-attribute-string function.
9373
 
 
9374
 
    This field is deprecated.  When it is defined, it should point to a function
9375
 
    that acts the same as the :attr:`tp_setattro` function, but taking a C string
9376
 
    instead of a Python string object to give the attribute name.  The signature is
9377
 
-   the same as for :cfunc:`PyObject_SetAttrString`.
9378
 
+   the same as for :c:func:`PyObject_SetAttrString`.
9379
 
 
9380
 
    This field is inherited by subtypes together with :attr:`tp_setattro`: a subtype
9381
 
    inherits both :attr:`tp_setattr` and :attr:`tp_setattro` from its base type when
9382
 
    the subtype's :attr:`tp_setattr` and :attr:`tp_setattro` are both *NULL*.
9383
 
 
9384
 
 
9385
 
-.. cmember:: cmpfunc PyTypeObject.tp_compare
9386
 
+.. c:member:: cmpfunc PyTypeObject.tp_compare
9387
 
 
9388
 
    An optional pointer to the three-way comparison function.
9389
 
 
9390
 
-   The signature is the same as for :cfunc:`PyObject_Compare`. The function should
9391
 
+   The signature is the same as for :c:func:`PyObject_Compare`. The function should
9392
 
    return ``1`` if *self* greater than *other*, ``0`` if *self* is equal to
9393
 
    *other*, and ``-1`` if *self* less than *other*.  It should return ``-1`` and
9394
 
    set an exception condition when an error occurred during the comparison.
9395
 
@@ -266,14 +266,14 @@
9396
 
    :attr:`tp_compare`, :attr:`tp_richcompare`, and :attr:`tp_hash` are all *NULL*.
9397
 
 
9398
 
 
9399
 
-.. cmember:: reprfunc PyTypeObject.tp_repr
9400
 
+.. c:member:: reprfunc PyTypeObject.tp_repr
9401
 
 
9402
 
    .. index:: builtin: repr
9403
 
 
9404
 
    An optional pointer to a function that implements the built-in function
9405
 
    :func:`repr`.
9406
 
 
9407
 
-   The signature is the same as for :cfunc:`PyObject_Repr`; it must return a string
9408
 
+   The signature is the same as for :c:func:`PyObject_Repr`; it must return a string
9409
 
    or a Unicode object.  Ideally, this function should return a string that, when
9410
 
    passed to :func:`eval`, given a suitable environment, returns an object with the
9411
 
    same value.  If this is not feasible, it should return a string starting with
9412
 
@@ -286,7 +286,7 @@
9413
 
 
9414
 
    This field is inherited by subtypes.
9415
 
 
9416
 
-.. cmember:: PyNumberMethods* tp_as_number
9417
 
+.. c:member:: PyNumberMethods* tp_as_number
9418
 
 
9419
 
    Pointer to an additional structure that contains fields relevant only to
9420
 
    objects which implement the number protocol.  These fields are documented in
9421
 
@@ -296,7 +296,7 @@
9422
 
    inherited individually.
9423
 
 
9424
 
 
9425
 
-.. cmember:: PySequenceMethods* tp_as_sequence
9426
 
+.. c:member:: PySequenceMethods* tp_as_sequence
9427
 
 
9428
 
    Pointer to an additional structure that contains fields relevant only to
9429
 
    objects which implement the sequence protocol.  These fields are documented
9430
 
@@ -306,7 +306,7 @@
9431
 
    are inherited individually.
9432
 
 
9433
 
 
9434
 
-.. cmember:: PyMappingMethods* tp_as_mapping
9435
 
+.. c:member:: PyMappingMethods* tp_as_mapping
9436
 
 
9437
 
    Pointer to an additional structure that contains fields relevant only to
9438
 
    objects which implement the mapping protocol.  These fields are documented in
9439
 
@@ -316,25 +316,25 @@
9440
 
    are inherited individually.
9441
 
 
9442
 
 
9443
 
-.. cmember:: hashfunc PyTypeObject.tp_hash
9444
 
+.. c:member:: hashfunc PyTypeObject.tp_hash
9445
 
 
9446
 
    .. index:: builtin: hash
9447
 
 
9448
 
    An optional pointer to a function that implements the built-in function
9449
 
    :func:`hash`.
9450
 
 
9451
 
-   The signature is the same as for :cfunc:`PyObject_Hash`; it must return a C
9452
 
+   The signature is the same as for :c:func:`PyObject_Hash`; it must return a C
9453
 
    long.  The value ``-1`` should not be returned as a normal return value; when an
9454
 
    error occurs during the computation of the hash value, the function should set
9455
 
    an exception and return ``-1``.
9456
 
 
9457
 
-   This field can be set explicitly to :cfunc:`PyObject_HashNotImplemented` to
9458
 
+   This field can be set explicitly to :c:func:`PyObject_HashNotImplemented` to
9459
 
    block inheritance of the hash method from a parent type. This is interpreted
9460
 
    as the equivalent of ``__hash__ = None`` at the Python level, causing
9461
 
    ``isinstance(o, collections.Hashable)`` to correctly return ``False``. Note
9462
 
    that the converse is also true - setting ``__hash__ = None`` on a class at
9463
 
    the Python level will result in the ``tp_hash`` slot being set to
9464
 
-   :cfunc:`PyObject_HashNotImplemented`.
9465
 
+   :c:func:`PyObject_HashNotImplemented`.
9466
 
 
9467
 
    When this field is not set, two possibilities exist: if the :attr:`tp_compare`
9468
 
    and :attr:`tp_richcompare` fields are both *NULL*, a default hash value based on
9469
 
@@ -346,39 +346,39 @@
9470
 
    :attr:`tp_compare`, :attr:`tp_richcompare` and :attr:`tp_hash` are all *NULL*.
9471
 
 
9472
 
 
9473
 
-.. cmember:: ternaryfunc PyTypeObject.tp_call
9474
 
+.. c:member:: ternaryfunc PyTypeObject.tp_call
9475
 
 
9476
 
    An optional pointer to a function that implements calling the object.  This
9477
 
    should be *NULL* if the object is not callable.  The signature is the same as
9478
 
-   for :cfunc:`PyObject_Call`.
9479
 
+   for :c:func:`PyObject_Call`.
9480
 
 
9481
 
    This field is inherited by subtypes.
9482
 
 
9483
 
 
9484
 
-.. cmember:: reprfunc PyTypeObject.tp_str
9485
 
+.. c:member:: reprfunc PyTypeObject.tp_str
9486
 
 
9487
 
    An optional pointer to a function that implements the built-in operation
9488
 
    :func:`str`.  (Note that :class:`str` is a type now, and :func:`str` calls the
9489
 
-   constructor for that type.  This constructor calls :cfunc:`PyObject_Str` to do
9490
 
-   the actual work, and :cfunc:`PyObject_Str` will call this handler.)
9491
 
+   constructor for that type.  This constructor calls :c:func:`PyObject_Str` to do
9492
 
+   the actual work, and :c:func:`PyObject_Str` will call this handler.)
9493
 
 
9494
 
-   The signature is the same as for :cfunc:`PyObject_Str`; it must return a string
9495
 
+   The signature is the same as for :c:func:`PyObject_Str`; it must return a string
9496
 
    or a Unicode object.  This function should return a "friendly" string
9497
 
    representation of the object, as this is the representation that will be used by
9498
 
    the print statement.
9499
 
 
9500
 
-   When this field is not set, :cfunc:`PyObject_Repr` is called to return a string
9501
 
+   When this field is not set, :c:func:`PyObject_Repr` is called to return a string
9502
 
    representation.
9503
 
 
9504
 
    This field is inherited by subtypes.
9505
 
 
9506
 
 
9507
 
-.. cmember:: getattrofunc PyTypeObject.tp_getattro
9508
 
+.. c:member:: getattrofunc PyTypeObject.tp_getattro
9509
 
 
9510
 
    An optional pointer to the get-attribute function.
9511
 
 
9512
 
-   The signature is the same as for :cfunc:`PyObject_GetAttr`.  It is usually
9513
 
-   convenient to set this field to :cfunc:`PyObject_GenericGetAttr`, which
9514
 
+   The signature is the same as for :c:func:`PyObject_GetAttr`.  It is usually
9515
 
+   convenient to set this field to :c:func:`PyObject_GenericGetAttr`, which
9516
 
    implements the normal way of looking for object attributes.
9517
 
 
9518
 
    This field is inherited by subtypes together with :attr:`tp_getattr`: a subtype
9519
 
@@ -386,12 +386,12 @@
9520
 
    the subtype's :attr:`tp_getattr` and :attr:`tp_getattro` are both *NULL*.
9521
 
 
9522
 
 
9523
 
-.. cmember:: setattrofunc PyTypeObject.tp_setattro
9524
 
+.. c:member:: setattrofunc PyTypeObject.tp_setattro
9525
 
 
9526
 
    An optional pointer to the set-attribute function.
9527
 
 
9528
 
-   The signature is the same as for :cfunc:`PyObject_SetAttr`.  It is usually
9529
 
-   convenient to set this field to :cfunc:`PyObject_GenericSetAttr`, which
9530
 
+   The signature is the same as for :c:func:`PyObject_SetAttr`.  It is usually
9531
 
+   convenient to set this field to :c:func:`PyObject_GenericSetAttr`, which
9532
 
    implements the normal way of setting object attributes.
9533
 
 
9534
 
    This field is inherited by subtypes together with :attr:`tp_setattr`: a subtype
9535
 
@@ -399,7 +399,7 @@
9536
 
    the subtype's :attr:`tp_setattr` and :attr:`tp_setattro` are both *NULL*.
9537
 
 
9538
 
 
9539
 
-.. cmember:: PyBufferProcs* PyTypeObject.tp_as_buffer
9540
 
+.. c:member:: PyBufferProcs* PyTypeObject.tp_as_buffer
9541
 
 
9542
 
    Pointer to an additional structure that contains fields relevant only to objects
9543
 
    which implement the buffer interface.  These fields are documented in
9544
 
@@ -409,7 +409,7 @@
9545
 
    inherited individually.
9546
 
 
9547
 
 
9548
 
-.. cmember:: long PyTypeObject.tp_flags
9549
 
+.. c:member:: long PyTypeObject.tp_flags
9550
 
 
9551
 
    This field is a bit mask of various flags.  Some flags indicate variant
9552
 
    semantics for certain situations; others are used to indicate that certain
9553
 
@@ -433,19 +433,19 @@
9554
 
 
9555
 
    The following bit masks are currently defined; these can be ORed together using
9556
 
    the ``|`` operator to form the value of the :attr:`tp_flags` field.  The macro
9557
 
-   :cfunc:`PyType_HasFeature` takes a type and a flags value, *tp* and *f*, and
9558
 
+   :c:func:`PyType_HasFeature` takes a type and a flags value, *tp* and *f*, and
9559
 
    checks whether ``tp->tp_flags & f`` is non-zero.
9560
 
 
9561
 
 
9562
 
    .. data:: Py_TPFLAGS_HAVE_GETCHARBUFFER
9563
 
 
9564
 
-      If this bit is set, the :ctype:`PyBufferProcs` struct referenced by
9565
 
+      If this bit is set, the :c:type:`PyBufferProcs` struct referenced by
9566
 
       :attr:`tp_as_buffer` has the :attr:`bf_getcharbuffer` field.
9567
 
 
9568
 
 
9569
 
    .. data:: Py_TPFLAGS_HAVE_SEQUENCE_IN
9570
 
 
9571
 
-      If this bit is set, the :ctype:`PySequenceMethods` struct referenced by
9572
 
+      If this bit is set, the :c:type:`PySequenceMethods` struct referenced by
9573
 
       :attr:`tp_as_sequence` has the :attr:`sq_contains` field.
9574
 
 
9575
 
 
9576
 
@@ -457,23 +457,23 @@
9577
 
 
9578
 
    .. data:: Py_TPFLAGS_HAVE_INPLACEOPS
9579
 
 
9580
 
-      If this bit is set, the :ctype:`PySequenceMethods` struct referenced by
9581
 
-      :attr:`tp_as_sequence` and the :ctype:`PyNumberMethods` structure referenced by
9582
 
+      If this bit is set, the :c:type:`PySequenceMethods` struct referenced by
9583
 
+      :attr:`tp_as_sequence` and the :c:type:`PyNumberMethods` structure referenced by
9584
 
       :attr:`tp_as_number` contain the fields for in-place operators. In particular,
9585
 
-      this means that the :ctype:`PyNumberMethods` structure has the fields
9586
 
+      this means that the :c:type:`PyNumberMethods` structure has the fields
9587
 
       :attr:`nb_inplace_add`, :attr:`nb_inplace_subtract`,
9588
 
       :attr:`nb_inplace_multiply`, :attr:`nb_inplace_divide`,
9589
 
       :attr:`nb_inplace_remainder`, :attr:`nb_inplace_power`,
9590
 
       :attr:`nb_inplace_lshift`, :attr:`nb_inplace_rshift`, :attr:`nb_inplace_and`,
9591
 
       :attr:`nb_inplace_xor`, and :attr:`nb_inplace_or`; and the
9592
 
-      :ctype:`PySequenceMethods` struct has the fields :attr:`sq_inplace_concat` and
9593
 
+      :c:type:`PySequenceMethods` struct has the fields :attr:`sq_inplace_concat` and
9594
 
       :attr:`sq_inplace_repeat`.
9595
 
 
9596
 
 
9597
 
    .. data:: Py_TPFLAGS_CHECKTYPES
9598
 
 
9599
 
       If this bit is set, the binary and ternary operations in the
9600
 
-      :ctype:`PyNumberMethods` structure referenced by :attr:`tp_as_number` accept
9601
 
+      :c:type:`PyNumberMethods` structure referenced by :attr:`tp_as_number` accept
9602
 
       arguments of arbitrary object types, and do their own type conversions if
9603
 
       needed.  If this bit is clear, those operations require that all arguments have
9604
 
       the current type as their type, and the caller is supposed to perform a coercion
9605
 
@@ -532,20 +532,20 @@
9606
 
    .. data:: Py_TPFLAGS_READY
9607
 
 
9608
 
       This bit is set when the type object has been fully initialized by
9609
 
-      :cfunc:`PyType_Ready`.
9610
 
+      :c:func:`PyType_Ready`.
9611
 
 
9612
 
 
9613
 
    .. data:: Py_TPFLAGS_READYING
9614
 
 
9615
 
-      This bit is set while :cfunc:`PyType_Ready` is in the process of initializing
9616
 
+      This bit is set while :c:func:`PyType_Ready` is in the process of initializing
9617
 
       the type object.
9618
 
 
9619
 
 
9620
 
    .. data:: Py_TPFLAGS_HAVE_GC
9621
 
 
9622
 
       This bit is set when the object supports garbage collection.  If this bit
9623
 
-      is set, instances must be created using :cfunc:`PyObject_GC_New` and
9624
 
-      destroyed using :cfunc:`PyObject_GC_Del`.  More information in section
9625
 
+      is set, instances must be created using :c:func:`PyObject_GC_New` and
9626
 
+      destroyed using :c:func:`PyObject_GC_Del`.  More information in section
9627
 
       :ref:`supporting-cycle-detection`.  This bit also implies that the
9628
 
       GC-related fields :attr:`tp_traverse` and :attr:`tp_clear` are present in
9629
 
       the type object; but those fields also exist when
9630
 
@@ -563,7 +563,7 @@
9631
 
       :const:`Py_TPFLAGS_HAVE_ITER`, and :const:`Py_TPFLAGS_HAVE_CLASS`.
9632
 
 
9633
 
 
9634
 
-.. cmember:: char* PyTypeObject.tp_doc
9635
 
+.. c:member:: char* PyTypeObject.tp_doc
9636
 
 
9637
 
    An optional pointer to a NUL-terminated C string giving the docstring for this
9638
 
    type object.  This is exposed as the :attr:`__doc__` attribute on the type and
9639
 
@@ -575,7 +575,7 @@
9640
 
 :const:`Py_TPFLAGS_HAVE_RICHCOMPARE` flag bit is set.
9641
 
 
9642
 
 
9643
 
-.. cmember:: traverseproc PyTypeObject.tp_traverse
9644
 
+.. c:member:: traverseproc PyTypeObject.tp_traverse
9645
 
 
9646
 
    An optional pointer to a traversal function for the garbage collector.  This is
9647
 
    only used if the :const:`Py_TPFLAGS_HAVE_GC` flag bit is set.  More information
9648
 
@@ -584,8 +584,8 @@
9649
 
 
9650
 
    The :attr:`tp_traverse` pointer is used by the garbage collector to detect
9651
 
    reference cycles. A typical implementation of a :attr:`tp_traverse` function
9652
 
-   simply calls :cfunc:`Py_VISIT` on each of the instance's members that are Python
9653
 
-   objects.  For example, this is function :cfunc:`local_traverse` from the
9654
 
+   simply calls :c:func:`Py_VISIT` on each of the instance's members that are Python
9655
 
+   objects.  For example, this is function :c:func:`local_traverse` from the
9656
 
    :mod:`thread` extension module::
9657
 
 
9658
 
       static int
9659
 
@@ -597,7 +597,7 @@
9660
 
           return 0;
9661
 
       }
9662
 
 
9663
 
-   Note that :cfunc:`Py_VISIT` is called only on those members that can participate
9664
 
+   Note that :c:func:`Py_VISIT` is called only on those members that can participate
9665
 
    in reference cycles.  Although there is also a ``self->key`` member, it can only
9666
 
    be *NULL* or a Python string and therefore cannot be part of a reference cycle.
9667
 
 
9668
 
@@ -605,8 +605,8 @@
9669
 
    debugging aid you may want to visit it anyway just so the :mod:`gc` module's
9670
 
    :func:`get_referents` function will include it.
9671
 
 
9672
 
-   Note that :cfunc:`Py_VISIT` requires the *visit* and *arg* parameters to
9673
 
-   :cfunc:`local_traverse` to have these specific names; don't name them just
9674
 
+   Note that :c:func:`Py_VISIT` requires the *visit* and *arg* parameters to
9675
 
+   :c:func:`local_traverse` to have these specific names; don't name them just
9676
 
    anything.
9677
 
 
9678
 
    This field is inherited by subtypes together with :attr:`tp_clear` and the
9679
 
@@ -616,7 +616,7 @@
9680
 
    bit set.
9681
 
 
9682
 
 
9683
 
-.. cmember:: inquiry PyTypeObject.tp_clear
9684
 
+.. c:member:: inquiry PyTypeObject.tp_clear
9685
 
 
9686
 
    An optional pointer to a clear function for the garbage collector. This is only
9687
 
    used if the :const:`Py_TPFLAGS_HAVE_GC` flag bit is set.
9688
 
@@ -645,7 +645,7 @@
9689
 
           return 0;
9690
 
       }
9691
 
 
9692
 
-   The :cfunc:`Py_CLEAR` macro should be used, because clearing references is
9693
 
+   The :c:func:`Py_CLEAR` macro should be used, because clearing references is
9694
 
    delicate:  the reference to the contained object must not be decremented until
9695
 
    after the pointer to the contained object is set to *NULL*.  This is because
9696
 
    decrementing the reference count may cause the contained object to become trash,
9697
 
@@ -654,7 +654,7 @@
9698
 
    contained object). If it's possible for such code to reference *self* again,
9699
 
    it's important that the pointer to the contained object be *NULL* at that time,
9700
 
    so that *self* knows the contained object can no longer be used.  The
9701
 
-   :cfunc:`Py_CLEAR` macro performs the operations in a safe order.
9702
 
+   :c:func:`Py_CLEAR` macro performs the operations in a safe order.
9703
 
 
9704
 
    Because the goal of :attr:`tp_clear` functions is to break reference cycles,
9705
 
    it's not necessary to clear contained objects like Python strings or Python
9706
 
@@ -672,7 +672,7 @@
9707
 
    bit set.
9708
 
 
9709
 
 
9710
 
-.. cmember:: richcmpfunc PyTypeObject.tp_richcompare
9711
 
+.. c:member:: richcmpfunc PyTypeObject.tp_richcompare
9712
 
 
9713
 
    An optional pointer to the rich comparison function, whose signature is
9714
 
    ``PyObject *tp_richcompare(PyObject *a, PyObject *b, int op)``.
9715
 
@@ -694,7 +694,7 @@
9716
 
    :attr:`tp_compare`, :attr:`tp_richcompare`, and :attr:`tp_hash` are all *NULL*.
9717
 
 
9718
 
    The following constants are defined to be used as the third argument for
9719
 
-   :attr:`tp_richcompare` and for :cfunc:`PyObject_RichCompare`:
9720
 
+   :attr:`tp_richcompare` and for :c:func:`PyObject_RichCompare`:
9721
 
 
9722
 
    +----------------+------------+
9723
 
    | Constant       | Comparison |
9724
 
@@ -716,13 +716,13 @@
9725
 
 The next field only exists if the :const:`Py_TPFLAGS_HAVE_WEAKREFS` flag bit is
9726
 
 set.
9727
 
 
9728
 
-.. cmember:: long PyTypeObject.tp_weaklistoffset
9729
 
+.. c:member:: long PyTypeObject.tp_weaklistoffset
9730
 
 
9731
 
    If the instances of this type are weakly referenceable, this field is greater
9732
 
    than zero and contains the offset in the instance structure of the weak
9733
 
    reference list head (ignoring the GC header, if present); this offset is used by
9734
 
-   :cfunc:`PyObject_ClearWeakRefs` and the :cfunc:`PyWeakref_\*` functions.  The
9735
 
-   instance structure needs to include a field of type :ctype:`PyObject\*` which is
9736
 
+   :c:func:`PyObject_ClearWeakRefs` and the :c:func:`PyWeakref_\*` functions.  The
9737
 
+   instance structure needs to include a field of type :c:type:`PyObject\*` which is
9738
 
    initialized to *NULL*.
9739
 
 
9740
 
    Do not confuse this field with :attr:`tp_weaklist`; that is the list head for
9741
 
@@ -751,19 +751,19 @@
9742
 
 set.
9743
 
 
9744
 
 
9745
 
-.. cmember:: getiterfunc PyTypeObject.tp_iter
9746
 
+.. c:member:: getiterfunc PyTypeObject.tp_iter
9747
 
 
9748
 
    An optional pointer to a function that returns an iterator for the object.  Its
9749
 
    presence normally signals that the instances of this type are iterable (although
9750
 
    sequences may be iterable without this function, and classic instances always
9751
 
    have this function, even if they don't define an :meth:`__iter__` method).
9752
 
 
9753
 
-   This function has the same signature as :cfunc:`PyObject_GetIter`.
9754
 
+   This function has the same signature as :c:func:`PyObject_GetIter`.
9755
 
 
9756
 
    This field is inherited by subtypes.
9757
 
 
9758
 
 
9759
 
-.. cmember:: iternextfunc PyTypeObject.tp_iternext
9760
 
+.. c:member:: iternextfunc PyTypeObject.tp_iternext
9761
 
 
9762
 
    An optional pointer to a function that returns the next item in an iterator.
9763
 
    When the iterator is exhausted, it must return *NULL*; a :exc:`StopIteration`
9764
 
@@ -776,7 +776,7 @@
9765
 
    function should return the iterator instance itself (not a new iterator
9766
 
    instance).
9767
 
 
9768
 
-   This function has the same signature as :cfunc:`PyIter_Next`.
9769
 
+   This function has the same signature as :c:func:`PyIter_Next`.
9770
 
 
9771
 
    This field is inherited by subtypes.
9772
 
 
9773
 
@@ -784,9 +784,9 @@
9774
 
 :const:`Py_TPFLAGS_HAVE_CLASS` flag bit is set.
9775
 
 
9776
 
 
9777
 
-.. cmember:: struct PyMethodDef* PyTypeObject.tp_methods
9778
 
+.. c:member:: struct PyMethodDef* PyTypeObject.tp_methods
9779
 
 
9780
 
-   An optional pointer to a static *NULL*-terminated array of :ctype:`PyMethodDef`
9781
 
+   An optional pointer to a static *NULL*-terminated array of :c:type:`PyMethodDef`
9782
 
    structures, declaring regular methods of this type.
9783
 
 
9784
 
    For each entry in the array, an entry is added to the type's dictionary (see
9785
 
@@ -796,9 +796,9 @@
9786
 
    different mechanism).
9787
 
 
9788
 
 
9789
 
-.. cmember:: struct PyMemberDef* PyTypeObject.tp_members
9790
 
+.. c:member:: struct PyMemberDef* PyTypeObject.tp_members
9791
 
 
9792
 
-   An optional pointer to a static *NULL*-terminated array of :ctype:`PyMemberDef`
9793
 
+   An optional pointer to a static *NULL*-terminated array of :c:type:`PyMemberDef`
9794
 
    structures, declaring regular data members (fields or slots) of instances of
9795
 
    this type.
9796
 
 
9797
 
@@ -809,9 +809,9 @@
9798
 
    different mechanism).
9799
 
 
9800
 
 
9801
 
-.. cmember:: struct PyGetSetDef* PyTypeObject.tp_getset
9802
 
+.. c:member:: struct PyGetSetDef* PyTypeObject.tp_getset
9803
 
 
9804
 
-   An optional pointer to a static *NULL*-terminated array of :ctype:`PyGetSetDef`
9805
 
+   An optional pointer to a static *NULL*-terminated array of :c:type:`PyGetSetDef`
9806
 
    structures, declaring computed attributes of instances of this type.
9807
 
 
9808
 
    For each entry in the array, an entry is added to the type's dictionary (see
9809
 
@@ -836,7 +836,7 @@
9810
 
       } PyGetSetDef;
9811
 
 
9812
 
 
9813
 
-.. cmember:: PyTypeObject* PyTypeObject.tp_base
9814
 
+.. c:member:: PyTypeObject* PyTypeObject.tp_base
9815
 
 
9816
 
    An optional pointer to a base type from which type properties are inherited.  At
9817
 
    this level, only single inheritance is supported; multiple inheritance require
9818
 
@@ -847,13 +847,13 @@
9819
 
    :class:`object`).
9820
 
 
9821
 
 
9822
 
-.. cmember:: PyObject* PyTypeObject.tp_dict
9823
 
+.. c:member:: PyObject* PyTypeObject.tp_dict
9824
 
 
9825
 
-   The type's dictionary is stored here by :cfunc:`PyType_Ready`.
9826
 
+   The type's dictionary is stored here by :c:func:`PyType_Ready`.
9827
 
 
9828
 
    This field should normally be initialized to *NULL* before PyType_Ready is
9829
 
    called; it may also be initialized to a dictionary containing initial attributes
9830
 
-   for the type.  Once :cfunc:`PyType_Ready` has initialized the type, extra
9831
 
+   for the type.  Once :c:func:`PyType_Ready` has initialized the type, extra
9832
 
    attributes for the type may be added to this dictionary only if they don't
9833
 
    correspond to overloaded operations (like :meth:`__add__`).
9834
 
 
9835
 
@@ -861,7 +861,7 @@
9836
 
    are inherited through a different mechanism).
9837
 
 
9838
 
 
9839
 
-.. cmember:: descrgetfunc PyTypeObject.tp_descr_get
9840
 
+.. c:member:: descrgetfunc PyTypeObject.tp_descr_get
9841
 
 
9842
 
    An optional pointer to a "descriptor get" function.
9843
 
 
9844
 
@@ -874,7 +874,7 @@
9845
 
    This field is inherited by subtypes.
9846
 
 
9847
 
 
9848
 
-.. cmember:: descrsetfunc PyTypeObject.tp_descr_set
9849
 
+.. c:member:: descrsetfunc PyTypeObject.tp_descr_set
9850
 
 
9851
 
    An optional pointer to a "descriptor set" function.
9852
 
 
9853
 
@@ -887,12 +887,12 @@
9854
 
    .. XXX explain.
9855
 
 
9856
 
 
9857
 
-.. cmember:: long PyTypeObject.tp_dictoffset
9858
 
+.. c:member:: long PyTypeObject.tp_dictoffset
9859
 
 
9860
 
    If the instances of this type have a dictionary containing instance variables,
9861
 
    this field is non-zero and contains the offset in the instances of the type of
9862
 
    the instance variable dictionary; this offset is used by
9863
 
-   :cfunc:`PyObject_GenericGetAttr`.
9864
 
+   :c:func:`PyObject_GenericGetAttr`.
9865
 
 
9866
 
    Do not confuse this field with :attr:`tp_dict`; that is the dictionary for
9867
 
    attributes of the type object itself.
9868
 
@@ -920,7 +920,7 @@
9869
 
    taken from the type object, and :attr:`ob_size` is taken from the instance.  The
9870
 
    absolute value is taken because long ints use the sign of :attr:`ob_size` to
9871
 
    store the sign of the number.  (There's never a need to do this calculation
9872
 
-   yourself; it is done for you by :cfunc:`_PyObject_GetDictPtr`.)
9873
 
+   yourself; it is done for you by :c:func:`_PyObject_GetDictPtr`.)
9874
 
 
9875
 
    This field is inherited by subtypes, but see the rules listed below. A subtype
9876
 
    may override this offset; this means that the subtype instances store the
9877
 
@@ -940,7 +940,7 @@
9878
 
    added as a feature just like :attr:`__weakref__` though.)
9879
 
 
9880
 
 
9881
 
-.. cmember:: initproc PyTypeObject.tp_init
9882
 
+.. c:member:: initproc PyTypeObject.tp_init
9883
 
 
9884
 
    An optional pointer to an instance initialization function.
9885
 
 
9886
 
@@ -970,7 +970,7 @@
9887
 
    This field is inherited by subtypes.
9888
 
 
9889
 
 
9890
 
-.. cmember:: allocfunc PyTypeObject.tp_alloc
9891
 
+.. c:member:: allocfunc PyTypeObject.tp_alloc
9892
 
 
9893
 
    An optional pointer to an instance allocation function.
9894
 
 
9895
 
@@ -993,11 +993,11 @@
9896
 
 
9897
 
    This field is inherited by static subtypes, but not by dynamic subtypes
9898
 
    (subtypes created by a class statement); in the latter, this field is always set
9899
 
-   to :cfunc:`PyType_GenericAlloc`, to force a standard heap allocation strategy.
9900
 
+   to :c:func:`PyType_GenericAlloc`, to force a standard heap allocation strategy.
9901
 
    That is also the recommended value for statically defined types.
9902
 
 
9903
 
 
9904
 
-.. cmember:: newfunc PyTypeObject.tp_new
9905
 
+.. c:member:: newfunc PyTypeObject.tp_new
9906
 
 
9907
 
    An optional pointer to an instance creation function.
9908
 
 
9909
 
@@ -1029,16 +1029,16 @@
9910
 
    being linked with Python 2.2.
9911
 
 
9912
 
 
9913
 
-.. cmember:: destructor PyTypeObject.tp_free
9914
 
+.. c:member:: destructor PyTypeObject.tp_free
9915
 
 
9916
 
    An optional pointer to an instance deallocation function.
9917
 
 
9918
 
    The signature of this function has changed slightly: in Python 2.2 and 2.2.1,
9919
 
-   its signature is :ctype:`destructor`::
9920
 
+   its signature is :c:type:`destructor`::
9921
 
 
9922
 
       void tp_free(PyObject *)
9923
 
 
9924
 
-   In Python 2.3 and beyond, its signature is :ctype:`freefunc`::
9925
 
+   In Python 2.3 and beyond, its signature is :c:type:`freefunc`::
9926
 
 
9927
 
       void tp_free(void *)
9928
 
 
9929
 
@@ -1047,11 +1047,11 @@
9930
 
 
9931
 
    This field is inherited by static subtypes, but not by dynamic subtypes
9932
 
    (subtypes created by a class statement); in the latter, this field is set to a
9933
 
-   deallocator suitable to match :cfunc:`PyType_GenericAlloc` and the value of the
9934
 
+   deallocator suitable to match :c:func:`PyType_GenericAlloc` and the value of the
9935
 
    :const:`Py_TPFLAGS_HAVE_GC` flag bit.
9936
 
 
9937
 
 
9938
 
-.. cmember:: inquiry PyTypeObject.tp_is_gc
9939
 
+.. c:member:: inquiry PyTypeObject.tp_is_gc
9940
 
 
9941
 
    An optional pointer to a function called by the garbage collector.
9942
 
 
9943
 
@@ -1066,14 +1066,14 @@
9944
 
       int tp_is_gc(PyObject *self)
9945
 
 
9946
 
    (The only example of this are types themselves.  The metatype,
9947
 
-   :cdata:`PyType_Type`, defines this function to distinguish between statically
9948
 
+   :c:data:`PyType_Type`, defines this function to distinguish between statically
9949
 
    and dynamically allocated types.)
9950
 
 
9951
 
    This field is inherited by subtypes.  (VERSION NOTE: in Python 2.2, it was not
9952
 
    inherited.  It is inherited in 2.2.1 and later versions.)
9953
 
 
9954
 
 
9955
 
-.. cmember:: PyObject* PyTypeObject.tp_bases
9956
 
+.. c:member:: PyObject* PyTypeObject.tp_bases
9957
 
 
9958
 
    Tuple of base types.
9959
 
 
9960
 
@@ -1083,25 +1083,25 @@
9961
 
    This field is not inherited.
9962
 
 
9963
 
 
9964
 
-.. cmember:: PyObject* PyTypeObject.tp_mro
9965
 
+.. c:member:: PyObject* PyTypeObject.tp_mro
9966
 
 
9967
 
    Tuple containing the expanded set of base types, starting with the type itself
9968
 
    and ending with :class:`object`, in Method Resolution Order.
9969
 
 
9970
 
-   This field is not inherited; it is calculated fresh by :cfunc:`PyType_Ready`.
9971
 
+   This field is not inherited; it is calculated fresh by :c:func:`PyType_Ready`.
9972
 
 
9973
 
 
9974
 
-.. cmember:: PyObject* PyTypeObject.tp_cache
9975
 
+.. c:member:: PyObject* PyTypeObject.tp_cache
9976
 
 
9977
 
    Unused.  Not inherited.  Internal use only.
9978
 
 
9979
 
 
9980
 
-.. cmember:: PyObject* PyTypeObject.tp_subclasses
9981
 
+.. c:member:: PyObject* PyTypeObject.tp_subclasses
9982
 
 
9983
 
    List of weak references to subclasses.  Not inherited.  Internal use only.
9984
 
 
9985
 
 
9986
 
-.. cmember:: PyObject* PyTypeObject.tp_weaklist
9987
 
+.. c:member:: PyObject* PyTypeObject.tp_weaklist
9988
 
 
9989
 
    Weak reference list head, for weak references to this type object.  Not
9990
 
    inherited.  Internal use only.
9991
 
@@ -1112,22 +1112,22 @@
9992
 
 subtypes.
9993
 
 
9994
 
 
9995
 
-.. cmember:: Py_ssize_t PyTypeObject.tp_allocs
9996
 
+.. c:member:: Py_ssize_t PyTypeObject.tp_allocs
9997
 
 
9998
 
    Number of allocations.
9999
 
 
10000
 
 
10001
 
-.. cmember:: Py_ssize_t PyTypeObject.tp_frees
10002
 
+.. c:member:: Py_ssize_t PyTypeObject.tp_frees
10003
 
 
10004
 
    Number of frees.
10005
 
 
10006
 
 
10007
 
-.. cmember:: Py_ssize_t PyTypeObject.tp_maxalloc
10008
 
+.. c:member:: Py_ssize_t PyTypeObject.tp_maxalloc
10009
 
 
10010
 
    Maximum simultaneously allocated objects.
10011
 
 
10012
 
 
10013
 
-.. cmember:: PyTypeObject* PyTypeObject.tp_next
10014
 
+.. c:member:: PyTypeObject* PyTypeObject.tp_next
10015
 
 
10016
 
    Pointer to the next type object with a non-zero :attr:`tp_allocs` field.
10017
 
 
10018
 
@@ -1150,7 +1150,7 @@
10019
 
 .. sectionauthor:: Amaury Forgeot d'Arc
10020
 
 
10021
 
 
10022
 
-.. ctype:: PyNumberMethods
10023
 
+.. c:type:: PyNumberMethods
10024
 
 
10025
 
    This structure holds pointers to the functions which an object uses to
10026
 
    implement the number protocol.  Almost every function below is used by the
10027
 
@@ -1215,9 +1215,9 @@
10028
 
   the coercion method specified by the :attr:`nb_coerce` member to convert the
10029
 
   arguments:
10030
 
 
10031
 
-  .. cmember:: coercion PyNumberMethods.nb_coerce
10032
 
+  .. c:member:: coercion PyNumberMethods.nb_coerce
10033
 
 
10034
 
-     This function is used by :cfunc:`PyNumber_CoerceEx` and has the same
10035
 
+     This function is used by :c:func:`PyNumber_CoerceEx` and has the same
10036
 
      signature.  The first argument is always a pointer to an object of the
10037
 
      defined type.  If the conversion to a common "larger" type is possible, the
10038
 
      function replaces the pointers with new references to the converted objects
10039
 
@@ -1243,26 +1243,26 @@
10040
 
 .. sectionauthor:: Amaury Forgeot d'Arc
10041
 
 
10042
 
 
10043
 
-.. ctype:: PyMappingMethods
10044
 
+.. c:type:: PyMappingMethods
10045
 
 
10046
 
    This structure holds pointers to the functions which an object uses to
10047
 
    implement the mapping protocol.  It has three members:
10048
 
 
10049
 
-.. cmember:: lenfunc PyMappingMethods.mp_length
10050
 
+.. c:member:: lenfunc PyMappingMethods.mp_length
10051
 
 
10052
 
-   This function is used by :cfunc:`PyMapping_Length` and
10053
 
-   :cfunc:`PyObject_Size`, and has the same signature.  This slot may be set to
10054
 
+   This function is used by :c:func:`PyMapping_Length` and
10055
 
+   :c:func:`PyObject_Size`, and has the same signature.  This slot may be set to
10056
 
    *NULL* if the object has no defined length.
10057
 
 
10058
 
-.. cmember:: binaryfunc PyMappingMethods.mp_subscript
10059
 
+.. c:member:: binaryfunc PyMappingMethods.mp_subscript
10060
 
 
10061
 
-   This function is used by :cfunc:`PyObject_GetItem` and has the same
10062
 
-   signature.  This slot must be filled for the :cfunc:`PyMapping_Check`
10063
 
+   This function is used by :c:func:`PyObject_GetItem` and has the same
10064
 
+   signature.  This slot must be filled for the :c:func:`PyMapping_Check`
10065
 
    function to return ``1``, it can be *NULL* otherwise.
10066
 
 
10067
 
-.. cmember:: objobjargproc PyMappingMethods.mp_ass_subscript
10068
 
+.. c:member:: objobjargproc PyMappingMethods.mp_ass_subscript
10069
 
 
10070
 
-   This function is used by :cfunc:`PyObject_SetItem` and has the same
10071
 
+   This function is used by :c:func:`PyObject_SetItem` and has the same
10072
 
    signature.  If this slot is *NULL*, the object does not support item
10073
 
    assignment.
10074
 
 
10075
 
@@ -1275,32 +1275,32 @@
10076
 
 .. sectionauthor:: Amaury Forgeot d'Arc
10077
 
 
10078
 
 
10079
 
-.. ctype:: PySequenceMethods
10080
 
+.. c:type:: PySequenceMethods
10081
 
 
10082
 
    This structure holds pointers to the functions which an object uses to
10083
 
    implement the sequence protocol.
10084
 
 
10085
 
-.. cmember:: lenfunc PySequenceMethods.sq_length
10086
 
+.. c:member:: lenfunc PySequenceMethods.sq_length
10087
 
 
10088
 
-   This function is used by :cfunc:`PySequence_Size` and :cfunc:`PyObject_Size`,
10089
 
+   This function is used by :c:func:`PySequence_Size` and :c:func:`PyObject_Size`,
10090
 
    and has the same signature.
10091
 
 
10092
 
-.. cmember:: binaryfunc PySequenceMethods.sq_concat
10093
 
+.. c:member:: binaryfunc PySequenceMethods.sq_concat
10094
 
 
10095
 
-   This function is used by :cfunc:`PySequence_Concat` and has the same
10096
 
+   This function is used by :c:func:`PySequence_Concat` and has the same
10097
 
    signature.  It is also used by the ``+`` operator, after trying the numeric
10098
 
    addition via the :attr:`tp_as_number.nb_add` slot.
10099
 
 
10100
 
-.. cmember:: ssizeargfunc PySequenceMethods.sq_repeat
10101
 
+.. c:member:: ssizeargfunc PySequenceMethods.sq_repeat
10102
 
 
10103
 
-   This function is used by :cfunc:`PySequence_Repeat` and has the same
10104
 
+   This function is used by :c:func:`PySequence_Repeat` and has the same
10105
 
    signature.  It is also used by the ``*`` operator, after trying numeric
10106
 
    multiplication via the :attr:`tp_as_number.nb_mul` slot.
10107
 
 
10108
 
-.. cmember:: ssizeargfunc PySequenceMethods.sq_item
10109
 
+.. c:member:: ssizeargfunc PySequenceMethods.sq_item
10110
 
 
10111
 
-   This function is used by :cfunc:`PySequence_GetItem` and has the same
10112
 
-   signature.  This slot must be filled for the :cfunc:`PySequence_Check`
10113
 
+   This function is used by :c:func:`PySequence_GetItem` and has the same
10114
 
+   signature.  This slot must be filled for the :c:func:`PySequence_Check`
10115
 
    function to return ``1``, it can be *NULL* otherwise.
10116
 
 
10117
 
    Negative indexes are handled as follows: if the :attr:`sq_length` slot is
10118
 
@@ -1308,27 +1308,27 @@
10119
 
    index which is passed to :attr:`sq_item`.  If :attr:`sq_length` is *NULL*,
10120
 
    the index is passed as is to the function.
10121
 
 
10122
 
-.. cmember:: ssizeobjargproc PySequenceMethods.sq_ass_item
10123
 
+.. c:member:: ssizeobjargproc PySequenceMethods.sq_ass_item
10124
 
 
10125
 
-   This function is used by :cfunc:`PySequence_SetItem` and has the same
10126
 
+   This function is used by :c:func:`PySequence_SetItem` and has the same
10127
 
    signature.  This slot may be left to *NULL* if the object does not support
10128
 
    item assignment.
10129
 
 
10130
 
-.. cmember:: objobjproc PySequenceMethods.sq_contains
10131
 
+.. c:member:: objobjproc PySequenceMethods.sq_contains
10132
 
 
10133
 
-   This function may be used by :cfunc:`PySequence_Contains` and has the same
10134
 
+   This function may be used by :c:func:`PySequence_Contains` and has the same
10135
 
    signature.  This slot may be left to *NULL*, in this case
10136
 
-   :cfunc:`PySequence_Contains` simply traverses the sequence until it finds a
10137
 
+   :c:func:`PySequence_Contains` simply traverses the sequence until it finds a
10138
 
    match.
10139
 
 
10140
 
-.. cmember:: binaryfunc PySequenceMethods.sq_inplace_concat
10141
 
+.. c:member:: binaryfunc PySequenceMethods.sq_inplace_concat
10142
 
 
10143
 
-   This function is used by :cfunc:`PySequence_InPlaceConcat` and has the same
10144
 
+   This function is used by :c:func:`PySequence_InPlaceConcat` and has the same
10145
 
    signature.  It should modify its first operand, and return it.
10146
 
 
10147
 
-.. cmember:: ssizeargfunc PySequenceMethods.sq_inplace_repeat
10148
 
+.. c:member:: ssizeargfunc PySequenceMethods.sq_inplace_repeat
10149
 
 
10150
 
-   This function is used by :cfunc:`PySequence_InPlaceRepeat` and has the same
10151
 
+   This function is used by :c:func:`PySequence_InPlaceRepeat` and has the same
10152
 
    signature.  It should modify its first operand, and return it.
10153
 
 
10154
 
 .. XXX need to explain precedence between mapping and sequence
10155
 
@@ -1349,45 +1349,45 @@
10156
 
 to be non-contiguous in memory.
10157
 
 
10158
 
 If an object does not export the buffer interface, then its :attr:`tp_as_buffer`
10159
 
-member in the :ctype:`PyTypeObject` structure should be *NULL*.  Otherwise, the
10160
 
-:attr:`tp_as_buffer` will point to a :ctype:`PyBufferProcs` structure.
10161
 
+member in the :c:type:`PyTypeObject` structure should be *NULL*.  Otherwise, the
10162
 
+:attr:`tp_as_buffer` will point to a :c:type:`PyBufferProcs` structure.
10163
 
 
10164
 
 .. note::
10165
 
 
10166
 
-   It is very important that your :ctype:`PyTypeObject` structure uses
10167
 
+   It is very important that your :c:type:`PyTypeObject` structure uses
10168
 
    :const:`Py_TPFLAGS_DEFAULT` for the value of the :attr:`tp_flags` member rather
10169
 
-   than ``0``.  This tells the Python runtime that your :ctype:`PyBufferProcs`
10170
 
+   than ``0``.  This tells the Python runtime that your :c:type:`PyBufferProcs`
10171
 
    structure contains the :attr:`bf_getcharbuffer` slot. Older versions of Python
10172
 
    did not have this member, so a new Python interpreter using an old extension
10173
 
    needs to be able to test for its presence before using it.
10174
 
 
10175
 
 
10176
 
-.. ctype:: PyBufferProcs
10177
 
+.. c:type:: PyBufferProcs
10178
 
 
10179
 
    Structure used to hold the function pointers which define an implementation of
10180
 
    the buffer protocol.
10181
 
 
10182
 
-   The first slot is :attr:`bf_getreadbuffer`, of type :ctype:`getreadbufferproc`.
10183
 
+   The first slot is :attr:`bf_getreadbuffer`, of type :c:type:`getreadbufferproc`.
10184
 
    If this slot is *NULL*, then the object does not support reading from the
10185
 
    internal data.  This is non-sensical, so implementors should fill this in, but
10186
 
    callers should test that the slot contains a non-*NULL* value.
10187
 
 
10188
 
    The next slot is :attr:`bf_getwritebuffer` having type
10189
 
-   :ctype:`getwritebufferproc`.  This slot may be *NULL* if the object does not
10190
 
+   :c:type:`getwritebufferproc`.  This slot may be *NULL* if the object does not
10191
 
    allow writing into its returned buffers.
10192
 
 
10193
 
-   The third slot is :attr:`bf_getsegcount`, with type :ctype:`getsegcountproc`.
10194
 
+   The third slot is :attr:`bf_getsegcount`, with type :c:type:`getsegcountproc`.
10195
 
    This slot must not be *NULL* and is used to inform the caller how many segments
10196
 
-   the object contains.  Simple objects such as :ctype:`PyString_Type` and
10197
 
-   :ctype:`PyBuffer_Type` objects contain a single segment.
10198
 
+   the object contains.  Simple objects such as :c:type:`PyString_Type` and
10199
 
+   :c:type:`PyBuffer_Type` objects contain a single segment.
10200
 
 
10201
 
    .. index:: single: PyType_HasFeature()
10202
 
 
10203
 
-   The last slot is :attr:`bf_getcharbuffer`, of type :ctype:`getcharbufferproc`.
10204
 
+   The last slot is :attr:`bf_getcharbuffer`, of type :c:type:`getcharbufferproc`.
10205
 
    This slot will only be present if the :const:`Py_TPFLAGS_HAVE_GETCHARBUFFER`
10206
 
    flag is present in the :attr:`tp_flags` field of the object's
10207
 
-   :ctype:`PyTypeObject`. Before using this slot, the caller should test whether it
10208
 
-   is present by using the :cfunc:`PyType_HasFeature` function.  If the flag is
10209
 
+   :c:type:`PyTypeObject`. Before using this slot, the caller should test whether it
10210
 
+   is present by using the :c:func:`PyType_HasFeature` function.  If the flag is
10211
 
    present, :attr:`bf_getcharbuffer` may be *NULL*, indicating that the object's
10212
 
    contents cannot be used as *8-bit characters*. The slot function may also raise
10213
 
    an error if the object's contents cannot be interpreted as 8-bit characters.
10214
 
@@ -1411,7 +1411,7 @@
10215
 
    buffer interface or that the :attr:`bf_getcharbuffer` slot is non-*NULL*.
10216
 
 
10217
 
 
10218
 
-.. ctype:: Py_ssize_t (*readbufferproc) (PyObject *self, Py_ssize_t segment, void **ptrptr)
10219
 
+.. c:type:: Py_ssize_t (*readbufferproc) (PyObject *self, Py_ssize_t segment, void **ptrptr)
10220
 
 
10221
 
    Return a pointer to a readable segment of the buffer in ``*ptrptr``.  This
10222
 
    function is allowed to raise an exception, in which case it must return ``-1``.
10223
 
@@ -1421,7 +1421,7 @@
10224
 
    ``*ptrptr`` to a pointer to that memory.
10225
 
 
10226
 
 
10227
 
-.. ctype:: Py_ssize_t (*writebufferproc) (PyObject *self, Py_ssize_t segment, void **ptrptr)
10228
 
+.. c:type:: Py_ssize_t (*writebufferproc) (PyObject *self, Py_ssize_t segment, void **ptrptr)
10229
 
 
10230
 
    Return a pointer to a writable memory buffer in ``*ptrptr``, and the length of
10231
 
    that segment as the function return value.  The memory buffer must correspond to
10232
 
@@ -1435,14 +1435,14 @@
10233
 
       segment. That indicates a blatant programming error in the C code.
10234
 
 
10235
 
 
10236
 
-.. ctype:: Py_ssize_t (*segcountproc) (PyObject *self, Py_ssize_t *lenp)
10237
 
+.. c:type:: Py_ssize_t (*segcountproc) (PyObject *self, Py_ssize_t *lenp)
10238
 
 
10239
 
    Return the number of memory segments which comprise the buffer.  If *lenp* is
10240
 
    not *NULL*, the implementation must report the sum of the sizes (in bytes) of
10241
 
    all segments in ``*lenp``. The function cannot fail.
10242
 
 
10243
 
 
10244
 
-.. ctype:: Py_ssize_t (*charbufferproc) (PyObject *self, Py_ssize_t segment, const char **ptrptr)
10245
 
+.. c:type:: Py_ssize_t (*charbufferproc) (PyObject *self, Py_ssize_t segment, const char **ptrptr)
10246
 
 
10247
 
    Return the size of the segment *segment* that *ptrptr*  is set to.  ``*ptrptr``
10248
 
    is set to the memory buffer. Returns ``-1`` on error.
10249
 
diff -r 8527427914a2 Doc/c-api/unicode.rst
10250
 
--- a/Doc/c-api/unicode.rst
10251
 
+++ b/Doc/c-api/unicode.rst
10252
 
@@ -18,39 +18,39 @@
10253
 
 Python:
10254
 
 
10255
 
 
10256
 
-.. ctype:: Py_UNICODE
10257
 
+.. c:type:: Py_UNICODE
10258
 
 
10259
 
    This type represents the storage type which is used by Python internally as
10260
 
    basis for holding Unicode ordinals.  Python's default builds use a 16-bit type
10261
 
-   for :ctype:`Py_UNICODE` and store Unicode values internally as UCS2. It is also
10262
 
+   for :c:type:`Py_UNICODE` and store Unicode values internally as UCS2. It is also
10263
 
    possible to build a UCS4 version of Python (most recent Linux distributions come
10264
 
    with UCS4 builds of Python). These builds then use a 32-bit type for
10265
 
-   :ctype:`Py_UNICODE` and store Unicode data internally as UCS4. On platforms
10266
 
-   where :ctype:`wchar_t` is available and compatible with the chosen Python
10267
 
-   Unicode build variant, :ctype:`Py_UNICODE` is a typedef alias for
10268
 
-   :ctype:`wchar_t` to enhance native platform compatibility. On all other
10269
 
-   platforms, :ctype:`Py_UNICODE` is a typedef alias for either :ctype:`unsigned
10270
 
-   short` (UCS2) or :ctype:`unsigned long` (UCS4).
10271
 
+   :c:type:`Py_UNICODE` and store Unicode data internally as UCS4. On platforms
10272
 
+   where :c:type:`wchar_t` is available and compatible with the chosen Python
10273
 
+   Unicode build variant, :c:type:`Py_UNICODE` is a typedef alias for
10274
 
+   :c:type:`wchar_t` to enhance native platform compatibility. On all other
10275
 
+   platforms, :c:type:`Py_UNICODE` is a typedef alias for either :c:type:`unsigned
10276
 
+   short` (UCS2) or :c:type:`unsigned long` (UCS4).
10277
 
 
10278
 
 Note that UCS2 and UCS4 Python builds are not binary compatible. Please keep
10279
 
 this in mind when writing extensions or interfaces.
10280
 
 
10281
 
 
10282
 
-.. ctype:: PyUnicodeObject
10283
 
+.. c:type:: PyUnicodeObject
10284
 
 
10285
 
-   This subtype of :ctype:`PyObject` represents a Python Unicode object.
10286
 
+   This subtype of :c:type:`PyObject` represents a Python Unicode object.
10287
 
 
10288
 
 
10289
 
-.. cvar:: PyTypeObject PyUnicode_Type
10290
 
+.. c:var:: PyTypeObject PyUnicode_Type
10291
 
 
10292
 
-   This instance of :ctype:`PyTypeObject` represents the Python Unicode type.  It
10293
 
+   This instance of :c:type:`PyTypeObject` represents the Python Unicode type.  It
10294
 
    is exposed to Python code as ``unicode`` and ``types.UnicodeType``.
10295
 
 
10296
 
 The following APIs are really C macros and can be used to do fast checks and to
10297
 
 access internal read-only data of Unicode objects:
10298
 
 
10299
 
 
10300
 
-.. cfunction:: int PyUnicode_Check(PyObject *o)
10301
 
+.. c:function:: int PyUnicode_Check(PyObject *o)
10302
 
 
10303
 
    Return true if the object *o* is a Unicode object or an instance of a Unicode
10304
 
    subtype.
10305
 
@@ -59,7 +59,7 @@
10306
 
       Allowed subtypes to be accepted.
10307
 
 
10308
 
 
10309
 
-.. cfunction:: int PyUnicode_CheckExact(PyObject *o)
10310
 
+.. c:function:: int PyUnicode_CheckExact(PyObject *o)
10311
 
 
10312
 
    Return true if the object *o* is a Unicode object, but not an instance of a
10313
 
    subtype.
10314
 
@@ -67,39 +67,39 @@
10315
 
    .. versionadded:: 2.2
10316
 
 
10317
 
 
10318
 
-.. cfunction:: Py_ssize_t PyUnicode_GET_SIZE(PyObject *o)
10319
 
+.. c:function:: Py_ssize_t PyUnicode_GET_SIZE(PyObject *o)
10320
 
 
10321
 
-   Return the size of the object.  *o* has to be a :ctype:`PyUnicodeObject` (not
10322
 
+   Return the size of the object.  *o* has to be a :c:type:`PyUnicodeObject` (not
10323
 
    checked).
10324
 
 
10325
 
    .. versionchanged:: 2.5
10326
 
-      This function returned an :ctype:`int` type. This might require changes
10327
 
+      This function returned an :c:type:`int` type. This might require changes
10328
 
       in your code for properly supporting 64-bit systems.
10329
 
 
10330
 
 
10331
 
-.. cfunction:: Py_ssize_t PyUnicode_GET_DATA_SIZE(PyObject *o)
10332
 
+.. c:function:: Py_ssize_t PyUnicode_GET_DATA_SIZE(PyObject *o)
10333
 
 
10334
 
    Return the size of the object's internal buffer in bytes.  *o* has to be a
10335
 
-   :ctype:`PyUnicodeObject` (not checked).
10336
 
+   :c:type:`PyUnicodeObject` (not checked).
10337
 
 
10338
 
    .. versionchanged:: 2.5
10339
 
-      This function returned an :ctype:`int` type. This might require changes
10340
 
+      This function returned an :c:type:`int` type. This might require changes
10341
 
       in your code for properly supporting 64-bit systems.
10342
 
 
10343
 
 
10344
 
-.. cfunction:: Py_UNICODE* PyUnicode_AS_UNICODE(PyObject *o)
10345
 
+.. c:function:: Py_UNICODE* PyUnicode_AS_UNICODE(PyObject *o)
10346
 
 
10347
 
-   Return a pointer to the internal :ctype:`Py_UNICODE` buffer of the object.  *o*
10348
 
-   has to be a :ctype:`PyUnicodeObject` (not checked).
10349
 
+   Return a pointer to the internal :c:type:`Py_UNICODE` buffer of the object.  *o*
10350
 
+   has to be a :c:type:`PyUnicodeObject` (not checked).
10351
 
 
10352
 
 
10353
 
-.. cfunction:: const char* PyUnicode_AS_DATA(PyObject *o)
10354
 
+.. c:function:: const char* PyUnicode_AS_DATA(PyObject *o)
10355
 
 
10356
 
    Return a pointer to the internal buffer of the object. *o* has to be a
10357
 
-   :ctype:`PyUnicodeObject` (not checked).
10358
 
+   :c:type:`PyUnicodeObject` (not checked).
10359
 
 
10360
 
 
10361
 
-.. cfunction:: int PyUnicode_ClearFreeList()
10362
 
+.. c:function:: int PyUnicode_ClearFreeList()
10363
 
 
10364
 
    Clear the free list. Return the total number of freed items.
10365
 
 
10366
 
@@ -114,86 +114,86 @@
10367
 
 the Python configuration.
10368
 
 
10369
 
 
10370
 
-.. cfunction:: int Py_UNICODE_ISSPACE(Py_UNICODE ch)
10371
 
+.. c:function:: int Py_UNICODE_ISSPACE(Py_UNICODE ch)
10372
 
 
10373
 
    Return 1 or 0 depending on whether *ch* is a whitespace character.
10374
 
 
10375
 
 
10376
 
-.. cfunction:: int Py_UNICODE_ISLOWER(Py_UNICODE ch)
10377
 
+.. c:function:: int Py_UNICODE_ISLOWER(Py_UNICODE ch)
10378
 
 
10379
 
    Return 1 or 0 depending on whether *ch* is a lowercase character.
10380
 
 
10381
 
 
10382
 
-.. cfunction:: int Py_UNICODE_ISUPPER(Py_UNICODE ch)
10383
 
+.. c:function:: int Py_UNICODE_ISUPPER(Py_UNICODE ch)
10384
 
 
10385
 
    Return 1 or 0 depending on whether *ch* is an uppercase character.
10386
 
 
10387
 
 
10388
 
-.. cfunction:: int Py_UNICODE_ISTITLE(Py_UNICODE ch)
10389
 
+.. c:function:: int Py_UNICODE_ISTITLE(Py_UNICODE ch)
10390
 
 
10391
 
    Return 1 or 0 depending on whether *ch* is a titlecase character.
10392
 
 
10393
 
 
10394
 
-.. cfunction:: int Py_UNICODE_ISLINEBREAK(Py_UNICODE ch)
10395
 
+.. c:function:: int Py_UNICODE_ISLINEBREAK(Py_UNICODE ch)
10396
 
 
10397
 
    Return 1 or 0 depending on whether *ch* is a linebreak character.
10398
 
 
10399
 
 
10400
 
-.. cfunction:: int Py_UNICODE_ISDECIMAL(Py_UNICODE ch)
10401
 
+.. c:function:: int Py_UNICODE_ISDECIMAL(Py_UNICODE ch)
10402
 
 
10403
 
    Return 1 or 0 depending on whether *ch* is a decimal character.
10404
 
 
10405
 
 
10406
 
-.. cfunction:: int Py_UNICODE_ISDIGIT(Py_UNICODE ch)
10407
 
+.. c:function:: int Py_UNICODE_ISDIGIT(Py_UNICODE ch)
10408
 
 
10409
 
    Return 1 or 0 depending on whether *ch* is a digit character.
10410
 
 
10411
 
 
10412
 
-.. cfunction:: int Py_UNICODE_ISNUMERIC(Py_UNICODE ch)
10413
 
+.. c:function:: int Py_UNICODE_ISNUMERIC(Py_UNICODE ch)
10414
 
 
10415
 
    Return 1 or 0 depending on whether *ch* is a numeric character.
10416
 
 
10417
 
 
10418
 
-.. cfunction:: int Py_UNICODE_ISALPHA(Py_UNICODE ch)
10419
 
+.. c:function:: int Py_UNICODE_ISALPHA(Py_UNICODE ch)
10420
 
 
10421
 
    Return 1 or 0 depending on whether *ch* is an alphabetic character.
10422
 
 
10423
 
 
10424
 
-.. cfunction:: int Py_UNICODE_ISALNUM(Py_UNICODE ch)
10425
 
+.. c:function:: int Py_UNICODE_ISALNUM(Py_UNICODE ch)
10426
 
 
10427
 
    Return 1 or 0 depending on whether *ch* is an alphanumeric character.
10428
 
 
10429
 
 These APIs can be used for fast direct character conversions:
10430
 
 
10431
 
 
10432
 
-.. cfunction:: Py_UNICODE Py_UNICODE_TOLOWER(Py_UNICODE ch)
10433
 
+.. c:function:: Py_UNICODE Py_UNICODE_TOLOWER(Py_UNICODE ch)
10434
 
 
10435
 
    Return the character *ch* converted to lower case.
10436
 
 
10437
 
 
10438
 
-.. cfunction:: Py_UNICODE Py_UNICODE_TOUPPER(Py_UNICODE ch)
10439
 
+.. c:function:: Py_UNICODE Py_UNICODE_TOUPPER(Py_UNICODE ch)
10440
 
 
10441
 
    Return the character *ch* converted to upper case.
10442
 
 
10443
 
 
10444
 
-.. cfunction:: Py_UNICODE Py_UNICODE_TOTITLE(Py_UNICODE ch)
10445
 
+.. c:function:: Py_UNICODE Py_UNICODE_TOTITLE(Py_UNICODE ch)
10446
 
 
10447
 
    Return the character *ch* converted to title case.
10448
 
 
10449
 
 
10450
 
-.. cfunction:: int Py_UNICODE_TODECIMAL(Py_UNICODE ch)
10451
 
+.. c:function:: int Py_UNICODE_TODECIMAL(Py_UNICODE ch)
10452
 
 
10453
 
    Return the character *ch* converted to a decimal positive integer.  Return
10454
 
    ``-1`` if this is not possible.  This macro does not raise exceptions.
10455
 
 
10456
 
 
10457
 
-.. cfunction:: int Py_UNICODE_TODIGIT(Py_UNICODE ch)
10458
 
+.. c:function:: int Py_UNICODE_TODIGIT(Py_UNICODE ch)
10459
 
 
10460
 
    Return the character *ch* converted to a single digit integer. Return ``-1`` if
10461
 
    this is not possible.  This macro does not raise exceptions.
10462
 
 
10463
 
 
10464
 
-.. cfunction:: double Py_UNICODE_TONUMERIC(Py_UNICODE ch)
10465
 
+.. c:function:: double Py_UNICODE_TONUMERIC(Py_UNICODE ch)
10466
 
 
10467
 
    Return the character *ch* converted to a double. Return ``-1.0`` if this is not
10468
 
    possible.  This macro does not raise exceptions.
10469
 
@@ -206,7 +206,7 @@
10470
 
 APIs:
10471
 
 
10472
 
 
10473
 
-.. cfunction:: PyObject* PyUnicode_FromUnicode(const Py_UNICODE *u, Py_ssize_t size)
10474
 
+.. c:function:: PyObject* PyUnicode_FromUnicode(const Py_UNICODE *u, Py_ssize_t size)
10475
 
 
10476
 
    Create a Unicode object from the Py_UNICODE buffer *u* of the given size. *u*
10477
 
    may be *NULL* which causes the contents to be undefined. It is the user's
10478
 
@@ -216,11 +216,11 @@
10479
 
    is *NULL*.
10480
 
 
10481
 
    .. versionchanged:: 2.5
10482
 
-      This function used an :ctype:`int` type for *size*. This might require
10483
 
+      This function used an :c:type:`int` type for *size*. This might require
10484
 
       changes in your code for properly supporting 64-bit systems.
10485
 
 
10486
 
 
10487
 
-.. cfunction:: PyObject* PyUnicode_FromStringAndSize(const char *u, Py_ssize_t size)
10488
 
+.. c:function:: PyObject* PyUnicode_FromStringAndSize(const char *u, Py_ssize_t size)
10489
 
 
10490
 
    Create a Unicode object from the char buffer *u*.  The bytes will be interpreted
10491
 
    as being UTF-8 encoded.  *u* may also be *NULL* which
10492
 
@@ -232,7 +232,7 @@
10493
 
    .. versionadded:: 2.6
10494
 
 
10495
 
 
10496
 
-.. cfunction:: PyObject *PyUnicode_FromString(const char *u)
10497
 
+.. c:function:: PyObject *PyUnicode_FromString(const char *u)
10498
 
 
10499
 
    Create a Unicode object from an UTF-8 encoded null-terminated char buffer
10500
 
    *u*.
10501
 
@@ -240,9 +240,9 @@
10502
 
    .. versionadded:: 2.6
10503
 
 
10504
 
 
10505
 
-.. cfunction:: PyObject* PyUnicode_FromFormat(const char *format, ...)
10506
 
+.. c:function:: PyObject* PyUnicode_FromFormat(const char *format, ...)
10507
 
 
10508
 
-   Take a C :cfunc:`printf`\ -style *format* string and a variable number of
10509
 
+   Take a C :c:func:`printf`\ -style *format* string and a variable number of
10510
 
    arguments, calculate the size of the resulting Python unicode string and return
10511
 
    a string with the values formatted into it.  The variable arguments must be C
10512
 
    types and must correspond exactly to the format characters in the *format*
10513
 
@@ -317,7 +317,7 @@
10514
 
    .. versionadded:: 2.6
10515
 
 
10516
 
 
10517
 
-.. cfunction:: PyObject* PyUnicode_FromFormatV(const char *format, va_list vargs)
10518
 
+.. c:function:: PyObject* PyUnicode_FromFormatV(const char *format, va_list vargs)
10519
 
 
10520
 
    Identical to :func:`PyUnicode_FromFormat` except that it takes exactly two
10521
 
    arguments.
10522
 
@@ -325,22 +325,25 @@
10523
 
    .. versionadded:: 2.6
10524
 
 
10525
 
 
10526
 
-.. cfunction:: Py_UNICODE* PyUnicode_AsUnicode(PyObject *unicode)
10527
 
+.. c:function:: Py_UNICODE* PyUnicode_AsUnicode(PyObject *unicode)
10528
 
 
10529
 
-   Return a read-only pointer to the Unicode object's internal :ctype:`Py_UNICODE`
10530
 
-   buffer, *NULL* if *unicode* is not a Unicode object.
10531
 
+   Return a read-only pointer to the Unicode object's internal
10532
 
+   :c:type:`Py_UNICODE` buffer, *NULL* if *unicode* is not a Unicode object.
10533
 
+   Note that the resulting :c:type:`Py_UNICODE*` string may contain embedded
10534
 
+   null characters, which would cause the string to be truncated when used in
10535
 
+   most C functions.
10536
 
 
10537
 
 
10538
 
-.. cfunction:: Py_ssize_t PyUnicode_GetSize(PyObject *unicode)
10539
 
+.. c:function:: Py_ssize_t PyUnicode_GetSize(PyObject *unicode)
10540
 
 
10541
 
    Return the length of the Unicode object.
10542
 
 
10543
 
    .. versionchanged:: 2.5
10544
 
-      This function returned an :ctype:`int` type. This might require changes
10545
 
+      This function returned an :c:type:`int` type. This might require changes
10546
 
       in your code for properly supporting 64-bit systems.
10547
 
 
10548
 
 
10549
 
-.. cfunction:: PyObject* PyUnicode_FromEncodedObject(PyObject *obj, const char *encoding, const char *errors)
10550
 
+.. c:function:: PyObject* PyUnicode_FromEncodedObject(PyObject *obj, const char *encoding, const char *errors)
10551
 
 
10552
 
    Coerce an encoded object *obj* to an Unicode object and return a reference with
10553
 
    incremented refcount.
10554
 
@@ -357,44 +360,46 @@
10555
 
    decref'ing the returned objects.
10556
 
 
10557
 
 
10558
 
-.. cfunction:: PyObject* PyUnicode_FromObject(PyObject *obj)
10559
 
+.. c:function:: PyObject* PyUnicode_FromObject(PyObject *obj)
10560
 
 
10561
 
    Shortcut for ``PyUnicode_FromEncodedObject(obj, NULL, "strict")`` which is used
10562
 
    throughout the interpreter whenever coercion to Unicode is needed.
10563
 
 
10564
 
-If the platform supports :ctype:`wchar_t` and provides a header file wchar.h,
10565
 
+If the platform supports :c:type:`wchar_t` and provides a header file wchar.h,
10566
 
 Python can interface directly to this type using the following functions.
10567
 
-Support is optimized if Python's own :ctype:`Py_UNICODE` type is identical to
10568
 
-the system's :ctype:`wchar_t`.
10569
 
+Support is optimized if Python's own :c:type:`Py_UNICODE` type is identical to
10570
 
+the system's :c:type:`wchar_t`.
10571
 
 
10572
 
 
10573
 
 wchar_t Support
10574
 
 """""""""""""""
10575
 
 
10576
 
-:ctype:`wchar_t` support for platforms which support it:
10577
 
+:c:type:`wchar_t` support for platforms which support it:
10578
 
 
10579
 
-.. cfunction:: PyObject* PyUnicode_FromWideChar(const wchar_t *w, Py_ssize_t size)
10580
 
+.. c:function:: PyObject* PyUnicode_FromWideChar(const wchar_t *w, Py_ssize_t size)
10581
 
 
10582
 
-   Create a Unicode object from the :ctype:`wchar_t` buffer *w* of the given *size*.
10583
 
+   Create a Unicode object from the :c:type:`wchar_t` buffer *w* of the given *size*.
10584
 
    Return *NULL* on failure.
10585
 
 
10586
 
    .. versionchanged:: 2.5
10587
 
-      This function used an :ctype:`int` type for *size*. This might require
10588
 
+      This function used an :c:type:`int` type for *size*. This might require
10589
 
       changes in your code for properly supporting 64-bit systems.
10590
 
 
10591
 
 
10592
 
-.. cfunction:: Py_ssize_t PyUnicode_AsWideChar(PyUnicodeObject *unicode, wchar_t *w, Py_ssize_t size)
10593
 
+.. c:function:: Py_ssize_t PyUnicode_AsWideChar(PyUnicodeObject *unicode, wchar_t *w, Py_ssize_t size)
10594
 
 
10595
 
-   Copy the Unicode object contents into the :ctype:`wchar_t` buffer *w*.  At most
10596
 
-   *size* :ctype:`wchar_t` characters are copied (excluding a possibly trailing
10597
 
-   0-termination character).  Return the number of :ctype:`wchar_t` characters
10598
 
-   copied or -1 in case of an error.  Note that the resulting :ctype:`wchar_t`
10599
 
+   Copy the Unicode object contents into the :c:type:`wchar_t` buffer *w*.  At most
10600
 
+   *size* :c:type:`wchar_t` characters are copied (excluding a possibly trailing
10601
 
+   0-termination character).  Return the number of :c:type:`wchar_t` characters
10602
 
+   copied or -1 in case of an error.  Note that the resulting :c:type:`wchar_t`
10603
 
    string may or may not be 0-terminated.  It is the responsibility of the caller
10604
 
-   to make sure that the :ctype:`wchar_t` string is 0-terminated in case this is
10605
 
-   required by the application.
10606
 
+   to make sure that the :c:type:`wchar_t` string is 0-terminated in case this is
10607
 
+   required by the application. Also, note that the :c:type:`wchar_t*` string
10608
 
+   might contain null characters, which would cause the string to be truncated
10609
 
+   when used with most C functions.
10610
 
 
10611
 
    .. versionchanged:: 2.5
10612
 
-      This function returned an :ctype:`int` type and used an :ctype:`int`
10613
 
+      This function returned an :c:type:`int` type and used an :c:type:`int`
10614
 
       type for *size*. This might require changes in your code for properly
10615
 
       supporting 64-bit systems.
10616
 
 
10617
 
@@ -412,7 +417,7 @@
10618
 
 object constructor.
10619
 
 
10620
 
 Setting encoding to *NULL* causes the default encoding to be used which is
10621
 
-ASCII.  The file system calls should use :cdata:`Py_FileSystemDefaultEncoding`
10622
 
+ASCII.  The file system calls should use :c:data:`Py_FileSystemDefaultEncoding`
10623
 
 as the encoding for file names. This variable should be treated as read-only: on
10624
 
 some systems, it will be a pointer to a static string, on others, it will change
10625
 
 at run-time (such as when the application invokes setlocale).
10626
 
@@ -431,7 +436,7 @@
10627
 
 These are the generic codec APIs:
10628
 
 
10629
 
 
10630
 
-.. cfunction:: PyObject* PyUnicode_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors)
10631
 
+.. c:function:: PyObject* PyUnicode_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors)
10632
 
 
10633
 
    Create a Unicode object by decoding *size* bytes of the encoded string *s*.
10634
 
    *encoding* and *errors* have the same meaning as the parameters of the same name
10635
 
@@ -440,24 +445,24 @@
10636
 
    the codec.
10637
 
 
10638
 
    .. versionchanged:: 2.5
10639
 
-      This function used an :ctype:`int` type for *size*. This might require
10640
 
+      This function used an :c:type:`int` type for *size*. This might require
10641
 
       changes in your code for properly supporting 64-bit systems.
10642
 
 
10643
 
 
10644
 
-.. cfunction:: PyObject* PyUnicode_Encode(const Py_UNICODE *s, Py_ssize_t size, const char *encoding, const char *errors)
10645
 
+.. c:function:: PyObject* PyUnicode_Encode(const Py_UNICODE *s, Py_ssize_t size, const char *encoding, const char *errors)
10646
 
 
10647
 
-   Encode the :ctype:`Py_UNICODE` buffer *s* of the given *size* and return a Python
10648
 
+   Encode the :c:type:`Py_UNICODE` buffer *s* of the given *size* and return a Python
10649
 
    string object.  *encoding* and *errors* have the same meaning as the parameters
10650
 
    of the same name in the Unicode :meth:`encode` method.  The codec to be used is
10651
 
    looked up using the Python codec registry.  Return *NULL* if an exception was
10652
 
    raised by the codec.
10653
 
 
10654
 
    .. versionchanged:: 2.5
10655
 
-      This function used an :ctype:`int` type for *size*. This might require
10656
 
+      This function used an :c:type:`int` type for *size*. This might require
10657
 
       changes in your code for properly supporting 64-bit systems.
10658
 
 
10659
 
 
10660
 
-.. cfunction:: PyObject* PyUnicode_AsEncodedString(PyObject *unicode, const char *encoding, const char *errors)
10661
 
+.. c:function:: PyObject* PyUnicode_AsEncodedString(PyObject *unicode, const char *encoding, const char *errors)
10662
 
 
10663
 
    Encode a Unicode object and return the result as Python string object.
10664
 
    *encoding* and *errors* have the same meaning as the parameters of the same name
10665
 
@@ -472,19 +477,19 @@
10666
 
 These are the UTF-8 codec APIs:
10667
 
 
10668
 
 
10669
 
-.. cfunction:: PyObject* PyUnicode_DecodeUTF8(const char *s, Py_ssize_t size, const char *errors)
10670
 
+.. c:function:: PyObject* PyUnicode_DecodeUTF8(const char *s, Py_ssize_t size, const char *errors)
10671
 
 
10672
 
    Create a Unicode object by decoding *size* bytes of the UTF-8 encoded string
10673
 
    *s*. Return *NULL* if an exception was raised by the codec.
10674
 
 
10675
 
    .. versionchanged:: 2.5
10676
 
-      This function used an :ctype:`int` type for *size*. This might require
10677
 
+      This function used an :c:type:`int` type for *size*. This might require
10678
 
       changes in your code for properly supporting 64-bit systems.
10679
 
 
10680
 
 
10681
 
-.. cfunction:: PyObject* PyUnicode_DecodeUTF8Stateful(const char *s, Py_ssize_t size, const char *errors, Py_ssize_t *consumed)
10682
 
+.. c:function:: PyObject* PyUnicode_DecodeUTF8Stateful(const char *s, Py_ssize_t size, const char *errors, Py_ssize_t *consumed)
10683
 
 
10684
 
-   If *consumed* is *NULL*, behave like :cfunc:`PyUnicode_DecodeUTF8`. If
10685
 
+   If *consumed* is *NULL*, behave like :c:func:`PyUnicode_DecodeUTF8`. If
10686
 
    *consumed* is not *NULL*, trailing incomplete UTF-8 byte sequences will not be
10687
 
    treated as an error. Those bytes will not be decoded and the number of bytes
10688
 
    that have been decoded will be stored in *consumed*.
10689
 
@@ -492,21 +497,21 @@
10690
 
    .. versionadded:: 2.4
10691
 
 
10692
 
    .. versionchanged:: 2.5
10693
 
-      This function used an :ctype:`int` type for *size*. This might require
10694
 
+      This function used an :c:type:`int` type for *size*. This might require
10695
 
       changes in your code for properly supporting 64-bit systems.
10696
 
 
10697
 
 
10698
 
-.. cfunction:: PyObject* PyUnicode_EncodeUTF8(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
10699
 
+.. c:function:: PyObject* PyUnicode_EncodeUTF8(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
10700
 
 
10701
 
-   Encode the :ctype:`Py_UNICODE` buffer *s* of the given *size* using UTF-8 and return a
10702
 
+   Encode the :c:type:`Py_UNICODE` buffer *s* of the given *size* using UTF-8 and return a
10703
 
    Python string object.  Return *NULL* if an exception was raised by the codec.
10704
 
 
10705
 
    .. versionchanged:: 2.5
10706
 
-      This function used an :ctype:`int` type for *size*. This might require
10707
 
+      This function used an :c:type:`int` type for *size*. This might require
10708
 
       changes in your code for properly supporting 64-bit systems.
10709
 
 
10710
 
 
10711
 
-.. cfunction:: PyObject* PyUnicode_AsUTF8String(PyObject *unicode)
10712
 
+.. c:function:: PyObject* PyUnicode_AsUTF8String(PyObject *unicode)
10713
 
 
10714
 
    Encode a Unicode object using UTF-8 and return the result as Python string
10715
 
    object.  Error handling is "strict".  Return *NULL* if an exception was raised
10716
 
@@ -519,7 +524,7 @@
10717
 
 These are the UTF-32 codec APIs:
10718
 
 
10719
 
 
10720
 
-.. cfunction:: PyObject* PyUnicode_DecodeUTF32(const char *s, Py_ssize_t size, const char *errors, int *byteorder)
10721
 
+.. c:function:: PyObject* PyUnicode_DecodeUTF32(const char *s, Py_ssize_t size, const char *errors, int *byteorder)
10722
 
 
10723
 
    Decode *size* bytes from a UTF-32 encoded buffer string and return the
10724
 
    corresponding Unicode object.  *errors* (if non-*NULL*) defines the error
10725
 
@@ -549,10 +554,10 @@
10726
 
    .. versionadded:: 2.6
10727
 
 
10728
 
 
10729
 
-.. cfunction:: PyObject* PyUnicode_DecodeUTF32Stateful(const char *s, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed)
10730
 
+.. c:function:: PyObject* PyUnicode_DecodeUTF32Stateful(const char *s, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed)
10731
 
 
10732
 
-   If *consumed* is *NULL*, behave like :cfunc:`PyUnicode_DecodeUTF32`. If
10733
 
-   *consumed* is not *NULL*, :cfunc:`PyUnicode_DecodeUTF32Stateful` will not treat
10734
 
+   If *consumed* is *NULL*, behave like :c:func:`PyUnicode_DecodeUTF32`. If
10735
 
+   *consumed* is not *NULL*, :c:func:`PyUnicode_DecodeUTF32Stateful` will not treat
10736
 
    trailing incomplete UTF-32 byte sequences (such as a number of bytes not divisible
10737
 
    by four) as an error. Those bytes will not be decoded and the number of bytes
10738
 
    that have been decoded will be stored in *consumed*.
10739
 
@@ -560,7 +565,7 @@
10740
 
    .. versionadded:: 2.6
10741
 
 
10742
 
 
10743
 
-.. cfunction:: PyObject* PyUnicode_EncodeUTF32(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder)
10744
 
+.. c:function:: PyObject* PyUnicode_EncodeUTF32(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder)
10745
 
 
10746
 
    Return a Python bytes object holding the UTF-32 encoded value of the Unicode
10747
 
    data in *s*.  Output is written according to the following byte order::
10748
 
@@ -580,7 +585,7 @@
10749
 
    .. versionadded:: 2.6
10750
 
 
10751
 
 
10752
 
-.. cfunction:: PyObject* PyUnicode_AsUTF32String(PyObject *unicode)
10753
 
+.. c:function:: PyObject* PyUnicode_AsUTF32String(PyObject *unicode)
10754
 
 
10755
 
    Return a Python string using the UTF-32 encoding in native byte order. The
10756
 
    string always starts with a BOM mark.  Error handling is "strict".  Return
10757
 
@@ -595,7 +600,7 @@
10758
 
 These are the UTF-16 codec APIs:
10759
 
 
10760
 
 
10761
 
-.. cfunction:: PyObject* PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors, int *byteorder)
10762
 
+.. c:function:: PyObject* PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors, int *byteorder)
10763
 
 
10764
 
    Decode *size* bytes from a UTF-16 encoded buffer string and return the
10765
 
    corresponding Unicode object.  *errors* (if non-*NULL*) defines the error
10766
 
@@ -622,14 +627,14 @@
10767
 
    Return *NULL* if an exception was raised by the codec.
10768
 
 
10769
 
    .. versionchanged:: 2.5
10770
 
-      This function used an :ctype:`int` type for *size*. This might require
10771
 
+      This function used an :c:type:`int` type for *size*. This might require
10772
 
       changes in your code for properly supporting 64-bit systems.
10773
 
 
10774
 
 
10775
 
-.. cfunction:: PyObject* PyUnicode_DecodeUTF16Stateful(const char *s, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed)
10776
 
+.. c:function:: PyObject* PyUnicode_DecodeUTF16Stateful(const char *s, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed)
10777
 
 
10778
 
-   If *consumed* is *NULL*, behave like :cfunc:`PyUnicode_DecodeUTF16`. If
10779
 
-   *consumed* is not *NULL*, :cfunc:`PyUnicode_DecodeUTF16Stateful` will not treat
10780
 
+   If *consumed* is *NULL*, behave like :c:func:`PyUnicode_DecodeUTF16`. If
10781
 
+   *consumed* is not *NULL*, :c:func:`PyUnicode_DecodeUTF16Stateful` will not treat
10782
 
    trailing incomplete UTF-16 byte sequences (such as an odd number of bytes or a
10783
 
    split surrogate pair) as an error. Those bytes will not be decoded and the
10784
 
    number of bytes that have been decoded will be stored in *consumed*.
10785
 
@@ -637,12 +642,12 @@
10786
 
    .. versionadded:: 2.4
10787
 
 
10788
 
    .. versionchanged:: 2.5
10789
 
-      This function used an :ctype:`int` type for *size* and an :ctype:`int *`
10790
 
+      This function used an :c:type:`int` type for *size* and an :c:type:`int *`
10791
 
       type for *consumed*. This might require changes in your code for
10792
 
       properly supporting 64-bit systems.
10793
 
 
10794
 
 
10795
 
-.. cfunction:: PyObject* PyUnicode_EncodeUTF16(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder)
10796
 
+.. c:function:: PyObject* PyUnicode_EncodeUTF16(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder)
10797
 
 
10798
 
    Return a Python string object holding the UTF-16 encoded value of the Unicode
10799
 
    data in *s*.  Output is written according to the following byte order::
10800
 
@@ -654,18 +659,18 @@
10801
 
    If byteorder is ``0``, the output string will always start with the Unicode BOM
10802
 
    mark (U+FEFF). In the other two modes, no BOM mark is prepended.
10803
 
 
10804
 
-   If *Py_UNICODE_WIDE* is defined, a single :ctype:`Py_UNICODE` value may get
10805
 
-   represented as a surrogate pair. If it is not defined, each :ctype:`Py_UNICODE`
10806
 
+   If *Py_UNICODE_WIDE* is defined, a single :c:type:`Py_UNICODE` value may get
10807
 
+   represented as a surrogate pair. If it is not defined, each :c:type:`Py_UNICODE`
10808
 
    values is interpreted as an UCS-2 character.
10809
 
 
10810
 
    Return *NULL* if an exception was raised by the codec.
10811
 
 
10812
 
    .. versionchanged:: 2.5
10813
 
-      This function used an :ctype:`int` type for *size*. This might require
10814
 
+      This function used an :c:type:`int` type for *size*. This might require
10815
 
       changes in your code for properly supporting 64-bit systems.
10816
 
 
10817
 
 
10818
 
-.. cfunction:: PyObject* PyUnicode_AsUTF16String(PyObject *unicode)
10819
 
+.. c:function:: PyObject* PyUnicode_AsUTF16String(PyObject *unicode)
10820
 
 
10821
 
    Return a Python string using the UTF-16 encoding in native byte order. The
10822
 
    string always starts with a BOM mark.  Error handling is "strict".  Return
10823
 
@@ -678,23 +683,23 @@
10824
 
 These are the UTF-7 codec APIs:
10825
 
 
10826
 
 
10827
 
-.. cfunction:: PyObject* PyUnicode_DecodeUTF7(const char *s, Py_ssize_t size, const char *errors)
10828
 
+.. c:function:: PyObject* PyUnicode_DecodeUTF7(const char *s, Py_ssize_t size, const char *errors)
10829
 
 
10830
 
    Create a Unicode object by decoding *size* bytes of the UTF-7 encoded string
10831
 
    *s*.  Return *NULL* if an exception was raised by the codec.
10832
 
 
10833
 
 
10834
 
-.. cfunction:: PyObject* PyUnicode_DecodeUTF7Stateful(const char *s, Py_ssize_t size, const char *errors, Py_ssize_t *consumed)
10835
 
+.. c:function:: PyObject* PyUnicode_DecodeUTF7Stateful(const char *s, Py_ssize_t size, const char *errors, Py_ssize_t *consumed)
10836
 
 
10837
 
-   If *consumed* is *NULL*, behave like :cfunc:`PyUnicode_DecodeUTF7`.  If
10838
 
+   If *consumed* is *NULL*, behave like :c:func:`PyUnicode_DecodeUTF7`.  If
10839
 
    *consumed* is not *NULL*, trailing incomplete UTF-7 base-64 sections will not
10840
 
    be treated as an error.  Those bytes will not be decoded and the number of
10841
 
    bytes that have been decoded will be stored in *consumed*.
10842
 
 
10843
 
 
10844
 
-.. cfunction:: PyObject* PyUnicode_EncodeUTF7(const Py_UNICODE *s, Py_ssize_t size, int base64SetO, int base64WhiteSpace, const char *errors)
10845
 
+.. c:function:: PyObject* PyUnicode_EncodeUTF7(const Py_UNICODE *s, Py_ssize_t size, int base64SetO, int base64WhiteSpace, const char *errors)
10846
 
 
10847
 
-   Encode the :ctype:`Py_UNICODE` buffer of the given size using UTF-7 and
10848
 
+   Encode the :c:type:`Py_UNICODE` buffer of the given size using UTF-7 and
10849
 
    return a Python bytes object.  Return *NULL* if an exception was raised by
10850
 
    the codec.
10851
 
 
10852
 
@@ -710,28 +715,28 @@
10853
 
 These are the "Unicode Escape" codec APIs:
10854
 
 
10855
 
 
10856
 
-.. cfunction:: PyObject* PyUnicode_DecodeUnicodeEscape(const char *s, Py_ssize_t size, const char *errors)
10857
 
+.. c:function:: PyObject* PyUnicode_DecodeUnicodeEscape(const char *s, Py_ssize_t size, const char *errors)
10858
 
 
10859
 
    Create a Unicode object by decoding *size* bytes of the Unicode-Escape encoded
10860
 
    string *s*.  Return *NULL* if an exception was raised by the codec.
10861
 
 
10862
 
    .. versionchanged:: 2.5
10863
 
-      This function used an :ctype:`int` type for *size*. This might require
10864
 
+      This function used an :c:type:`int` type for *size*. This might require
10865
 
       changes in your code for properly supporting 64-bit systems.
10866
 
 
10867
 
 
10868
 
-.. cfunction:: PyObject* PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s, Py_ssize_t size)
10869
 
+.. c:function:: PyObject* PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s, Py_ssize_t size)
10870
 
 
10871
 
-   Encode the :ctype:`Py_UNICODE` buffer of the given *size* using Unicode-Escape and
10872
 
+   Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Unicode-Escape and
10873
 
    return a Python string object.  Return *NULL* if an exception was raised by the
10874
 
    codec.
10875
 
 
10876
 
    .. versionchanged:: 2.5
10877
 
-      This function used an :ctype:`int` type for *size*. This might require
10878
 
+      This function used an :c:type:`int` type for *size*. This might require
10879
 
       changes in your code for properly supporting 64-bit systems.
10880
 
 
10881
 
 
10882
 
-.. cfunction:: PyObject* PyUnicode_AsUnicodeEscapeString(PyObject *unicode)
10883
 
+.. c:function:: PyObject* PyUnicode_AsUnicodeEscapeString(PyObject *unicode)
10884
 
 
10885
 
    Encode a Unicode object using Unicode-Escape and return the result as Python
10886
 
    string object.  Error handling is "strict". Return *NULL* if an exception was
10887
 
@@ -744,28 +749,28 @@
10888
 
 These are the "Raw Unicode Escape" codec APIs:
10889
 
 
10890
 
 
10891
 
-.. cfunction:: PyObject* PyUnicode_DecodeRawUnicodeEscape(const char *s, Py_ssize_t size, const char *errors)
10892
 
+.. c:function:: PyObject* PyUnicode_DecodeRawUnicodeEscape(const char *s, Py_ssize_t size, const char *errors)
10893
 
 
10894
 
    Create a Unicode object by decoding *size* bytes of the Raw-Unicode-Escape
10895
 
    encoded string *s*.  Return *NULL* if an exception was raised by the codec.
10896
 
 
10897
 
    .. versionchanged:: 2.5
10898
 
-      This function used an :ctype:`int` type for *size*. This might require
10899
 
+      This function used an :c:type:`int` type for *size*. This might require
10900
 
       changes in your code for properly supporting 64-bit systems.
10901
 
 
10902
 
 
10903
 
-.. cfunction:: PyObject* PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
10904
 
+.. c:function:: PyObject* PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
10905
 
 
10906
 
-   Encode the :ctype:`Py_UNICODE` buffer of the given *size* using Raw-Unicode-Escape
10907
 
+   Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Raw-Unicode-Escape
10908
 
    and return a Python string object.  Return *NULL* if an exception was raised by
10909
 
    the codec.
10910
 
 
10911
 
    .. versionchanged:: 2.5
10912
 
-      This function used an :ctype:`int` type for *size*. This might require
10913
 
+      This function used an :c:type:`int` type for *size*. This might require
10914
 
       changes in your code for properly supporting 64-bit systems.
10915
 
 
10916
 
 
10917
 
-.. cfunction:: PyObject* PyUnicode_AsRawUnicodeEscapeString(PyObject *unicode)
10918
 
+.. c:function:: PyObject* PyUnicode_AsRawUnicodeEscapeString(PyObject *unicode)
10919
 
 
10920
 
    Encode a Unicode object using Raw-Unicode-Escape and return the result as
10921
 
    Python string object. Error handling is "strict". Return *NULL* if an exception
10922
 
@@ -779,27 +784,27 @@
10923
 
 ordinals and only these are accepted by the codecs during encoding.
10924
 
 
10925
 
 
10926
 
-.. cfunction:: PyObject* PyUnicode_DecodeLatin1(const char *s, Py_ssize_t size, const char *errors)
10927
 
+.. c:function:: PyObject* PyUnicode_DecodeLatin1(const char *s, Py_ssize_t size, const char *errors)
10928
 
 
10929
 
    Create a Unicode object by decoding *size* bytes of the Latin-1 encoded string
10930
 
    *s*.  Return *NULL* if an exception was raised by the codec.
10931
 
 
10932
 
    .. versionchanged:: 2.5
10933
 
-      This function used an :ctype:`int` type for *size*. This might require
10934
 
+      This function used an :c:type:`int` type for *size*. This might require
10935
 
       changes in your code for properly supporting 64-bit systems.
10936
 
 
10937
 
 
10938
 
-.. cfunction:: PyObject* PyUnicode_EncodeLatin1(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
10939
 
+.. c:function:: PyObject* PyUnicode_EncodeLatin1(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
10940
 
 
10941
 
-   Encode the :ctype:`Py_UNICODE` buffer of the given *size* using Latin-1 and return
10942
 
+   Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Latin-1 and return
10943
 
    a Python string object.  Return *NULL* if an exception was raised by the codec.
10944
 
 
10945
 
    .. versionchanged:: 2.5
10946
 
-      This function used an :ctype:`int` type for *size*. This might require
10947
 
+      This function used an :c:type:`int` type for *size*. This might require
10948
 
       changes in your code for properly supporting 64-bit systems.
10949
 
 
10950
 
 
10951
 
-.. cfunction:: PyObject* PyUnicode_AsLatin1String(PyObject *unicode)
10952
 
+.. c:function:: PyObject* PyUnicode_AsLatin1String(PyObject *unicode)
10953
 
 
10954
 
    Encode a Unicode object using Latin-1 and return the result as Python string
10955
 
    object.  Error handling is "strict".  Return *NULL* if an exception was raised
10956
 
@@ -813,27 +818,27 @@
10957
 
 codes generate errors.
10958
 
 
10959
 
 
10960
 
-.. cfunction:: PyObject* PyUnicode_DecodeASCII(const char *s, Py_ssize_t size, const char *errors)
10961
 
+.. c:function:: PyObject* PyUnicode_DecodeASCII(const char *s, Py_ssize_t size, const char *errors)
10962
 
 
10963
 
    Create a Unicode object by decoding *size* bytes of the ASCII encoded string
10964
 
    *s*.  Return *NULL* if an exception was raised by the codec.
10965
 
 
10966
 
    .. versionchanged:: 2.5
10967
 
-      This function used an :ctype:`int` type for *size*. This might require
10968
 
+      This function used an :c:type:`int` type for *size*. This might require
10969
 
       changes in your code for properly supporting 64-bit systems.
10970
 
 
10971
 
 
10972
 
-.. cfunction:: PyObject* PyUnicode_EncodeASCII(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
10973
 
+.. c:function:: PyObject* PyUnicode_EncodeASCII(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
10974
 
 
10975
 
-   Encode the :ctype:`Py_UNICODE` buffer of the given *size* using ASCII and return a
10976
 
+   Encode the :c:type:`Py_UNICODE` buffer of the given *size* using ASCII and return a
10977
 
    Python string object.  Return *NULL* if an exception was raised by the codec.
10978
 
 
10979
 
    .. versionchanged:: 2.5
10980
 
-      This function used an :ctype:`int` type for *size*. This might require
10981
 
+      This function used an :c:type:`int` type for *size*. This might require
10982
 
       changes in your code for properly supporting 64-bit systems.
10983
 
 
10984
 
 
10985
 
-.. cfunction:: PyObject* PyUnicode_AsASCIIString(PyObject *unicode)
10986
 
+.. c:function:: PyObject* PyUnicode_AsASCIIString(PyObject *unicode)
10987
 
 
10988
 
    Encode a Unicode object using ASCII and return the result as Python string
10989
 
    object.  Error handling is "strict".  Return *NULL* if an exception was raised
10990
 
@@ -866,7 +871,7 @@
10991
 
 
10992
 
 These are the mapping codec APIs:
10993
 
 
10994
 
-.. cfunction:: PyObject* PyUnicode_DecodeCharmap(const char *s, Py_ssize_t size, PyObject *mapping, const char *errors)
10995
 
+.. c:function:: PyObject* PyUnicode_DecodeCharmap(const char *s, Py_ssize_t size, PyObject *mapping, const char *errors)
10996
 
 
10997
 
    Create a Unicode object by decoding *size* bytes of the encoded string *s* using
10998
 
    the given *mapping* object.  Return *NULL* if an exception was raised by the
10999
 
@@ -879,22 +884,22 @@
11000
 
       Allowed unicode string as mapping argument.
11001
 
 
11002
 
    .. versionchanged:: 2.5
11003
 
-      This function used an :ctype:`int` type for *size*. This might require
11004
 
+      This function used an :c:type:`int` type for *size*. This might require
11005
 
       changes in your code for properly supporting 64-bit systems.
11006
 
 
11007
 
 
11008
 
-.. cfunction:: PyObject* PyUnicode_EncodeCharmap(const Py_UNICODE *s, Py_ssize_t size, PyObject *mapping, const char *errors)
11009
 
+.. c:function:: PyObject* PyUnicode_EncodeCharmap(const Py_UNICODE *s, Py_ssize_t size, PyObject *mapping, const char *errors)
11010
 
 
11011
 
-   Encode the :ctype:`Py_UNICODE` buffer of the given *size* using the given
11012
 
+   Encode the :c:type:`Py_UNICODE` buffer of the given *size* using the given
11013
 
    *mapping* object and return a Python string object. Return *NULL* if an
11014
 
    exception was raised by the codec.
11015
 
 
11016
 
    .. versionchanged:: 2.5
11017
 
-      This function used an :ctype:`int` type for *size*. This might require
11018
 
+      This function used an :c:type:`int` type for *size*. This might require
11019
 
       changes in your code for properly supporting 64-bit systems.
11020
 
 
11021
 
 
11022
 
-.. cfunction:: PyObject* PyUnicode_AsCharmapString(PyObject *unicode, PyObject *mapping)
11023
 
+.. c:function:: PyObject* PyUnicode_AsCharmapString(PyObject *unicode, PyObject *mapping)
11024
 
 
11025
 
    Encode a Unicode object using the given *mapping* object and return the result
11026
 
    as Python string object.  Error handling is "strict".  Return *NULL* if an
11027
 
@@ -903,9 +908,9 @@
11028
 
 The following codec API is special in that maps Unicode to Unicode.
11029
 
 
11030
 
 
11031
 
-.. cfunction:: PyObject* PyUnicode_TranslateCharmap(const Py_UNICODE *s, Py_ssize_t size, PyObject *table, const char *errors)
11032
 
+.. c:function:: PyObject* PyUnicode_TranslateCharmap(const Py_UNICODE *s, Py_ssize_t size, PyObject *table, const char *errors)
11033
 
 
11034
 
-   Translate a :ctype:`Py_UNICODE` buffer of the given *size* by applying a
11035
 
+   Translate a :c:type:`Py_UNICODE` buffer of the given *size* by applying a
11036
 
    character mapping *table* to it and return the resulting Unicode object.  Return
11037
 
    *NULL* when an exception was raised by the codec.
11038
 
 
11039
 
@@ -917,7 +922,7 @@
11040
 
    :exc:`LookupError`) are left untouched and are copied as-is.
11041
 
 
11042
 
    .. versionchanged:: 2.5
11043
 
-      This function used an :ctype:`int` type for *size*. This might require
11044
 
+      This function used an :c:type:`int` type for *size*. This might require
11045
 
       changes in your code for properly supporting 64-bit systems.
11046
 
 
11047
 
 
11048
 
@@ -930,37 +935,37 @@
11049
 
 the user settings on the machine running the codec.
11050
 
 
11051
 
 
11052
 
-.. cfunction:: PyObject* PyUnicode_DecodeMBCS(const char *s, Py_ssize_t size, const char *errors)
11053
 
+.. c:function:: PyObject* PyUnicode_DecodeMBCS(const char *s, Py_ssize_t size, const char *errors)
11054
 
 
11055
 
    Create a Unicode object by decoding *size* bytes of the MBCS encoded string *s*.
11056
 
    Return *NULL* if an exception was raised by the codec.
11057
 
 
11058
 
    .. versionchanged:: 2.5
11059
 
-      This function used an :ctype:`int` type for *size*. This might require
11060
 
+      This function used an :c:type:`int` type for *size*. This might require
11061
 
       changes in your code for properly supporting 64-bit systems.
11062
 
 
11063
 
 
11064
 
-.. cfunction:: PyObject* PyUnicode_DecodeMBCSStateful(const char *s, int size, const char *errors, int *consumed)
11065
 
+.. c:function:: PyObject* PyUnicode_DecodeMBCSStateful(const char *s, int size, const char *errors, int *consumed)
11066
 
 
11067
 
-   If *consumed* is *NULL*, behave like :cfunc:`PyUnicode_DecodeMBCS`. If
11068
 
-   *consumed* is not *NULL*, :cfunc:`PyUnicode_DecodeMBCSStateful` will not decode
11069
 
+   If *consumed* is *NULL*, behave like :c:func:`PyUnicode_DecodeMBCS`. If
11070
 
+   *consumed* is not *NULL*, :c:func:`PyUnicode_DecodeMBCSStateful` will not decode
11071
 
    trailing lead byte and the number of bytes that have been decoded will be stored
11072
 
    in *consumed*.
11073
 
 
11074
 
    .. versionadded:: 2.5
11075
 
 
11076
 
 
11077
 
-.. cfunction:: PyObject* PyUnicode_EncodeMBCS(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
11078
 
+.. c:function:: PyObject* PyUnicode_EncodeMBCS(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
11079
 
 
11080
 
-   Encode the :ctype:`Py_UNICODE` buffer of the given *size* using MBCS and return a
11081
 
+   Encode the :c:type:`Py_UNICODE` buffer of the given *size* using MBCS and return a
11082
 
    Python string object.  Return *NULL* if an exception was raised by the codec.
11083
 
 
11084
 
    .. versionchanged:: 2.5
11085
 
-      This function used an :ctype:`int` type for *size*. This might require
11086
 
+      This function used an :c:type:`int` type for *size*. This might require
11087
 
       changes in your code for properly supporting 64-bit systems.
11088
 
 
11089
 
 
11090
 
-.. cfunction:: PyObject* PyUnicode_AsMBCSString(PyObject *unicode)
11091
 
+.. c:function:: PyObject* PyUnicode_AsMBCSString(PyObject *unicode)
11092
 
 
11093
 
    Encode a Unicode object using MBCS and return the result as Python string
11094
 
    object.  Error handling is "strict".  Return *NULL* if an exception was raised
11095
 
@@ -982,12 +987,12 @@
11096
 
 They all return *NULL* or ``-1`` if an exception occurs.
11097
 
 
11098
 
 
11099
 
-.. cfunction:: PyObject* PyUnicode_Concat(PyObject *left, PyObject *right)
11100
 
+.. c:function:: PyObject* PyUnicode_Concat(PyObject *left, PyObject *right)
11101
 
 
11102
 
    Concat two strings giving a new Unicode string.
11103
 
 
11104
 
 
11105
 
-.. cfunction:: PyObject* PyUnicode_Split(PyObject *s, PyObject *sep, Py_ssize_t maxsplit)
11106
 
+.. c:function:: PyObject* PyUnicode_Split(PyObject *s, PyObject *sep, Py_ssize_t maxsplit)
11107
 
 
11108
 
    Split a string giving a list of Unicode strings.  If *sep* is *NULL*, splitting
11109
 
    will be done at all whitespace substrings.  Otherwise, splits occur at the given
11110
 
@@ -995,18 +1000,18 @@
11111
 
    set.  Separators are not included in the resulting list.
11112
 
 
11113
 
    .. versionchanged:: 2.5
11114
 
-      This function used an :ctype:`int` type for *maxsplit*. This might require
11115
 
+      This function used an :c:type:`int` type for *maxsplit*. This might require
11116
 
       changes in your code for properly supporting 64-bit systems.
11117
 
 
11118
 
 
11119
 
-.. cfunction:: PyObject* PyUnicode_Splitlines(PyObject *s, int keepend)
11120
 
+.. c:function:: PyObject* PyUnicode_Splitlines(PyObject *s, int keepend)
11121
 
 
11122
 
    Split a Unicode string at line breaks, returning a list of Unicode strings.
11123
 
    CRLF is considered to be one line break.  If *keepend* is 0, the Line break
11124
 
    characters are not included in the resulting strings.
11125
 
 
11126
 
 
11127
 
-.. cfunction:: PyObject* PyUnicode_Translate(PyObject *str, PyObject *table, const char *errors)
11128
 
+.. c:function:: PyObject* PyUnicode_Translate(PyObject *str, PyObject *table, const char *errors)
11129
 
 
11130
 
    Translate a string by applying a character mapping table to it and return the
11131
 
    resulting Unicode object.
11132
 
@@ -1022,25 +1027,25 @@
11133
 
    use the default error handling.
11134
 
 
11135
 
 
11136
 
-.. cfunction:: PyObject* PyUnicode_Join(PyObject *separator, PyObject *seq)
11137
 
+.. c:function:: PyObject* PyUnicode_Join(PyObject *separator, PyObject *seq)
11138
 
 
11139
 
    Join a sequence of strings using the given *separator* and return the resulting
11140
 
    Unicode string.
11141
 
 
11142
 
 
11143
 
-.. cfunction:: int PyUnicode_Tailmatch(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction)
11144
 
+.. c:function:: int PyUnicode_Tailmatch(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction)
11145
 
 
11146
 
    Return 1 if *substr* matches ``str[start:end]`` at the given tail end
11147
 
    (*direction* == -1 means to do a prefix match, *direction* == 1 a suffix match),
11148
 
    0 otherwise. Return ``-1`` if an error occurred.
11149
 
 
11150
 
    .. versionchanged:: 2.5
11151
 
-      This function used an :ctype:`int` type for *start* and *end*. This
11152
 
+      This function used an :c:type:`int` type for *start* and *end*. This
11153
 
       might require changes in your code for properly supporting 64-bit
11154
 
       systems.
11155
 
 
11156
 
 
11157
 
-.. cfunction:: Py_ssize_t PyUnicode_Find(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction)
11158
 
+.. c:function:: Py_ssize_t PyUnicode_Find(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction)
11159
 
 
11160
 
    Return the first position of *substr* in ``str[start:end]`` using the given
11161
 
    *direction* (*direction* == 1 means to do a forward search, *direction* == -1 a
11162
 
@@ -1049,40 +1054,40 @@
11163
 
    occurred and an exception has been set.
11164
 
 
11165
 
    .. versionchanged:: 2.5
11166
 
-      This function used an :ctype:`int` type for *start* and *end*. This
11167
 
+      This function used an :c:type:`int` type for *start* and *end*. This
11168
 
       might require changes in your code for properly supporting 64-bit
11169
 
       systems.
11170
 
 
11171
 
 
11172
 
-.. cfunction:: Py_ssize_t PyUnicode_Count(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end)
11173
 
+.. c:function:: Py_ssize_t PyUnicode_Count(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end)
11174
 
 
11175
 
    Return the number of non-overlapping occurrences of *substr* in
11176
 
    ``str[start:end]``.  Return ``-1`` if an error occurred.
11177
 
 
11178
 
    .. versionchanged:: 2.5
11179
 
-      This function returned an :ctype:`int` type and used an :ctype:`int`
11180
 
+      This function returned an :c:type:`int` type and used an :c:type:`int`
11181
 
       type for *start* and *end*. This might require changes in your code for
11182
 
       properly supporting 64-bit systems.
11183
 
 
11184
 
 
11185
 
-.. cfunction:: PyObject* PyUnicode_Replace(PyObject *str, PyObject *substr, PyObject *replstr, Py_ssize_t maxcount)
11186
 
+.. c:function:: PyObject* PyUnicode_Replace(PyObject *str, PyObject *substr, PyObject *replstr, Py_ssize_t maxcount)
11187
 
 
11188
 
    Replace at most *maxcount* occurrences of *substr* in *str* with *replstr* and
11189
 
    return the resulting Unicode object. *maxcount* == -1 means replace all
11190
 
    occurrences.
11191
 
 
11192
 
    .. versionchanged:: 2.5
11193
 
-      This function used an :ctype:`int` type for *maxcount*. This might
11194
 
+      This function used an :c:type:`int` type for *maxcount*. This might
11195
 
       require changes in your code for properly supporting 64-bit systems.
11196
 
 
11197
 
 
11198
 
-.. cfunction:: int PyUnicode_Compare(PyObject *left, PyObject *right)
11199
 
+.. c:function:: int PyUnicode_Compare(PyObject *left, PyObject *right)
11200
 
 
11201
 
    Compare two strings and return -1, 0, 1 for less than, equal, and greater than,
11202
 
    respectively.
11203
 
 
11204
 
 
11205
 
-.. cfunction:: int PyUnicode_RichCompare(PyObject *left,  PyObject *right,  int op)
11206
 
+.. c:function:: int PyUnicode_RichCompare(PyObject *left,  PyObject *right,  int op)
11207
 
 
11208
 
    Rich compare two unicode strings and return one of the following:
11209
 
 
11210
 
@@ -1098,13 +1103,13 @@
11211
 
    :const:`Py_NE`, :const:`Py_LT`, and :const:`Py_LE`.
11212
 
 
11213
 
 
11214
 
-.. cfunction:: PyObject* PyUnicode_Format(PyObject *format, PyObject *args)
11215
 
+.. c:function:: PyObject* PyUnicode_Format(PyObject *format, PyObject *args)
11216
 
 
11217
 
    Return a new string object from *format* and *args*; this is analogous to
11218
 
    ``format % args``.  The *args* argument must be a tuple.
11219
 
 
11220
 
 
11221
 
-.. cfunction:: int PyUnicode_Contains(PyObject *container, PyObject *element)
11222
 
+.. c:function:: int PyUnicode_Contains(PyObject *container, PyObject *element)
11223
 
 
11224
 
    Check whether *element* is contained in *container* and return true or false
11225
 
    accordingly.
11226
 
diff -r 8527427914a2 Doc/c-api/veryhigh.rst
11227
 
--- a/Doc/c-api/veryhigh.rst
11228
 
+++ b/Doc/c-api/veryhigh.rst
11229
 
@@ -16,23 +16,23 @@
11230
 
 :const:`Py_file_input`, and :const:`Py_single_input`.  These are described
11231
 
 following the functions which accept them as parameters.
11232
 
 
11233
 
-Note also that several of these functions take :ctype:`FILE\*` parameters.  One
11234
 
-particular issue which needs to be handled carefully is that the :ctype:`FILE`
11235
 
+Note also that several of these functions take :c:type:`FILE\*` parameters.  One
11236
 
+particular issue which needs to be handled carefully is that the :c:type:`FILE`
11237
 
 structure for different C libraries can be different and incompatible.  Under
11238
 
 Windows (at least), it is possible for dynamically linked extensions to actually
11239
 
-use different libraries, so care should be taken that :ctype:`FILE\*` parameters
11240
 
+use different libraries, so care should be taken that :c:type:`FILE\*` parameters
11241
 
 are only passed to these functions if it is certain that they were created by
11242
 
 the same library that the Python runtime is using.
11243
 
 
11244
 
 
11245
 
-.. cfunction:: int Py_Main(int argc, char **argv)
11246
 
+.. c:function:: int Py_Main(int argc, char **argv)
11247
 
 
11248
 
    The main program for the standard interpreter.  This is made available for
11249
 
    programs which embed Python.  The *argc* and *argv* parameters should be
11250
 
-   prepared exactly as those which are passed to a C program's :cfunc:`main`
11251
 
+   prepared exactly as those which are passed to a C program's :c:func:`main`
11252
 
    function.  It is important to note that the argument list may be modified (but
11253
 
    the contents of the strings pointed to by the argument list are not). The return
11254
 
-   value will be ```0``` if the interpreter exits normally (ie, without an
11255
 
+   value will be ``0`` if the interpreter exits normally (ie, without an
11256
 
    exception), ``1`` if the interpreter exits due to an exception, or ``2``
11257
 
    if the parameter list does not represent a valid Python command line.
11258
 
 
11259
 
@@ -41,40 +41,40 @@
11260
 
    ``Py_InspectFlag`` is not set.
11261
 
 
11262
 
 
11263
 
-.. cfunction:: int PyRun_AnyFile(FILE *fp, const char *filename)
11264
 
+.. c:function:: int PyRun_AnyFile(FILE *fp, const char *filename)
11265
 
 
11266
 
-   This is a simplified interface to :cfunc:`PyRun_AnyFileExFlags` below, leaving
11267
 
+   This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, leaving
11268
 
    *closeit* set to ``0`` and *flags* set to *NULL*.
11269
 
 
11270
 
 
11271
 
-.. cfunction:: int PyRun_AnyFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
11272
 
+.. c:function:: int PyRun_AnyFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
11273
 
 
11274
 
-   This is a simplified interface to :cfunc:`PyRun_AnyFileExFlags` below, leaving
11275
 
+   This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, leaving
11276
 
    the *closeit* argument set to ``0``.
11277
 
 
11278
 
 
11279
 
-.. cfunction:: int PyRun_AnyFileEx(FILE *fp, const char *filename, int closeit)
11280
 
+.. c:function:: int PyRun_AnyFileEx(FILE *fp, const char *filename, int closeit)
11281
 
 
11282
 
-   This is a simplified interface to :cfunc:`PyRun_AnyFileExFlags` below, leaving
11283
 
+   This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, leaving
11284
 
    the *flags* argument set to *NULL*.
11285
 
 
11286
 
 
11287
 
-.. cfunction:: int PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags)
11288
 
+.. c:function:: int PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags)
11289
 
 
11290
 
    If *fp* refers to a file associated with an interactive device (console or
11291
 
    terminal input or Unix pseudo-terminal), return the value of
11292
 
-   :cfunc:`PyRun_InteractiveLoop`, otherwise return the result of
11293
 
-   :cfunc:`PyRun_SimpleFile`.  If *filename* is *NULL*, this function uses
11294
 
+   :c:func:`PyRun_InteractiveLoop`, otherwise return the result of
11295
 
+   :c:func:`PyRun_SimpleFile`.  If *filename* is *NULL*, this function uses
11296
 
    ``"???"`` as the filename.
11297
 
 
11298
 
 
11299
 
-.. cfunction:: int PyRun_SimpleString(const char *command)
11300
 
+.. c:function:: int PyRun_SimpleString(const char *command)
11301
 
 
11302
 
-   This is a simplified interface to :cfunc:`PyRun_SimpleStringFlags` below,
11303
 
+   This is a simplified interface to :c:func:`PyRun_SimpleStringFlags` below,
11304
 
    leaving the *PyCompilerFlags\** argument set to NULL.
11305
 
 
11306
 
 
11307
 
-.. cfunction:: int PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags)
11308
 
+.. c:function:: int PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags)
11309
 
 
11310
 
    Executes the Python source code from *command* in the :mod:`__main__` module
11311
 
    according to the *flags* argument. If :mod:`__main__` does not already exist, it
11312
 
@@ -87,39 +87,39 @@
11313
 
    ``Py_InspectFlag`` is not set.
11314
 
 
11315
 
 
11316
 
-.. cfunction:: int PyRun_SimpleFile(FILE *fp, const char *filename)
11317
 
+.. c:function:: int PyRun_SimpleFile(FILE *fp, const char *filename)
11318
 
 
11319
 
-   This is a simplified interface to :cfunc:`PyRun_SimpleFileExFlags` below,
11320
 
+   This is a simplified interface to :c:func:`PyRun_SimpleFileExFlags` below,
11321
 
    leaving *closeit* set to ``0`` and *flags* set to *NULL*.
11322
 
 
11323
 
 
11324
 
-.. cfunction:: int PyRun_SimpleFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
11325
 
+.. c:function:: int PyRun_SimpleFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
11326
 
 
11327
 
-   This is a simplified interface to :cfunc:`PyRun_SimpleFileExFlags` below,
11328
 
+   This is a simplified interface to :c:func:`PyRun_SimpleFileExFlags` below,
11329
 
    leaving *closeit* set to ``0``.
11330
 
 
11331
 
 
11332
 
-.. cfunction:: int PyRun_SimpleFileEx(FILE *fp, const char *filename, int closeit)
11333
 
+.. c:function:: int PyRun_SimpleFileEx(FILE *fp, const char *filename, int closeit)
11334
 
 
11335
 
-   This is a simplified interface to :cfunc:`PyRun_SimpleFileExFlags` below,
11336
 
+   This is a simplified interface to :c:func:`PyRun_SimpleFileExFlags` below,
11337
 
    leaving *flags* set to *NULL*.
11338
 
 
11339
 
 
11340
 
-.. cfunction:: int PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags)
11341
 
+.. c:function:: int PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags)
11342
 
 
11343
 
-   Similar to :cfunc:`PyRun_SimpleStringFlags`, but the Python source code is read
11344
 
+   Similar to :c:func:`PyRun_SimpleStringFlags`, but the Python source code is read
11345
 
    from *fp* instead of an in-memory string. *filename* should be the name of the
11346
 
    file.  If *closeit* is true, the file is closed before PyRun_SimpleFileExFlags
11347
 
    returns.
11348
 
 
11349
 
 
11350
 
-.. cfunction:: int PyRun_InteractiveOne(FILE *fp, const char *filename)
11351
 
+.. c:function:: int PyRun_InteractiveOne(FILE *fp, const char *filename)
11352
 
 
11353
 
-   This is a simplified interface to :cfunc:`PyRun_InteractiveOneFlags` below,
11354
 
+   This is a simplified interface to :c:func:`PyRun_InteractiveOneFlags` below,
11355
 
    leaving *flags* set to *NULL*.
11356
 
 
11357
 
 
11358
 
-.. cfunction:: int PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
11359
 
+.. c:function:: int PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
11360
 
 
11361
 
    Read and execute a single statement from a file associated with an
11362
 
    interactive device according to the *flags* argument.  The user will be
11363
 
@@ -130,34 +130,34 @@
11364
 
    :file:`Python.h`, so must be included specifically if needed.)
11365
 
 
11366
 
 
11367
 
-.. cfunction:: int PyRun_InteractiveLoop(FILE *fp, const char *filename)
11368
 
+.. c:function:: int PyRun_InteractiveLoop(FILE *fp, const char *filename)
11369
 
 
11370
 
-   This is a simplified interface to :cfunc:`PyRun_InteractiveLoopFlags` below,
11371
 
+   This is a simplified interface to :c:func:`PyRun_InteractiveLoopFlags` below,
11372
 
    leaving *flags* set to *NULL*.
11373
 
 
11374
 
 
11375
 
-.. cfunction:: int PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
11376
 
+.. c:function:: int PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
11377
 
 
11378
 
    Read and execute statements from a file associated with an interactive device
11379
 
    until EOF is reached.  The user will be prompted using ``sys.ps1`` and
11380
 
    ``sys.ps2``.  Returns ``0`` at EOF.
11381
 
 
11382
 
 
11383
 
-.. cfunction:: struct _node* PyParser_SimpleParseString(const char *str, int start)
11384
 
+.. c:function:: struct _node* PyParser_SimpleParseString(const char *str, int start)
11385
 
 
11386
 
    This is a simplified interface to
11387
 
-   :cfunc:`PyParser_SimpleParseStringFlagsFilename` below, leaving  *filename* set
11388
 
+   :c:func:`PyParser_SimpleParseStringFlagsFilename` below, leaving  *filename* set
11389
 
    to *NULL* and *flags* set to ``0``.
11390
 
 
11391
 
 
11392
 
-.. cfunction:: struct _node* PyParser_SimpleParseStringFlags( const char *str, int start, int flags)
11393
 
+.. c:function:: struct _node* PyParser_SimpleParseStringFlags( const char *str, int start, int flags)
11394
 
 
11395
 
    This is a simplified interface to
11396
 
-   :cfunc:`PyParser_SimpleParseStringFlagsFilename` below, leaving  *filename* set
11397
 
+   :c:func:`PyParser_SimpleParseStringFlagsFilename` below, leaving  *filename* set
11398
 
    to *NULL*.
11399
 
 
11400
 
 
11401
 
-.. cfunction:: struct _node* PyParser_SimpleParseStringFlagsFilename( const char *str, const char *filename, int start, int flags)
11402
 
+.. c:function:: struct _node* PyParser_SimpleParseStringFlagsFilename( const char *str, const char *filename, int start, int flags)
11403
 
 
11404
 
    Parse Python source code from *str* using the start token *start* according to
11405
 
    the *flags* argument.  The result can be used to create a code object which can
11406
 
@@ -165,25 +165,25 @@
11407
 
    many times.
11408
 
 
11409
 
 
11410
 
-.. cfunction:: struct _node* PyParser_SimpleParseFile(FILE *fp, const char *filename, int start)
11411
 
+.. c:function:: struct _node* PyParser_SimpleParseFile(FILE *fp, const char *filename, int start)
11412
 
 
11413
 
-   This is a simplified interface to :cfunc:`PyParser_SimpleParseFileFlags` below,
11414
 
+   This is a simplified interface to :c:func:`PyParser_SimpleParseFileFlags` below,
11415
 
    leaving *flags* set to ``0``
11416
 
 
11417
 
 
11418
 
-.. cfunction:: struct _node* PyParser_SimpleParseFileFlags(FILE *fp, const char *filename, int start, int flags)
11419
 
+.. c:function:: struct _node* PyParser_SimpleParseFileFlags(FILE *fp, const char *filename, int start, int flags)
11420
 
 
11421
 
-   Similar to :cfunc:`PyParser_SimpleParseStringFlagsFilename`, but the Python
11422
 
+   Similar to :c:func:`PyParser_SimpleParseStringFlagsFilename`, but the Python
11423
 
    source code is read from *fp* instead of an in-memory string.
11424
 
 
11425
 
 
11426
 
-.. cfunction:: PyObject* PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals)
11427
 
+.. c:function:: PyObject* PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals)
11428
 
 
11429
 
-   This is a simplified interface to :cfunc:`PyRun_StringFlags` below, leaving
11430
 
+   This is a simplified interface to :c:func:`PyRun_StringFlags` below, leaving
11431
 
    *flags* set to *NULL*.
11432
 
 
11433
 
 
11434
 
-.. cfunction:: PyObject* PyRun_StringFlags(const char *str, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags)
11435
 
+.. c:function:: PyObject* PyRun_StringFlags(const char *str, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags)
11436
 
 
11437
 
    Execute Python source code from *str* in the context specified by the
11438
 
    dictionaries *globals* and *locals* with the compiler flags specified by
11439
 
@@ -194,39 +194,39 @@
11440
 
    exception was raised.
11441
 
 
11442
 
 
11443
 
-.. cfunction:: PyObject* PyRun_File(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals)
11444
 
+.. c:function:: PyObject* PyRun_File(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals)
11445
 
 
11446
 
-   This is a simplified interface to :cfunc:`PyRun_FileExFlags` below, leaving
11447
 
+   This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving
11448
 
    *closeit* set to ``0`` and *flags* set to *NULL*.
11449
 
 
11450
 
 
11451
 
-.. cfunction:: PyObject* PyRun_FileEx(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit)
11452
 
+.. c:function:: PyObject* PyRun_FileEx(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit)
11453
 
 
11454
 
-   This is a simplified interface to :cfunc:`PyRun_FileExFlags` below, leaving
11455
 
+   This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving
11456
 
    *flags* set to *NULL*.
11457
 
 
11458
 
 
11459
 
-.. cfunction:: PyObject* PyRun_FileFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags)
11460
 
+.. c:function:: PyObject* PyRun_FileFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags)
11461
 
 
11462
 
-   This is a simplified interface to :cfunc:`PyRun_FileExFlags` below, leaving
11463
 
+   This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving
11464
 
    *closeit* set to ``0``.
11465
 
 
11466
 
 
11467
 
-.. cfunction:: PyObject* PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit, PyCompilerFlags *flags)
11468
 
+.. c:function:: PyObject* PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit, PyCompilerFlags *flags)
11469
 
 
11470
 
-   Similar to :cfunc:`PyRun_StringFlags`, but the Python source code is read from
11471
 
+   Similar to :c:func:`PyRun_StringFlags`, but the Python source code is read from
11472
 
    *fp* instead of an in-memory string. *filename* should be the name of the file.
11473
 
-   If *closeit* is true, the file is closed before :cfunc:`PyRun_FileExFlags`
11474
 
+   If *closeit* is true, the file is closed before :c:func:`PyRun_FileExFlags`
11475
 
    returns.
11476
 
 
11477
 
 
11478
 
-.. cfunction:: PyObject* Py_CompileString(const char *str, const char *filename, int start)
11479
 
+.. c:function:: PyObject* Py_CompileString(const char *str, const char *filename, int start)
11480
 
 
11481
 
-   This is a simplified interface to :cfunc:`Py_CompileStringFlags` below, leaving
11482
 
+   This is a simplified interface to :c:func:`Py_CompileStringFlags` below, leaving
11483
 
    *flags* set to *NULL*.
11484
 
 
11485
 
 
11486
 
-.. cfunction:: PyObject* Py_CompileStringFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags)
11487
 
+.. c:function:: PyObject* Py_CompileStringFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags)
11488
 
 
11489
 
    Parse and compile the Python source code in *str*, returning the resulting code
11490
 
    object.  The start token is given by *start*; this can be used to constrain the
11491
 
@@ -237,14 +237,14 @@
11492
 
    be parsed or compiled.
11493
 
 
11494
 
 
11495
 
-.. cfunction:: PyObject* PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals)
11496
 
+.. c:function:: PyObject* PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals)
11497
 
 
11498
 
-   This is a simplified interface to :cfunc:`PyEval_EvalCodeEx`, with just
11499
 
+   This is a simplified interface to :c:func:`PyEval_EvalCodeEx`, with just
11500
 
    the code object, and the dictionaries of global and local variables.
11501
 
    The other arguments are set to *NULL*.
11502
 
 
11503
 
 
11504
 
-.. cfunction:: PyObject* PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, PyObject **args, int argcount, PyObject **kws, int kwcount, PyObject **defs, int defcount, PyObject *closure)
11505
 
+.. c:function:: PyObject* PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, PyObject **args, int argcount, PyObject **kws, int kwcount, PyObject **defs, int defcount, PyObject *closure)
11506
 
 
11507
 
    Evaluate a precompiled code object, given a particular environment for its
11508
 
    evaluation.  This environment consists of dictionaries of global and local
11509
 
@@ -252,13 +252,13 @@
11510
 
    cells.
11511
 
 
11512
 
 
11513
 
-.. cfunction:: PyObject* PyEval_EvalFrame(PyFrameObject *f)
11514
 
+.. c:function:: PyObject* PyEval_EvalFrame(PyFrameObject *f)
11515
 
 
11516
 
    Evaluate an execution frame.  This is a simplified interface to
11517
 
    PyEval_EvalFrameEx, for backward compatibility.
11518
 
 
11519
 
 
11520
 
-.. cfunction:: PyObject* PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
11521
 
+.. c:function:: PyObject* PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
11522
 
 
11523
 
    This is the main, unvarnished function of Python interpretation.  It is
11524
 
    literally 2000 lines long.  The code object associated with the execution
11525
 
@@ -268,39 +268,39 @@
11526
 
    :meth:`throw` methods of generator objects.
11527
 
 
11528
 
 
11529
 
-.. cfunction:: int PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
11530
 
+.. c:function:: int PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
11531
 
 
11532
 
    This function changes the flags of the current evaluation frame, and returns
11533
 
    true on success, false on failure.
11534
 
 
11535
 
 
11536
 
-.. cvar:: int Py_eval_input
11537
 
+.. c:var:: int Py_eval_input
11538
 
 
11539
 
    .. index:: single: Py_CompileString()
11540
 
 
11541
 
    The start symbol from the Python grammar for isolated expressions; for use with
11542
 
-   :cfunc:`Py_CompileString`.
11543
 
+   :c:func:`Py_CompileString`.
11544
 
 
11545
 
 
11546
 
-.. cvar:: int Py_file_input
11547
 
+.. c:var:: int Py_file_input
11548
 
 
11549
 
    .. index:: single: Py_CompileString()
11550
 
 
11551
 
    The start symbol from the Python grammar for sequences of statements as read
11552
 
-   from a file or other source; for use with :cfunc:`Py_CompileString`.  This is
11553
 
+   from a file or other source; for use with :c:func:`Py_CompileString`.  This is
11554
 
    the symbol to use when compiling arbitrarily long Python source code.
11555
 
 
11556
 
 
11557
 
-.. cvar:: int Py_single_input
11558
 
+.. c:var:: int Py_single_input
11559
 
 
11560
 
    .. index:: single: Py_CompileString()
11561
 
 
11562
 
    The start symbol from the Python grammar for a single statement; for use with
11563
 
-   :cfunc:`Py_CompileString`. This is the symbol used for the interactive
11564
 
+   :c:func:`Py_CompileString`. This is the symbol used for the interactive
11565
 
    interpreter loop.
11566
 
 
11567
 
 
11568
 
-.. ctype:: struct PyCompilerFlags
11569
 
+.. c:type:: struct PyCompilerFlags
11570
 
 
11571
 
    This is the structure used to hold compiler flags.  In cases where code is only
11572
 
    being compiled, it is passed as ``int flags``, and in cases where code is being
11573
 
@@ -316,7 +316,7 @@
11574
 
       }
11575
 
 
11576
 
 
11577
 
-.. cvar:: int CO_FUTURE_DIVISION
11578
 
+.. c:var:: int CO_FUTURE_DIVISION
11579
 
 
11580
 
    This bit can be set in *flags* to cause division operator ``/`` to be
11581
 
    interpreted as "true division" according to :pep:`238`.
11582
 
diff -r 8527427914a2 Doc/c-api/weakref.rst
11583
 
--- a/Doc/c-api/weakref.rst
11584
 
+++ b/Doc/c-api/weakref.rst
11585
 
@@ -11,28 +11,28 @@
11586
 
 as much as it can.
11587
 
 
11588
 
 
11589
 
-.. cfunction:: int PyWeakref_Check(ob)
11590
 
+.. c:function:: int PyWeakref_Check(ob)
11591
 
 
11592
 
    Return true if *ob* is either a reference or proxy object.
11593
 
 
11594
 
    .. versionadded:: 2.2
11595
 
 
11596
 
 
11597
 
-.. cfunction:: int PyWeakref_CheckRef(ob)
11598
 
+.. c:function:: int PyWeakref_CheckRef(ob)
11599
 
 
11600
 
    Return true if *ob* is a reference object.
11601
 
 
11602
 
    .. versionadded:: 2.2
11603
 
 
11604
 
 
11605
 
-.. cfunction:: int PyWeakref_CheckProxy(ob)
11606
 
+.. c:function:: int PyWeakref_CheckProxy(ob)
11607
 
 
11608
 
    Return true if *ob* is a proxy object.
11609
 
 
11610
 
    .. versionadded:: 2.2
11611
 
 
11612
 
 
11613
 
-.. cfunction:: PyObject* PyWeakref_NewRef(PyObject *ob, PyObject *callback)
11614
 
+.. c:function:: PyObject* PyWeakref_NewRef(PyObject *ob, PyObject *callback)
11615
 
 
11616
 
    Return a weak reference object for the object *ob*.  This will always return
11617
 
    a new reference, but is not guaranteed to create a new object; an existing
11618
 
@@ -46,7 +46,7 @@
11619
 
    .. versionadded:: 2.2
11620
 
 
11621
 
 
11622
 
-.. cfunction:: PyObject* PyWeakref_NewProxy(PyObject *ob, PyObject *callback)
11623
 
+.. c:function:: PyObject* PyWeakref_NewProxy(PyObject *ob, PyObject *callback)
11624
 
 
11625
 
    Return a weak reference proxy object for the object *ob*.  This will always
11626
 
    return a new reference, but is not guaranteed to create a new object; an
11627
 
@@ -60,7 +60,7 @@
11628
 
    .. versionadded:: 2.2
11629
 
 
11630
 
 
11631
 
-.. cfunction:: PyObject* PyWeakref_GetObject(PyObject *ref)
11632
 
+.. c:function:: PyObject* PyWeakref_GetObject(PyObject *ref)
11633
 
 
11634
 
    Return the referenced object from a weak reference, *ref*.  If the referent is
11635
 
    no longer live, returns :const:`Py_None`.
11636
 
@@ -70,14 +70,14 @@
11637
 
    .. warning::
11638
 
 
11639
 
       This function returns a **borrowed reference** to the referenced object.
11640
 
-      This means that you should always call :cfunc:`Py_INCREF` on the object
11641
 
+      This means that you should always call :c:func:`Py_INCREF` on the object
11642
 
       except if you know that it cannot be destroyed while you are still
11643
 
       using it.
11644
 
 
11645
 
 
11646
 
-.. cfunction:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)
11647
 
+.. c:function:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)
11648
 
 
11649
 
-   Similar to :cfunc:`PyWeakref_GetObject`, but implemented as a macro that does no
11650
 
+   Similar to :c:func:`PyWeakref_GetObject`, but implemented as a macro that does no
11651
 
    error checking.
11652
 
 
11653
 
    .. versionadded:: 2.2
11654
 
diff -r 8527427914a2 Doc/conf.py
11655
 
--- a/Doc/conf.py
11656
 
+++ b/Doc/conf.py
11657
 
@@ -63,6 +63,9 @@
11658
 
 # Options for HTML output
11659
 
 # -----------------------
11660
 
 
11661
 
+html_theme = 'default'
11662
 
+html_theme_options = {'collapsiblesidebar': True}
11663
 
+
11664
 
 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
11665
 
 # using the given strftime format.
11666
 
 html_last_updated_fmt = '%b %d, %Y'
11667
 
@@ -83,7 +86,7 @@
11668
 
 }
11669
 
 
11670
 
 # Output an OpenSearch description file.
11671
 
-html_use_opensearch = 'http://docs.python.org/dev'
11672
 
+html_use_opensearch = 'http://docs.python.org/'
11673
 
 
11674
 
 # Additional static files.
11675
 
 html_static_path = ['tools/sphinxext/static']
11676
 
@@ -112,8 +115,6 @@
11677
 
      'The Python/C API', _stdauthor, 'manual'),
11678
 
     ('distutils/index', 'distutils.tex',
11679
 
      'Distributing Python Modules', _stdauthor, 'manual'),
11680
 
-    ('documenting/index', 'documenting.tex',
11681
 
-     'Documenting Python', 'Georg Brandl', 'manual'),
11682
 
     ('extending/index', 'extending.tex',
11683
 
      'Extending and Embedding Python', _stdauthor, 'manual'),
11684
 
     ('install/index', 'install.tex',
11685
 
@@ -151,7 +152,7 @@
11686
 
 latex_appendices = ['glossary', 'about', 'license', 'copyright']
11687
 
 
11688
 
 # Get LaTeX to handle Unicode correctly
11689
 
-latex_elements = {'inputenc': r'\usepackage[utf8x]{inputenc}'}
11690
 
+latex_elements = {'inputenc': r'\usepackage[utf8x]{inputenc}', 'utf8extra': ''}
11691
 
 
11692
 
 # Options for the coverage checker
11693
 
 # --------------------------------
11694
 
diff -r 8527427914a2 Doc/contents.rst
11695
 
--- a/Doc/contents.rst
11696
 
+++ b/Doc/contents.rst
11697
 
@@ -13,7 +13,6 @@
11698
 
    c-api/index.rst
11699
 
    distutils/index.rst
11700
 
    install/index.rst
11701
 
-   documenting/index.rst
11702
 
    howto/index.rst
11703
 
    faq/index.rst
11704
 
    glossary.rst
11705
 
diff -r 8527427914a2 Doc/copyright.rst
11706
 
--- a/Doc/copyright.rst
11707
 
+++ b/Doc/copyright.rst
11708
 
@@ -4,7 +4,7 @@
11709
 
 
11710
 
 Python and this documentation is:
11711
 
 
11712
 
-Copyright © 2001-2010 Python Software Foundation. All rights reserved.
11713
 
+Copyright © 2001-2012 Python Software Foundation. All rights reserved.
11714
 
 
11715
 
 Copyright © 2000 BeOpen.com. All rights reserved.
11716
 
 
11717
 
diff -r 8527427914a2 Doc/distutils/apiref.rst
11718
 
--- a/Doc/distutils/apiref.rst
11719
 
+++ b/Doc/distutils/apiref.rst
11720
 
@@ -31,8 +31,9 @@
11721
 
    +====================+================================+=============================================================+
11722
 
    | *name*             | The name of the package        | a string                                                    |
11723
 
    +--------------------+--------------------------------+-------------------------------------------------------------+
11724
 
-   | *version*          | The version number of the      | See :mod:`distutils.version`                                |
11725
 
-   |                    | package                        |                                                             |
11726
 
+   | *version*          | The version number of the      | a string                                                    |
11727
 
+   |                    | package; see                   |                                                             |
11728
 
+   |                    | :mod:`distutils.version`       |                                                             |
11729
 
    +--------------------+--------------------------------+-------------------------------------------------------------+
11730
 
    | *description*      | A single line describing the   | a string                                                    |
11731
 
    |                    | package                        |                                                             |
11732
 
@@ -49,14 +50,14 @@
11733
 
    |                    | maintainer, if different from  |                                                             |
11734
 
    |                    | the author                     |                                                             |
11735
 
    +--------------------+--------------------------------+-------------------------------------------------------------+
11736
 
-   | *maintainer_email* | The email address of the       |                                                             |
11737
 
+   | *maintainer_email* | The email address of the       | a string                                                    |
11738
 
    |                    | current maintainer, if         |                                                             |
11739
 
    |                    | different from the author      |                                                             |
11740
 
    +--------------------+--------------------------------+-------------------------------------------------------------+
11741
 
-   | *url*              | A URL for the package          | a URL                                                       |
11742
 
+   | *url*              | A URL for the package          | a string                                                    |
11743
 
    |                    | (homepage)                     |                                                             |
11744
 
    +--------------------+--------------------------------+-------------------------------------------------------------+
11745
 
-   | *download_url*     | A URL to download the package  | a URL                                                       |
11746
 
+   | *download_url*     | A URL to download the package  | a string                                                    |
11747
 
    +--------------------+--------------------------------+-------------------------------------------------------------+
11748
 
    | *packages*         | A list of Python packages that | a list of strings                                           |
11749
 
    |                    | distutils will manipulate      |                                                             |
11750
 
@@ -68,14 +69,13 @@
11751
 
    |                    | files to be built and          |                                                             |
11752
 
    |                    | installed                      |                                                             |
11753
 
    +--------------------+--------------------------------+-------------------------------------------------------------+
11754
 
-   | *ext_modules*      | A list of Python extensions to | A list of  instances of                                     |
11755
 
+   | *ext_modules*      | A list of Python extensions to | a list of instances of                                      |
11756
 
    |                    | be built                       | :class:`distutils.core.Extension`                           |
11757
 
    +--------------------+--------------------------------+-------------------------------------------------------------+
11758
 
-   | *classifiers*      | A list of categories for the   | The list of available                                       |
11759
 
-   |                    | package                        | categorizations is at                                       |
11760
 
-   |                    |                                | http://pypi.python.org/pypi?:action=list_classifiers.       |
11761
 
+   | *classifiers*      | A list of categories for the   | a list of strings; valid classifiers are listed on `PyPI    |
11762
 
+   |                    | package                        | <http://pypi.python.org/pypi?:action=list_classifiers>`_.   |
11763
 
    +--------------------+--------------------------------+-------------------------------------------------------------+
11764
 
-   | *distclass*        | the :class:`Distribution`      | A subclass of                                               |
11765
 
+   | *distclass*        | the :class:`Distribution`      | a subclass of                                               |
11766
 
    |                    | class to use                   | :class:`distutils.core.Distribution`                        |
11767
 
    +--------------------+--------------------------------+-------------------------------------------------------------+
11768
 
    | *script_name*      | The name of the setup.py       | a string                                                    |
11769
 
@@ -85,15 +85,15 @@
11770
 
    | *script_args*      | Arguments to supply to the     | a list of strings                                           |
11771
 
    |                    | setup script                   |                                                             |
11772
 
    +--------------------+--------------------------------+-------------------------------------------------------------+
11773
 
-   | *options*          | default options for the setup  | a string                                                    |
11774
 
+   | *options*          | default options for the setup  | a dictionary                                                |
11775
 
    |                    | script                         |                                                             |
11776
 
    +--------------------+--------------------------------+-------------------------------------------------------------+
11777
 
    | *license*          | The license for the package    | a string                                                    |
11778
 
    +--------------------+--------------------------------+-------------------------------------------------------------+
11779
 
-   | *keywords*         | Descriptive meta-data, see     |                                                             |
11780
 
+   | *keywords*         | Descriptive meta-data, see     | a list of strings or a comma-separated string               |
11781
 
    |                    | :pep:`314`                     |                                                             |
11782
 
    +--------------------+--------------------------------+-------------------------------------------------------------+
11783
 
-   | *platforms*        |                                |                                                             |
11784
 
+   | *platforms*        |                                | a list of strings or a comma-separated string               |
11785
 
    +--------------------+--------------------------------+-------------------------------------------------------------+
11786
 
    | *cmdclass*         | A mapping of command names to  | a dictionary                                                |
11787
 
    |                    | :class:`Command` subclasses    |                                                             |
11788
 
@@ -165,13 +165,13 @@
11789
 
    +------------------------+--------------------------------+---------------------------+
11790
 
    | argument name          | value                          | type                      |
11791
 
    +========================+================================+===========================+
11792
 
-   | *name*                 | the full name of the           | string                    |
11793
 
+   | *name*                 | the full name of the           | a string                  |
11794
 
    |                        | extension, including any       |                           |
11795
 
    |                        | packages --- ie. *not* a       |                           |
11796
 
    |                        | filename or pathname, but      |                           |
11797
 
    |                        | Python dotted name             |                           |
11798
 
    +------------------------+--------------------------------+---------------------------+
11799
 
-   | *sources*              | list of source filenames,      | string                    |
11800
 
+   | *sources*              | list of source filenames,      | a list of strings         |
11801
 
    |                        | relative to the distribution   |                           |
11802
 
    |                        | root (where the setup script   |                           |
11803
 
    |                        | lives), in Unix form (slash-   |                           |
11804
 
@@ -184,12 +184,12 @@
11805
 
    |                        | as source for a Python         |                           |
11806
 
    |                        | extension.                     |                           |
11807
 
    +------------------------+--------------------------------+---------------------------+
11808
 
-   | *include_dirs*         | list of directories to search  | string                    |
11809
 
+   | *include_dirs*         | list of directories to search  | a list of strings         |
11810
 
    |                        | for C/C++ header files (in     |                           |
11811
 
    |                        | Unix form for portability)     |                           |
11812
 
    +------------------------+--------------------------------+---------------------------+
11813
 
-   | *define_macros*        | list of macros to define; each | (string, string) tuple or |
11814
 
-   |                        | macro is defined using a       | (name, ``None``)          |
11815
 
+   | *define_macros*        | list of macros to define; each | a list of tuples          |
11816
 
+   |                        | macro is defined using a       |                           |
11817
 
    |                        | 2-tuple ``(name, value)``,     |                           |
11818
 
    |                        | where *value* is               |                           |
11819
 
    |                        | either the string to define it |                           |
11820
 
@@ -200,31 +200,31 @@
11821
 
    |                        | on Unix C compiler command     |                           |
11822
 
    |                        | line)                          |                           |
11823
 
    +------------------------+--------------------------------+---------------------------+
11824
 
-   | *undef_macros*         | list of macros to undefine     | string                    |
11825
 
+   | *undef_macros*         | list of macros to undefine     | a list of strings         |
11826
 
    |                        | explicitly                     |                           |
11827
 
    +------------------------+--------------------------------+---------------------------+
11828
 
-   | *library_dirs*         | list of directories to search  | string                    |
11829
 
+   | *library_dirs*         | list of directories to search  | a list of strings         |
11830
 
    |                        | for C/C++ libraries at link    |                           |
11831
 
    |                        | time                           |                           |
11832
 
    +------------------------+--------------------------------+---------------------------+
11833
 
-   | *libraries*            | list of library names (not     | string                    |
11834
 
+   | *libraries*            | list of library names (not     | a list of strings         |
11835
 
    |                        | filenames or paths) to link    |                           |
11836
 
    |                        | against                        |                           |
11837
 
    +------------------------+--------------------------------+---------------------------+
11838
 
-   | *runtime_library_dirs* | list of directories to search  | string                    |
11839
 
+   | *runtime_library_dirs* | list of directories to search  | a list of strings         |
11840
 
    |                        | for C/C++ libraries at run     |                           |
11841
 
    |                        | time (for shared extensions,   |                           |
11842
 
    |                        | this is when the extension is  |                           |
11843
 
    |                        | loaded)                        |                           |
11844
 
    +------------------------+--------------------------------+---------------------------+
11845
 
-   | *extra_objects*        | list of extra files to link    | string                    |
11846
 
+   | *extra_objects*        | list of extra files to link    | a list of strings         |
11847
 
    |                        | with (eg. object files not     |                           |
11848
 
    |                        | implied by 'sources', static   |                           |
11849
 
    |                        | library that must be           |                           |
11850
 
    |                        | explicitly specified, binary   |                           |
11851
 
    |                        | resource files, etc.)          |                           |
11852
 
    +------------------------+--------------------------------+---------------------------+
11853
 
-   | *extra_compile_args*   | any extra platform- and        | string                    |
11854
 
+   | *extra_compile_args*   | any extra platform- and        | a list of strings         |
11855
 
    |                        | compiler-specific information  |                           |
11856
 
    |                        | to use when compiling the      |                           |
11857
 
    |                        | source files in 'sources'. For |                           |
11858
 
@@ -235,7 +235,7 @@
11859
 
    |                        | for other platforms it could   |                           |
11860
 
    |                        | be anything.                   |                           |
11861
 
    +------------------------+--------------------------------+---------------------------+
11862
 
-   | *extra_link_args*      | any extra platform- and        | string                    |
11863
 
+   | *extra_link_args*      | any extra platform- and        | a list of strings         |
11864
 
    |                        | compiler-specific information  |                           |
11865
 
    |                        | to use when linking object     |                           |
11866
 
    |                        | files together to create the   |                           |
11867
 
@@ -244,7 +244,7 @@
11868
 
    |                        | Similar interpretation as for  |                           |
11869
 
    |                        | 'extra_compile_args'.          |                           |
11870
 
    +------------------------+--------------------------------+---------------------------+
11871
 
-   | *export_symbols*       | list of symbols to be exported | string                    |
11872
 
+   | *export_symbols*       | list of symbols to be exported | a list of strings         |
11873
 
    |                        | from a shared extension. Not   |                           |
11874
 
    |                        | used on all platforms, and not |                           |
11875
 
    |                        | generally necessary for Python |                           |
11876
 
@@ -252,10 +252,10 @@
11877
 
    |                        | export exactly one symbol:     |                           |
11878
 
    |                        | ``init`` + extension_name.     |                           |
11879
 
    +------------------------+--------------------------------+---------------------------+
11880
 
-   | *depends*              | list of files that the         | string                    |
11881
 
+   | *depends*              | list of files that the         | a list of strings         |
11882
 
    |                        | extension depends on           |                           |
11883
 
    +------------------------+--------------------------------+---------------------------+
11884
 
-   | *language*             | extension language (i.e.       | string                    |
11885
 
+   | *language*             | extension language (i.e.       | a string                  |
11886
 
    |                        | ``'c'``, ``'c++'``,            |                           |
11887
 
    |                        | ``'objc'``). Will be detected  |                           |
11888
 
    |                        | from the source extensions if  |                           |
11889
 
@@ -1736,7 +1736,7 @@
11890
 
    Set final values for all the options that this command supports. This is
11891
 
    always called as late as possible, ie.  after any option assignments from the
11892
 
    command-line or from other commands have been done.  Thus, this is the place
11893
 
-   to to code option dependencies: if *foo* depends on *bar*, then it is safe to
11894
 
+   to code option dependencies: if *foo* depends on *bar*, then it is safe to
11895
 
    set *foo* from *bar* as long as *foo* still has the same value it was
11896
 
    assigned in :meth:`initialize_options`.
11897
 
 
11898
 
@@ -1815,7 +1815,7 @@
11899
 
 .. module:: distutils.command.bdist_msi
11900
 
    :synopsis: Build a binary distribution as a Windows MSI file
11901
 
 
11902
 
-.. class:: bdist_msi(Command)
11903
 
+.. class:: bdist_msi
11904
 
 
11905
 
    Builds a `Windows Installer`_ (.msi) binary package.
11906
 
 
11907
 
diff -r 8527427914a2 Doc/distutils/builtdist.rst
11908
 
--- a/Doc/distutils/builtdist.rst
11909
 
+++ b/Doc/distutils/builtdist.rst
11910
 
@@ -426,7 +426,7 @@
11911
 
 
11912
 
    Which folders are available depends on the exact Windows version, and probably
11913
 
    also the configuration.  For details refer to Microsoft's documentation of the
11914
 
-   :cfunc:`SHGetSpecialFolderPath` function.
11915
 
+   :c:func:`SHGetSpecialFolderPath` function.
11916
 
 
11917
 
 
11918
 
 .. function:: create_shortcut(target, description, filename[, arguments[, workdir[, iconpath[, iconindex]]]])
11919
 
diff -r 8527427914a2 Doc/distutils/introduction.rst
11920
 
--- a/Doc/distutils/introduction.rst
11921
 
+++ b/Doc/distutils/introduction.rst
11922
 
@@ -79,11 +79,17 @@
11923
 
   for an example)
11924
 
 
11925
 
 To create a source distribution for this module, you would create a setup
11926
 
-script, :file:`setup.py`, containing the above code, and run::
11927
 
+script, :file:`setup.py`, containing the above code, and run this command from a
11928
 
+terminal::
11929
 
 
11930
 
    python setup.py sdist
11931
 
 
11932
 
-which will create an archive file (e.g., tarball on Unix, ZIP file on Windows)
11933
 
+For Windows, open a command prompt windows (:menuselection:`Start -->
11934
 
+Accessories`) and change the command to::
11935
 
+
11936
 
+   setup.py sdist
11937
 
+
11938
 
+:command:`sdist` will create an archive file (e.g., tarball on Unix, ZIP file on Windows)
11939
 
 containing your setup script :file:`setup.py`, and your module :file:`foo.py`.
11940
 
 The archive file will be named :file:`foo-1.0.tar.gz` (or :file:`.zip`), and
11941
 
 will unpack into a directory :file:`foo-1.0`.
11942
 
diff -r 8527427914a2 Doc/distutils/setupscript.rst
11943
 
--- a/Doc/distutils/setupscript.rst
11944
 
+++ b/Doc/distutils/setupscript.rst
11945
 
@@ -72,7 +72,7 @@
11946
 
 promising that the Distutils will find a file :file:`foo/__init__.py` (which
11947
 
 might be spelled differently on your system, but you get the idea) relative to
11948
 
 the directory where your setup script lives.  If you break this promise, the
11949
 
-Distutils will issue a warning but still process the broken package anyways.
11950
 
+Distutils will issue a warning but still process the broken package anyway.
11951
 
 
11952
 
 If you use a different convention to lay out your source directory, that's no
11953
 
 problem: you just have to supply the :option:`package_dir` option to tell the
11954
 
@@ -254,7 +254,7 @@
11955
 
 
11956
 
 If you need to include header files from some other Python extension, you can
11957
 
 take advantage of the fact that header files are installed in a consistent way
11958
 
-by the Distutils :command:`install_header` command.  For example, the Numerical
11959
 
+by the Distutils :command:`install_headers` command.  For example, the Numerical
11960
 
 Python header files are installed (on a standard Unix installation) to
11961
 
 :file:`/usr/local/include/python1.5/Numerical`. (The exact location will differ
11962
 
 according to your platform and Python installation.)  Since the Python include
11963
 
@@ -334,10 +334,6 @@
11964
 
 
11965
 
 There are still some other options which can be used to handle special cases.
11966
 
 
11967
 
-The :option:`optional` option is a boolean; if it is true,
11968
 
-a build failure in the extension will not abort the build process, but
11969
 
-instead simply not install the failing extension.
11970
 
-
11971
 
 The :option:`extra_objects` option is a list of object files to be passed to the
11972
 
 linker. These files must not have extensions, as the default extension for the
11973
 
 compiler is used.
11974
 
diff -r 8527427914a2 Doc/distutils/sourcedist.rst
11975
 
--- a/Doc/distutils/sourcedist.rst
11976
 
+++ b/Doc/distutils/sourcedist.rst
11977
 
@@ -111,12 +111,22 @@
11978
 
 :file:`MANIFEST`, you must specify everything: the default set of files
11979
 
 described above does not apply in this case.
11980
 
 
11981
 
-.. versionadded:: 2.7
11982
 
+.. versionchanged:: 2.7
11983
 
+   An existing generated :file:`MANIFEST` will be regenerated without
11984
 
+   :command:`sdist` comparing its modification time to the one of
11985
 
+   :file:`MANIFEST.in` or :file:`setup.py`.
11986
 
+
11987
 
+.. versionchanged:: 2.7.1
11988
 
    :file:`MANIFEST` files start with a comment indicating they are generated.
11989
 
    Files without this comment are not overwritten or removed.
11990
 
 
11991
 
+.. versionchanged:: 2.7.3
11992
 
+   :command:`sdist` will read a :file:`MANIFEST` file if no :file:`MANIFEST.in`
11993
 
+   exists, like it did before 2.7.
11994
 
+
11995
 
 See :ref:`manifest_template` section for a syntax reference.
11996
 
 
11997
 
+
11998
 
 .. _manifest-options:
11999
 
 
12000
 
 Manifest-related options
12001
 
@@ -124,16 +134,16 @@
12002
 
 
12003
 
 The normal course of operations for the :command:`sdist` command is as follows:
12004
 
 
12005
 
-* if the manifest file, :file:`MANIFEST` doesn't exist, read :file:`MANIFEST.in`
12006
 
-  and create the manifest
12007
 
+* if the manifest file (:file:`MANIFEST` by default) exists and the first line
12008
 
+  does not have a comment indicating it is generated from :file:`MANIFEST.in`,
12009
 
+  then it is used as is, unaltered
12010
 
+
12011
 
+* if the manifest file doesn't exist or has been previously automatically
12012
 
+  generated, read :file:`MANIFEST.in` and create the manifest
12013
 
 
12014
 
 * if neither :file:`MANIFEST` nor :file:`MANIFEST.in` exist, create a manifest
12015
 
   with just the default file set
12016
 
 
12017
 
-* if either :file:`MANIFEST.in` or the setup script (:file:`setup.py`) are more
12018
 
-  recent than :file:`MANIFEST`, recreate :file:`MANIFEST` by reading
12019
 
-  :file:`MANIFEST.in`
12020
 
-
12021
 
 * use the list of files now in :file:`MANIFEST` (either just generated or read
12022
 
   in) to create the source distribution archive(s)
12023
 
 
12024
 
@@ -271,8 +281,3 @@
12025
 
 ``a-z``, ``a-zA-Z``, ``a-f0-9_.``).  The definition of "regular filename
12026
 
 character" is platform-specific: on Unix it is anything except slash; on Windows
12027
 
 anything except backslash or colon.
12028
 
-
12029
 
-.. versionchanged:: 2.7
12030
 
-    An existing generated :file:`MANIFEST` will be regenerated without
12031
 
-    :command:`sdist` comparing its modification time to the one of
12032
 
-    :file:`MANIFEST.in` or :file:`setup.py`.
12033
 
diff -r 8527427914a2 Doc/documenting/building.rst
12034
 
--- a/Doc/documenting/building.rst
12035
 
+++ /dev/null
12036
 
@@ -1,91 +0,0 @@
12037
 
-Building the documentation
12038
 
-==========================
12039
 
-
12040
 
-You need to have Python 2.4 or higher installed; the toolset used to build the
12041
 
-docs is written in Python.  It is called *Sphinx*, it is not included in this
12042
 
-tree, but maintained separately.  Also needed are the docutils, supplying the
12043
 
-base markup that Sphinx uses, Jinja, a templating engine, and optionally
12044
 
-Pygments, a code highlighter.
12045
 
-
12046
 
-
12047
 
-Using make
12048
 
-----------
12049
 
-
12050
 
-Luckily, a Makefile has been prepared so that on Unix, provided you have
12051
 
-installed Python and Subversion, you can just run ::
12052
 
-
12053
 
-   make html
12054
 
-
12055
 
-to check out the necessary toolset in the `tools/` subdirectory and build the
12056
 
-HTML output files.  To view the generated HTML, point your favorite browser at
12057
 
-the top-level index `build/html/index.html` after running "make".
12058
 
-
12059
 
-Available make targets are:
12060
 
-
12061
 
- * "html", which builds standalone HTML files for offline viewing.
12062
 
-
12063
 
- * "htmlhelp", which builds HTML files and a HTML Help project file usable to
12064
 
-   convert them into a single Compiled HTML (.chm) file -- these are popular
12065
 
-   under Microsoft Windows, but very handy on every platform.
12066
 
-
12067
 
-   To create the CHM file, you need to run the Microsoft HTML Help Workshop
12068
 
-   over the generated project (.hhp) file.
12069
 
-
12070
 
- * "latex", which builds LaTeX source files as input to "pdflatex" to produce
12071
 
-   PDF documents.
12072
 
-
12073
 
- * "text", which builds a plain text file for each source file.
12074
 
-
12075
 
- * "linkcheck", which checks all external references to see whether they are
12076
 
-   broken, redirected or malformed, and outputs this information to stdout
12077
 
-   as well as a plain-text (.txt) file.
12078
 
-
12079
 
- * "changes", which builds an overview over all versionadded/versionchanged/
12080
 
-   deprecated items in the current version. This is meant as a help for the
12081
 
-   writer of the "What's New" document.
12082
 
-
12083
 
- * "coverage", which builds a coverage overview for standard library modules
12084
 
-   and C API.
12085
 
-
12086
 
- * "pydoc-topics", which builds a Python module containing a dictionary with
12087
 
-   plain text documentation for the labels defined in
12088
 
-   `tools/sphinxext/pyspecific.py` -- pydoc needs these to show topic and
12089
 
-   keyword help.
12090
 
-
12091
 
-A "make update" updates the Subversion checkouts in `tools/`.
12092
 
-
12093
 
-
12094
 
-Without make
12095
 
-------------
12096
 
-
12097
 
-You'll need to install the Sphinx package, either by checking it out via ::
12098
 
-
12099
 
-   svn co http://svn.python.org/projects/external/Sphinx-0.6.5/sphinx tools/sphinx
12100
 
-
12101
 
-or by installing it from PyPI.
12102
 
-
12103
 
-Then, you need to install Docutils, either by checking it out via ::
12104
 
-
12105
 
-   svn co http://svn.python.org/projects/external/docutils-0.6/docutils tools/docutils
12106
 
-
12107
 
-or by installing it from http://docutils.sf.net/.
12108
 
-
12109
 
-You also need Jinja2, either by checking it out via ::
12110
 
-
12111
 
-   svn co http://svn.python.org/projects/external/Jinja-2.3.1/jinja2 tools/jinja2
12112
 
-
12113
 
-or by installing it from PyPI.
12114
 
-
12115
 
-You can optionally also install Pygments, either as a checkout via ::
12116
 
-
12117
 
-   svn co http://svn.python.org/projects/external/Pygments-1.3.1/pygments tools/pygments
12118
 
-
12119
 
-or from PyPI at http://pypi.python.org/pypi/Pygments.
12120
 
-
12121
 
-
12122
 
-Then, make an output directory, e.g. under `build/`, and run ::
12123
 
-
12124
 
-   python tools/sphinx-build.py -b<builder> . build/<outputdirectory>
12125
 
-
12126
 
-where `<builder>` is one of html, text, latex, or htmlhelp (for explanations see
12127
 
-the make targets above).
12128
 
diff -r 8527427914a2 Doc/documenting/fromlatex.rst
12129
 
--- a/Doc/documenting/fromlatex.rst
12130
 
+++ /dev/null
12131
 
@@ -1,202 +0,0 @@
12132
 
-.. highlightlang:: rest
12133
 
-
12134
 
-Differences to the LaTeX markup
12135
 
-===============================
12136
 
-
12137
 
-Though the markup language is different, most of the concepts and markup types
12138
 
-of the old LaTeX docs have been kept -- environments as reST directives, inline
12139
 
-commands as reST roles and so forth.
12140
 
-
12141
 
-However, there are some differences in the way these work, partly due to the
12142
 
-differences in the markup languages, partly due to improvements in Sphinx.  This
12143
 
-section lists these differences, in order to give those familiar with the old
12144
 
-format a quick overview of what they might run into.
12145
 
-
12146
 
-Inline markup
12147
 
--------------
12148
 
-
12149
 
-These changes have been made to inline markup:
12150
 
-
12151
 
-* **Cross-reference roles**
12152
 
-
12153
 
-  Most of the following semantic roles existed previously as inline commands,
12154
 
-  but didn't do anything except formatting the content as code.  Now, they
12155
 
-  cross-reference to known targets (some names have also been shortened):
12156
 
-
12157
 
-  | *mod* (previously *refmodule* or *module*)
12158
 
-  | *func* (previously *function*)
12159
 
-  | *data* (new)
12160
 
-  | *const*
12161
 
-  | *class*
12162
 
-  | *meth* (previously *method*)
12163
 
-  | *attr* (previously *member*)
12164
 
-  | *exc* (previously *exception*)
12165
 
-  | *cdata*
12166
 
-  | *cfunc* (previously *cfunction*)
12167
 
-  | *cmacro* (previously *csimplemacro*)
12168
 
-  | *ctype*
12169
 
-
12170
 
-  Also different is the handling of *func* and *meth*: while previously
12171
 
-  parentheses were added to the callable name (like ``\func{str()}``), they are
12172
 
-  now appended by the build system -- appending them in the source will result
12173
 
-  in double parentheses.  This also means that ``:func:`str(object)``` will not
12174
 
-  work as expected -- use ````str(object)```` instead!
12175
 
-
12176
 
-* **Inline commands implemented as directives**
12177
 
-
12178
 
-  These were inline commands in LaTeX, but are now directives in reST:
12179
 
-
12180
 
-  | *deprecated*
12181
 
-  | *versionadded*
12182
 
-  | *versionchanged*
12183
 
-
12184
 
-  These are used like so::
12185
 
-
12186
 
-     .. deprecated:: 2.5
12187
 
-        Reason of deprecation.
12188
 
-
12189
 
-  Also, no period is appended to the text for *versionadded* and
12190
 
-  *versionchanged*.
12191
 
-
12192
 
-  | *note*
12193
 
-  | *warning*
12194
 
-
12195
 
-  These are used like so::
12196
 
-
12197
 
-     .. note::
12198
 
-
12199
 
-        Content of note.
12200
 
-
12201
 
-* **Otherwise changed commands**
12202
 
-
12203
 
-  The *samp* command previously formatted code and added quotation marks around
12204
 
-  it.  The *samp* role, however, features a new highlighting system just like
12205
 
-  *file* does:
12206
 
-
12207
 
-     ``:samp:`open({filename}, {mode})``` results in :samp:`open({filename}, {mode})`
12208
 
-
12209
 
-* **Dropped commands**
12210
 
-
12211
 
-  These were commands in LaTeX, but are not available as roles:
12212
 
-
12213
 
-  | *bfcode*
12214
 
-  | *character* (use :samp:`\`\`'c'\`\``)
12215
 
-  | *citetitle* (use ```Title <URL>`_``)
12216
 
-  | *code* (use ````code````)
12217
 
-  | *email* (just write the address in body text)
12218
 
-  | *filenq*
12219
 
-  | *filevar* (use the ``{...}`` highlighting feature of *file*)
12220
 
-  | *programopt*, *longprogramopt* (use *option*)
12221
 
-  | *ulink* (use ```Title <URL>`_``)
12222
 
-  | *url* (just write the URL in body text)
12223
 
-  | *var* (use ``*var*``)
12224
 
-  | *infinity*, *plusminus* (use the Unicode character)
12225
 
-  | *shortversion*, *version* (use the ``|version|`` and ``|release|`` substitutions)
12226
 
-  | *emph*, *strong* (use the reST markup)
12227
 
-
12228
 
-* **Backslash escaping**
12229
 
-
12230
 
-  In reST, a backslash must be escaped in normal text, and in the content of
12231
 
-  roles.  However, in code literals and literal blocks, it must not be escaped.
12232
 
-  Example: ``:file:`C:\\Temp\\my.tmp``` vs. ````open("C:\Temp\my.tmp")````.
12233
 
-
12234
 
-
12235
 
-Information units
12236
 
------------------
12237
 
-
12238
 
-Information units (*...desc* environments) have been made reST directives.
12239
 
-These changes to information units should be noted:
12240
 
-
12241
 
-* **New names**
12242
 
-
12243
 
-  "desc" has been removed from every name.  Additionally, these directives have
12244
 
-  new names:
12245
 
-
12246
 
-  | *cfunction* (previously *cfuncdesc*)
12247
 
-  | *cmacro* (previously *csimplemacrodesc*)
12248
 
-  | *exception* (previously *excdesc*)
12249
 
-  | *function* (previously *funcdesc*)
12250
 
-  | *attribute* (previously *memberdesc*)
12251
 
-
12252
 
-  The *classdesc\** and *excclassdesc* environments have been dropped, the
12253
 
-  *class* and *exception* directives support classes documented with and without
12254
 
-  constructor arguments.
12255
 
-
12256
 
-* **Multiple objects**
12257
 
-
12258
 
-  The equivalent of the *...line* commands is::
12259
 
-
12260
 
-     .. function:: do_foo(bar)
12261
 
-                   do_bar(baz)
12262
 
-
12263
 
-        Description of the functions.
12264
 
-
12265
 
-  IOW, just give one signatures per line, at the same indentation level.
12266
 
-
12267
 
-* **Arguments**
12268
 
-
12269
 
-  There is no *optional* command.  Just give function signatures like they
12270
 
-  should appear in the output::
12271
 
-
12272
 
-     .. function:: open(filename[, mode[, buffering]])
12273
 
-
12274
 
-        Description.
12275
 
-
12276
 
-  Note: markup in the signature is not supported.
12277
 
-
12278
 
-* **Indexing**
12279
 
-
12280
 
-  The *...descni* environments have been dropped.  To mark an information unit
12281
 
-  as unsuitable for index entry generation, use the *noindex* option like so::
12282
 
-
12283
 
-     .. function:: foo_*
12284
 
-        :noindex:
12285
 
-
12286
 
-        Description.
12287
 
-
12288
 
-* **New information units**
12289
 
-
12290
 
-  There are new generic information units: One is called "describe" and can be
12291
 
-  used to document things that are not covered by the other units::
12292
 
-
12293
 
-     .. describe:: a == b
12294
 
-
12295
 
-        The equals operator.
12296
 
-
12297
 
-  The others are::
12298
 
-
12299
 
-     .. cmdoption:: -O
12300
 
-
12301
 
-        Describes a command-line option.
12302
 
-
12303
 
-     .. envvar:: PYTHONINSPECT
12304
 
-
12305
 
-        Describes an environment variable.
12306
 
-
12307
 
-
12308
 
-Structure
12309
 
----------
12310
 
-
12311
 
-The LaTeX docs were split in several toplevel manuals.  Now, all files are part
12312
 
-of the same documentation tree, as indicated by the *toctree* directives in the
12313
 
-sources (though individual output formats may choose to split them up into parts
12314
 
-again).  Every *toctree* directive embeds other files as subdocuments of the
12315
 
-current file (this structure is not necessarily mirrored in the filesystem
12316
 
-layout).  The toplevel file is :file:`contents.rst`.
12317
 
-
12318
 
-However, most of the old directory structure has been kept, with the
12319
 
-directories renamed as follows:
12320
 
-
12321
 
-* :file:`api` -> :file:`c-api`
12322
 
-* :file:`dist` -> :file:`distutils`, with the single TeX file split up
12323
 
-* :file:`doc` -> :file:`documenting`
12324
 
-* :file:`ext` -> :file:`extending`
12325
 
-* :file:`inst` -> :file:`installing`
12326
 
-* :file:`lib` -> :file:`library`
12327
 
-* :file:`mac` -> merged into :file:`library`, with :file:`mac/using.tex`
12328
 
-  moved to :file:`using/mac.rst`
12329
 
-* :file:`ref` -> :file:`reference`
12330
 
-* :file:`tut` -> :file:`tutorial`, with the single TeX file split up
12331
 
-
12332
 
-
12333
 
-.. XXX more (index-generating, production lists, ...)
12334
 
diff -r 8527427914a2 Doc/documenting/index.rst
12335
 
--- a/Doc/documenting/index.rst
12336
 
+++ /dev/null
12337
 
@@ -1,38 +0,0 @@
12338
 
-.. _documenting-index:
12339
 
-
12340
 
-######################
12341
 
-  Documenting Python
12342
 
-######################
12343
 
-
12344
 
-
12345
 
-The Python language has a substantial body of documentation, much of it
12346
 
-contributed by various authors. The markup used for the Python documentation is
12347
 
-`reStructuredText`_, developed by the `docutils`_ project, amended by custom
12348
 
-directives and using a toolset named `Sphinx`_ to postprocess the HTML output.
12349
 
-
12350
 
-This document describes the style guide for our documentation as well as the
12351
 
-custom reStructuredText markup introduced by Sphinx to support Python
12352
 
-documentation and how it should be used.
12353
 
-
12354
 
-.. _reStructuredText: http://docutils.sf.net/rst.html
12355
 
-.. _docutils: http://docutils.sf.net/
12356
 
-.. _Sphinx: http://sphinx.pocoo.org/
12357
 
-
12358
 
-.. note::
12359
 
-
12360
 
-   If you're interested in contributing to Python's documentation, there's no
12361
 
-   need to write reStructuredText if you're not so inclined; plain text
12362
 
-   contributions are more than welcome as well.  Send an e-mail to
12363
 
-   docs@python.org or open an issue on the :ref:`tracker <reporting-bugs>`.
12364
 
-
12365
 
-
12366
 
-.. toctree::
12367
 
-   :numbered:
12368
 
-   :maxdepth: 1
12369
 
-
12370
 
-   intro.rst
12371
 
-   style.rst
12372
 
-   rest.rst
12373
 
-   markup.rst
12374
 
-   fromlatex.rst
12375
 
-   building.rst
12376
 
diff -r 8527427914a2 Doc/documenting/intro.rst
12377
 
--- a/Doc/documenting/intro.rst
12378
 
+++ /dev/null
12379
 
@@ -1,29 +0,0 @@
12380
 
-Introduction
12381
 
-============
12382
 
-
12383
 
-Python's documentation has long been considered to be good for a free
12384
 
-programming language.  There are a number of reasons for this, the most
12385
 
-important being the early commitment of Python's creator, Guido van Rossum, to
12386
 
-providing documentation on the language and its libraries, and the continuing
12387
 
-involvement of the user community in providing assistance for creating and
12388
 
-maintaining documentation.
12389
 
-
12390
 
-The involvement of the community takes many forms, from authoring to bug reports
12391
 
-to just plain complaining when the documentation could be more complete or
12392
 
-easier to use.
12393
 
-
12394
 
-This document is aimed at authors and potential authors of documentation for
12395
 
-Python.  More specifically, it is for people contributing to the standard
12396
 
-documentation and developing additional documents using the same tools as the
12397
 
-standard documents.  This guide will be less useful for authors using the Python
12398
 
-documentation tools for topics other than Python, and less useful still for
12399
 
-authors not using the tools at all.
12400
 
-
12401
 
-If your interest is in contributing to the Python documentation, but you don't
12402
 
-have the time or inclination to learn reStructuredText and the markup structures
12403
 
-documented here, there's a welcoming place for you among the Python contributors
12404
 
-as well.  Any time you feel that you can clarify existing documentation or
12405
 
-provide documentation that's missing, the existing documentation team will
12406
 
-gladly work with you to integrate your text, dealing with the markup for you.
12407
 
-Please don't let the material in this document stand between the documentation
12408
 
-and your desire to help out!
12409
 
\ No newline at end of file
12410
 
diff -r 8527427914a2 Doc/documenting/markup.rst
12411
 
--- a/Doc/documenting/markup.rst
12412
 
+++ /dev/null
12413
 
@@ -1,857 +0,0 @@
12414
 
-.. highlightlang:: rest
12415
 
-
12416
 
-Additional Markup Constructs
12417
 
-============================
12418
 
-
12419
 
-Sphinx adds a lot of new directives and interpreted text roles to standard reST
12420
 
-markup.  This section contains the reference material for these facilities.
12421
 
-Documentation for "standard" reST constructs is not included here, though
12422
 
-they are used in the Python documentation.
12423
 
-
12424
 
-.. note::
12425
 
-
12426
 
-   This is just an overview of Sphinx' extended markup capabilities; full
12427
 
-   coverage can be found in `its own documentation
12428
 
-   <http://sphinx.pocoo.org/contents.html>`_.
12429
 
-
12430
 
-
12431
 
-Meta-information markup
12432
 
------------------------
12433
 
-
12434
 
-.. describe:: sectionauthor
12435
 
-
12436
 
-   Identifies the author of the current section.  The argument should include
12437
 
-   the author's name such that it can be used for presentation (though it isn't)
12438
 
-   and email address.  The domain name portion of the address should be lower
12439
 
-   case.  Example::
12440
 
-
12441
 
-      .. sectionauthor:: Guido van Rossum <guido@python.org>
12442
 
-
12443
 
-   Currently, this markup isn't reflected in the output in any way, but it helps
12444
 
-   keep track of contributions.
12445
 
-
12446
 
-
12447
 
-Module-specific markup
12448
 
-----------------------
12449
 
-
12450
 
-The markup described in this section is used to provide information about a
12451
 
-module being documented.  Each module should be documented in its own file.
12452
 
-Normally this markup appears after the title heading of that file; a typical
12453
 
-file might start like this::
12454
 
-
12455
 
-   :mod:`parrot` -- Dead parrot access
12456
 
-   ===================================
12457
 
-
12458
 
-   .. module:: parrot
12459
 
-      :platform: Unix, Windows
12460
 
-      :synopsis: Analyze and reanimate dead parrots.
12461
 
-   .. moduleauthor:: Eric Cleese <eric@python.invalid>
12462
 
-   .. moduleauthor:: John Idle <john@python.invalid>
12463
 
-
12464
 
-As you can see, the module-specific markup consists of two directives, the
12465
 
-``module`` directive and the ``moduleauthor`` directive.
12466
 
-
12467
 
-.. describe:: module
12468
 
-
12469
 
-   This directive marks the beginning of the description of a module (or package
12470
 
-   submodule, in which case the name should be fully qualified, including the
12471
 
-   package name).
12472
 
-
12473
 
-   The ``platform`` option, if present, is a comma-separated list of the
12474
 
-   platforms on which the module is available (if it is available on all
12475
 
-   platforms, the option should be omitted).  The keys are short identifiers;
12476
 
-   examples that are in use include "IRIX", "Mac", "Windows", and "Unix".  It is
12477
 
-   important to use a key which has already been used when applicable.
12478
 
-
12479
 
-   The ``synopsis`` option should consist of one sentence describing the
12480
 
-   module's purpose -- it is currently only used in the Global Module Index.
12481
 
-
12482
 
-   The ``deprecated`` option can be given (with no value) to mark a module as
12483
 
-   deprecated; it will be designated as such in various locations then.
12484
 
-
12485
 
-.. describe:: moduleauthor
12486
 
-
12487
 
-   The ``moduleauthor`` directive, which can appear multiple times, names the
12488
 
-   authors of the module code, just like ``sectionauthor`` names the author(s)
12489
 
-   of a piece of documentation.  It too does not result in any output currently.
12490
 
-
12491
 
-.. note::
12492
 
-
12493
 
-   It is important to make the section title of a module-describing file
12494
 
-   meaningful since that value will be inserted in the table-of-contents trees
12495
 
-   in overview files.
12496
 
-
12497
 
-
12498
 
-Information units
12499
 
------------------
12500
 
-
12501
 
-There are a number of directives used to describe specific features provided by
12502
 
-modules.  Each directive requires one or more signatures to provide basic
12503
 
-information about what is being described, and the content should be the
12504
 
-description.  The basic version makes entries in the general index; if no index
12505
 
-entry is desired, you can give the directive option flag ``:noindex:``.  The
12506
 
-following example shows all of the features of this directive type::
12507
 
-
12508
 
-    .. function:: spam(eggs)
12509
 
-                  ham(eggs)
12510
 
-       :noindex:
12511
 
-
12512
 
-       Spam or ham the foo.
12513
 
-
12514
 
-The signatures of object methods or data attributes should always include the
12515
 
-type name (``.. method:: FileInput.input(...)``), even if it is obvious from the
12516
 
-context which type they belong to; this is to enable consistent
12517
 
-cross-references.  If you describe methods belonging to an abstract protocol,
12518
 
-such as "context managers", include a (pseudo-)type name too to make the
12519
 
-index entries more informative.
12520
 
-
12521
 
-The directives are:
12522
 
-
12523
 
-.. describe:: cfunction
12524
 
-
12525
 
-   Describes a C function. The signature should be given as in C, e.g.::
12526
 
-
12527
 
-      .. cfunction:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
12528
 
-
12529
 
-   This is also used to describe function-like preprocessor macros.  The names
12530
 
-   of the arguments should be given so they may be used in the description.
12531
 
-
12532
 
-   Note that you don't have to backslash-escape asterisks in the signature,
12533
 
-   as it is not parsed by the reST inliner.
12534
 
-
12535
 
-.. describe:: cmember
12536
 
-
12537
 
-   Describes a C struct member. Example signature::
12538
 
-
12539
 
-      .. cmember:: PyObject* PyTypeObject.tp_bases
12540
 
-
12541
 
-   The text of the description should include the range of values allowed, how
12542
 
-   the value should be interpreted, and whether the value can be changed.
12543
 
-   References to structure members in text should use the ``member`` role.
12544
 
-
12545
 
-.. describe:: cmacro
12546
 
-
12547
 
-   Describes a "simple" C macro.  Simple macros are macros which are used
12548
 
-   for code expansion, but which do not take arguments so cannot be described as
12549
 
-   functions.  This is not to be used for simple constant definitions.  Examples
12550
 
-   of its use in the Python documentation include :cmacro:`PyObject_HEAD` and
12551
 
-   :cmacro:`Py_BEGIN_ALLOW_THREADS`.
12552
 
-
12553
 
-.. describe:: ctype
12554
 
-
12555
 
-   Describes a C type. The signature should just be the type name.
12556
 
-
12557
 
-.. describe:: cvar
12558
 
-
12559
 
-   Describes a global C variable.  The signature should include the type, such
12560
 
-   as::
12561
 
-
12562
 
-      .. cvar:: PyObject* PyClass_Type
12563
 
-
12564
 
-.. describe:: data
12565
 
-
12566
 
-   Describes global data in a module, including both variables and values used
12567
 
-   as "defined constants."  Class and object attributes are not documented
12568
 
-   using this directive.
12569
 
-
12570
 
-.. describe:: exception
12571
 
-
12572
 
-   Describes an exception class.  The signature can, but need not include
12573
 
-   parentheses with constructor arguments.
12574
 
-
12575
 
-.. describe:: function
12576
 
-
12577
 
-   Describes a module-level function.  The signature should include the
12578
 
-   parameters, enclosing optional parameters in brackets.  Default values can be
12579
 
-   given if it enhances clarity.  For example::
12580
 
-
12581
 
-      .. function:: repeat([repeat=3[, number=1000000]])
12582
 
-
12583
 
-   Object methods are not documented using this directive. Bound object methods
12584
 
-   placed in the module namespace as part of the public interface of the module
12585
 
-   are documented using this, as they are equivalent to normal functions for
12586
 
-   most purposes.
12587
 
-
12588
 
-   The description should include information about the parameters required and
12589
 
-   how they are used (especially whether mutable objects passed as parameters
12590
 
-   are modified), side effects, and possible exceptions.  A small example may be
12591
 
-   provided.
12592
 
-
12593
 
-.. describe:: class
12594
 
-
12595
 
-   Describes a class.  The signature can include parentheses with parameters
12596
 
-   which will be shown as the constructor arguments.
12597
 
-
12598
 
-.. describe:: attribute
12599
 
-
12600
 
-   Describes an object data attribute.  The description should include
12601
 
-   information about the type of the data to be expected and whether it may be
12602
 
-   changed directly.  This directive should be nested in a class directive,
12603
 
-   like in this example::
12604
 
-
12605
 
-      .. class:: Spam
12606
 
-
12607
 
-            Description of the class.
12608
 
-
12609
 
-            .. data:: ham
12610
 
-
12611
 
-               Description of the attribute.
12612
 
-
12613
 
-   If is also possible to document an attribute outside of a class directive,
12614
 
-   for example if the documentation for different attributes and methods is
12615
 
-   split in multiple sections.  The class name should then be included
12616
 
-   explicitly::
12617
 
-
12618
 
-      .. data:: Spam.eggs
12619
 
-
12620
 
-.. describe:: method
12621
 
-
12622
 
-   Describes an object method.  The parameters should not include the ``self``
12623
 
-   parameter.  The description should include similar information to that
12624
 
-   described for ``function``.  This directive should be nested in a class
12625
 
-   directive, like in the example above.
12626
 
-
12627
 
-.. describe:: opcode
12628
 
-
12629
 
-   Describes a Python :term:`bytecode` instruction.
12630
 
-
12631
 
-.. describe:: cmdoption
12632
 
-
12633
 
-   Describes a Python command line option or switch.  Option argument names
12634
 
-   should be enclosed in angle brackets.  Example::
12635
 
-
12636
 
-      .. cmdoption:: -m <module>
12637
 
-
12638
 
-         Run a module as a script.
12639
 
-
12640
 
-.. describe:: envvar
12641
 
-
12642
 
-   Describes an environment variable that Python uses or defines.
12643
 
-
12644
 
-
12645
 
-There is also a generic version of these directives:
12646
 
-
12647
 
-.. describe:: describe
12648
 
-
12649
 
-   This directive produces the same formatting as the specific ones explained
12650
 
-   above but does not create index entries or cross-referencing targets.  It is
12651
 
-   used, for example, to describe the directives in this document. Example::
12652
 
-
12653
 
-      .. describe:: opcode
12654
 
-
12655
 
-         Describes a Python bytecode instruction.
12656
 
-
12657
 
-
12658
 
-Showing code examples
12659
 
----------------------
12660
 
-
12661
 
-Examples of Python source code or interactive sessions are represented using
12662
 
-standard reST literal blocks.  They are started by a ``::`` at the end of the
12663
 
-preceding paragraph and delimited by indentation.
12664
 
-
12665
 
-Representing an interactive session requires including the prompts and output
12666
 
-along with the Python code.  No special markup is required for interactive
12667
 
-sessions.  After the last line of input or output presented, there should not be
12668
 
-an "unused" primary prompt; this is an example of what *not* to do::
12669
 
-
12670
 
-   >>> 1 + 1
12671
 
-   2
12672
 
-   >>>
12673
 
-
12674
 
-Syntax highlighting is handled in a smart way:
12675
 
-
12676
 
-* There is a "highlighting language" for each source file.  Per default,
12677
 
-  this is ``'python'`` as the majority of files will have to highlight Python
12678
 
-  snippets.
12679
 
-
12680
 
-* Within Python highlighting mode, interactive sessions are recognized
12681
 
-  automatically and highlighted appropriately.
12682
 
-
12683
 
-* The highlighting language can be changed using the ``highlightlang``
12684
 
-  directive, used as follows::
12685
 
-
12686
 
-     .. highlightlang:: c
12687
 
-
12688
 
-  This language is used until the next ``highlightlang`` directive is
12689
 
-  encountered.
12690
 
-
12691
 
-* The values normally used for the highlighting language are:
12692
 
-
12693
 
-  * ``python`` (the default)
12694
 
-  * ``c``
12695
 
-  * ``rest``
12696
 
-  * ``none`` (no highlighting)
12697
 
-
12698
 
-* If highlighting with the current language fails, the block is not highlighted
12699
 
-  in any way.
12700
 
-
12701
 
-Longer displays of verbatim text may be included by storing the example text in
12702
 
-an external file containing only plain text.  The file may be included using the
12703
 
-``literalinclude`` directive. [1]_ For example, to include the Python source file
12704
 
-:file:`example.py`, use::
12705
 
-
12706
 
-   .. literalinclude:: example.py
12707
 
-
12708
 
-The file name is relative to the current file's path.  Documentation-specific
12709
 
-include files should be placed in the ``Doc/includes`` subdirectory.
12710
 
-
12711
 
-
12712
 
-Inline markup
12713
 
--------------
12714
 
-
12715
 
-As said before, Sphinx uses interpreted text roles to insert semantic markup in
12716
 
-documents.
12717
 
-
12718
 
-Names of local variables, such as function/method arguments, are an exception,
12719
 
-they should be marked simply with ``*var*``.
12720
 
-
12721
 
-For all other roles, you have to write ``:rolename:`content```.
12722
 
-
12723
 
-There are some additional facilities that make cross-referencing roles more
12724
 
-versatile:
12725
 
-
12726
 
-* You may supply an explicit title and reference target, like in reST direct
12727
 
-  hyperlinks: ``:role:`title <target>``` will refer to *target*, but the link
12728
 
-  text will be *title*.
12729
 
-
12730
 
-* If you prefix the content with ``!``, no reference/hyperlink will be created.
12731
 
-
12732
 
-* For the Python object roles, if you prefix the content with ``~``, the link
12733
 
-  text will only be the last component of the target.  For example,
12734
 
-  ``:meth:`~Queue.Queue.get``` will refer to ``Queue.Queue.get`` but only
12735
 
-  display ``get`` as the link text.
12736
 
-
12737
 
-  In HTML output, the link's ``title`` attribute (that is e.g. shown as a
12738
 
-  tool-tip on mouse-hover) will always be the full target name.
12739
 
-
12740
 
-The following roles refer to objects in modules and are possibly hyperlinked if
12741
 
-a matching identifier is found:
12742
 
-
12743
 
-.. describe:: mod
12744
 
-
12745
 
-   The name of a module; a dotted name may be used.  This should also be used for
12746
 
-   package names.
12747
 
-
12748
 
-.. describe:: func
12749
 
-
12750
 
-   The name of a Python function; dotted names may be used.  The role text
12751
 
-   should not include trailing parentheses to enhance readability.  The
12752
 
-   parentheses are stripped when searching for identifiers.
12753
 
-
12754
 
-.. describe:: data
12755
 
-
12756
 
-   The name of a module-level variable or constant.
12757
 
-
12758
 
-.. describe:: const
12759
 
-
12760
 
-   The name of a "defined" constant.  This may be a C-language ``#define``
12761
 
-   or a Python variable that is not intended to be changed.
12762
 
-
12763
 
-.. describe:: class
12764
 
-
12765
 
-   A class name; a dotted name may be used.
12766
 
-
12767
 
-.. describe:: meth
12768
 
-
12769
 
-   The name of a method of an object.  The role text should include the type
12770
 
-   name and the method name.  A dotted name may be used.
12771
 
-
12772
 
-.. describe:: attr
12773
 
-
12774
 
-   The name of a data attribute of an object.
12775
 
-
12776
 
-.. describe:: exc
12777
 
-
12778
 
-   The name of an exception. A dotted name may be used.
12779
 
-
12780
 
-The name enclosed in this markup can include a module name and/or a class name.
12781
 
-For example, ``:func:`filter``` could refer to a function named ``filter`` in
12782
 
-the current module, or the built-in function of that name.  In contrast,
12783
 
-``:func:`foo.filter``` clearly refers to the ``filter`` function in the ``foo``
12784
 
-module.
12785
 
-
12786
 
-Normally, names in these roles are searched first without any further
12787
 
-qualification, then with the current module name prepended, then with the
12788
 
-current module and class name (if any) prepended.  If you prefix the name with a
12789
 
-dot, this order is reversed.  For example, in the documentation of the
12790
 
-:mod:`codecs` module, ``:func:`open``` always refers to the built-in function,
12791
 
-while ``:func:`.open``` refers to :func:`codecs.open`.
12792
 
-
12793
 
-A similar heuristic is used to determine whether the name is an attribute of
12794
 
-the currently documented class.
12795
 
-
12796
 
-The following roles create cross-references to C-language constructs if they
12797
 
-are defined in the API documentation:
12798
 
-
12799
 
-.. describe:: cdata
12800
 
-
12801
 
-   The name of a C-language variable.
12802
 
-
12803
 
-.. describe:: cfunc
12804
 
-
12805
 
-   The name of a C-language function. Should include trailing parentheses.
12806
 
-
12807
 
-.. describe:: cmacro
12808
 
-
12809
 
-   The name of a "simple" C macro, as defined above.
12810
 
-
12811
 
-.. describe:: ctype
12812
 
-
12813
 
-   The name of a C-language type.
12814
 
-
12815
 
-
12816
 
-The following role does possibly create a cross-reference, but does not refer
12817
 
-to objects:
12818
 
-
12819
 
-.. describe:: token
12820
 
-
12821
 
-   The name of a grammar token (used in the reference manual to create links
12822
 
-   between production displays).
12823
 
-
12824
 
-
12825
 
-The following role creates a cross-reference to the term in the glossary:
12826
 
-
12827
 
-.. describe:: term
12828
 
-
12829
 
-   Reference to a term in the glossary.  The glossary is created using the
12830
 
-   ``glossary`` directive containing a definition list with terms and
12831
 
-   definitions.  It does not have to be in the same file as the ``term``
12832
 
-   markup, in fact, by default the Python docs have one global glossary
12833
 
-   in the ``glossary.rst`` file.
12834
 
-
12835
 
-   If you use a term that's not explained in a glossary, you'll get a warning
12836
 
-   during build.
12837
 
-
12838
 
----------
12839
 
-
12840
 
-The following roles don't do anything special except formatting the text
12841
 
-in a different style:
12842
 
-
12843
 
-.. describe:: command
12844
 
-
12845
 
-   The name of an OS-level command, such as ``rm``.
12846
 
-
12847
 
-.. describe:: dfn
12848
 
-
12849
 
-   Mark the defining instance of a term in the text.  (No index entries are
12850
 
-   generated.)
12851
 
-
12852
 
-.. describe:: envvar
12853
 
-
12854
 
-   An environment variable.  Index entries are generated.
12855
 
-
12856
 
-.. describe:: file
12857
 
-
12858
 
-   The name of a file or directory.  Within the contents, you can use curly
12859
 
-   braces to indicate a "variable" part, for example::
12860
 
-
12861
 
-      ... is installed in :file:`/usr/lib/python2.{x}/site-packages` ...
12862
 
-
12863
 
-   In the built documentation, the ``x`` will be displayed differently to
12864
 
-   indicate that it is to be replaced by the Python minor version.
12865
 
-
12866
 
-.. describe:: guilabel
12867
 
-
12868
 
-   Labels presented as part of an interactive user interface should be marked
12869
 
-   using ``guilabel``.  This includes labels from text-based interfaces such as
12870
 
-   those created using :mod:`curses` or other text-based libraries.  Any label
12871
 
-   used in the interface should be marked with this role, including button
12872
 
-   labels, window titles, field names, menu and menu selection names, and even
12873
 
-   values in selection lists.
12874
 
-
12875
 
-.. describe:: kbd
12876
 
-
12877
 
-   Mark a sequence of keystrokes.  What form the key sequence takes may depend
12878
 
-   on platform- or application-specific conventions.  When there are no relevant
12879
 
-   conventions, the names of modifier keys should be spelled out, to improve
12880
 
-   accessibility for new users and non-native speakers.  For example, an
12881
 
-   *xemacs* key sequence may be marked like ``:kbd:`C-x C-f```, but without
12882
 
-   reference to a specific application or platform, the same sequence should be
12883
 
-   marked as ``:kbd:`Control-x Control-f```.
12884
 
-
12885
 
-.. describe:: keyword
12886
 
-
12887
 
-   The name of a keyword in Python.
12888
 
-
12889
 
-.. describe:: mailheader
12890
 
-
12891
 
-   The name of an RFC 822-style mail header.  This markup does not imply that
12892
 
-   the header is being used in an email message, but can be used to refer to any
12893
 
-   header of the same "style."  This is also used for headers defined by the
12894
 
-   various MIME specifications.  The header name should be entered in the same
12895
 
-   way it would normally be found in practice, with the camel-casing conventions
12896
 
-   being preferred where there is more than one common usage. For example:
12897
 
-   ``:mailheader:`Content-Type```.
12898
 
-
12899
 
-.. describe:: makevar
12900
 
-
12901
 
-   The name of a :command:`make` variable.
12902
 
-
12903
 
-.. describe:: manpage
12904
 
-
12905
 
-   A reference to a Unix manual page including the section,
12906
 
-   e.g. ``:manpage:`ls(1)```.
12907
 
-
12908
 
-.. describe:: menuselection
12909
 
-
12910
 
-   Menu selections should be marked using the ``menuselection`` role.  This is
12911
 
-   used to mark a complete sequence of menu selections, including selecting
12912
 
-   submenus and choosing a specific operation, or any subsequence of such a
12913
 
-   sequence.  The names of individual selections should be separated by
12914
 
-   ``-->``.
12915
 
-
12916
 
-   For example, to mark the selection "Start > Programs", use this markup::
12917
 
-
12918
 
-      :menuselection:`Start --> Programs`
12919
 
-
12920
 
-   When including a selection that includes some trailing indicator, such as the
12921
 
-   ellipsis some operating systems use to indicate that the command opens a
12922
 
-   dialog, the indicator should be omitted from the selection name.
12923
 
-
12924
 
-.. describe:: mimetype
12925
 
-
12926
 
-   The name of a MIME type, or a component of a MIME type (the major or minor
12927
 
-   portion, taken alone).
12928
 
-
12929
 
-.. describe:: newsgroup
12930
 
-
12931
 
-   The name of a Usenet newsgroup.
12932
 
-
12933
 
-.. describe:: option
12934
 
-
12935
 
-   A command-line option of Python.  The leading hyphen(s) must be included.
12936
 
-   If a matching ``cmdoption`` directive exists, it is linked to.  For options
12937
 
-   of other programs or scripts, use simple ````code```` markup.
12938
 
-
12939
 
-.. describe:: program
12940
 
-
12941
 
-   The name of an executable program.  This may differ from the file name for
12942
 
-   the executable for some platforms.  In particular, the ``.exe`` (or other)
12943
 
-   extension should be omitted for Windows programs.
12944
 
-
12945
 
-.. describe:: regexp
12946
 
-
12947
 
-   A regular expression. Quotes should not be included.
12948
 
-
12949
 
-.. describe:: samp
12950
 
-
12951
 
-   A piece of literal text, such as code.  Within the contents, you can use
12952
 
-   curly braces to indicate a "variable" part, as in ``:file:``.
12953
 
-
12954
 
-   If you don't need the "variable part" indication, use the standard
12955
 
-   ````code```` instead.
12956
 
-
12957
 
-
12958
 
-The following roles generate external links:
12959
 
-
12960
 
-.. describe:: pep
12961
 
-
12962
 
-   A reference to a Python Enhancement Proposal.  This generates appropriate
12963
 
-   index entries. The text "PEP *number*\ " is generated; in the HTML output,
12964
 
-   this text is a hyperlink to an online copy of the specified PEP.
12965
 
-
12966
 
-.. describe:: rfc
12967
 
-
12968
 
-   A reference to an Internet Request for Comments.  This generates appropriate
12969
 
-   index entries. The text "RFC *number*\ " is generated; in the HTML output,
12970
 
-   this text is a hyperlink to an online copy of the specified RFC.
12971
 
-
12972
 
-
12973
 
-Note that there are no special roles for including hyperlinks as you can use
12974
 
-the standard reST markup for that purpose.
12975
 
-
12976
 
-
12977
 
-.. _doc-ref-role:
12978
 
-
12979
 
-Cross-linking markup
12980
 
---------------------
12981
 
-
12982
 
-To support cross-referencing to arbitrary sections in the documentation, the
12983
 
-standard reST labels are "abused" a bit: Every label must precede a section
12984
 
-title; and every label name must be unique throughout the entire documentation
12985
 
-source.
12986
 
-
12987
 
-You can then reference to these sections using the ``:ref:`label-name``` role.
12988
 
-
12989
 
-Example::
12990
 
-
12991
 
-   .. _my-reference-label:
12992
 
-
12993
 
-   Section to cross-reference
12994
 
-   --------------------------
12995
 
-
12996
 
-   This is the text of the section.
12997
 
-
12998
 
-   It refers to the section itself, see :ref:`my-reference-label`.
12999
 
-
13000
 
-The ``:ref:`` invocation is replaced with the section title.
13001
 
-
13002
 
-
13003
 
-Paragraph-level markup
13004
 
-----------------------
13005
 
-
13006
 
-These directives create short paragraphs and can be used inside information
13007
 
-units as well as normal text:
13008
 
-
13009
 
-.. describe:: note
13010
 
-
13011
 
-   An especially important bit of information about an API that a user should be
13012
 
-   aware of when using whatever bit of API the note pertains to.  The content of
13013
 
-   the directive should be written in complete sentences and include all
13014
 
-   appropriate punctuation.
13015
 
-
13016
 
-   Example::
13017
 
-
13018
 
-      .. note::
13019
 
-
13020
 
-         This function is not suitable for sending spam e-mails.
13021
 
-
13022
 
-.. describe:: warning
13023
 
-
13024
 
-   An important bit of information about an API that a user should be aware of
13025
 
-   when using whatever bit of API the warning pertains to.  The content of the
13026
 
-   directive should be written in complete sentences and include all appropriate
13027
 
-   punctuation.  In the interest of not scaring users away from pages filled
13028
 
-   with warnings, this directive should only be chosen over ``note`` for
13029
 
-   information regarding the possibility of crashes, data loss, or security
13030
 
-   implications.
13031
 
-
13032
 
-.. describe:: versionadded
13033
 
-
13034
 
-   This directive documents the version of Python which added the described
13035
 
-   feature to the library or C API. When this applies to an entire module, it
13036
 
-   should be placed at the top of the module section before any prose.
13037
 
-
13038
 
-   The first argument must be given and is the version in question; you can add
13039
 
-   a second argument consisting of a *brief* explanation of the change.
13040
 
-
13041
 
-   Example::
13042
 
-
13043
 
-      .. versionadded:: 2.5
13044
 
-         The *spam* parameter.
13045
 
-
13046
 
-   Note that there must be no blank line between the directive head and the
13047
 
-   explanation; this is to make these blocks visually continuous in the markup.
13048
 
-
13049
 
-.. describe:: versionchanged
13050
 
-
13051
 
-   Similar to ``versionadded``, but describes when and what changed in the named
13052
 
-   feature in some way (new parameters, changed side effects, etc.).
13053
 
-
13054
 
---------------
13055
 
-
13056
 
-.. describe:: impl-detail
13057
 
-
13058
 
-   This directive is used to mark CPython-specific information.  Use either with
13059
 
-   a block content or a single sentence as an argument, i.e. either ::
13060
 
-
13061
 
-      .. impl-detail::
13062
 
-
13063
 
-         This describes some implementation detail.
13064
 
-
13065
 
-         More explanation.
13066
 
-
13067
 
-   or ::
13068
 
-
13069
 
-      .. impl-detail:: This shortly mentions an implementation detail.
13070
 
-
13071
 
-   "\ **CPython implementation detail:**\ " is automatically prepended to the
13072
 
-   content.
13073
 
-
13074
 
-.. describe:: seealso
13075
 
-
13076
 
-   Many sections include a list of references to module documentation or
13077
 
-   external documents.  These lists are created using the ``seealso`` directive.
13078
 
-
13079
 
-   The ``seealso`` directive is typically placed in a section just before any
13080
 
-   sub-sections.  For the HTML output, it is shown boxed off from the main flow
13081
 
-   of the text.
13082
 
-
13083
 
-   The content of the ``seealso`` directive should be a reST definition list.
13084
 
-   Example::
13085
 
-
13086
 
-      .. seealso::
13087
 
-
13088
 
-         Module :mod:`zipfile`
13089
 
-            Documentation of the :mod:`zipfile` standard module.
13090
 
-
13091
 
-         `GNU tar manual, Basic Tar Format <http://link>`_
13092
 
-            Documentation for tar archive files, including GNU tar extensions.
13093
 
-
13094
 
-.. describe:: rubric
13095
 
-
13096
 
-   This directive creates a paragraph heading that is not used to create a
13097
 
-   table of contents node.  It is currently used for the "Footnotes" caption.
13098
 
-
13099
 
-.. describe:: centered
13100
 
-
13101
 
-   This directive creates a centered boldfaced paragraph.  Use it as follows::
13102
 
-
13103
 
-      .. centered::
13104
 
-
13105
 
-         Paragraph contents.
13106
 
-
13107
 
-
13108
 
-Table-of-contents markup
13109
 
-------------------------
13110
 
-
13111
 
-Since reST does not have facilities to interconnect several documents, or split
13112
 
-documents into multiple output files, Sphinx uses a custom directive to add
13113
 
-relations between the single files the documentation is made of, as well as
13114
 
-tables of contents.  The ``toctree`` directive is the central element.
13115
 
-
13116
 
-.. describe:: toctree
13117
 
-
13118
 
-   This directive inserts a "TOC tree" at the current location, using the
13119
 
-   individual TOCs (including "sub-TOC trees") of the files given in the
13120
 
-   directive body.  A numeric ``maxdepth`` option may be given to indicate the
13121
 
-   depth of the tree; by default, all levels are included.
13122
 
-
13123
 
-   Consider this example (taken from the library reference index)::
13124
 
-
13125
 
-      .. toctree::
13126
 
-         :maxdepth: 2
13127
 
-
13128
 
-         intro
13129
 
-         strings
13130
 
-         datatypes
13131
 
-         numeric
13132
 
-         (many more files listed here)
13133
 
-
13134
 
-   This accomplishes two things:
13135
 
-
13136
 
-   * Tables of contents from all those files are inserted, with a maximum depth
13137
 
-     of two, that means one nested heading.  ``toctree`` directives in those
13138
 
-     files are also taken into account.
13139
 
-   * Sphinx knows that the relative order of the files ``intro``,
13140
 
-     ``strings`` and so forth, and it knows that they are children of the
13141
 
-     shown file, the library index.  From this information it generates "next
13142
 
-     chapter", "previous chapter" and "parent chapter" links.
13143
 
-
13144
 
-   In the end, all files included in the build process must occur in one
13145
 
-   ``toctree`` directive; Sphinx will emit a warning if it finds a file that is
13146
 
-   not included, because that means that this file will not be reachable through
13147
 
-   standard navigation.
13148
 
-
13149
 
-   The special file ``contents.rst`` at the root of the source directory is the
13150
 
-   "root" of the TOC tree hierarchy; from it the "Contents" page is generated.
13151
 
-
13152
 
-
13153
 
-Index-generating markup
13154
 
------------------------
13155
 
-
13156
 
-Sphinx automatically creates index entries from all information units (like
13157
 
-functions, classes or attributes) like discussed before.
13158
 
-
13159
 
-However, there is also an explicit directive available, to make the index more
13160
 
-comprehensive and enable index entries in documents where information is not
13161
 
-mainly contained in information units, such as the language reference.
13162
 
-
13163
 
-The directive is ``index`` and contains one or more index entries.  Each entry
13164
 
-consists of a type and a value, separated by a colon.
13165
 
-
13166
 
-For example::
13167
 
-
13168
 
-   .. index::
13169
 
-      single: execution; context
13170
 
-      module: __main__
13171
 
-      module: sys
13172
 
-      triple: module; search; path
13173
 
-
13174
 
-This directive contains five entries, which will be converted to entries in the
13175
 
-generated index which link to the exact location of the index statement (or, in
13176
 
-case of offline media, the corresponding page number).
13177
 
-
13178
 
-The possible entry types are:
13179
 
-
13180
 
-single
13181
 
-   Creates a single index entry.  Can be made a subentry by separating the
13182
 
-   subentry text with a semicolon (this notation is also used below to describe
13183
 
-   what entries are created).
13184
 
-pair
13185
 
-   ``pair: loop; statement`` is a shortcut that creates two index entries,
13186
 
-   namely ``loop; statement`` and ``statement; loop``.
13187
 
-triple
13188
 
-   Likewise, ``triple: module; search; path`` is a shortcut that creates three
13189
 
-   index entries, which are ``module; search path``, ``search; path, module`` and
13190
 
-   ``path; module search``.
13191
 
-module, keyword, operator, object, exception, statement, builtin
13192
 
-   These all create two index entries.  For example, ``module: hashlib`` creates
13193
 
-   the entries ``module; hashlib`` and ``hashlib; module``.
13194
 
-
13195
 
-For index directives containing only "single" entries, there is a shorthand
13196
 
-notation::
13197
 
-
13198
 
-   .. index:: BNF, grammar, syntax, notation
13199
 
-
13200
 
-This creates four index entries.
13201
 
-
13202
 
-
13203
 
-Grammar production displays
13204
 
----------------------------
13205
 
-
13206
 
-Special markup is available for displaying the productions of a formal grammar.
13207
 
-The markup is simple and does not attempt to model all aspects of BNF (or any
13208
 
-derived forms), but provides enough to allow context-free grammars to be
13209
 
-displayed in a way that causes uses of a symbol to be rendered as hyperlinks to
13210
 
-the definition of the symbol.  There is this directive:
13211
 
-
13212
 
-.. describe:: productionlist
13213
 
-
13214
 
-   This directive is used to enclose a group of productions.  Each production is
13215
 
-   given on a single line and consists of a name, separated by a colon from the
13216
 
-   following definition.  If the definition spans multiple lines, each
13217
 
-   continuation line must begin with a colon placed at the same column as in the
13218
 
-   first line.
13219
 
-
13220
 
-   Blank lines are not allowed within ``productionlist`` directive arguments.
13221
 
-
13222
 
-   The definition can contain token names which are marked as interpreted text
13223
 
-   (e.g. ``unaryneg ::= "-" `integer```) -- this generates cross-references
13224
 
-   to the productions of these tokens.
13225
 
-
13226
 
-   Note that no further reST parsing is done in the production, so that you
13227
 
-   don't have to escape ``*`` or ``|`` characters.
13228
 
-
13229
 
-
13230
 
-.. XXX describe optional first parameter
13231
 
-
13232
 
-The following is an example taken from the Python Reference Manual::
13233
 
-
13234
 
-   .. productionlist::
13235
 
-      try_stmt: try1_stmt | try2_stmt
13236
 
-      try1_stmt: "try" ":" `suite`
13237
 
-               : ("except" [`expression` ["," `target`]] ":" `suite`)+
13238
 
-               : ["else" ":" `suite`]
13239
 
-               : ["finally" ":" `suite`]
13240
 
-      try2_stmt: "try" ":" `suite`
13241
 
-               : "finally" ":" `suite`
13242
 
-
13243
 
-
13244
 
-Substitutions
13245
 
--------------
13246
 
-
13247
 
-The documentation system provides three substitutions that are defined by default.
13248
 
-They are set in the build configuration file :file:`conf.py`.
13249
 
-
13250
 
-.. describe:: |release|
13251
 
-
13252
 
-   Replaced by the Python release the documentation refers to.  This is the full
13253
 
-   version string including alpha/beta/release candidate tags, e.g. ``2.5.2b3``.
13254
 
-
13255
 
-.. describe:: |version|
13256
 
-
13257
 
-   Replaced by the Python version the documentation refers to. This consists
13258
 
-   only of the major and minor version parts, e.g. ``2.5``, even for version
13259
 
-   2.5.1.
13260
 
-
13261
 
-.. describe:: |today|
13262
 
-
13263
 
-   Replaced by either today's date, or the date set in the build configuration
13264
 
-   file.  Normally has the format ``April 14, 2007``.
13265
 
-
13266
 
-
13267
 
-.. rubric:: Footnotes
13268
 
-
13269
 
-.. [1] There is a standard ``.. include`` directive, but it raises errors if the
13270
 
-       file is not found.  This one only emits a warning.
13271
 
diff -r 8527427914a2 Doc/documenting/rest.rst
13272
 
--- a/Doc/documenting/rest.rst
13273
 
+++ /dev/null
13274
 
@@ -1,243 +0,0 @@
13275
 
-.. highlightlang:: rest
13276
 
-
13277
 
-reStructuredText Primer
13278
 
-=======================
13279
 
-
13280
 
-This section is a brief introduction to reStructuredText (reST) concepts and
13281
 
-syntax, intended to provide authors with enough information to author documents
13282
 
-productively.  Since reST was designed to be a simple, unobtrusive markup
13283
 
-language, this will not take too long.
13284
 
-
13285
 
-.. seealso::
13286
 
-
13287
 
-    The authoritative `reStructuredText User
13288
 
-    Documentation <http://docutils.sourceforge.net/rst.html>`_.
13289
 
-
13290
 
-
13291
 
-Paragraphs
13292
 
-----------
13293
 
-
13294
 
-The paragraph is the most basic block in a reST document.  Paragraphs are simply
13295
 
-chunks of text separated by one or more blank lines.  As in Python, indentation
13296
 
-is significant in reST, so all lines of the same paragraph must be left-aligned
13297
 
-to the same level of indentation.
13298
 
-
13299
 
-
13300
 
-Inline markup
13301
 
--------------
13302
 
-
13303
 
-The standard reST inline markup is quite simple: use
13304
 
-
13305
 
-* one asterisk: ``*text*`` for emphasis (italics),
13306
 
-* two asterisks: ``**text**`` for strong emphasis (boldface), and
13307
 
-* backquotes: ````text```` for code samples.
13308
 
-
13309
 
-If asterisks or backquotes appear in running text and could be confused with
13310
 
-inline markup delimiters, they have to be escaped with a backslash.
13311
 
-
13312
 
-Be aware of some restrictions of this markup:
13313
 
-
13314
 
-* it may not be nested,
13315
 
-* content may not start or end with whitespace: ``* text*`` is wrong,
13316
 
-* it must be separated from surrounding text by non-word characters.  Use a
13317
 
-  backslash escaped space to work around that: ``thisis\ *one*\ word``.
13318
 
-
13319
 
-These restrictions may be lifted in future versions of the docutils.
13320
 
-
13321
 
-reST also allows for custom "interpreted text roles"', which signify that the
13322
 
-enclosed text should be interpreted in a specific way.  Sphinx uses this to
13323
 
-provide semantic markup and cross-referencing of identifiers, as described in
13324
 
-the appropriate section.  The general syntax is ``:rolename:`content```.
13325
 
-
13326
 
-
13327
 
-Lists and Quotes
13328
 
-----------------
13329
 
-
13330
 
-List markup is natural: just place an asterisk at the start of a paragraph and
13331
 
-indent properly.  The same goes for numbered lists; they can also be
13332
 
-autonumbered using a ``#`` sign::
13333
 
-
13334
 
-   * This is a bulleted list.
13335
 
-   * It has two items, the second
13336
 
-     item uses two lines.
13337
 
-
13338
 
-   1. This is a numbered list.
13339
 
-   2. It has two items too.
13340
 
-
13341
 
-   #. This is a numbered list.
13342
 
-   #. It has two items too.
13343
 
-
13344
 
-
13345
 
-Nested lists are possible, but be aware that they must be separated from the
13346
 
-parent list items by blank lines::
13347
 
-
13348
 
-   * this is
13349
 
-   * a list
13350
 
-
13351
 
-     * with a nested list
13352
 
-     * and some subitems
13353
 
-
13354
 
-   * and here the parent list continues
13355
 
-
13356
 
-Definition lists are created as follows::
13357
 
-
13358
 
-   term (up to a line of text)
13359
 
-      Definition of the term, which must be indented
13360
 
-
13361
 
-      and can even consist of multiple paragraphs
13362
 
-
13363
 
-   next term
13364
 
-      Description.
13365
 
-
13366
 
-
13367
 
-Paragraphs are quoted by just indenting them more than the surrounding
13368
 
-paragraphs.
13369
 
-
13370
 
-
13371
 
-Source Code
13372
 
------------
13373
 
-
13374
 
-Literal code blocks are introduced by ending a paragraph with the special marker
13375
 
-``::``.  The literal block must be indented::
13376
 
-
13377
 
-   This is a normal text paragraph. The next paragraph is a code sample::
13378
 
-
13379
 
-      It is not processed in any way, except
13380
 
-      that the indentation is removed.
13381
 
-
13382
 
-      It can span multiple lines.
13383
 
-
13384
 
-   This is a normal text paragraph again.
13385
 
-
13386
 
-The handling of the ``::`` marker is smart:
13387
 
-
13388
 
-* If it occurs as a paragraph of its own, that paragraph is completely left
13389
 
-  out of the document.
13390
 
-* If it is preceded by whitespace, the marker is removed.
13391
 
-* If it is preceded by non-whitespace, the marker is replaced by a single
13392
 
-  colon.
13393
 
-
13394
 
-That way, the second sentence in the above example's first paragraph would be
13395
 
-rendered as "The next paragraph is a code sample:".
13396
 
-
13397
 
-
13398
 
-Hyperlinks
13399
 
-----------
13400
 
-
13401
 
-External links
13402
 
-^^^^^^^^^^^^^^
13403
 
-
13404
 
-Use ```Link text <http://target>`_`` for inline web links.  If the link text
13405
 
-should be the web address, you don't need special markup at all, the parser
13406
 
-finds links and mail addresses in ordinary text.
13407
 
-
13408
 
-Internal links
13409
 
-^^^^^^^^^^^^^^
13410
 
-
13411
 
-Internal linking is done via a special reST role, see the section on specific
13412
 
-markup, :ref:`doc-ref-role`.
13413
 
-
13414
 
-
13415
 
-Sections
13416
 
---------
13417
 
-
13418
 
-Section headers are created by underlining (and optionally overlining) the
13419
 
-section title with a punctuation character, at least as long as the text::
13420
 
-
13421
 
-   =================
13422
 
-   This is a heading
13423
 
-   =================
13424
 
-
13425
 
-Normally, there are no heading levels assigned to certain characters as the
13426
 
-structure is determined from the succession of headings.  However, for the
13427
 
-Python documentation, we use this convention:
13428
 
-
13429
 
-* ``#`` with overline, for parts
13430
 
-* ``*`` with overline, for chapters
13431
 
-* ``=``, for sections
13432
 
-* ``-``, for subsections
13433
 
-* ``^``, for subsubsections
13434
 
-* ``"``, for paragraphs
13435
 
-
13436
 
-
13437
 
-Explicit Markup
13438
 
----------------
13439
 
-
13440
 
-"Explicit markup" is used in reST for most constructs that need special
13441
 
-handling, such as footnotes, specially-highlighted paragraphs, comments, and
13442
 
-generic directives.
13443
 
-
13444
 
-An explicit markup block begins with a line starting with ``..`` followed by
13445
 
-whitespace and is terminated by the next paragraph at the same level of
13446
 
-indentation.  (There needs to be a blank line between explicit markup and normal
13447
 
-paragraphs.  This may all sound a bit complicated, but it is intuitive enough
13448
 
-when you write it.)
13449
 
-
13450
 
-
13451
 
-Directives
13452
 
-----------
13453
 
-
13454
 
-A directive is a generic block of explicit markup.  Besides roles, it is one of
13455
 
-the extension mechanisms of reST, and Sphinx makes heavy use of it.
13456
 
-
13457
 
-Basically, a directive consists of a name, arguments, options and content. (Keep
13458
 
-this terminology in mind, it is used in the next chapter describing custom
13459
 
-directives.)  Looking at this example, ::
13460
 
-
13461
 
-   .. function:: foo(x)
13462
 
-                 foo(y, z)
13463
 
-      :bar: no
13464
 
-
13465
 
-      Return a line of text input from the user.
13466
 
-
13467
 
-``function`` is the directive name.  It is given two arguments here, the
13468
 
-remainder of the first line and the second line, as well as one option ``bar``
13469
 
-(as you can see, options are given in the lines immediately following the
13470
 
-arguments and indicated by the colons).
13471
 
-
13472
 
-The directive content follows after a blank line and is indented relative to the
13473
 
-directive start.
13474
 
-
13475
 
-
13476
 
-Footnotes
13477
 
----------
13478
 
-
13479
 
-For footnotes, use ``[#]_`` to mark the footnote location, and add the footnote
13480
 
-body at the bottom of the document after a "Footnotes" rubric heading, like so::
13481
 
-
13482
 
-   Lorem ipsum [#]_ dolor sit amet ... [#]_
13483
 
-
13484
 
-   .. rubric:: Footnotes
13485
 
-
13486
 
-   .. [#] Text of the first footnote.
13487
 
-   .. [#] Text of the second footnote.
13488
 
-
13489
 
-You can also explicitly number the footnotes for better context.
13490
 
-
13491
 
-
13492
 
-Comments
13493
 
---------
13494
 
-
13495
 
-Every explicit markup block which isn't a valid markup construct (like the
13496
 
-footnotes above) is regarded as a comment.
13497
 
-
13498
 
-
13499
 
-Source encoding
13500
 
----------------
13501
 
-
13502
 
-Since the easiest way to include special characters like em dashes or copyright
13503
 
-signs in reST is to directly write them as Unicode characters, one has to
13504
 
-specify an encoding:
13505
 
-
13506
 
-All Python documentation source files must be in UTF-8 encoding, and the HTML
13507
 
-documents written from them will be in that encoding as well.
13508
 
-
13509
 
-
13510
 
-Gotchas
13511
 
--------
13512
 
-
13513
 
-There are some problems one commonly runs into while authoring reST documents:
13514
 
-
13515
 
-* **Separation of inline markup:** As said above, inline markup spans must be
13516
 
-  separated from the surrounding text by non-word characters, you have to use
13517
 
-  an escaped space to get around that.
13518
 
diff -r 8527427914a2 Doc/documenting/style.rst
13519
 
--- a/Doc/documenting/style.rst
13520
 
+++ /dev/null
13521
 
@@ -1,174 +0,0 @@
13522
 
-.. highlightlang:: rest
13523
 
-
13524
 
-Style Guide
13525
 
-===========
13526
 
-
13527
 
-The Python documentation should follow the `Apple Publications Style Guide`_
13528
 
-wherever possible. This particular style guide was selected mostly because it
13529
 
-seems reasonable and is easy to get online.
13530
 
-
13531
 
-Topics which are not covered in Apple's style guide will be discussed in
13532
 
-this document.
13533
 
-
13534
 
-All reST files use an indentation of 3 spaces.  The maximum line length is 80
13535
 
-characters for normal text, but tables, deeply indented code samples and long
13536
 
-links may extend beyond that.
13537
 
-
13538
 
-Make generous use of blank lines where applicable; they help grouping things
13539
 
-together.
13540
 
-
13541
 
-A sentence-ending period may be followed by one or two spaces; while reST
13542
 
-ignores the second space, it is customarily put in by some users, for example
13543
 
-to aid Emacs' auto-fill mode.
13544
 
-
13545
 
-Footnotes are generally discouraged, though they may be used when they are the
13546
 
-best way to present specific information. When a footnote reference is added at
13547
 
-the end of the sentence, it should follow the sentence-ending punctuation. The
13548
 
-reST markup should appear something like this::
13549
 
-
13550
 
-    This sentence has a footnote reference. [#]_ This is the next sentence.
13551
 
-
13552
 
-Footnotes should be gathered at the end of a file, or if the file is very long,
13553
 
-at the end of a section. The docutils will automatically create backlinks to
13554
 
-the footnote reference.
13555
 
-
13556
 
-Footnotes may appear in the middle of sentences where appropriate.
13557
 
-
13558
 
-Many special names are used in the Python documentation, including the names of
13559
 
-operating systems, programming languages, standards bodies, and the like. Most
13560
 
-of these entities are not assigned any special markup, but the preferred
13561
 
-spellings are given here to aid authors in maintaining the consistency of
13562
 
-presentation in the Python documentation.
13563
 
-
13564
 
-Other terms and words deserve special mention as well; these conventions should
13565
 
-be used to ensure consistency throughout the documentation:
13566
 
-
13567
 
-CPU
13568
 
-    For "central processing unit." Many style guides say this should be spelled
13569
 
-    out on the first use (and if you must use it, do so!). For the Python
13570
 
-    documentation, this abbreviation should be avoided since there's no
13571
 
-    reasonable way to predict which occurrence will be the first seen by the
13572
 
-    reader. It is better to use the word "processor" instead.
13573
 
-
13574
 
-POSIX
13575
 
-    The name assigned to a particular group of standards. This is always
13576
 
-    uppercase.
13577
 
-
13578
 
-Python
13579
 
-    The name of our favorite programming language is always capitalized.
13580
 
-
13581
 
-Unicode
13582
 
-    The name of a character set and matching encoding. This is always written
13583
 
-    capitalized.
13584
 
-
13585
 
-Unix
13586
 
-    The name of the operating system developed at AT&T Bell Labs in the early
13587
 
-    1970s.
13588
 
-
13589
 
-Affirmative Tone
13590
 
-----------------
13591
 
-
13592
 
-The documentation focuses on affirmatively stating what the language does and
13593
 
-how to use it effectively.
13594
 
-
13595
 
-Except for certain security risks or segfault risks, the docs should avoid
13596
 
-wording along the lines of "feature x is dangerous" or "experts only".  These
13597
 
-kinds of value judgments belong in external blogs and wikis, not in the core
13598
 
-documentation.
13599
 
-
13600
 
-Bad example (creating worry in the mind of a reader):
13601
 
-
13602
 
-    Warning: failing to explicitly close a file could result in lost data or
13603
 
-    excessive resource consumption.  Never rely on reference counting to
13604
 
-    automatically close a file.
13605
 
-
13606
 
-Good example (establishing confident knowledge in the effective use of the language):
13607
 
-
13608
 
-    A best practice for using files is use a try/finally pair to explicitly
13609
 
-    close a file after it is used.  Alternatively, using a with-statement can
13610
 
-    achieve the same effect.  This assures that files are flushed and file
13611
 
-    descriptor resources are released in a timely manner.
13612
 
-
13613
 
-Economy of Expression
13614
 
----------------------
13615
 
-
13616
 
-More documentation is not necessarily better documentation.  Err on the side
13617
 
-of being succinct.
13618
 
-
13619
 
-It is an unfortunate fact that making documentation longer can be an impediment
13620
 
-to understanding and can result in even more ways to misread or misinterpret the
13621
 
-text.  Long descriptions full of corner cases and caveats can create the
13622
 
-impression that a function is more complex or harder to use than it actually is.
13623
 
-
13624
 
-The documentation for :func:`super` is an example of where a good deal of
13625
 
-information was condensed into a few short paragraphs.  Discussion of
13626
 
-:func:`super` could have filled a chapter in a book, but it is often easier to
13627
 
-grasp a terse description than a lengthy narrative.
13628
 
-
13629
 
-
13630
 
-Code Examples
13631
 
--------------
13632
 
-
13633
 
-Short code examples can be a useful adjunct to understanding.  Readers can often
13634
 
-grasp a simple example more quickly than they can digest a formal description in
13635
 
-prose.
13636
 
-
13637
 
-People learn faster with concrete, motivating examples that match the context of
13638
 
-a typical use case.  For instance, the :func:`str.rpartition` method is better
13639
 
-demonstrated with an example splitting the domain from a URL than it would be
13640
 
-with an example of removing the last word from a line of Monty Python dialog.
13641
 
-
13642
 
-The ellipsis for the :attr:`sys.ps2` secondary interpreter prompt should only be
13643
 
-used sparingly, where it is necessary to clearly differentiate between input
13644
 
-lines and output lines.  Besides contributing visual clutter, it makes it
13645
 
-difficult for readers to cut-and-paste examples so they can experiment with
13646
 
-variations.
13647
 
-
13648
 
-Code Equivalents
13649
 
-----------------
13650
 
-
13651
 
-Giving pure Python code equivalents (or approximate equivalents) can be a useful
13652
 
-adjunct to a prose description.  A documenter should carefully weigh whether the
13653
 
-code equivalent adds value.
13654
 
-
13655
 
-A good example is the code equivalent for :func:`all`.  The short 4-line code
13656
 
-equivalent is easily digested; it re-emphasizes the early-out behavior; and it
13657
 
-clarifies the handling of the corner-case where the iterable is empty.  In
13658
 
-addition, it serves as a model for people wanting to implement a commonly
13659
 
-requested alternative where :func:`all` would return the specific object
13660
 
-evaluating to False whenever the function terminates early.
13661
 
-
13662
 
-A more questionable example is the code for :func:`itertools.groupby`.  Its code
13663
 
-equivalent borders on being too complex to be a quick aid to understanding.
13664
 
-Despite its complexity, the code equivalent was kept because it serves as a
13665
 
-model to alternative implementations and because the operation of the "grouper"
13666
 
-is more easily shown in code than in English prose.
13667
 
-
13668
 
-An example of when not to use a code equivalent is for the :func:`oct` function.
13669
 
-The exact steps in converting a number to octal doesn't add value for a user
13670
 
-trying to learn what the function does.
13671
 
-
13672
 
-Audience
13673
 
---------
13674
 
-
13675
 
-The tone of the tutorial (and all the docs) needs to be respectful of the
13676
 
-reader's intelligence.  Don't presume that the readers are stupid.  Lay out the
13677
 
-relevant information, show motivating use cases, provide glossary links, and do
13678
 
-your best to connect the dots, but don't talk down to them or waste their time.
13679
 
-
13680
 
-The tutorial is meant for newcomers, many of whom will be using the tutorial to
13681
 
-evaluate the language as a whole.  The experience needs to be positive and not
13682
 
-leave the reader with worries that something bad will happen if they make a
13683
 
-misstep.  The tutorial serves as guide for intelligent and curious readers,
13684
 
-saving details for the how-to guides and other sources.
13685
 
-
13686
 
-Be careful accepting requests for documentation changes from the rare but vocal
13687
 
-category of reader who is looking for vindication for one of their programming
13688
 
-errors ("I made a mistake, therefore the docs must be wrong ...").  Typically,
13689
 
-the documentation wasn't consulted until after the error was made.  It is
13690
 
-unfortunate, but typically no documentation edit would have saved the user from
13691
 
-making false assumptions about the language ("I was surprised by ...").
13692
 
-
13693
 
-
13694
 
-.. _Apple Publications Style Guide: http://developer.apple.com/mac/library/documentation/UserExperience/Conceptual/APStyleGuide/APSG_2009.pdf
13695
 
-
13696
 
diff -r 8527427914a2 Doc/extending/embedding.rst
13697
 
--- a/Doc/extending/embedding.rst
13698
 
+++ b/Doc/extending/embedding.rst
13699
 
@@ -25,14 +25,14 @@
13700
 
 
13701
 
 So if you are embedding Python, you are providing your own main program.  One of
13702
 
 the things this main program has to do is initialize the Python interpreter.  At
13703
 
-the very least, you have to call the function :cfunc:`Py_Initialize`.  There are
13704
 
+the very least, you have to call the function :c:func:`Py_Initialize`.  There are
13705
 
 optional calls to pass command line arguments to Python.  Then later you can
13706
 
 call the interpreter from any part of the application.
13707
 
 
13708
 
 There are several different ways to call the interpreter: you can pass a string
13709
 
-containing Python statements to :cfunc:`PyRun_SimpleString`, or you can pass a
13710
 
+containing Python statements to :c:func:`PyRun_SimpleString`, or you can pass a
13711
 
 stdio file pointer and a file name (for identification in error messages only)
13712
 
-to :cfunc:`PyRun_SimpleFile`.  You can also call the lower-level operations
13713
 
+to :c:func:`PyRun_SimpleFile`.  You can also call the lower-level operations
13714
 
 described in the previous chapters to construct and use Python objects.
13715
 
 
13716
 
 A simple demo of embedding Python can be found in the directory
13717
 
@@ -69,12 +69,12 @@
13718
 
    }
13719
 
 
13720
 
 The above code first initializes the Python interpreter with
13721
 
-:cfunc:`Py_Initialize`, followed by the execution of a hard-coded Python script
13722
 
-that print the date and time.  Afterwards, the :cfunc:`Py_Finalize` call shuts
13723
 
+:c:func:`Py_Initialize`, followed by the execution of a hard-coded Python script
13724
 
+that print the date and time.  Afterwards, the :c:func:`Py_Finalize` call shuts
13725
 
 the interpreter down, followed by the end of the program.  In a real program,
13726
 
 you may want to get the Python script from another source, perhaps a text-editor
13727
 
 routine, a file, or a database.  Getting the Python code from a file can better
13728
 
-be done by using the :cfunc:`PyRun_SimpleFile` function, which saves you the
13729
 
+be done by using the :c:func:`PyRun_SimpleFile` function, which saves you the
13730
 
 trouble of allocating memory space and loading the file contents.
13731
 
 
13732
 
 
13733
 
@@ -162,8 +162,8 @@
13734
 
    pModule = PyImport_Import(pName);
13735
 
 
13736
 
 After initializing the interpreter, the script is loaded using
13737
 
-:cfunc:`PyImport_Import`.  This routine needs a Python string as its argument,
13738
 
-which is constructed using the :cfunc:`PyString_FromString` data conversion
13739
 
+:c:func:`PyImport_Import`.  This routine needs a Python string as its argument,
13740
 
+which is constructed using the :c:func:`PyString_FromString` data conversion
13741
 
 routine. ::
13742
 
 
13743
 
    pFunc = PyObject_GetAttrString(pModule, argv[2]);
13744
 
@@ -175,7 +175,7 @@
13745
 
    Py_XDECREF(pFunc);
13746
 
 
13747
 
 Once the script is loaded, the name we're looking for is retrieved using
13748
 
-:cfunc:`PyObject_GetAttrString`.  If the name exists, and the object returned is
13749
 
+:c:func:`PyObject_GetAttrString`.  If the name exists, and the object returned is
13750
 
 callable, you can safely assume that it is a function.  The program then
13751
 
 proceeds by constructing a tuple of arguments as normal.  The call to the Python
13752
 
 function is then made with::
13753
 
@@ -218,8 +218,8 @@
13754
 
        {NULL, NULL, 0, NULL}
13755
 
    };
13756
 
 
13757
 
-Insert the above code just above the :cfunc:`main` function. Also, insert the
13758
 
-following two statements directly after :cfunc:`Py_Initialize`::
13759
 
+Insert the above code just above the :c:func:`main` function. Also, insert the
13760
 
+following two statements directly after :c:func:`Py_Initialize`::
13761
 
 
13762
 
    numargs = argc;
13763
 
    Py_InitModule("emb", EmbMethods);
13764
 
diff -r 8527427914a2 Doc/extending/extending.rst
13765
 
--- a/Doc/extending/extending.rst
13766
 
+++ b/Doc/extending/extending.rst
13767
 
@@ -35,7 +35,7 @@
13768
 
 
13769
 
 Let's create an extension module called ``spam`` (the favorite food of Monty
13770
 
 Python fans...) and let's say we want to create a Python interface to the C
13771
 
-library function :cfunc:`system`. [#]_ This function takes a null-terminated
13772
 
+library function :c:func:`system`. [#]_ This function takes a null-terminated
13773
 
 character string as argument and returns an integer.  We want this function to
13774
 
 be callable from Python as follows::
13775
 
 
13776
 
@@ -65,8 +65,8 @@
13777
 
 since they are used extensively by the Python interpreter, ``"Python.h"``
13778
 
 includes a few standard header files: ``<stdio.h>``, ``<string.h>``,
13779
 
 ``<errno.h>``, and ``<stdlib.h>``.  If the latter header file does not exist on
13780
 
-your system, it declares the functions :cfunc:`malloc`, :cfunc:`free` and
13781
 
-:cfunc:`realloc` directly.
13782
 
+your system, it declares the functions :c:func:`malloc`, :c:func:`free` and
13783
 
+:c:func:`realloc` directly.
13784
 
 
13785
 
 The next thing we add to our module file is the C function that will be called
13786
 
 when the Python expression ``spam.system(string)`` is evaluated (we'll see
13787
 
@@ -96,12 +96,12 @@
13788
 
 arguments.  Each item of the tuple corresponds to an argument in the call's
13789
 
 argument list.  The arguments are Python objects --- in order to do anything
13790
 
 with them in our C function we have to convert them to C values.  The function
13791
 
-:cfunc:`PyArg_ParseTuple` in the Python API checks the argument types and
13792
 
+:c:func:`PyArg_ParseTuple` in the Python API checks the argument types and
13793
 
 converts them to C values.  It uses a template string to determine the required
13794
 
 types of the arguments as well as the types of the C variables into which to
13795
 
 store the converted values.  More about this later.
13796
 
 
13797
 
-:cfunc:`PyArg_ParseTuple` returns true (nonzero) if all arguments have the right
13798
 
+:c:func:`PyArg_ParseTuple` returns true (nonzero) if all arguments have the right
13799
 
 type and its components have been stored in the variables whose addresses are
13800
 
 passed.  It returns false (zero) if an invalid argument list was passed.  In the
13801
 
 latter case it also raises an appropriate exception so the calling function can
13802
 
@@ -127,77 +127,77 @@
13803
 
 
13804
 
 The Python API defines a number of functions to set various types of exceptions.
13805
 
 
13806
 
-The most common one is :cfunc:`PyErr_SetString`.  Its arguments are an exception
13807
 
+The most common one is :c:func:`PyErr_SetString`.  Its arguments are an exception
13808
 
 object and a C string.  The exception object is usually a predefined object like
13809
 
-:cdata:`PyExc_ZeroDivisionError`.  The C string indicates the cause of the error
13810
 
+:c:data:`PyExc_ZeroDivisionError`.  The C string indicates the cause of the error
13811
 
 and is converted to a Python string object and stored as the "associated value"
13812
 
 of the exception.
13813
 
 
13814
 
-Another useful function is :cfunc:`PyErr_SetFromErrno`, which only takes an
13815
 
+Another useful function is :c:func:`PyErr_SetFromErrno`, which only takes an
13816
 
 exception argument and constructs the associated value by inspection of the
13817
 
-global variable :cdata:`errno`.  The most general function is
13818
 
-:cfunc:`PyErr_SetObject`, which takes two object arguments, the exception and
13819
 
-its associated value.  You don't need to :cfunc:`Py_INCREF` the objects passed
13820
 
+global variable :c:data:`errno`.  The most general function is
13821
 
+:c:func:`PyErr_SetObject`, which takes two object arguments, the exception and
13822
 
+its associated value.  You don't need to :c:func:`Py_INCREF` the objects passed
13823
 
 to any of these functions.
13824
 
 
13825
 
 You can test non-destructively whether an exception has been set with
13826
 
-:cfunc:`PyErr_Occurred`.  This returns the current exception object, or *NULL*
13827
 
+:c:func:`PyErr_Occurred`.  This returns the current exception object, or *NULL*
13828
 
 if no exception has occurred.  You normally don't need to call
13829
 
-:cfunc:`PyErr_Occurred` to see whether an error occurred in a function call,
13830
 
+:c:func:`PyErr_Occurred` to see whether an error occurred in a function call,
13831
 
 since you should be able to tell from the return value.
13832
 
 
13833
 
 When a function *f* that calls another function *g* detects that the latter
13834
 
 fails, *f* should itself return an error value (usually *NULL* or ``-1``).  It
13835
 
-should *not* call one of the :cfunc:`PyErr_\*` functions --- one has already
13836
 
+should *not* call one of the :c:func:`PyErr_\*` functions --- one has already
13837
 
 been called by *g*. *f*'s caller is then supposed to also return an error
13838
 
-indication to *its* caller, again *without* calling :cfunc:`PyErr_\*`, and so on
13839
 
+indication to *its* caller, again *without* calling :c:func:`PyErr_\*`, and so on
13840
 
 --- the most detailed cause of the error was already reported by the function
13841
 
 that first detected it.  Once the error reaches the Python interpreter's main
13842
 
 loop, this aborts the currently executing Python code and tries to find an
13843
 
 exception handler specified by the Python programmer.
13844
 
 
13845
 
 (There are situations where a module can actually give a more detailed error
13846
 
-message by calling another :cfunc:`PyErr_\*` function, and in such cases it is
13847
 
+message by calling another :c:func:`PyErr_\*` function, and in such cases it is
13848
 
 fine to do so.  As a general rule, however, this is not necessary, and can cause
13849
 
 information about the cause of the error to be lost: most operations can fail
13850
 
 for a variety of reasons.)
13851
 
 
13852
 
 To ignore an exception set by a function call that failed, the exception
13853
 
-condition must be cleared explicitly by calling :cfunc:`PyErr_Clear`.  The only
13854
 
-time C code should call :cfunc:`PyErr_Clear` is if it doesn't want to pass the
13855
 
+condition must be cleared explicitly by calling :c:func:`PyErr_Clear`.  The only
13856
 
+time C code should call :c:func:`PyErr_Clear` is if it doesn't want to pass the
13857
 
 error on to the interpreter but wants to handle it completely by itself
13858
 
 (possibly by trying something else, or pretending nothing went wrong).
13859
 
 
13860
 
-Every failing :cfunc:`malloc` call must be turned into an exception --- the
13861
 
-direct caller of :cfunc:`malloc` (or :cfunc:`realloc`) must call
13862
 
-:cfunc:`PyErr_NoMemory` and return a failure indicator itself.  All the
13863
 
-object-creating functions (for example, :cfunc:`PyInt_FromLong`) already do
13864
 
-this, so this note is only relevant to those who call :cfunc:`malloc` directly.
13865
 
+Every failing :c:func:`malloc` call must be turned into an exception --- the
13866
 
+direct caller of :c:func:`malloc` (or :c:func:`realloc`) must call
13867
 
+:c:func:`PyErr_NoMemory` and return a failure indicator itself.  All the
13868
 
+object-creating functions (for example, :c:func:`PyInt_FromLong`) already do
13869
 
+this, so this note is only relevant to those who call :c:func:`malloc` directly.
13870
 
 
13871
 
-Also note that, with the important exception of :cfunc:`PyArg_ParseTuple` and
13872
 
+Also note that, with the important exception of :c:func:`PyArg_ParseTuple` and
13873
 
 friends, functions that return an integer status usually return a positive value
13874
 
 or zero for success and ``-1`` for failure, like Unix system calls.
13875
 
 
13876
 
-Finally, be careful to clean up garbage (by making :cfunc:`Py_XDECREF` or
13877
 
-:cfunc:`Py_DECREF` calls for objects you have already created) when you return
13878
 
+Finally, be careful to clean up garbage (by making :c:func:`Py_XDECREF` or
13879
 
+:c:func:`Py_DECREF` calls for objects you have already created) when you return
13880
 
 an error indicator!
13881
 
 
13882
 
 The choice of which exception to raise is entirely yours.  There are predeclared
13883
 
 C objects corresponding to all built-in Python exceptions, such as
13884
 
-:cdata:`PyExc_ZeroDivisionError`, which you can use directly. Of course, you
13885
 
-should choose exceptions wisely --- don't use :cdata:`PyExc_TypeError` to mean
13886
 
-that a file couldn't be opened (that should probably be :cdata:`PyExc_IOError`).
13887
 
-If something's wrong with the argument list, the :cfunc:`PyArg_ParseTuple`
13888
 
-function usually raises :cdata:`PyExc_TypeError`.  If you have an argument whose
13889
 
+:c:data:`PyExc_ZeroDivisionError`, which you can use directly. Of course, you
13890
 
+should choose exceptions wisely --- don't use :c:data:`PyExc_TypeError` to mean
13891
 
+that a file couldn't be opened (that should probably be :c:data:`PyExc_IOError`).
13892
 
+If something's wrong with the argument list, the :c:func:`PyArg_ParseTuple`
13893
 
+function usually raises :c:data:`PyExc_TypeError`.  If you have an argument whose
13894
 
 value must be in a particular range or must satisfy other conditions,
13895
 
-:cdata:`PyExc_ValueError` is appropriate.
13896
 
+:c:data:`PyExc_ValueError` is appropriate.
13897
 
 
13898
 
 You can also define a new exception that is unique to your module. For this, you
13899
 
 usually declare a static object variable at the beginning of your file::
13900
 
 
13901
 
    static PyObject *SpamError;
13902
 
 
13903
 
-and initialize it in your module's initialization function (:cfunc:`initspam`)
13904
 
+and initialize it in your module's initialization function (:c:func:`initspam`)
13905
 
 with an exception object (leaving out the error checking for now)::
13906
 
 
13907
 
    PyMODINIT_FUNC
13908
 
@@ -215,14 +215,14 @@
13909
 
    }
13910
 
 
13911
 
 Note that the Python name for the exception object is :exc:`spam.error`.  The
13912
 
-:cfunc:`PyErr_NewException` function may create a class with the base class
13913
 
+:c:func:`PyErr_NewException` function may create a class with the base class
13914
 
 being :exc:`Exception` (unless another class is passed in instead of *NULL*),
13915
 
 described in :ref:`bltin-exceptions`.
13916
 
 
13917
 
-Note also that the :cdata:`SpamError` variable retains a reference to the newly
13918
 
+Note also that the :c:data:`SpamError` variable retains a reference to the newly
13919
 
 created exception class; this is intentional!  Since the exception could be
13920
 
 removed from the module by external code, an owned reference to the class is
13921
 
-needed to ensure that it will not be discarded, causing :cdata:`SpamError` to
13922
 
+needed to ensure that it will not be discarded, causing :c:data:`SpamError` to
13923
 
 become a dangling pointer. Should it become a dangling pointer, C code which
13924
 
 raises the exception could cause a core dump or other unintended side effects.
13925
 
 
13926
 
@@ -230,7 +230,7 @@
13927
 
 sample.
13928
 
 
13929
 
 The :exc:`spam.error` exception can be raised in your extension module using a
13930
 
-call to :cfunc:`PyErr_SetString` as shown below::
13931
 
+call to :c:func:`PyErr_SetString` as shown below::
13932
 
 
13933
 
    static PyObject *
13934
 
    spam_system(PyObject *self, PyObject *args)
13935
 
@@ -262,22 +262,22 @@
13936
 
 
13937
 
 It returns *NULL* (the error indicator for functions returning object pointers)
13938
 
 if an error is detected in the argument list, relying on the exception set by
13939
 
-:cfunc:`PyArg_ParseTuple`.  Otherwise the string value of the argument has been
13940
 
-copied to the local variable :cdata:`command`.  This is a pointer assignment and
13941
 
+:c:func:`PyArg_ParseTuple`.  Otherwise the string value of the argument has been
13942
 
+copied to the local variable :c:data:`command`.  This is a pointer assignment and
13943
 
 you are not supposed to modify the string to which it points (so in Standard C,
13944
 
-the variable :cdata:`command` should properly be declared as ``const char
13945
 
+the variable :c:data:`command` should properly be declared as ``const char
13946
 
 *command``).
13947
 
 
13948
 
-The next statement is a call to the Unix function :cfunc:`system`, passing it
13949
 
-the string we just got from :cfunc:`PyArg_ParseTuple`::
13950
 
+The next statement is a call to the Unix function :c:func:`system`, passing it
13951
 
+the string we just got from :c:func:`PyArg_ParseTuple`::
13952
 
 
13953
 
    sts = system(command);
13954
 
 
13955
 
-Our :func:`spam.system` function must return the value of :cdata:`sts` as a
13956
 
-Python object.  This is done using the function :cfunc:`Py_BuildValue`, which is
13957
 
-something like the inverse of :cfunc:`PyArg_ParseTuple`: it takes a format
13958
 
+Our :func:`spam.system` function must return the value of :c:data:`sts` as a
13959
 
+Python object.  This is done using the function :c:func:`Py_BuildValue`, which is
13960
 
+something like the inverse of :c:func:`PyArg_ParseTuple`: it takes a format
13961
 
 string and an arbitrary number of C values, and returns a new Python object.
13962
 
-More info on :cfunc:`Py_BuildValue` is given later. ::
13963
 
+More info on :c:func:`Py_BuildValue` is given later. ::
13964
 
 
13965
 
    return Py_BuildValue("i", sts);
13966
 
 
13967
 
@@ -285,14 +285,14 @@
13968
 
 on the heap in Python!)
13969
 
 
13970
 
 If you have a C function that returns no useful argument (a function returning
13971
 
-:ctype:`void`), the corresponding Python function must return ``None``.   You
13972
 
-need this idiom to do so (which is implemented by the :cmacro:`Py_RETURN_NONE`
13973
 
+:c:type:`void`), the corresponding Python function must return ``None``.   You
13974
 
+need this idiom to do so (which is implemented by the :c:macro:`Py_RETURN_NONE`
13975
 
 macro)::
13976
 
 
13977
 
    Py_INCREF(Py_None);
13978
 
    return Py_None;
13979
 
 
13980
 
-:cdata:`Py_None` is the C name for the special Python object ``None``.  It is a
13981
 
+:c:data:`Py_None` is the C name for the special Python object ``None``.  It is a
13982
 
 genuine Python object rather than a *NULL* pointer, which means "error" in most
13983
 
 contexts, as we have seen.
13984
 
 
13985
 
@@ -302,7 +302,7 @@
13986
 
 The Module's Method Table and Initialization Function
13987
 
 =====================================================
13988
 
 
13989
 
-I promised to show how :cfunc:`spam_system` is called from Python programs.
13990
 
+I promised to show how :c:func:`spam_system` is called from Python programs.
13991
 
 First, we need to list its name and address in a "method table"::
13992
 
 
13993
 
    static PyMethodDef SpamMethods[] = {
13994
 
@@ -316,21 +316,21 @@
13995
 
 Note the third entry (``METH_VARARGS``).  This is a flag telling the interpreter
13996
 
 the calling convention to be used for the C function.  It should normally always
13997
 
 be ``METH_VARARGS`` or ``METH_VARARGS | METH_KEYWORDS``; a value of ``0`` means
13998
 
-that an obsolete variant of :cfunc:`PyArg_ParseTuple` is used.
13999
 
+that an obsolete variant of :c:func:`PyArg_ParseTuple` is used.
14000
 
 
14001
 
 When using only ``METH_VARARGS``, the function should expect the Python-level
14002
 
 parameters to be passed in as a tuple acceptable for parsing via
14003
 
-:cfunc:`PyArg_ParseTuple`; more information on this function is provided below.
14004
 
+:c:func:`PyArg_ParseTuple`; more information on this function is provided below.
14005
 
 
14006
 
 The :const:`METH_KEYWORDS` bit may be set in the third field if keyword
14007
 
 arguments should be passed to the function.  In this case, the C function should
14008
 
 accept a third ``PyObject *`` parameter which will be a dictionary of keywords.
14009
 
-Use :cfunc:`PyArg_ParseTupleAndKeywords` to parse the arguments to such a
14010
 
+Use :c:func:`PyArg_ParseTupleAndKeywords` to parse the arguments to such a
14011
 
 function.
14012
 
 
14013
 
 The method table must be passed to the interpreter in the module's
14014
 
 initialization function.  The initialization function must be named
14015
 
-:cfunc:`initname`, where *name* is the name of the module, and should be the
14016
 
+:c:func:`initname`, where *name* is the name of the module, and should be the
14017
 
 only non-\ ``static`` item defined in the module file::
14018
 
 
14019
 
    PyMODINIT_FUNC
14020
 
@@ -344,21 +344,21 @@
14021
 
 declares the function as ``extern "C"``.
14022
 
 
14023
 
 When the Python program imports module :mod:`spam` for the first time,
14024
 
-:cfunc:`initspam` is called. (See below for comments about embedding Python.)
14025
 
-It calls :cfunc:`Py_InitModule`, which creates a "module object" (which is
14026
 
+:c:func:`initspam` is called. (See below for comments about embedding Python.)
14027
 
+It calls :c:func:`Py_InitModule`, which creates a "module object" (which is
14028
 
 inserted in the dictionary ``sys.modules`` under the key ``"spam"``), and
14029
 
 inserts built-in function objects into the newly created module based upon the
14030
 
-table (an array of :ctype:`PyMethodDef` structures) that was passed as its
14031
 
-second argument. :cfunc:`Py_InitModule` returns a pointer to the module object
14032
 
+table (an array of :c:type:`PyMethodDef` structures) that was passed as its
14033
 
+second argument. :c:func:`Py_InitModule` returns a pointer to the module object
14034
 
 that it creates (which is unused here).  It may abort with a fatal error for
14035
 
 certain errors, or return *NULL* if the module could not be initialized
14036
 
 satisfactorily.
14037
 
 
14038
 
-When embedding Python, the :cfunc:`initspam` function is not called
14039
 
-automatically unless there's an entry in the :cdata:`_PyImport_Inittab` table.
14040
 
+When embedding Python, the :c:func:`initspam` function is not called
14041
 
+automatically unless there's an entry in the :c:data:`_PyImport_Inittab` table.
14042
 
 The easiest way to handle this is to statically initialize your
14043
 
-statically-linked modules by directly calling :cfunc:`initspam` after the call
14044
 
-to :cfunc:`Py_Initialize`::
14045
 
+statically-linked modules by directly calling :c:func:`initspam` after the call
14046
 
+to :c:func:`Py_Initialize`::
14047
 
 
14048
 
    int
14049
 
    main(int argc, char *argv[])
14050
 
@@ -378,12 +378,12 @@
14051
 
 .. note::
14052
 
 
14053
 
    Removing entries from ``sys.modules`` or importing compiled modules into
14054
 
-   multiple interpreters within a process (or following a :cfunc:`fork` without an
14055
 
-   intervening :cfunc:`exec`) can create problems for some extension modules.
14056
 
+   multiple interpreters within a process (or following a :c:func:`fork` without an
14057
 
+   intervening :c:func:`exec`) can create problems for some extension modules.
14058
 
    Extension module authors should exercise caution when initializing internal data
14059
 
    structures. Note also that the :func:`reload` function can be used with
14060
 
    extension modules, and will call the module initialization function
14061
 
-   (:cfunc:`initspam` in the example), but will not load the module again if it was
14062
 
+   (:c:func:`initspam` in the example), but will not load the module again if it was
14063
 
    loaded from a dynamically loadable object file (:file:`.so` on Unix,
14064
 
    :file:`.dll` on Windows).
14065
 
 
14066
 
@@ -447,7 +447,7 @@
14067
 
 Calling a Python function is easy.  First, the Python program must somehow pass
14068
 
 you the Python function object.  You should provide a function (or some other
14069
 
 interface) to do this.  When this function is called, save a pointer to the
14070
 
-Python function object (be careful to :cfunc:`Py_INCREF` it!) in a global
14071
 
+Python function object (be careful to :c:func:`Py_INCREF` it!) in a global
14072
 
 variable --- or wherever you see fit. For example, the following function might
14073
 
 be part of a module definition::
14074
 
 
14075
 
@@ -476,10 +476,10 @@
14076
 
 
14077
 
 This function must be registered with the interpreter using the
14078
 
 :const:`METH_VARARGS` flag; this is described in section :ref:`methodtable`.  The
14079
 
-:cfunc:`PyArg_ParseTuple` function and its arguments are documented in section
14080
 
+:c:func:`PyArg_ParseTuple` function and its arguments are documented in section
14081
 
 :ref:`parsetuple`.
14082
 
 
14083
 
-The macros :cfunc:`Py_XINCREF` and :cfunc:`Py_XDECREF` increment/decrement the
14084
 
+The macros :c:func:`Py_XINCREF` and :c:func:`Py_XDECREF` increment/decrement the
14085
 
 reference count of an object and are safe in the presence of *NULL* pointers
14086
 
 (but note that *temp* will not be  *NULL* in this context).  More info on them
14087
 
 in section :ref:`refcounts`.
14088
 
@@ -487,12 +487,12 @@
14089
 
 .. index:: single: PyObject_CallObject()
14090
 
 
14091
 
 Later, when it is time to call the function, you call the C function
14092
 
-:cfunc:`PyObject_CallObject`.  This function has two arguments, both pointers to
14093
 
+:c:func:`PyObject_CallObject`.  This function has two arguments, both pointers to
14094
 
 arbitrary Python objects: the Python function, and the argument list.  The
14095
 
 argument list must always be a tuple object, whose length is the number of
14096
 
 arguments.  To call the Python function with no arguments, pass in NULL, or
14097
 
 an empty tuple; to call it with one argument, pass a singleton tuple.
14098
 
-:cfunc:`Py_BuildValue` returns a tuple when its format string consists of zero
14099
 
+:c:func:`Py_BuildValue` returns a tuple when its format string consists of zero
14100
 
 or more format codes between parentheses.  For example::
14101
 
 
14102
 
    int arg;
14103
 
@@ -506,25 +506,25 @@
14104
 
    result = PyObject_CallObject(my_callback, arglist);
14105
 
    Py_DECREF(arglist);
14106
 
 
14107
 
-:cfunc:`PyObject_CallObject` returns a Python object pointer: this is the return
14108
 
-value of the Python function.  :cfunc:`PyObject_CallObject` is
14109
 
+:c:func:`PyObject_CallObject` returns a Python object pointer: this is the return
14110
 
+value of the Python function.  :c:func:`PyObject_CallObject` is
14111
 
 "reference-count-neutral" with respect to its arguments.  In the example a new
14112
 
-tuple was created to serve as the argument list, which is :cfunc:`Py_DECREF`\
14113
 
+tuple was created to serve as the argument list, which is :c:func:`Py_DECREF`\
14114
 
 -ed immediately after the call.
14115
 
 
14116
 
-The return value of :cfunc:`PyObject_CallObject` is "new": either it is a brand
14117
 
+The return value of :c:func:`PyObject_CallObject` is "new": either it is a brand
14118
 
 new object, or it is an existing object whose reference count has been
14119
 
 incremented.  So, unless you want to save it in a global variable, you should
14120
 
-somehow :cfunc:`Py_DECREF` the result, even (especially!) if you are not
14121
 
+somehow :c:func:`Py_DECREF` the result, even (especially!) if you are not
14122
 
 interested in its value.
14123
 
 
14124
 
 Before you do this, however, it is important to check that the return value
14125
 
 isn't *NULL*.  If it is, the Python function terminated by raising an exception.
14126
 
-If the C code that called :cfunc:`PyObject_CallObject` is called from Python, it
14127
 
+If the C code that called :c:func:`PyObject_CallObject` is called from Python, it
14128
 
 should now return an error indication to its Python caller, so the interpreter
14129
 
 can print a stack trace, or the calling Python code can handle the exception.
14130
 
 If this is not possible or desirable, the exception should be cleared by calling
14131
 
-:cfunc:`PyErr_Clear`.  For example::
14132
 
+:c:func:`PyErr_Clear`.  For example::
14133
 
 
14134
 
    if (result == NULL)
14135
 
        return NULL; /* Pass error back */
14136
 
@@ -532,12 +532,12 @@
14137
 
    Py_DECREF(result);
14138
 
 
14139
 
 Depending on the desired interface to the Python callback function, you may also
14140
 
-have to provide an argument list to :cfunc:`PyObject_CallObject`.  In some cases
14141
 
+have to provide an argument list to :c:func:`PyObject_CallObject`.  In some cases
14142
 
 the argument list is also provided by the Python program, through the same
14143
 
 interface that specified the callback function.  It can then be saved and used
14144
 
 in the same manner as the function object.  In other cases, you may have to
14145
 
 construct a new tuple to pass as the argument list.  The simplest way to do this
14146
 
-is to call :cfunc:`Py_BuildValue`.  For example, if you want to pass an integral
14147
 
+is to call :c:func:`Py_BuildValue`.  For example, if you want to pass an integral
14148
 
 event code, you might use the following code::
14149
 
 
14150
 
    PyObject *arglist;
14151
 
@@ -552,11 +552,11 @@
14152
 
 
14153
 
 Note the placement of ``Py_DECREF(arglist)`` immediately after the call, before
14154
 
 the error check!  Also note that strictly speaking this code is not complete:
14155
 
-:cfunc:`Py_BuildValue` may run out of memory, and this should be checked.
14156
 
+:c:func:`Py_BuildValue` may run out of memory, and this should be checked.
14157
 
 
14158
 
 You may also call a function with keyword arguments by using
14159
 
-:cfunc:`PyObject_Call`, which supports arguments and keyword arguments.  As in
14160
 
-the above example, we use :cfunc:`Py_BuildValue` to construct the dictionary. ::
14161
 
+:c:func:`PyObject_Call`, which supports arguments and keyword arguments.  As in
14162
 
+the above example, we use :c:func:`Py_BuildValue` to construct the dictionary. ::
14163
 
 
14164
 
    PyObject *dict;
14165
 
    ...
14166
 
@@ -576,7 +576,7 @@
14167
 
 
14168
 
 .. index:: single: PyArg_ParseTuple()
14169
 
 
14170
 
-The :cfunc:`PyArg_ParseTuple` function is declared as follows::
14171
 
+The :c:func:`PyArg_ParseTuple` function is declared as follows::
14172
 
 
14173
 
    int PyArg_ParseTuple(PyObject *arg, char *format, ...);
14174
 
 
14175
 
@@ -586,7 +586,7 @@
14176
 
 Manual.  The remaining arguments must be addresses of variables whose type is
14177
 
 determined by the format string.
14178
 
 
14179
 
-Note that while :cfunc:`PyArg_ParseTuple` checks that the Python arguments have
14180
 
+Note that while :c:func:`PyArg_ParseTuple` checks that the Python arguments have
14181
 
 the required types, it cannot check the validity of the addresses of C variables
14182
 
 passed to the call: if you make mistakes there, your code will probably crash or
14183
 
 at least overwrite random bits in memory.  So be careful!
14184
 
@@ -663,17 +663,17 @@
14185
 
 
14186
 
 .. index:: single: PyArg_ParseTupleAndKeywords()
14187
 
 
14188
 
-The :cfunc:`PyArg_ParseTupleAndKeywords` function is declared as follows::
14189
 
+The :c:func:`PyArg_ParseTupleAndKeywords` function is declared as follows::
14190
 
 
14191
 
    int PyArg_ParseTupleAndKeywords(PyObject *arg, PyObject *kwdict,
14192
 
                                    char *format, char *kwlist[], ...);
14193
 
 
14194
 
 The *arg* and *format* parameters are identical to those of the
14195
 
-:cfunc:`PyArg_ParseTuple` function.  The *kwdict* parameter is the dictionary of
14196
 
+:c:func:`PyArg_ParseTuple` function.  The *kwdict* parameter is the dictionary of
14197
 
 keywords received as the third parameter from the Python runtime.  The *kwlist*
14198
 
 parameter is a *NULL*-terminated list of strings which identify the parameters;
14199
 
 the names are matched with the type information from *format* from left to
14200
 
-right.  On success, :cfunc:`PyArg_ParseTupleAndKeywords` returns true, otherwise
14201
 
+right.  On success, :c:func:`PyArg_ParseTupleAndKeywords` returns true, otherwise
14202
 
 it returns false and raises an appropriate exception.
14203
 
 
14204
 
 .. note::
14205
 
@@ -737,19 +737,19 @@
14206
 
 Building Arbitrary Values
14207
 
 =========================
14208
 
 
14209
 
-This function is the counterpart to :cfunc:`PyArg_ParseTuple`.  It is declared
14210
 
+This function is the counterpart to :c:func:`PyArg_ParseTuple`.  It is declared
14211
 
 as follows::
14212
 
 
14213
 
    PyObject *Py_BuildValue(char *format, ...);
14214
 
 
14215
 
 It recognizes a set of format units similar to the ones recognized by
14216
 
-:cfunc:`PyArg_ParseTuple`, but the arguments (which are input to the function,
14217
 
+:c:func:`PyArg_ParseTuple`, but the arguments (which are input to the function,
14218
 
 not output) must not be pointers, just values.  It returns a new Python object,
14219
 
 suitable for returning from a C function called from Python.
14220
 
 
14221
 
-One difference with :cfunc:`PyArg_ParseTuple`: while the latter requires its
14222
 
+One difference with :c:func:`PyArg_ParseTuple`: while the latter requires its
14223
 
 first argument to be a tuple (since Python argument lists are always represented
14224
 
-as tuples internally), :cfunc:`Py_BuildValue` does not always build a tuple.  It
14225
 
+as tuples internally), :c:func:`Py_BuildValue` does not always build a tuple.  It
14226
 
 builds a tuple only if its format string contains two or more format units. If
14227
 
 the format string is empty, it returns ``None``; if it contains exactly one
14228
 
 format unit, it returns whatever object is described by that format unit.  To
14229
 
@@ -781,18 +781,18 @@
14230
 
 
14231
 
 In languages like C or C++, the programmer is responsible for dynamic allocation
14232
 
 and deallocation of memory on the heap.  In C, this is done using the functions
14233
 
-:cfunc:`malloc` and :cfunc:`free`.  In C++, the operators ``new`` and
14234
 
+:c:func:`malloc` and :c:func:`free`.  In C++, the operators ``new`` and
14235
 
 ``delete`` are used with essentially the same meaning and we'll restrict
14236
 
 the following discussion to the C case.
14237
 
 
14238
 
-Every block of memory allocated with :cfunc:`malloc` should eventually be
14239
 
-returned to the pool of available memory by exactly one call to :cfunc:`free`.
14240
 
-It is important to call :cfunc:`free` at the right time.  If a block's address
14241
 
-is forgotten but :cfunc:`free` is not called for it, the memory it occupies
14242
 
+Every block of memory allocated with :c:func:`malloc` should eventually be
14243
 
+returned to the pool of available memory by exactly one call to :c:func:`free`.
14244
 
+It is important to call :c:func:`free` at the right time.  If a block's address
14245
 
+is forgotten but :c:func:`free` is not called for it, the memory it occupies
14246
 
 cannot be reused until the program terminates.  This is called a :dfn:`memory
14247
 
-leak`.  On the other hand, if a program calls :cfunc:`free` for a block and then
14248
 
+leak`.  On the other hand, if a program calls :c:func:`free` for a block and then
14249
 
 continues to use the block, it creates a conflict with re-use of the block
14250
 
-through another :cfunc:`malloc` call.  This is called :dfn:`using freed memory`.
14251
 
+through another :c:func:`malloc` call.  This is called :dfn:`using freed memory`.
14252
 
 It has the same bad consequences as referencing uninitialized data --- core
14253
 
 dumps, wrong results, mysterious crashes.
14254
 
 
14255
 
@@ -809,7 +809,7 @@
14256
 
 important to prevent leaks from happening by having a coding convention or
14257
 
 strategy that minimizes this kind of errors.
14258
 
 
14259
 
-Since Python makes heavy use of :cfunc:`malloc` and :cfunc:`free`, it needs a
14260
 
+Since Python makes heavy use of :c:func:`malloc` and :c:func:`free`, it needs a
14261
 
 strategy to avoid memory leaks as well as the use of freed memory.  The chosen
14262
 
 method is called :dfn:`reference counting`.  The principle is simple: every
14263
 
 object contains a counter, which is incremented when a reference to the object
14264
 
@@ -821,11 +821,11 @@
14265
 
 (Sometimes, reference counting is also referred to as a garbage collection
14266
 
 strategy, hence my use of "automatic" to distinguish the two.)  The big
14267
 
 advantage of automatic garbage collection is that the user doesn't need to call
14268
 
-:cfunc:`free` explicitly.  (Another claimed advantage is an improvement in speed
14269
 
+:c:func:`free` explicitly.  (Another claimed advantage is an improvement in speed
14270
 
 or memory usage --- this is no hard fact however.)  The disadvantage is that for
14271
 
 C, there is no truly portable automatic garbage collector, while reference
14272
 
-counting can be implemented portably (as long as the functions :cfunc:`malloc`
14273
 
-and :cfunc:`free` are available --- which the C Standard guarantees). Maybe some
14274
 
+counting can be implemented portably (as long as the functions :c:func:`malloc`
14275
 
+and :c:func:`free` are available --- which the C Standard guarantees). Maybe some
14276
 
 day a sufficiently portable automatic garbage collector will be available for C.
14277
 
 Until then, we'll have to live with reference counts.
14278
 
 
14279
 
@@ -861,9 +861,9 @@
14280
 
 ----------------------------
14281
 
 
14282
 
 There are two macros, ``Py_INCREF(x)`` and ``Py_DECREF(x)``, which handle the
14283
 
-incrementing and decrementing of the reference count. :cfunc:`Py_DECREF` also
14284
 
+incrementing and decrementing of the reference count. :c:func:`Py_DECREF` also
14285
 
 frees the object when the count reaches zero. For flexibility, it doesn't call
14286
 
-:cfunc:`free` directly --- rather, it makes a call through a function pointer in
14287
 
+:c:func:`free` directly --- rather, it makes a call through a function pointer in
14288
 
 the object's :dfn:`type object`.  For this purpose (and others), every object
14289
 
 also contains a pointer to its type object.
14290
 
 
14291
 
@@ -871,13 +871,13 @@
14292
 
 Let's first introduce some terms.  Nobody "owns" an object; however, you can
14293
 
 :dfn:`own a reference` to an object.  An object's reference count is now defined
14294
 
 as the number of owned references to it.  The owner of a reference is
14295
 
-responsible for calling :cfunc:`Py_DECREF` when the reference is no longer
14296
 
+responsible for calling :c:func:`Py_DECREF` when the reference is no longer
14297
 
 needed.  Ownership of a reference can be transferred.  There are three ways to
14298
 
-dispose of an owned reference: pass it on, store it, or call :cfunc:`Py_DECREF`.
14299
 
+dispose of an owned reference: pass it on, store it, or call :c:func:`Py_DECREF`.
14300
 
 Forgetting to dispose of an owned reference creates a memory leak.
14301
 
 
14302
 
 It is also possible to :dfn:`borrow` [#]_ a reference to an object.  The
14303
 
-borrower of a reference should not call :cfunc:`Py_DECREF`.  The borrower must
14304
 
+borrower of a reference should not call :c:func:`Py_DECREF`.  The borrower must
14305
 
 not hold on to the object longer than the owner from which it was borrowed.
14306
 
 Using a borrowed reference after the owner has disposed of it risks using freed
14307
 
 memory and should be avoided completely. [#]_
14308
 
@@ -891,7 +891,7 @@
14309
 
 disposed of it.
14310
 
 
14311
 
 A borrowed reference can be changed into an owned reference by calling
14312
 
-:cfunc:`Py_INCREF`.  This does not affect the status of the owner from which the
14313
 
+:c:func:`Py_INCREF`.  This does not affect the status of the owner from which the
14314
 
 reference was borrowed --- it creates a new owned reference, and gives full
14315
 
 owner responsibilities (the new owner must dispose of the reference properly, as
14316
 
 well as the previous owner).
14317
 
@@ -908,36 +908,36 @@
14318
 
 
14319
 
 Most functions that return a reference to an object pass on ownership with the
14320
 
 reference.  In particular, all functions whose function it is to create a new
14321
 
-object, such as :cfunc:`PyInt_FromLong` and :cfunc:`Py_BuildValue`, pass
14322
 
+object, such as :c:func:`PyInt_FromLong` and :c:func:`Py_BuildValue`, pass
14323
 
 ownership to the receiver.  Even if the object is not actually new, you still
14324
 
 receive ownership of a new reference to that object.  For instance,
14325
 
-:cfunc:`PyInt_FromLong` maintains a cache of popular values and can return a
14326
 
+:c:func:`PyInt_FromLong` maintains a cache of popular values and can return a
14327
 
 reference to a cached item.
14328
 
 
14329
 
 Many functions that extract objects from other objects also transfer ownership
14330
 
-with the reference, for instance :cfunc:`PyObject_GetAttrString`.  The picture
14331
 
+with the reference, for instance :c:func:`PyObject_GetAttrString`.  The picture
14332
 
 is less clear, here, however, since a few common routines are exceptions:
14333
 
-:cfunc:`PyTuple_GetItem`, :cfunc:`PyList_GetItem`, :cfunc:`PyDict_GetItem`, and
14334
 
-:cfunc:`PyDict_GetItemString` all return references that you borrow from the
14335
 
+:c:func:`PyTuple_GetItem`, :c:func:`PyList_GetItem`, :c:func:`PyDict_GetItem`, and
14336
 
+:c:func:`PyDict_GetItemString` all return references that you borrow from the
14337
 
 tuple, list or dictionary.
14338
 
 
14339
 
-The function :cfunc:`PyImport_AddModule` also returns a borrowed reference, even
14340
 
+The function :c:func:`PyImport_AddModule` also returns a borrowed reference, even
14341
 
 though it may actually create the object it returns: this is possible because an
14342
 
 owned reference to the object is stored in ``sys.modules``.
14343
 
 
14344
 
 When you pass an object reference into another function, in general, the
14345
 
 function borrows the reference from you --- if it needs to store it, it will use
14346
 
-:cfunc:`Py_INCREF` to become an independent owner.  There are exactly two
14347
 
-important exceptions to this rule: :cfunc:`PyTuple_SetItem` and
14348
 
-:cfunc:`PyList_SetItem`.  These functions take over ownership of the item passed
14349
 
-to them --- even if they fail!  (Note that :cfunc:`PyDict_SetItem` and friends
14350
 
+:c:func:`Py_INCREF` to become an independent owner.  There are exactly two
14351
 
+important exceptions to this rule: :c:func:`PyTuple_SetItem` and
14352
 
+:c:func:`PyList_SetItem`.  These functions take over ownership of the item passed
14353
 
+to them --- even if they fail!  (Note that :c:func:`PyDict_SetItem` and friends
14354
 
 don't take over ownership --- they are "normal.")
14355
 
 
14356
 
 When a C function is called from Python, it borrows references to its arguments
14357
 
 from the caller.  The caller owns a reference to the object, so the borrowed
14358
 
 reference's lifetime is guaranteed until the function returns.  Only when such a
14359
 
 borrowed reference must be stored or passed on, it must be turned into an owned
14360
 
-reference by calling :cfunc:`Py_INCREF`.
14361
 
+reference by calling :c:func:`Py_INCREF`.
14362
 
 
14363
 
 The object reference returned from a C function that is called from Python must
14364
 
 be an owned reference --- ownership is transferred from the function to its
14365
 
@@ -953,7 +953,7 @@
14366
 
 can lead to problems.  These all have to do with implicit invocations of the
14367
 
 interpreter, which can cause the owner of a reference to dispose of it.
14368
 
 
14369
 
-The first and most important case to know about is using :cfunc:`Py_DECREF` on
14370
 
+The first and most important case to know about is using :c:func:`Py_DECREF` on
14371
 
 an unrelated object while borrowing a reference to a list item.  For instance::
14372
 
 
14373
 
    void
14374
 
@@ -969,7 +969,7 @@
14375
 
 ``list[1]`` with the value ``0``, and finally prints the borrowed reference.
14376
 
 Looks harmless, right?  But it's not!
14377
 
 
14378
 
-Let's follow the control flow into :cfunc:`PyList_SetItem`.  The list owns
14379
 
+Let's follow the control flow into :c:func:`PyList_SetItem`.  The list owns
14380
 
 references to all its items, so when item 1 is replaced, it has to dispose of
14381
 
 the original item 1.  Now let's suppose the original item 1 was an instance of a
14382
 
 user-defined class, and let's further suppose that the class defined a
14383
 
@@ -978,8 +978,8 @@
14384
 
 
14385
 
 Since it is written in Python, the :meth:`__del__` method can execute arbitrary
14386
 
 Python code.  Could it perhaps do something to invalidate the reference to
14387
 
-``item`` in :cfunc:`bug`?  You bet!  Assuming that the list passed into
14388
 
-:cfunc:`bug` is accessible to the :meth:`__del__` method, it could execute a
14389
 
+``item`` in :c:func:`bug`?  You bet!  Assuming that the list passed into
14390
 
+:c:func:`bug` is accessible to the :meth:`__del__` method, it could execute a
14391
 
 statement to the effect of ``del list[0]``, and assuming this was the last
14392
 
 reference to that object, it would free the memory associated with it, thereby
14393
 
 invalidating ``item``.
14394
 
@@ -1006,8 +1006,8 @@
14395
 
 threads.  Normally, multiple threads in the Python interpreter can't get in each
14396
 
 other's way, because there is a global lock protecting Python's entire object
14397
 
 space.  However, it is possible to temporarily release this lock using the macro
14398
 
-:cmacro:`Py_BEGIN_ALLOW_THREADS`, and to re-acquire it using
14399
 
-:cmacro:`Py_END_ALLOW_THREADS`.  This is common around blocking I/O calls, to
14400
 
+:c:macro:`Py_BEGIN_ALLOW_THREADS`, and to re-acquire it using
14401
 
+:c:macro:`Py_END_ALLOW_THREADS`.  This is common around blocking I/O calls, to
14402
 
 let other threads use the processor while waiting for the I/O to complete.
14403
 
 Obviously, the following function has the same problem as the previous one::
14404
 
 
14405
 
@@ -1036,11 +1036,11 @@
14406
 
 redundant tests and the code would run more slowly.
14407
 
 
14408
 
 It is better to test for *NULL* only at the "source:" when a pointer that may be
14409
 
-*NULL* is received, for example, from :cfunc:`malloc` or from a function that
14410
 
+*NULL* is received, for example, from :c:func:`malloc` or from a function that
14411
 
 may raise an exception.
14412
 
 
14413
 
-The macros :cfunc:`Py_INCREF` and :cfunc:`Py_DECREF` do not check for *NULL*
14414
 
-pointers --- however, their variants :cfunc:`Py_XINCREF` and :cfunc:`Py_XDECREF`
14415
 
+The macros :c:func:`Py_INCREF` and :c:func:`Py_DECREF` do not check for *NULL*
14416
 
+pointers --- however, their variants :c:func:`Py_XINCREF` and :c:func:`Py_XDECREF`
14417
 
 do.
14418
 
 
14419
 
 The macros for checking for a particular object type (``Pytype_Check()``) don't
14420
 
@@ -1114,7 +1114,7 @@
14421
 
 
14422
 
 Python provides a special mechanism to pass C-level information (pointers) from
14423
 
 one extension module to another one: Capsules. A Capsule is a Python data type
14424
 
-which stores a pointer (:ctype:`void \*`).  Capsules can only be created and
14425
 
+which stores a pointer (:c:type:`void \*`).  Capsules can only be created and
14426
 
 accessed via their C API, but they can be passed around like any other Python
14427
 
 object. In particular,  they can be assigned to a name in an extension module's
14428
 
 namespace. Other extension modules can then import this module, retrieve the
14429
 
@@ -1127,8 +1127,8 @@
14430
 
 different ways between the module providing the code and the client modules.
14431
 
 
14432
 
 Whichever method you choose, it's important to name your Capsules properly.
14433
 
-The function :cfunc:`PyCapsule_New` takes a name parameter
14434
 
-(:ctype:`const char \*`); you're permitted to pass in a *NULL* name, but
14435
 
+The function :c:func:`PyCapsule_New` takes a name parameter
14436
 
+(:c:type:`const char \*`); you're permitted to pass in a *NULL* name, but
14437
 
 we strongly encourage you to specify a name.  Properly named Capsules provide
14438
 
 a degree of runtime type-safety; there is no feasible way to tell one unnamed
14439
 
 Capsule from another.
14440
 
@@ -1138,7 +1138,7 @@
14441
 
 
14442
 
     modulename.attributename
14443
 
 
14444
 
-The convenience function :cfunc:`PyCapsule_Import` makes it easy to
14445
 
+The convenience function :c:func:`PyCapsule_Import` makes it easy to
14446
 
 load a C API provided via a Capsule, but only if the Capsule's name
14447
 
 matches this convention.  This behavior gives C API users a high degree
14448
 
 of certainty that the Capsule they load contains the correct C API.
14449
 
@@ -1146,19 +1146,19 @@
14450
 
 The following example demonstrates an approach that puts most of the burden on
14451
 
 the writer of the exporting module, which is appropriate for commonly used
14452
 
 library modules. It stores all C API pointers (just one in the example!) in an
14453
 
-array of :ctype:`void` pointers which becomes the value of a Capsule. The header
14454
 
+array of :c:type:`void` pointers which becomes the value of a Capsule. The header
14455
 
 file corresponding to the module provides a macro that takes care of importing
14456
 
 the module and retrieving its C API pointers; client modules only have to call
14457
 
 this macro before accessing the C API.
14458
 
 
14459
 
 The exporting module is a modification of the :mod:`spam` module from section
14460
 
 :ref:`extending-simpleexample`. The function :func:`spam.system` does not call
14461
 
-the C library function :cfunc:`system` directly, but a function
14462
 
-:cfunc:`PySpam_System`, which would of course do something more complicated in
14463
 
+the C library function :c:func:`system` directly, but a function
14464
 
+:c:func:`PySpam_System`, which would of course do something more complicated in
14465
 
 reality (such as adding "spam" to every command). This function
14466
 
-:cfunc:`PySpam_System` is also exported to other extension modules.
14467
 
+:c:func:`PySpam_System` is also exported to other extension modules.
14468
 
 
14469
 
-The function :cfunc:`PySpam_System` is a plain C function, declared
14470
 
+The function :c:func:`PySpam_System` is a plain C function, declared
14471
 
 ``static`` like everything else::
14472
 
 
14473
 
    static int
14474
 
@@ -1167,7 +1167,7 @@
14475
 
        return system(command);
14476
 
    }
14477
 
 
14478
 
-The function :cfunc:`spam_system` is modified in a trivial way::
14479
 
+The function :c:func:`spam_system` is modified in a trivial way::
14480
 
 
14481
 
    static PyObject *
14482
 
    spam_system(PyObject *self, PyObject *args)
14483
 
@@ -1270,8 +1270,8 @@
14484
 
    #endif /* !defined(Py_SPAMMODULE_H) */
14485
 
 
14486
 
 All that a client module must do in order to have access to the function
14487
 
-:cfunc:`PySpam_System` is to call the function (or rather macro)
14488
 
-:cfunc:`import_spam` in its initialization function::
14489
 
+:c:func:`PySpam_System` is to call the function (or rather macro)
14490
 
+:c:func:`import_spam` in its initialization function::
14491
 
 
14492
 
    PyMODINIT_FUNC
14493
 
    initclient(void)
14494
 
diff -r 8527427914a2 Doc/extending/newtypes.rst
14495
 
--- a/Doc/extending/newtypes.rst
14496
 
+++ b/Doc/extending/newtypes.rst
14497
 
@@ -34,12 +34,11 @@
14498
 
 ==========
14499
 
 
14500
 
 The Python runtime sees all Python objects as variables of type
14501
 
-:ctype:`PyObject\*`.  A :ctype:`PyObject` is not a very magnificent object - it
14502
 
+:c:type:`PyObject\*`.  A :c:type:`PyObject` is not a very magnificent object - it
14503
 
 just contains the refcount and a pointer to the object's "type object".  This is
14504
 
 where the action is; the type object determines which (C) functions get called
14505
 
 when, for instance, an attribute gets looked up on an object or it is multiplied
14506
 
-by another object.  These C functions are called "type methods" to distinguish
14507
 
-them from things like ``[].append`` (which we call "object methods").
14508
 
+by another object.  These C functions are called "type methods".
14509
 
 
14510
 
 So, if you want to define a new object type, you need to create a new type
14511
 
 object.
14512
 
@@ -104,7 +103,7 @@
14513
 
        "Noddy objects",           /* tp_doc */
14514
 
    };
14515
 
 
14516
 
-Now if you go and look up the definition of :ctype:`PyTypeObject` in
14517
 
+Now if you go and look up the definition of :c:type:`PyTypeObject` in
14518
 
 :file:`object.h` you'll see that it has many more fields that the definition
14519
 
 above.  The remaining fields will be filled with zeros by the C compiler, and
14520
 
 it's common practice to not specify them explicitly unless you need them.
14521
 
@@ -120,7 +119,7 @@
14522
 
 
14523
 
 as the type of a type object is "type", but this isn't strictly conforming C and
14524
 
 some compilers complain.  Fortunately, this member will be filled in for us by
14525
 
-:cfunc:`PyType_Ready`. ::
14526
 
+:c:func:`PyType_Ready`. ::
14527
 
 
14528
 
    0,                          /* ob_size */
14529
 
 
14530
 
@@ -146,7 +145,7 @@
14531
 
    sizeof(noddy_NoddyObject),  /* tp_basicsize */
14532
 
 
14533
 
 This is so that Python knows how much memory to allocate when you call
14534
 
-:cfunc:`PyObject_New`.
14535
 
+:c:func:`PyObject_New`.
14536
 
 
14537
 
 .. note::
14538
 
 
14539
 
@@ -186,12 +185,12 @@
14540
 
 For now, all we want to be able to do is to create new :class:`Noddy` objects.
14541
 
 To enable object creation, we have to provide a :attr:`tp_new` implementation.
14542
 
 In this case, we can just use the default implementation provided by the API
14543
 
-function :cfunc:`PyType_GenericNew`.  We'd like to just assign this to the
14544
 
+function :c:func:`PyType_GenericNew`.  We'd like to just assign this to the
14545
 
 :attr:`tp_new` slot, but we can't, for portability sake, On some platforms or
14546
 
 compilers, we can't statically initialize a structure member with a function
14547
 
 defined in another C module, so, instead, we'll assign the :attr:`tp_new` slot
14548
 
 in the module initialization function just before calling
14549
 
-:cfunc:`PyType_Ready`::
14550
 
+:c:func:`PyType_Ready`::
14551
 
 
14552
 
    noddy_NoddyType.tp_new = PyType_GenericNew;
14553
 
    if (PyType_Ready(&noddy_NoddyType) < 0)
14554
 
@@ -201,7 +200,7 @@
14555
 
 for a later section!
14556
 
 
14557
 
 Everything else in the file should be familiar, except for some code in
14558
 
-:cfunc:`initnoddy`::
14559
 
+:c:func:`initnoddy`::
14560
 
 
14561
 
    if (PyType_Ready(&noddy_NoddyType) < 0)
14562
 
        return;
14563
 
@@ -289,7 +288,7 @@
14564
 
    (destructor)Noddy_dealloc, /*tp_dealloc*/
14565
 
 
14566
 
 This method decrements the reference counts of the two Python attributes. We use
14567
 
-:cfunc:`Py_XDECREF` here because the :attr:`first` and :attr:`last` members
14568
 
+:c:func:`Py_XDECREF` here because the :attr:`first` and :attr:`last` members
14569
 
 could be *NULL*.  It then calls the :attr:`tp_free` member of the object's type
14570
 
 to free the object's memory.  Note that the object's type might not be
14571
 
 :class:`NoddyType`, because the object may be an instance of a subclass.
14572
 
@@ -335,8 +334,8 @@
14573
 
 the initial values of instance variables.  In this case, we use the new method
14574
 
 to make sure that the initial values of the members :attr:`first` and
14575
 
 :attr:`last` are not *NULL*. If we didn't care whether the initial values were
14576
 
-*NULL*, we could have used :cfunc:`PyType_GenericNew` as our new method, as we
14577
 
-did before.  :cfunc:`PyType_GenericNew` initializes all of the instance variable
14578
 
+*NULL*, we could have used :c:func:`PyType_GenericNew` as our new method, as we
14579
 
+did before.  :c:func:`PyType_GenericNew` initializes all of the instance variable
14580
 
 members to *NULL*.
14581
 
 
14582
 
 The new method is a static method that is passed the type being instantiated and
14583
 
@@ -346,7 +345,7 @@
14584
 
 methods. Note that if the type supports subclassing, the type passed may not be
14585
 
 the type being defined.  The new method calls the tp_alloc slot to allocate
14586
 
 memory. We don't fill the :attr:`tp_alloc` slot ourselves. Rather
14587
 
-:cfunc:`PyType_Ready` fills it for us by inheriting it from our base class,
14588
 
+:c:func:`PyType_Ready` fills it for us by inheriting it from our base class,
14589
 
 which is :class:`object` by default.  Most types use the default allocation.
14590
 
 
14591
 
 .. note::
14592
 
@@ -531,8 +530,8 @@
14593
 
 
14594
 
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
14595
 
 
14596
 
-We rename :cfunc:`initnoddy` to :cfunc:`initnoddy2` and update the module name
14597
 
-passed to :cfunc:`Py_InitModule3`.
14598
 
+We rename :c:func:`initnoddy` to :c:func:`initnoddy2` and update the module name
14599
 
+passed to :c:func:`Py_InitModule3`.
14600
 
 
14601
 
 Finally, we update our :file:`setup.py` file to build the new module::
14602
 
 
14603
 
@@ -598,7 +597,7 @@
14604
 
 deleted.  In our setter, we raise an error if the attribute is deleted or if the
14605
 
 attribute value is not a string.
14606
 
 
14607
 
-We create an array of :ctype:`PyGetSetDef` structures::
14608
 
+We create an array of :c:type:`PyGetSetDef` structures::
14609
 
 
14610
 
    static PyGetSetDef Noddy_getseters[] = {
14611
 
        {"first",
14612
 
@@ -618,7 +617,7 @@
14613
 
 
14614
 
 to register our attribute getters and setters.
14615
 
 
14616
 
-The last item in a :ctype:`PyGetSetDef` structure is the closure mentioned
14617
 
+The last item in a :c:type:`PyGetSetDef` structure is the closure mentioned
14618
 
 above. In this case, we aren't using the closure, so we just pass *NULL*.
14619
 
 
14620
 
 We also remove the member definitions for these attributes::
14621
 
@@ -663,8 +662,8 @@
14622
 
 
14623
 
 With these changes, we can assure that the :attr:`first` and :attr:`last`
14624
 
 members are never *NULL* so we can remove checks for *NULL* values in almost all
14625
 
-cases. This means that most of the :cfunc:`Py_XDECREF` calls can be converted to
14626
 
-:cfunc:`Py_DECREF` calls. The only place we can't change these calls is in the
14627
 
+cases. This means that most of the :c:func:`Py_XDECREF` calls can be converted to
14628
 
+:c:func:`Py_DECREF` calls. The only place we can't change these calls is in the
14629
 
 deallocator, where there is the possibility that the initialization of these
14630
 
 members failed in the constructor.
14631
 
 
14632
 
@@ -729,13 +728,13 @@
14633
 
    }
14634
 
 
14635
 
 For each subobject that can participate in cycles, we need to call the
14636
 
-:cfunc:`visit` function, which is passed to the traversal method. The
14637
 
-:cfunc:`visit` function takes as arguments the subobject and the extra argument
14638
 
+:c:func:`visit` function, which is passed to the traversal method. The
14639
 
+:c:func:`visit` function takes as arguments the subobject and the extra argument
14640
 
 *arg* passed to the traversal method.  It returns an integer value that must be
14641
 
 returned if it is non-zero.
14642
 
 
14643
 
-Python 2.4 and higher provide a :cfunc:`Py_VISIT` macro that automates calling
14644
 
-visit functions.  With :cfunc:`Py_VISIT`, :cfunc:`Noddy_traverse` can be
14645
 
+Python 2.4 and higher provide a :c:func:`Py_VISIT` macro that automates calling
14646
 
+visit functions.  With :c:func:`Py_VISIT`, :c:func:`Noddy_traverse` can be
14647
 
 simplified::
14648
 
 
14649
 
    static int
14650
 
@@ -749,7 +748,7 @@
14651
 
 .. note::
14652
 
 
14653
 
    Note that the :attr:`tp_traverse` implementation must name its arguments exactly
14654
 
-   *visit* and *arg* in order to use :cfunc:`Py_VISIT`.  This is to encourage
14655
 
+   *visit* and *arg* in order to use :c:func:`Py_VISIT`.  This is to encourage
14656
 
    uniformity across these boring implementations.
14657
 
 
14658
 
 We also need to provide a method for clearing any subobjects that can
14659
 
@@ -779,19 +778,19 @@
14660
 
        self->ob_type->tp_free((PyObject*)self);
14661
 
    }
14662
 
 
14663
 
-Notice the use of a temporary variable in :cfunc:`Noddy_clear`. We use the
14664
 
+Notice the use of a temporary variable in :c:func:`Noddy_clear`. We use the
14665
 
 temporary variable so that we can set each member to *NULL* before decrementing
14666
 
 its reference count.  We do this because, as was discussed earlier, if the
14667
 
 reference count drops to zero, we might cause code to run that calls back into
14668
 
 the object.  In addition, because we now support garbage collection, we also
14669
 
 have to worry about code being run that triggers garbage collection.  If garbage
14670
 
 collection is run, our :attr:`tp_traverse` handler could get called. We can't
14671
 
-take a chance of having :cfunc:`Noddy_traverse` called when a member's reference
14672
 
+take a chance of having :c:func:`Noddy_traverse` called when a member's reference
14673
 
 count has dropped to zero and its value hasn't been set to *NULL*.
14674
 
 
14675
 
-Python 2.4 and higher provide a :cfunc:`Py_CLEAR` that automates the careful
14676
 
-decrementing of reference counts.  With :cfunc:`Py_CLEAR`, the
14677
 
-:cfunc:`Noddy_clear` function can be simplified::
14678
 
+Python 2.4 and higher provide a :c:func:`Py_CLEAR` that automates the careful
14679
 
+decrementing of reference counts.  With :c:func:`Py_CLEAR`, the
14680
 
+:c:func:`Noddy_clear` function can be simplified::
14681
 
 
14682
 
    static int
14683
 
    Noddy_clear(Noddy *self)
14684
 
@@ -846,7 +845,7 @@
14685
 
 
14686
 
 The primary difference for derived type objects is that the base type's object
14687
 
 structure must be the first value. The base type will already include the
14688
 
-:cfunc:`PyObject_HEAD` at the beginning of its structure.
14689
 
+:c:func:`PyObject_HEAD` at the beginning of its structure.
14690
 
 
14691
 
 When a Python object is a :class:`Shoddy` instance, its *PyObject\** pointer can
14692
 
 be safely cast to both *PyListObject\** and *Shoddy\**. ::
14693
 
@@ -868,10 +867,10 @@
14694
 
 memory for the object with :attr:`tp_alloc`, that will be handled by the base
14695
 
 class when calling its :attr:`tp_new`.
14696
 
 
14697
 
-When filling out the :cfunc:`PyTypeObject` for the :class:`Shoddy` type, you see
14698
 
-a slot for :cfunc:`tp_base`. Due to cross platform compiler issues, you can't
14699
 
-fill that field directly with the :cfunc:`PyList_Type`; it can be done later in
14700
 
-the module's :cfunc:`init` function. ::
14701
 
+When filling out the :c:func:`PyTypeObject` for the :class:`Shoddy` type, you see
14702
 
+a slot for :c:func:`tp_base`. Due to cross platform compiler issues, you can't
14703
 
+fill that field directly with the :c:func:`PyList_Type`; it can be done later in
14704
 
+the module's :c:func:`init` function. ::
14705
 
 
14706
 
    PyMODINIT_FUNC
14707
 
    initshoddy(void)
14708
 
@@ -890,12 +889,12 @@
14709
 
        PyModule_AddObject(m, "Shoddy", (PyObject *) &ShoddyType);
14710
 
    }
14711
 
 
14712
 
-Before calling :cfunc:`PyType_Ready`, the type structure must have the
14713
 
+Before calling :c:func:`PyType_Ready`, the type structure must have the
14714
 
 :attr:`tp_base` slot filled in. When we are deriving a new type, it is not
14715
 
-necessary to fill out the :attr:`tp_alloc` slot with :cfunc:`PyType_GenericNew`
14716
 
+necessary to fill out the :attr:`tp_alloc` slot with :c:func:`PyType_GenericNew`
14717
 
 -- the allocate function from the base type will be inherited.
14718
 
 
14719
 
-After that, calling :cfunc:`PyType_Ready` and adding the type object to the
14720
 
+After that, calling :c:func:`PyType_Ready` and adding the type object to the
14721
 
 module is the same as with the basic :class:`Noddy` examples.
14722
 
 
14723
 
 
14724
 
@@ -907,7 +906,7 @@
14725
 
 This section aims to give a quick fly-by on the various type methods you can
14726
 
 implement and what they do.
14727
 
 
14728
 
-Here is the definition of :ctype:`PyTypeObject`, with some fields only used in
14729
 
+Here is the definition of :c:type:`PyTypeObject`, with some fields only used in
14730
 
 debug builds omitted:
14731
 
 
14732
 
 .. literalinclude:: ../includes/typestruct.h
14733
 
@@ -985,8 +984,8 @@
14734
 
 executed may detect that an exception has been set.  This can lead to misleading
14735
 
 errors from the interpreter.  The proper way to protect against this is to save
14736
 
 a pending exception before performing the unsafe action, and restoring it when
14737
 
-done.  This can be done using the :cfunc:`PyErr_Fetch` and
14738
 
-:cfunc:`PyErr_Restore` functions::
14739
 
+done.  This can be done using the :c:func:`PyErr_Fetch` and
14740
 
+:c:func:`PyErr_Restore` functions::
14741
 
 
14742
 
    static void
14743
 
    my_dealloc(PyObject *obj)
14744
 
@@ -1027,7 +1026,7 @@
14745
 
 object: the :func:`repr` function (or equivalent back-tick syntax), the
14746
 
 :func:`str` function, and the :keyword:`print` statement.  For most objects, the
14747
 
 :keyword:`print` statement is equivalent to the :func:`str` function, but it is
14748
 
-possible to special-case printing to a :ctype:`FILE\*` if necessary; this should
14749
 
+possible to special-case printing to a :c:type:`FILE\*` if necessary; this should
14750
 
 only be done if efficiency is identified as a problem and profiling suggests
14751
 
 that creating a temporary string object to be written to a file is too
14752
 
 expensive.
14753
 
@@ -1111,8 +1110,8 @@
14754
 
 
14755
 
 Python supports two pairs of attribute handlers; a type that supports attributes
14756
 
 only needs to implement the functions for one pair.  The difference is that one
14757
 
-pair takes the name of the attribute as a :ctype:`char\*`, while the other
14758
 
-accepts a :ctype:`PyObject\*`.  Each type can use whichever pair makes more
14759
 
+pair takes the name of the attribute as a :c:type:`char\*`, while the other
14760
 
+accepts a :c:type:`PyObject\*`.  Each type can use whichever pair makes more
14761
 
 sense for the implementation's convenience. ::
14762
 
 
14763
 
    getattrfunc  tp_getattr;        /* char * version */
14764
 
@@ -1123,7 +1122,7 @@
14765
 
 
14766
 
 If accessing attributes of an object is always a simple operation (this will be
14767
 
 explained shortly), there are generic implementations which can be used to
14768
 
-provide the :ctype:`PyObject\*` version of the attribute management functions.
14769
 
+provide the :c:type:`PyObject\*` version of the attribute management functions.
14770
 
 The actual need for type-specific attribute handlers almost completely
14771
 
 disappeared starting with Python 2.2, though there are many examples which have
14772
 
 not been updated to use some of the new generic mechanism that is available.
14773
 
@@ -1139,7 +1138,7 @@
14774
 
 Most extension types only use *simple* attributes.  So, what makes the
14775
 
 attributes simple?  There are only a couple of conditions that must be met:
14776
 
 
14777
 
-#. The name of the attributes must be known when :cfunc:`PyType_Ready` is
14778
 
+#. The name of the attributes must be known when :c:func:`PyType_Ready` is
14779
 
    called.
14780
 
 
14781
 
 #. No special processing is needed to record that an attribute was looked up or
14782
 
@@ -1148,7 +1147,7 @@
14783
 
 Note that this list does not place any restrictions on the values of the
14784
 
 attributes, when the values are computed, or how relevant data is stored.
14785
 
 
14786
 
-When :cfunc:`PyType_Ready` is called, it uses three tables referenced by the
14787
 
+When :c:func:`PyType_Ready` is called, it uses three tables referenced by the
14788
 
 type object to create :term:`descriptor`\s which are placed in the dictionary of the
14789
 
 type object.  Each descriptor controls access to one attribute of the instance
14790
 
 object.  Each of the tables is optional; if all three are *NULL*, instances of
14791
 
@@ -1163,7 +1162,7 @@
14792
 
    struct PyGetSetDef *tp_getset;
14793
 
 
14794
 
 If :attr:`tp_methods` is not *NULL*, it must refer to an array of
14795
 
-:ctype:`PyMethodDef` structures.  Each entry in the table is an instance of this
14796
 
+:c:type:`PyMethodDef` structures.  Each entry in the table is an instance of this
14797
 
 structure::
14798
 
 
14799
 
    typedef struct PyMethodDef {
14800
 
@@ -1248,9 +1247,9 @@
14801
 
 Type-specific Attribute Management
14802
 
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14803
 
 
14804
 
-For simplicity, only the :ctype:`char\*` version will be demonstrated here; the
14805
 
-type of the name parameter is the only difference between the :ctype:`char\*`
14806
 
-and :ctype:`PyObject\*` flavors of the interface. This example effectively does
14807
 
+For simplicity, only the :c:type:`char\*` version will be demonstrated here; the
14808
 
+type of the name parameter is the only difference between the :c:type:`char\*`
14809
 
+and :c:type:`PyObject\*` flavors of the interface. This example effectively does
14810
 
 the same thing as the generic example above, but does not use the generic
14811
 
 support added in Python 2.2.  The value in showing this is two-fold: it
14812
 
 demonstrates how basic attribute management can be done in a way that is
14813
 
@@ -1263,7 +1262,7 @@
14814
 
 method of a class would be called.
14815
 
 
14816
 
 A likely way to handle this is (1) to implement a set of functions (such as
14817
 
-:cfunc:`newdatatype_getSize` and :cfunc:`newdatatype_setSize` in the example
14818
 
+:c:func:`newdatatype_getSize` and :c:func:`newdatatype_setSize` in the example
14819
 
 below), (2) provide a method table listing these functions, and (3) provide a
14820
 
 getattr function that returns the result of a lookup in that table.  The method
14821
 
 table uses the same structure as the :attr:`tp_methods` field of the type
14822
 
@@ -1309,7 +1308,7 @@
14823
 
 The :attr:`tp_compare` handler is called when comparisons are needed and the
14824
 
 object does not implement the specific rich comparison method which matches the
14825
 
 requested comparison.  (It is always used if defined and the
14826
 
-:cfunc:`PyObject_Compare` or :cfunc:`PyObject_Cmp` functions are used, or if
14827
 
+:c:func:`PyObject_Compare` or :c:func:`PyObject_Cmp` functions are used, or if
14828
 
 :func:`cmp` is used from Python.) It is analogous to the :meth:`__cmp__` method.
14829
 
 This function should return ``-1`` if *obj1* is less than *obj2*, ``0`` if they
14830
 
 are equal, and ``1`` if *obj1* is greater than *obj2*. (It was previously
14831
 
@@ -1319,7 +1318,7 @@
14832
 
 
14833
 
 A :attr:`tp_compare` handler may raise an exception.  In this case it should
14834
 
 return a negative value.  The caller has to test for the exception using
14835
 
-:cfunc:`PyErr_Occurred`.
14836
 
+:c:func:`PyErr_Occurred`.
14837
 
 
14838
 
 Here is a sample implementation::
14839
 
 
14840
 
@@ -1367,8 +1366,8 @@
14841
 
 
14842
 
 If you wish your object to be able to act like a number, a sequence, or a
14843
 
 mapping object, then you place the address of a structure that implements the C
14844
 
-type :ctype:`PyNumberMethods`, :ctype:`PySequenceMethods`, or
14845
 
-:ctype:`PyMappingMethods`, respectively. It is up to you to fill in this
14846
 
+type :c:type:`PyNumberMethods`, :c:type:`PySequenceMethods`, or
14847
 
+:c:type:`PyMappingMethods`, respectively. It is up to you to fill in this
14848
 
 structure with appropriate values. You can find examples of the use of each of
14849
 
 these in the :file:`Objects` directory of the Python source distribution. ::
14850
 
 
14851
 
@@ -1400,11 +1399,11 @@
14852
 
    the call is ``obj1('hello')``, then *arg1* is ``obj1``.
14853
 
 
14854
 
 #. *arg2* is a tuple containing the arguments to the call.  You can use
14855
 
-   :cfunc:`PyArg_ParseTuple` to extract the arguments.
14856
 
+   :c:func:`PyArg_ParseTuple` to extract the arguments.
14857
 
 
14858
 
 #. *arg3* is a dictionary of keyword arguments that were passed. If this is
14859
 
    non-*NULL* and you support keyword arguments, use
14860
 
-   :cfunc:`PyArg_ParseTupleAndKeywords` to extract the arguments.  If you do not
14861
 
+   :c:func:`PyArg_ParseTupleAndKeywords` to extract the arguments.  If you do not
14862
 
    want to support keyword arguments and this is non-*NULL*, raise a
14863
 
    :exc:`TypeError` with a message saying that keyword arguments are not supported.
14864
 
 
14865
 
@@ -1479,7 +1478,7 @@
14866
 
 those objects which do not benefit by weak referencing (such as numbers).
14867
 
 
14868
 
 For an object to be weakly referencable, the extension must include a
14869
 
-:ctype:`PyObject\*` field in the instance structure for the use of the weak
14870
 
+:c:type:`PyObject\*` field in the instance structure for the use of the weak
14871
 
 reference mechanism; it must be initialized to *NULL* by the object's
14872
 
 constructor.  It must also set the :attr:`tp_weaklistoffset` field of the
14873
 
 corresponding type object to the offset of the field. For example, the instance
14874
 
@@ -1555,7 +1554,7 @@
14875
 
 examples of the function you want to implement.
14876
 
 
14877
 
 When you need to verify that an object is an instance of the type you are
14878
 
-implementing, use the :cfunc:`PyObject_TypeCheck` function. A sample of its use
14879
 
+implementing, use the :c:func:`PyObject_TypeCheck` function. A sample of its use
14880
 
 might be something like the following::
14881
 
 
14882
 
    if (! PyObject_TypeCheck(some_object, &MyType)) {
14883
 
diff -r 8527427914a2 Doc/extending/windows.rst
14884
 
--- a/Doc/extending/windows.rst
14885
 
+++ b/Doc/extending/windows.rst
14886
 
@@ -98,8 +98,8 @@
14887
 
    it.  Copy your C sources into it.  Note that the module source file name does
14888
 
    not necessarily have to match the module name, but the name of the
14889
 
    initialization function should match the module name --- you can only import a
14890
 
-   module :mod:`spam` if its initialization function is called :cfunc:`initspam`,
14891
 
-   and it should call :cfunc:`Py_InitModule` with the string ``"spam"`` as its
14892
 
+   module :mod:`spam` if its initialization function is called :c:func:`initspam`,
14893
 
+   and it should call :c:func:`Py_InitModule` with the string ``"spam"`` as its
14894
 
    first argument (use the minimal :file:`example.c` in this directory as a guide).
14895
 
    By convention, it lives in a file called :file:`spam.c` or :file:`spammodule.c`.
14896
 
    The output file should be called :file:`spam.pyd` (in Release mode) or
14897
 
@@ -263,7 +263,7 @@
14898
 
 
14899
 
 The first command created three files: :file:`spam.obj`, :file:`spam.dll` and
14900
 
 :file:`spam.lib`.  :file:`Spam.dll` does not contain any Python functions (such
14901
 
-as :cfunc:`PyArg_ParseTuple`), but it does know how to find the Python code
14902
 
+as :c:func:`PyArg_ParseTuple`), but it does know how to find the Python code
14903
 
 thanks to :file:`pythonXY.lib`.
14904
 
 
14905
 
 The second command created :file:`ni.dll` (and :file:`.obj` and :file:`.lib`),
14906
 
diff -r 8527427914a2 Doc/faq/design.rst
14907
 
--- a/Doc/faq/design.rst
14908
 
+++ b/Doc/faq/design.rst
14909
 
@@ -684,7 +684,7 @@
14910
 
 Python 2.6 adds an :mod:`abc` module that lets you define Abstract Base Classes
14911
 
 (ABCs).  You can then use :func:`isinstance` and :func:`issubclass` to check
14912
 
 whether an instance or a class implements a particular ABC.  The
14913
 
-:mod:`collections` modules defines a set of useful ABCs such as
14914
 
+:mod:`collections` module defines a set of useful ABCs such as
14915
 
 :class:`Iterable`, :class:`Container`, and :class:`MutableMapping`.
14916
 
 
14917
 
 For Python, many of the advantages of interface specifications can be obtained
14918
 
diff -r 8527427914a2 Doc/faq/extending.rst
14919
 
--- a/Doc/faq/extending.rst
14920
 
+++ b/Doc/faq/extending.rst
14921
 
@@ -60,41 +60,41 @@
14922
 
 How can I execute arbitrary Python statements from C?
14923
 
 -----------------------------------------------------
14924
 
 
14925
 
-The highest-level function to do this is :cfunc:`PyRun_SimpleString` which takes
14926
 
+The highest-level function to do this is :c:func:`PyRun_SimpleString` which takes
14927
 
 a single string argument to be executed in the context of the module
14928
 
 ``__main__`` and returns 0 for success and -1 when an exception occurred
14929
 
 (including ``SyntaxError``).  If you want more control, use
14930
 
-:cfunc:`PyRun_String`; see the source for :cfunc:`PyRun_SimpleString` in
14931
 
+:c:func:`PyRun_String`; see the source for :c:func:`PyRun_SimpleString` in
14932
 
 ``Python/pythonrun.c``.
14933
 
 
14934
 
 
14935
 
 How can I evaluate an arbitrary Python expression from C?
14936
 
 ---------------------------------------------------------
14937
 
 
14938
 
-Call the function :cfunc:`PyRun_String` from the previous question with the
14939
 
-start symbol :cdata:`Py_eval_input`; it parses an expression, evaluates it and
14940
 
+Call the function :c:func:`PyRun_String` from the previous question with the
14941
 
+start symbol :c:data:`Py_eval_input`; it parses an expression, evaluates it and
14942
 
 returns its value.
14943
 
 
14944
 
 
14945
 
 How do I extract C values from a Python object?
14946
 
 -----------------------------------------------
14947
 
 
14948
 
-That depends on the object's type.  If it's a tuple, :cfunc:`PyTuple_Size`
14949
 
-returns its length and :cfunc:`PyTuple_GetItem` returns the item at a specified
14950
 
-index.  Lists have similar functions, :cfunc:`PyListSize` and
14951
 
-:cfunc:`PyList_GetItem`.
14952
 
+That depends on the object's type.  If it's a tuple, :c:func:`PyTuple_Size`
14953
 
+returns its length and :c:func:`PyTuple_GetItem` returns the item at a specified
14954
 
+index.  Lists have similar functions, :c:func:`PyListSize` and
14955
 
+:c:func:`PyList_GetItem`.
14956
 
 
14957
 
-For strings, :cfunc:`PyString_Size` returns its length and
14958
 
-:cfunc:`PyString_AsString` a pointer to its value.  Note that Python strings may
14959
 
-contain null bytes so C's :cfunc:`strlen` should not be used.
14960
 
+For strings, :c:func:`PyString_Size` returns its length and
14961
 
+:c:func:`PyString_AsString` a pointer to its value.  Note that Python strings may
14962
 
+contain null bytes so C's :c:func:`strlen` should not be used.
14963
 
 
14964
 
 To test the type of an object, first make sure it isn't *NULL*, and then use
14965
 
-:cfunc:`PyString_Check`, :cfunc:`PyTuple_Check`, :cfunc:`PyList_Check`, etc.
14966
 
+:c:func:`PyString_Check`, :c:func:`PyTuple_Check`, :c:func:`PyList_Check`, etc.
14967
 
 
14968
 
 There is also a high-level API to Python objects which is provided by the
14969
 
 so-called 'abstract' interface -- read ``Include/abstract.h`` for further
14970
 
 details.  It allows interfacing with any kind of Python sequence using calls
14971
 
-like :cfunc:`PySequence_Length`, :cfunc:`PySequence_GetItem`, etc.)  as well as
14972
 
+like :c:func:`PySequence_Length`, :c:func:`PySequence_GetItem`, etc.)  as well as
14973
 
 many other useful protocols.
14974
 
 
14975
 
 
14976
 
@@ -103,7 +103,7 @@
14977
 
 
14978
 
 You can't.  Use ``t = PyTuple_New(n)`` instead, and fill it with objects using
14979
 
 ``PyTuple_SetItem(t, i, o)`` -- note that this "eats" a reference count of
14980
 
-``o``, so you have to :cfunc:`Py_INCREF` it.  Lists have similar functions
14981
 
+``o``, so you have to :c:func:`Py_INCREF` it.  Lists have similar functions
14982
 
 ``PyList_New(n)`` and ``PyList_SetItem(l, i, o)``.  Note that you *must* set all
14983
 
 the tuple items to some value before you pass the tuple to Python code --
14984
 
 ``PyTuple_New(n)`` initializes them to NULL, which isn't a valid Python value.
14985
 
@@ -112,9 +112,9 @@
14986
 
 How do I call an object's method from C?
14987
 
 ----------------------------------------
14988
 
 
14989
 
-The :cfunc:`PyObject_CallMethod` function can be used to call an arbitrary
14990
 
+The :c:func:`PyObject_CallMethod` function can be used to call an arbitrary
14991
 
 method of an object.  The parameters are the object, the name of the method to
14992
 
-call, a format string like that used with :cfunc:`Py_BuildValue`, and the
14993
 
+call, a format string like that used with :c:func:`Py_BuildValue`, and the
14994
 
 argument values::
14995
 
 
14996
 
    PyObject *
14997
 
@@ -122,7 +122,7 @@
14998
 
                        char *arg_format, ...);
14999
 
 
15000
 
 This works for any object that has methods -- whether built-in or user-defined.
15001
 
-You are responsible for eventually :cfunc:`Py_DECREF`\ 'ing the return value.
15002
 
+You are responsible for eventually :c:func:`Py_DECREF`\ 'ing the return value.
15003
 
 
15004
 
 To call, e.g., a file object's "seek" method with arguments 10, 0 (assuming the
15005
 
 file object pointer is "f")::
15006
 
@@ -135,7 +135,7 @@
15007
 
            Py_DECREF(res);
15008
 
    }
15009
 
 
15010
 
-Note that since :cfunc:`PyObject_CallObject` *always* wants a tuple for the
15011
 
+Note that since :c:func:`PyObject_CallObject` *always* wants a tuple for the
15012
 
 argument list, to call a function without arguments, pass "()" for the format,
15013
 
 and to call a function with one argument, surround the argument in parentheses,
15014
 
 e.g. "(i)".
15015
 
@@ -186,7 +186,7 @@
15016
 
 
15017
 
    attr = PyObject_GetAttrString(module, "<attrname>");
15018
 
 
15019
 
-Calling :cfunc:`PyObject_SetAttrString` to assign to variables in the module
15020
 
+Calling :c:func:`PyObject_SetAttrString` to assign to variables in the module
15021
 
 also works.
15022
 
 
15023
 
 
15024
 
@@ -267,16 +267,16 @@
15025
 
 In Python you can use the :mod:`codeop` module, which approximates the parser's
15026
 
 behavior sufficiently.  IDLE uses this, for example.
15027
 
 
15028
 
-The easiest way to do it in C is to call :cfunc:`PyRun_InteractiveLoop` (perhaps
15029
 
+The easiest way to do it in C is to call :c:func:`PyRun_InteractiveLoop` (perhaps
15030
 
 in a separate thread) and let the Python interpreter handle the input for
15031
 
-you. You can also set the :cfunc:`PyOS_ReadlineFunctionPointer` to point at your
15032
 
+you. You can also set the :c:func:`PyOS_ReadlineFunctionPointer` to point at your
15033
 
 custom input function. See ``Modules/readline.c`` and ``Parser/myreadline.c``
15034
 
 for more hints.
15035
 
 
15036
 
 However sometimes you have to run the embedded Python interpreter in the same
15037
 
 thread as your rest application and you can't allow the
15038
 
-:cfunc:`PyRun_InteractiveLoop` to stop while waiting for user input.  The one
15039
 
-solution then is to call :cfunc:`PyParser_ParseString` and test for ``e.error``
15040
 
+:c:func:`PyRun_InteractiveLoop` to stop while waiting for user input.  The one
15041
 
+solution then is to call :c:func:`PyParser_ParseString` and test for ``e.error``
15042
 
 equal to ``E_EOF``, which means the input is incomplete).  Here's a sample code
15043
 
 fragment, untested, inspired by code from Alex Farber::
15044
 
 
15045
 
@@ -307,8 +307,8 @@
15046
 
    }
15047
 
 
15048
 
 Another solution is trying to compile the received string with
15049
 
-:cfunc:`Py_CompileString`. If it compiles without errors, try to execute the
15050
 
-returned code object by calling :cfunc:`PyEval_EvalCode`. Otherwise save the
15051
 
+:c:func:`Py_CompileString`. If it compiles without errors, try to execute the
15052
 
+returned code object by calling :c:func:`PyEval_EvalCode`. Otherwise save the
15053
 
 input for later. If the compilation fails, find out if it's an error or just
15054
 
 more input is required - by extracting the message string from the exception
15055
 
 tuple and comparing it to the string "unexpected EOF while parsing".  Here is a
15056
 
@@ -460,8 +460,8 @@
15057
 
 7.x, in particular, provided a "python2" binary that is compiled with 4-byte
15058
 
 Unicode.  This only causes the link failure if the extension uses any of the
15059
 
 ``PyUnicode_*()`` functions.  It is also a problem if an extension uses any of
15060
 
-the Unicode-related format specifiers for :cfunc:`Py_BuildValue` (or similar) or
15061
 
-parameter specifications for :cfunc:`PyArg_ParseTuple`.
15062
 
+the Unicode-related format specifiers for :c:func:`Py_BuildValue` (or similar) or
15063
 
+parameter specifications for :c:func:`PyArg_ParseTuple`.
15064
 
 
15065
 
 You can check the size of the Unicode character a Python interpreter is using by
15066
 
 checking the value of sys.maxunicode:
15067
 
diff -r 8527427914a2 Doc/faq/general.rst
15068
 
--- a/Doc/faq/general.rst
15069
 
+++ b/Doc/faq/general.rst
15070
 
@@ -157,16 +157,14 @@
15071
 
 
15072
 
 The latest Python source distribution is always available from python.org, at
15073
 
 http://www.python.org/download/.  The latest development sources can be obtained
15074
 
-via anonymous Subversion at http://svn.python.org/projects/python/trunk.
15075
 
+via anonymous Mercurial access at http://hg.python.org/cpython.
15076
 
 
15077
 
 The source distribution is a gzipped tar file containing the complete C source,
15078
 
 Sphinx-formatted documentation, Python library modules, example programs, and
15079
 
 several useful pieces of freely distributable software.  The source will compile
15080
 
 and run out of the box on most UNIX platforms.
15081
 
 
15082
 
-.. XXX update link once the dev faq is relocated
15083
 
-
15084
 
-Consult the `Developer FAQ <http://www.python.org/dev/faq/>`__ for more
15085
 
+Consult the `Developer FAQ <http://docs.python.org/devguide/faq>`__ for more
15086
 
 information on getting the source code and compiling it.
15087
 
 
15088
 
 
15089
 
@@ -221,10 +219,8 @@
15090
 
 newsgroups and on the Python home page at http://www.python.org/; an RSS feed of
15091
 
 news is available.
15092
 
 
15093
 
-.. XXX update link once the dev faq is relocated
15094
 
-
15095
 
 You can also access the development version of Python through Subversion.  See
15096
 
-http://www.python.org/dev/faq/ for details.
15097
 
+http://docs.python.org/devguide/faq for details.
15098
 
 
15099
 
 
15100
 
 How do I submit bug reports and patches for Python?
15101
 
@@ -239,10 +235,8 @@
15102
 
 report bugs to Python, you can obtain your Roundup password through Roundup's
15103
 
 `password reset procedure <http://bugs.python.org/user?@template=forgotten>`_.
15104
 
 
15105
 
-.. XXX adapt link to dev guide
15106
 
-
15107
 
 For more information on how Python is developed, consult `the Python Developer's
15108
 
-Guide <http://python.org/dev/>`_.
15109
 
+Guide <http://docs.python.org/devguide/>`_.
15110
 
 
15111
 
 
15112
 
 Are there any published articles about Python that I can reference?
15113
 
diff -r 8527427914a2 Doc/faq/gui.rst
15114
 
--- a/Doc/faq/gui.rst
15115
 
+++ b/Doc/faq/gui.rst
15116
 
@@ -117,7 +117,7 @@
15117
 
 (http://tix.sourceforge.net/).
15118
 
 
15119
 
 Build Tix with SAM enabled, perform the appropriate call to
15120
 
-:cfunc:`Tclsam_init`, etc. inside Python's
15121
 
+:c:func:`Tclsam_init`, etc. inside Python's
15122
 
 :file:`Modules/tkappinit.c`, and link with libtclsam and libtksam (you
15123
 
 might include the Tix libraries as well).
15124
 
 
15125
 
@@ -126,7 +126,7 @@
15126
 
 ---------------------------------------------------
15127
 
 
15128
 
 Yes, and you don't even need threads!  But you'll have to restructure your I/O
15129
 
-code a bit.  Tk has the equivalent of Xt's :cfunc:`XtAddInput()` call, which allows you
15130
 
+code a bit.  Tk has the equivalent of Xt's :c:func:`XtAddInput()` call, which allows you
15131
 
 to register a callback function which will be called from the Tk mainloop when
15132
 
 I/O is possible on a file descriptor.  Here's what you need::
15133
 
 
15134
 
diff -r 8527427914a2 Doc/faq/library.rst
15135
 
--- a/Doc/faq/library.rst
15136
 
+++ b/Doc/faq/library.rst
15137
 
@@ -410,7 +410,7 @@
15138
 
 
15139
 
 Since then, the idea of getting rid of the GIL has occasionally come up but
15140
 
 nobody has found a way to deal with the expected slowdown, and users who don't
15141
 
-use threads would not be happy if their code ran at half at the speed.  Greg's
15142
 
+use threads would not be happy if their code ran at half the speed.  Greg's
15143
 
 free threading patch set has not been kept up-to-date for later Python versions.
15144
 
 
15145
 
 This doesn't mean that you can't make good use of Python on multi-CPU machines!
15146
 
diff -r 8527427914a2 Doc/faq/programming.rst
15147
 
--- a/Doc/faq/programming.rst
15148
 
+++ b/Doc/faq/programming.rst
15149
 
@@ -171,7 +171,7 @@
15150
 
 Thus to get the same effect as::
15151
 
 
15152
 
    L2 = []
15153
 
-   for i in range[3]:
15154
 
+   for i in range(3):
15155
 
        L2.append(L1[i])
15156
 
 
15157
 
 it is much shorter and far faster to use ::
15158
 
@@ -980,7 +980,7 @@
15159
 
 if the line uses something other than whitespace as a separator.
15160
 
 
15161
 
 For more complicated input parsing, regular expressions are more powerful
15162
 
-than C's :cfunc:`sscanf` and better suited for the task.
15163
 
+than C's :c:func:`sscanf` and better suited for the task.
15164
 
 
15165
 
 
15166
 
 What does 'UnicodeError: ASCII [decoding,encoding] error: ordinal not in range(128)' mean?
15167
 
diff -r 8527427914a2 Doc/faq/windows.rst
15168
 
--- a/Doc/faq/windows.rst
15169
 
+++ b/Doc/faq/windows.rst
15170
 
@@ -537,12 +537,12 @@
15171
 
 The Python 1.5.* DLLs (``python15.dll``) are all compiled with MS VC++ 5.0 and
15172
 
 with multithreading-DLL options (``/MD``).
15173
 
 
15174
 
-If you can't change compilers or flags, try using :cfunc:`Py_RunSimpleString`.
15175
 
+If you can't change compilers or flags, try using :c:func:`Py_RunSimpleString`.
15176
 
 A trick to get it to run an arbitrary file is to construct a call to
15177
 
 :func:`execfile` with the name of your file as argument.
15178
 
 
15179
 
 Also note that you can not mix-and-match Debug and Release versions.  If you
15180
 
-wish to use the Debug Multithreaded DLL, then your module *must* have an "_d"
15181
 
+wish to use the Debug Multithreaded DLL, then your module *must* have ``_d``
15182
 
 appended to the base name.
15183
 
 
15184
 
 
15185
 
diff -r 8527427914a2 Doc/glossary.rst
15186
 
--- a/Doc/glossary.rst
15187
 
+++ b/Doc/glossary.rst
15188
 
@@ -27,12 +27,16 @@
15189
 
       :ref:`2to3-reference`.
15190
 
 
15191
 
    abstract base class
15192
 
-      :ref:`abstract-base-classes` complement :term:`duck-typing` by
15193
 
+      Abstract base classes complement :term:`duck-typing` by
15194
 
       providing a way to define interfaces when other techniques like
15195
 
-      :func:`hasattr` would be clumsy. Python comes with many built-in ABCs for
15196
 
+      :func:`hasattr` would be clumsy or subtly wrong (for example with
15197
 
+      :ref:`magic methods <new-style-special-lookup>`).  ABCs introduce virtual
15198
 
+      subclasses, which are classes that don't inherit from a class but are
15199
 
+      still recognized by :func:`isinstance` and :func:`issubclass`; see the
15200
 
+      :mod:`abc` module documentation.  Python comes with many built-in ABCs for
15201
 
       data structures (in the :mod:`collections` module), numbers (in the
15202
 
       :mod:`numbers` module), and streams (in the :mod:`io` module). You can
15203
 
-      create your own ABC with the :mod:`abc` module.
15204
 
+      create your own ABCs with the :mod:`abc` module.
15205
 
 
15206
 
    argument
15207
 
       A value passed to a function or method, assigned to a named local
15208
 
@@ -57,11 +61,14 @@
15209
 
 
15210
 
    bytecode
15211
 
       Python source code is compiled into bytecode, the internal representation
15212
 
-      of a Python program in the interpreter.  The bytecode is also cached in
15213
 
-      ``.pyc`` and ``.pyo`` files so that executing the same file is faster the
15214
 
-      second time (recompilation from source to bytecode can be avoided).  This
15215
 
-      "intermediate language" is said to run on a :term:`virtual machine`
15216
 
-      that executes the machine code corresponding to each bytecode.
15217
 
+      of a Python program in the CPython interpreter.  The bytecode is also
15218
 
+      cached in ``.pyc`` and ``.pyo`` files so that executing the same file is
15219
 
+      faster the second time (recompilation from source to bytecode can be
15220
 
+      avoided).  This "intermediate language" is said to run on a
15221
 
+      :term:`virtual machine` that executes the machine code corresponding to
15222
 
+      each bytecode. Do note that bytecodes are not expected to work between
15223
 
+      different Python virtual machines, nor to be stable between Python
15224
 
+      releases.
15225
 
 
15226
 
       A list of bytecode instructions can be found in the documentation for
15227
 
       :ref:`the dis module <bytecodes>`.
15228
 
@@ -127,8 +134,9 @@
15229
 
          def f(...):
15230
 
              ...
15231
 
 
15232
 
-      See :ref:`the documentation for function definition <function>` for more
15233
 
-      about decorators.
15234
 
+      The same concept exists for classes, but is less commonly used there.  See
15235
 
+      the documentation for :ref:`function definitions <function>` and
15236
 
+      :ref:`class definitions <class>` for more about decorators.
15237
 
 
15238
 
    descriptor
15239
 
       Any *new-style* object which defines the methods :meth:`__get__`,
15240
 
@@ -164,8 +172,8 @@
15241
 
       well-designed code improves its flexibility by allowing polymorphic
15242
 
       substitution.  Duck-typing avoids tests using :func:`type` or
15243
 
       :func:`isinstance`.  (Note, however, that duck-typing can be complemented
15244
 
-      with :term:`abstract base class`\ es.)  Instead, it typically employs
15245
 
-      :func:`hasattr` tests or :term:`EAFP` programming.
15246
 
+      with :term:`abstract base classes <abstract base class>`.)  Instead, it
15247
 
+      typically employs :func:`hasattr` tests or :term:`EAFP` programming.
15248
 
 
15249
 
    EAFP
15250
 
       Easier to ask for forgiveness than permission.  This common Python coding
15251
 
@@ -177,17 +185,34 @@
15252
 
 
15253
 
    expression
15254
 
       A piece of syntax which can be evaluated to some value.  In other words,
15255
 
-      an expression is an accumulation of expression elements like literals, names,
15256
 
-      attribute access, operators or function calls which all return a value.
15257
 
-      In contrast to many other languages, not all language constructs are expressions.
15258
 
-      There are also :term:`statement`\s which cannot be used as expressions,
15259
 
-      such as :keyword:`print` or :keyword:`if`.  Assignments are also statements,
15260
 
-      not expressions.
15261
 
+      an expression is an accumulation of expression elements like literals,
15262
 
+      names, attribute access, operators or function calls which all return a
15263
 
+      value.  In contrast to many other languages, not all language constructs
15264
 
+      are expressions.  There are also :term:`statement`\s which cannot be used
15265
 
+      as expressions, such as :keyword:`print` or :keyword:`if`.  Assignments
15266
 
+      are also statements, not expressions.
15267
 
 
15268
 
    extension module
15269
 
       A module written in C or C++, using Python's C API to interact with the
15270
 
       core and with user code.
15271
 
 
15272
 
+   file object
15273
 
+      An object exposing a file-oriented API (with methods such as
15274
 
+      :meth:`read()` or :meth:`write()`) to an underlying resource.  Depending
15275
 
+      on the way it was created, a file object can mediate access to a real
15276
 
+      on-disk file or to another other type of storage or communication device
15277
 
+      (for example standard input/output, in-memory buffers, sockets, pipes,
15278
 
+      etc.).  File objects are also called :dfn:`file-like objects` or
15279
 
+      :dfn:`streams`.
15280
 
+
15281
 
+      There are actually three categories of file objects: raw binary files,
15282
 
+      buffered binary files and text files.  Their interfaces are defined in the
15283
 
+      :mod:`io` module.  The canonical way to create a file object is by using
15284
 
+      the :func:`open` function.
15285
 
+
15286
 
+   file-like object
15287
 
+      A synonym for :term:`file object`.
15288
 
+
15289
 
    finder
15290
 
       An object that tries to find the :term:`loader` for a module. It must
15291
 
       implement a method named :meth:`find_module`. See :pep:`302` for
15292
 
@@ -334,7 +359,7 @@
15293
 
       slowly.  See also :term:`interactive`.
15294
 
 
15295
 
    iterable
15296
 
-      A container object capable of returning its members one at a
15297
 
+      An object capable of returning its members one at a
15298
 
       time. Examples of iterables include all sequence types (such as
15299
 
       :class:`list`, :class:`str`, and :class:`tuple`) and some non-sequence
15300
 
       types like :class:`dict` and :class:`file` and objects of any classes you
15301
 
@@ -403,6 +428,12 @@
15302
 
       the :term:`EAFP` approach and is characterized by the presence of many
15303
 
       :keyword:`if` statements.
15304
 
 
15305
 
+      In a multi-threaded environment, the LBYL approach can risk introducing a
15306
 
+      race condition between "the looking" and "the leaping".  For example, the
15307
 
+      code, ``if key in mapping: return mapping[key]`` can fail if another
15308
 
+      thread removes *key* from *mapping* after the test, but before the lookup.
15309
 
+      This issue can be solved with locks or by using the EAFP approach.
15310
 
+
15311
 
    list
15312
 
       A built-in Python :term:`sequence`.  Despite its name it is more akin
15313
 
       to an array in other languages than to a linked list since access to
15314
 
@@ -423,9 +454,10 @@
15315
 
 
15316
 
    mapping
15317
 
       A container object that supports arbitrary key lookups and implements the
15318
 
-      methods specified in the :class:`Mapping` or :class:`MutableMapping`
15319
 
-      :ref:`abstract base classes <abstract-base-classes>`. Examples include
15320
 
-      :class:`dict`, :class:`collections.defaultdict`,
15321
 
+      methods specified in the :class:`~collections.Mapping` or
15322
 
+      :class:`~collections.MutableMapping`
15323
 
+      :ref:`abstract base classes <collections-abstract-base-classes>`.  Examples
15324
 
+      include :class:`dict`, :class:`collections.defaultdict`,
15325
 
       :class:`collections.OrderedDict` and :class:`collections.Counter`.
15326
 
 
15327
 
    metaclass
15328
 
@@ -447,6 +479,14 @@
15329
 
       its first :term:`argument` (which is usually called ``self``).
15330
 
       See :term:`function` and :term:`nested scope`.
15331
 
 
15332
 
+   method resolution order
15333
 
+      Method Resolution Order is the order in which base classes are searched
15334
 
+      for a member during lookup. See `The Python 2.3 Method Resolution Order
15335
 
+      <http://www.python.org/download/releases/2.3/mro/>`_.
15336
 
+
15337
 
+   MRO
15338
 
+      See :term:`method resolution order`.
15339
 
+
15340
 
    mutable
15341
 
       Mutable objects can change their value but keep their :func:`id`.  See
15342
 
       also :term:`immutable`.
15343
 
@@ -505,9 +545,9 @@
15344
 
       :term:`argument`.
15345
 
 
15346
 
    Python 3000
15347
 
-      Nickname for the next major Python version, 3.0 (coined long ago
15348
 
-      when the release of version 3 was something in the distant future.)  This
15349
 
-      is also abbreviated "Py3k".
15350
 
+      Nickname for the Python 3.x release line (coined long ago when the release
15351
 
+      of version 3 was something in the distant future.)  This is also
15352
 
+      abbreviated "Py3k".
15353
 
 
15354
 
    Pythonic
15355
 
       An idea or piece of code which closely follows the most common idioms
15356
 
@@ -530,7 +570,7 @@
15357
 
       object drops to zero, it is deallocated.  Reference counting is
15358
 
       generally not visible to Python code, but it is a key element of the
15359
 
       :term:`CPython` implementation.  The :mod:`sys` module defines a
15360
 
-      :func:`getrefcount` function that programmers can call to return the
15361
 
+      :func:`~sys.getrefcount` function that programmers can call to return the
15362
 
       reference count for a particular object.
15363
 
 
15364
 
    __slots__
15365
 
@@ -566,7 +606,15 @@
15366
 
    statement
15367
 
       A statement is part of a suite (a "block" of code).  A statement is either
15368
 
       an :term:`expression` or a one of several constructs with a keyword, such
15369
 
-      as :keyword:`if`, :keyword:`while` or :keyword:`print`.
15370
 
+      as :keyword:`if`, :keyword:`while` or :keyword:`for`.
15371
 
+
15372
 
+   struct sequence
15373
 
+      A tuple with named elements. Struct sequences expose an interface similiar
15374
 
+      to :term:`named tuple` in that elements can either be accessed either by
15375
 
+      index or as an attribute. However, they do not have any of the named tuple
15376
 
+      methods like :meth:`~collections.somenamedtuple._make` or
15377
 
+      :meth:`~collections.somenamedtuple._asdict`. Examples of struct sequences
15378
 
+      include :data:`sys.float_info` and the return value of :func:`os.stat`.
15379
 
 
15380
 
    triple-quoted string
15381
 
       A string which is bound by three instances of either a quotation mark
15382
 
diff -r 8527427914a2 Doc/howto/cporting.rst
15383
 
--- a/Doc/howto/cporting.rst
15384
 
+++ b/Doc/howto/cporting.rst
15385
 
@@ -1,5 +1,7 @@
15386
 
 .. highlightlang:: c
15387
 
 
15388
 
+.. _cporting-howto:
15389
 
+
15390
 
 ********************************
15391
 
 Porting Extension Modules to 3.0
15392
 
 ********************************
15393
 
@@ -20,7 +22,7 @@
15394
 
 =======================
15395
 
 
15396
 
 The easiest way to compile only some code for 3.0 is to check if
15397
 
-:cmacro:`PY_MAJOR_VERSION` is greater than or equal to 3. ::
15398
 
+:c:macro:`PY_MAJOR_VERSION` is greater than or equal to 3. ::
15399
 
 
15400
 
    #if PY_MAJOR_VERSION >= 3
15401
 
    #define IS_PY3K
15402
 
@@ -45,12 +47,12 @@
15403
 
 2.x's :func:`unicode` (``PyUnicode_*``).  The old 8-bit string type has become
15404
 
 :func:`bytes`.  Python 2.6 and later provide a compatibility header,
15405
 
 :file:`bytesobject.h`, mapping ``PyBytes`` names to ``PyString`` ones.  For best
15406
 
-compatibility with 3.0, :ctype:`PyUnicode` should be used for textual data and
15407
 
-:ctype:`PyBytes` for binary data.  It's also important to remember that
15408
 
-:ctype:`PyBytes` and :ctype:`PyUnicode` in 3.0 are not interchangeable like
15409
 
-:ctype:`PyString` and :ctype:`PyUnicode` are in 2.x.  The following example
15410
 
-shows best practices with regards to :ctype:`PyUnicode`, :ctype:`PyString`,
15411
 
-and :ctype:`PyBytes`. ::
15412
 
+compatibility with 3.0, :c:type:`PyUnicode` should be used for textual data and
15413
 
+:c:type:`PyBytes` for binary data.  It's also important to remember that
15414
 
+:c:type:`PyBytes` and :c:type:`PyUnicode` in 3.0 are not interchangeable like
15415
 
+:c:type:`PyString` and :c:type:`PyUnicode` are in 2.x.  The following example
15416
 
+shows best practices with regards to :c:type:`PyUnicode`, :c:type:`PyString`,
15417
 
+and :c:type:`PyBytes`. ::
15418
 
 
15419
 
    #include "stdlib.h"
15420
 
    #include "Python.h"
15421
 
@@ -207,6 +209,58 @@
15422
 
    }
15423
 
 
15424
 
 
15425
 
+CObject replaced with Capsule
15426
 
+=============================
15427
 
+
15428
 
+The :c:type:`Capsule` object was introduced in Python 3.1 and 2.7 to replace
15429
 
+:c:type:`CObject`.  CObjects were useful,
15430
 
+but the :c:type:`CObject` API was problematic: it didn't permit distinguishing
15431
 
+between valid CObjects, which allowed mismatched CObjects to crash the
15432
 
+interpreter, and some of its APIs relied on undefined behavior in C.
15433
 
+(For further reading on the rationale behind Capsules, please see :issue:`5630`.)
15434
 
+
15435
 
+If you're currently using CObjects, and you want to migrate to 3.1 or newer,
15436
 
+you'll need to switch to Capsules.
15437
 
+:c:type:`CObject` was deprecated in 3.1 and 2.7 and completely removed in
15438
 
+Python 3.2.  If you only support 2.7, or 3.1 and above, you
15439
 
+can simply switch to :c:type:`Capsule`.  If you need to support 3.0 or
15440
 
+versions of Python earlier than 2.7 you'll have to support both CObjects
15441
 
+and Capsules.
15442
 
+
15443
 
+The following example header file :file:`capsulethunk.h` may
15444
 
+solve the problem for you;
15445
 
+simply write your code against the :c:type:`Capsule` API, include
15446
 
+this header file after ``"Python.h"``, and you'll automatically use CObjects
15447
 
+in Python 3.0 or versions earlier than 2.7.
15448
 
+
15449
 
+:file:`capsulethunk.h` simulates Capsules using CObjects.  However,
15450
 
+:c:type:`CObject` provides no place to store the capsule's "name".  As a
15451
 
+result the simulated :c:type:`Capsule` objects created by :file:`capsulethunk.h`
15452
 
+behave slightly differently from real Capsules.  Specifically:
15453
 
+
15454
 
+  * The name parameter passed in to :c:func:`PyCapsule_New` is ignored.
15455
 
+
15456
 
+  * The name parameter passed in to :c:func:`PyCapsule_IsValid` and
15457
 
+    :c:func:`PyCapsule_GetPointer` is ignored, and no error checking
15458
 
+    of the name is performed.
15459
 
+
15460
 
+  * :c:func:`PyCapsule_GetName` always returns NULL.
15461
 
+
15462
 
+  * :c:func:`PyCapsule_SetName` always throws an exception and
15463
 
+    returns failure.  (Since there's no way to store a name
15464
 
+    in a CObject, noisy failure of :c:func:`PyCapsule_SetName`
15465
 
+    was deemed preferable to silent failure here.  If this is
15466
 
+    inconveient, feel free to modify your local
15467
 
+    copy as you see fit.)
15468
 
+
15469
 
+You can find :file:`capsulethunk.h` in the Python source distribution
15470
 
+in the :file:`Doc/includes` directory.  We also include it here for
15471
 
+your reference; here is :file:`capsulethunk.h`:
15472
 
+
15473
 
+.. literalinclude:: ../includes/capsulethunk.h
15474
 
+
15475
 
+
15476
 
+
15477
 
 Other options
15478
 
 =============
15479
 
 
15480
 
diff -r 8527427914a2 Doc/howto/descriptor.rst
15481
 
--- a/Doc/howto/descriptor.rst
15482
 
+++ b/Doc/howto/descriptor.rst
15483
 
@@ -42,7 +42,7 @@
15484
 
 
15485
 
 Descriptors are a powerful, general purpose protocol.  They are the mechanism
15486
 
 behind properties, methods, static methods, class methods, and :func:`super()`.
15487
 
-They are used used throughout Python itself to implement the new style classes
15488
 
+They are used throughout Python itself to implement the new style classes
15489
 
 introduced in version 2.2.  Descriptors simplify the underlying C-code and offer
15490
 
 a flexible set of new tools for everyday Python programs.
15491
 
 
15492
 
@@ -97,7 +97,7 @@
15493
 
 implementation works through a precedence chain that gives data descriptors
15494
 
 priority over instance variables, instance variables priority over non-data
15495
 
 descriptors, and assigns lowest priority to :meth:`__getattr__` if provided.  The
15496
 
-full C implementation can be found in :cfunc:`PyObject_GenericGetAttr()` in
15497
 
+full C implementation can be found in :c:func:`PyObject_GenericGetAttr()` in
15498
 
 `Objects/object.c <http://svn.python.org/view/python/trunk/Objects/object.c?view=markup>`_\.
15499
 
 
15500
 
 For classes, the machinery is in :meth:`type.__getattribute__` which transforms
15501
 
@@ -131,7 +131,7 @@
15502
 
 Note, in Python 2.2, ``super(B, obj).m()`` would only invoke :meth:`__get__` if
15503
 
 ``m`` was a data descriptor.  In Python 2.3, non-data descriptors also get
15504
 
 invoked unless an old-style class is involved.  The implementation details are
15505
 
-in :cfunc:`super_getattro()` in
15506
 
+in :c:func:`super_getattro()` in
15507
 
 `Objects/typeobject.c <http://svn.python.org/view/python/trunk/Objects/typeobject.c?view=markup>`_
15508
 
 and a pure Python equivalent can be found in `Guido's Tutorial`_.
15509
 
 
15510
 
@@ -297,7 +297,7 @@
15511
 
 
15512
 
 The output suggests that bound and unbound methods are two different types.
15513
 
 While they could have been implemented that way, the actual C implementation of
15514
 
-:ctype:`PyMethod_Type` in
15515
 
+:c:type:`PyMethod_Type` in
15516
 
 `Objects/classobject.c <http://svn.python.org/view/python/trunk/Objects/classobject.c?view=markup>`_
15517
 
 is a single object with two different representations depending on whether the
15518
 
 :attr:`im_self` field is set or is *NULL* (the C equivalent of *None*).
15519
 
diff -r 8527427914a2 Doc/howto/doanddont.rst
15520
 
--- a/Doc/howto/doanddont.rst
15521
 
+++ b/Doc/howto/doanddont.rst
15522
 
@@ -32,8 +32,8 @@
15523
 
 versions of Python do not check for the invalidity, it does not make it more
15524
 
 valid, no more than having a smart lawyer makes a man innocent. Do not use it
15525
 
 like that ever. Even in versions where it was accepted, it made the function
15526
 
-execution slower, because the compiler could not be certain which names are
15527
 
-local and which are global. In Python 2.1 this construct causes warnings, and
15528
 
+execution slower, because the compiler could not be certain which names were
15529
 
+local and which were global. In Python 2.1 this construct causes warnings, and
15530
 
 sometimes even errors.
15531
 
 
15532
 
 
15533
 
@@ -46,7 +46,7 @@
15534
 
 in your favourite editor. You also open yourself to trouble in the future, if
15535
 
 some module grows additional functions or classes.
15536
 
 
15537
 
-One of the most awful question asked on the newsgroup is why this code::
15538
 
+One of the most awful questions asked on the newsgroup is why this code::
15539
 
 
15540
 
    f = open("www")
15541
 
    f.read()
15542
 
@@ -113,7 +113,7 @@
15543
 
 
15544
 
 This is a "don't" which is much weaker than the previous "don't"s but is still
15545
 
 something you should not do if you don't have good reasons to do that. The
15546
 
-reason it is usually bad idea is because you suddenly have an object which lives
15547
 
+reason it is usually a bad idea is because you suddenly have an object which lives
15548
 
 in two separate namespaces. When the binding in one namespace changes, the
15549
 
 binding in the other will not, so there will be a discrepancy between them. This
15550
 
 happens when, for example, one module is reloaded, or changes the definition of
15551
 
diff -r 8527427914a2 Doc/howto/functional.rst
15552
 
--- a/Doc/howto/functional.rst
15553
 
+++ b/Doc/howto/functional.rst
15554
 
@@ -44,15 +44,14 @@
15555
 
   functional languages include the ML family (Standard ML, OCaml, and other
15556
 
   variants) and Haskell.
15557
 
 
15558
 
-The designers of some computer languages choose to emphasize one
15559
 
-particular approach to programming.  This often makes it difficult to
15560
 
-write programs that use a different approach.  Other languages are
15561
 
-multi-paradigm languages that support several different approaches.
15562
 
-Lisp, C++, and Python are multi-paradigm; you can write programs or
15563
 
-libraries that are largely procedural, object-oriented, or functional
15564
 
-in all of these languages.  In a large program, different sections
15565
 
-might be written using different approaches; the GUI might be
15566
 
-object-oriented while the processing logic is procedural or
15567
 
+The designers of some computer languages choose to emphasize one particular
15568
 
+approach to programming.  This often makes it difficult to write programs that
15569
 
+use a different approach.  Other languages are multi-paradigm languages that
15570
 
+support several different approaches.  Lisp, C++, and Python are
15571
 
+multi-paradigm; you can write programs or libraries that are largely
15572
 
+procedural, object-oriented, or functional in all of these languages.  In a
15573
 
+large program, different sections might be written using different approaches;
15574
 
+the GUI might be object-oriented while the processing logic is procedural or
15575
 
 functional, for example.
15576
 
 
15577
 
 In a functional program, input flows through a set of functions. Each function
15578
 
@@ -1115,132 +1114,6 @@
15579
 
 Consult the operator module's documentation for a complete list.
15580
 
 
15581
 
 
15582
 
-
15583
 
-The functional module
15584
 
----------------------
15585
 
-
15586
 
-Collin Winter's `functional module <http://oakwinter.com/code/functional/>`__
15587
 
-provides a number of more advanced tools for functional programming. It also
15588
 
-reimplements several Python built-ins, trying to make them more intuitive to
15589
 
-those used to functional programming in other languages.
15590
 
-
15591
 
-This section contains an introduction to some of the most important functions in
15592
 
-``functional``; full documentation can be found at `the project's website
15593
 
-<http://oakwinter.com/code/functional/documentation/>`__.
15594
 
-
15595
 
-``compose(outer, inner, unpack=False)``
15596
 
-
15597
 
-The ``compose()`` function implements function composition.  In other words, it
15598
 
-returns a wrapper around the ``outer`` and ``inner`` callables, such that the
15599
 
-return value from ``inner`` is fed directly to ``outer``.  That is, ::
15600
 
-
15601
 
-    >>> def add(a, b):
15602
 
-    ...     return a + b
15603
 
-    ...
15604
 
-    >>> def double(a):
15605
 
-    ...     return 2 * a
15606
 
-    ...
15607
 
-    >>> compose(double, add)(5, 6)
15608
 
-    22
15609
 
-
15610
 
-is equivalent to ::
15611
 
-
15612
 
-    >>> double(add(5, 6))
15613
 
-    22
15614
 
-
15615
 
-The ``unpack`` keyword is provided to work around the fact that Python functions
15616
 
-are not always `fully curried <http://en.wikipedia.org/wiki/Currying>`__.  By
15617
 
-default, it is expected that the ``inner`` function will return a single object
15618
 
-and that the ``outer`` function will take a single argument. Setting the
15619
 
-``unpack`` argument causes ``compose`` to expect a tuple from ``inner`` which
15620
 
-will be expanded before being passed to ``outer``. Put simply, ::
15621
 
-
15622
 
-    compose(f, g)(5, 6)
15623
 
-
15624
 
-is equivalent to::
15625
 
-
15626
 
-    f(g(5, 6))
15627
 
-
15628
 
-while ::
15629
 
-
15630
 
-    compose(f, g, unpack=True)(5, 6)
15631
 
-
15632
 
-is equivalent to::
15633
 
-
15634
 
-    f(*g(5, 6))
15635
 
-
15636
 
-Even though ``compose()`` only accepts two functions, it's trivial to build up a
15637
 
-version that will compose any number of functions. We'll use ``reduce()``,
15638
 
-``compose()`` and ``partial()`` (the last of which is provided by both
15639
 
-``functional`` and ``functools``). ::
15640
 
-
15641
 
-    from functional import compose, partial
15642
 
-
15643
 
-    multi_compose = partial(reduce, compose)
15644
 
-
15645
 
-
15646
 
-We can also use ``map()``, ``compose()`` and ``partial()`` to craft a version of
15647
 
-``"".join(...)`` that converts its arguments to string::
15648
 
-
15649
 
-    from functional import compose, partial
15650
 
-
15651
 
-    join = compose("".join, partial(map, str))
15652
 
-
15653
 
-
15654
 
-``flip(func)``
15655
 
-
15656
 
-``flip()`` wraps the callable in ``func`` and causes it to receive its
15657
 
-non-keyword arguments in reverse order. ::
15658
 
-
15659
 
-    >>> def triple(a, b, c):
15660
 
-    ...     return (a, b, c)
15661
 
-    ...
15662
 
-    >>> triple(5, 6, 7)
15663
 
-    (5, 6, 7)
15664
 
-    >>>
15665
 
-    >>> flipped_triple = flip(triple)
15666
 
-    >>> flipped_triple(5, 6, 7)
15667
 
-    (7, 6, 5)
15668
 
-
15669
 
-``foldl(func, start, iterable)``
15670
 
-
15671
 
-``foldl()`` takes a binary function, a starting value (usually some kind of
15672
 
-'zero'), and an iterable.  The function is applied to the starting value and the
15673
 
-first element of the list, then the result of that and the second element of the
15674
 
-list, then the result of that and the third element of the list, and so on.
15675
 
-
15676
 
-This means that a call such as::
15677
 
-
15678
 
-    foldl(f, 0, [1, 2, 3])
15679
 
-
15680
 
-is equivalent to::
15681
 
-
15682
 
-    f(f(f(0, 1), 2), 3)
15683
 
-
15684
 
-
15685
 
-``foldl()`` is roughly equivalent to the following recursive function::
15686
 
-
15687
 
-    def foldl(func, start, seq):
15688
 
-        if len(seq) == 0:
15689
 
-            return start
15690
 
-
15691
 
-        return foldl(func, func(start, seq[0]), seq[1:])
15692
 
-
15693
 
-Speaking of equivalence, the above ``foldl`` call can be expressed in terms of
15694
 
-the built-in ``reduce`` like so::
15695
 
-
15696
 
-    reduce(f, [1, 2, 3], 0)
15697
 
-
15698
 
-
15699
 
-We can use ``foldl()``, ``operator.concat()`` and ``partial()`` to write a
15700
 
-cleaner, more aesthetically-pleasing version of Python's ``"".join(...)``
15701
 
-idiom::
15702
 
-
15703
 
-    from functional import foldl, partial from operator import concat
15704
 
-
15705
 
-    join = partial(foldl, concat, "")
15706
 
-
15707
 
-
15708
 
 Revision History and Acknowledgements
15709
 
 =====================================
15710
 
 
15711
 
@@ -1296,9 +1169,10 @@
15712
 
 
15713
 
 Mertz also wrote a 3-part series of articles on functional programming
15714
 
 for IBM's DeveloperWorks site; see
15715
 
-`part 1 <http://www-128.ibm.com/developerworks/library/l-prog.html>`__,
15716
 
-`part 2 <http://www-128.ibm.com/developerworks/library/l-prog2.html>`__, and
15717
 
-`part 3 <http://www-128.ibm.com/developerworks/linux/library/l-prog3.html>`__,
15718
 
+
15719
 
+`part 1 <http://www.ibm.com/developerworks/linux/library/l-prog/index.html>`__,
15720
 
+`part 2 <http://www.ibm.com/developerworks/linux/library/l-prog2/index.html>`__, and
15721
 
+`part 3 <http://www.ibm.com/developerworks/linux/library/l-prog3/index.html>`__,
15722
 
 
15723
 
 
15724
 
 Python documentation
15725
 
diff -r 8527427914a2 Doc/howto/index.rst
15726
 
--- a/Doc/howto/index.rst
15727
 
+++ b/Doc/howto/index.rst
15728
 
@@ -14,6 +14,7 @@
15729
 
    :maxdepth: 1
15730
 
 
15731
 
    advocacy.rst
15732
 
+   pyporting.rst
15733
 
    cporting.rst
15734
 
    curses.rst
15735
 
    descriptor.rst
15736
 
diff -r 8527427914a2 Doc/howto/logging-cookbook.rst
15737
 
--- a/Doc/howto/logging-cookbook.rst
15738
 
+++ b/Doc/howto/logging-cookbook.rst
15739
 
@@ -610,9 +610,10 @@
15740
 
 to have all the processes log to a :class:`SocketHandler`, and have a separate
15741
 
 process which implements a socket server which reads from the socket and logs
15742
 
 to file. (If you prefer, you can dedicate one thread in one of the existing
15743
 
-processes to perform this function.) The following section documents this
15744
 
-approach in more detail and includes a working socket receiver which can be
15745
 
-used as a starting point for you to adapt in your own applications.
15746
 
+processes to perform this function.) :ref:`This section <network-logging>`
15747
 
+documents this approach in more detail and includes a working socket receiver
15748
 
+which can be used as a starting point for you to adapt in your own
15749
 
+applications.
15750
 
 
15751
 
 If you are using a recent version of Python which includes the
15752
 
 :mod:`multiprocessing` module, you could write your own handler which uses the
15753
 
@@ -679,6 +680,68 @@
15754
 
 ``.1``. Each of the existing backup files is renamed to increment the suffix
15755
 
 (``.1`` becomes ``.2``, etc.)  and the ``.6`` file is erased.
15756
 
 
15757
 
-Obviously this example sets the log length much much too small as an extreme
15758
 
+Obviously this example sets the log length much too small as an extreme
15759
 
 example.  You would want to set *maxBytes* to an appropriate value.
15760
 
 
15761
 
+An example dictionary-based configuration
15762
 
+-----------------------------------------
15763
 
+
15764
 
+Below is an example of a logging configuration dictionary - it's taken from
15765
 
+the `documentation on the Django project <https://docs.djangoproject.com/en/1.3/topics/logging/#configuring-logging>`_.
15766
 
+This dictionary is passed to :func:`~logging.config.dictConfig` to put the configuration into effect::
15767
 
+
15768
 
+    LOGGING = {
15769
 
+        'version': 1,
15770
 
+        'disable_existing_loggers': True,
15771
 
+        'formatters': {
15772
 
+            'verbose': {
15773
 
+                'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
15774
 
+            },
15775
 
+            'simple': {
15776
 
+                'format': '%(levelname)s %(message)s'
15777
 
+            },
15778
 
+        },
15779
 
+        'filters': {
15780
 
+            'special': {
15781
 
+                '()': 'project.logging.SpecialFilter',
15782
 
+                'foo': 'bar',
15783
 
+            }
15784
 
+        },
15785
 
+        'handlers': {
15786
 
+            'null': {
15787
 
+                'level':'DEBUG',
15788
 
+                'class':'django.utils.log.NullHandler',
15789
 
+            },
15790
 
+            'console':{
15791
 
+                'level':'DEBUG',
15792
 
+                'class':'logging.StreamHandler',
15793
 
+                'formatter': 'simple'
15794
 
+            },
15795
 
+            'mail_admins': {
15796
 
+                'level': 'ERROR',
15797
 
+                'class': 'django.utils.log.AdminEmailHandler',
15798
 
+                'filters': ['special']
15799
 
+            }
15800
 
+        },
15801
 
+        'loggers': {
15802
 
+            'django': {
15803
 
+                'handlers':['null'],
15804
 
+                'propagate': True,
15805
 
+                'level':'INFO',
15806
 
+            },
15807
 
+            'django.request': {
15808
 
+                'handlers': ['mail_admins'],
15809
 
+                'level': 'ERROR',
15810
 
+                'propagate': False,
15811
 
+            },
15812
 
+            'myproject.custom': {
15813
 
+                'handlers': ['console', 'mail_admins'],
15814
 
+                'level': 'INFO',
15815
 
+                'filters': ['special']
15816
 
+            }
15817
 
+        }
15818
 
+    }
15819
 
+
15820
 
+For more information about this configuration, you can see the `relevant
15821
 
+section <https://docs.djangoproject.com/en/1.3/topics/logging/#configuring-logging>`_
15822
 
+of the Django documentation.
15823
 
diff -r 8527427914a2 Doc/howto/logging.rst
15824
 
--- a/Doc/howto/logging.rst
15825
 
+++ b/Doc/howto/logging.rst
15826
 
@@ -670,7 +670,7 @@
15827
 
     version: 1
15828
 
     formatters:
15829
 
       simple:
15830
 
-        format: format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
15831
 
+        format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
15832
 
     handlers:
15833
 
       console:
15834
 
         class: logging.StreamHandler
15835
 
diff -r 8527427914a2 Doc/howto/pyporting.rst
15836
 
--- /dev/null
15837
 
+++ b/Doc/howto/pyporting.rst
15838
 
@@ -0,0 +1,703 @@
15839
 
+.. _pyporting-howto:
15840
 
+
15841
 
+*********************************
15842
 
+Porting Python 2 Code to Python 3
15843
 
+*********************************
15844
 
+
15845
 
+:author: Brett Cannon
15846
 
+
15847
 
+.. topic:: Abstract
15848
 
+
15849
 
+   With Python 3 being the future of Python while Python 2 is still in active
15850
 
+   use, it is good to have your project available for both major releases of
15851
 
+   Python. This guide is meant to help you choose which strategy works best
15852
 
+   for your project to support both Python 2 & 3 along with how to execute
15853
 
+   that strategy.
15854
 
+
15855
 
+   If you are looking to port an extension module instead of pure Python code,
15856
 
+   please see :ref:`cporting-howto`.
15857
 
+
15858
 
+
15859
 
+Choosing a Strategy
15860
 
+===================
15861
 
+
15862
 
+When a project makes the decision that it's time to support both Python 2 & 3,
15863
 
+a decision needs to be made as to how to go about accomplishing that goal.
15864
 
+The chosen strategy will depend on how large the project's existing
15865
 
+codebase is and how much divergence you want from your Python 2 codebase from
15866
 
+your Python 3 one (e.g., starting a new version with Python 3).
15867
 
+
15868
 
+If your project is brand-new or does not have a large codebase, then you may
15869
 
+want to consider writing/porting :ref:`all of your code for Python 3
15870
 
+and use 3to2 <use_3to2>` to port your code for Python 2.
15871
 
+
15872
 
+If you would prefer to maintain a codebase which is semantically **and**
15873
 
+syntactically compatible with Python 2 & 3 simultaneously, you can write
15874
 
+:ref:`use_same_source`. While this tends to lead to somewhat non-idiomatic
15875
 
+code, it does mean you keep a rapid development process for you, the developer.
15876
 
+
15877
 
+Finally, you do have the option of :ref:`using 2to3 <use_2to3>` to translate
15878
 
+Python 2 code into Python 3 code (with some manual help). This can take the
15879
 
+form of branching your code and using 2to3 to start a Python 3 branch. You can
15880
 
+also have users perform the translation as installation time automatically so
15881
 
+that you only have to maintain a Python 2 codebase.
15882
 
+
15883
 
+Regardless of which approach you choose, porting is not as hard or
15884
 
+time-consuming as you might initially think. You can also tackle the problem
15885
 
+piece-meal as a good portion of porting is simply updating your code to follow
15886
 
+current best practices in a Python 2/3 compatible way.
15887
 
+
15888
 
+
15889
 
+Universal Bits of Advice
15890
 
+------------------------
15891
 
+
15892
 
+Regardless of what strategy you pick, there are a few things you should
15893
 
+consider.
15894
 
+
15895
 
+One is make sure you have a robust test suite. You need to make sure everything
15896
 
+continues to work, just like when you support a new minor version of Python.
15897
 
+This means making sure your test suite is thorough and is ported properly
15898
 
+between Python 2 & 3. You will also most likely want to use something like tox_
15899
 
+to automate testing between both a Python 2 and Python 3 VM.
15900
 
+
15901
 
+Two, once your project has Python 3 support, make sure to add the proper
15902
 
+classifier on the Cheeseshop_ (PyPI_). To have your project listed as Python 3
15903
 
+compatible it must have the
15904
 
+`Python 3 classifier <http://pypi.python.org/pypi?:action=browse&c=533>`_
15905
 
+(from
15906
 
+http://techspot.zzzeek.org/2011/01/24/zzzeek-s-guide-to-python-3-porting/)::
15907
 
+
15908
 
+   setup(
15909
 
+     name='Your Library',
15910
 
+     version='1.0',
15911
 
+     classifiers=[
15912
 
+         # make sure to use :: Python *and* :: Python :: 3 so
15913
 
+         # that pypi can list the package on the python 3 page
15914
 
+         'Programming Language :: Python',
15915
 
+         'Programming Language :: Python :: 3'
15916
 
+     ],
15917
 
+     packages=['yourlibrary'],
15918
 
+     # make sure to add custom_fixers to the MANIFEST.in
15919
 
+     include_package_data=True,
15920
 
+     # ...
15921
 
+   )
15922
 
+
15923
 
+
15924
 
+Doing so will cause your project to show up in the
15925
 
+`Python 3 packages list
15926
 
+<http://pypi.python.org/pypi?:action=browse&c=533&show=all>`_. You will know
15927
 
+you set the classifier properly as visiting your project page on the Cheeseshop
15928
 
+will show a Python 3 logo in the upper-left corner of the page.
15929
 
+
15930
 
+Three, the six_ project provides a library which helps iron out differences
15931
 
+between Python 2 & 3. If you find there is a sticky point that is a continual
15932
 
+point of contention in your translation or maintenance of code, consider using
15933
 
+a source-compatible solution relying on six. If you have to create your own
15934
 
+Python 2/3 compatible solution, you can use ``sys.version_info[0] >= 3`` as a
15935
 
+guard.
15936
 
+
15937
 
+Four, read all the approaches. Just because some bit of advice applies to one
15938
 
+approach more than another doesn't mean that some advice doesn't apply to other
15939
 
+strategies.
15940
 
+
15941
 
+Five, drop support for older Python versions if possible. `Python 2.5`_
15942
 
+introduced a lot of useful syntax and libraries which have become idiomatic
15943
 
+in Python 3. `Python 2.6`_ introduced future statements which makes
15944
 
+compatibility much easier if you are going from Python 2 to 3.
15945
 
+`Python 2.7`_ continues the trend in the stdlib. So choose the newest version
15946
 
+of Python which you believe can be your minimum support version
15947
 
+and work from there.
15948
 
+
15949
 
+
15950
 
+.. _tox: http://codespeak.net/tox/
15951
 
+.. _Cheeseshop:
15952
 
+.. _PyPI: http://pypi.python.org/
15953
 
+.. _six: http://packages.python.org/six
15954
 
+.. _Python 2.7: http://www.python.org/2.7.x
15955
 
+.. _Python 2.6: http://www.python.org/2.6.x
15956
 
+.. _Python 2.5: http://www.python.org/2.5.x
15957
 
+.. _Python 2.4: http://www.python.org/2.4.x
15958
 
+.. _Python 2.3: http://www.python.org/2.3.x
15959
 
+.. _Python 2.2: http://www.python.org/2.2.x
15960
 
+
15961
 
+
15962
 
+.. _use_3to2:
15963
 
+
15964
 
+Python 3 and 3to2
15965
 
+=================
15966
 
+
15967
 
+If you are starting a new project or your codebase is small enough, you may
15968
 
+want to consider writing your code for Python 3 and backporting to Python 2
15969
 
+using 3to2_. Thanks to Python 3 being more strict about things than Python 2
15970
 
+(e.g., bytes vs. strings), the source translation can be easier and more
15971
 
+straightforward than from Python 2 to 3. Plus it gives you more direct
15972
 
+experience developing in Python 3 which, since it is the future of Python, is a
15973
 
+good thing long-term.
15974
 
+
15975
 
+A drawback of this approach is that 3to2 is a third-party project. This means
15976
 
+that the Python core developers (and thus this guide) can make no promises
15977
 
+about how well 3to2 works at any time. There is nothing to suggest, though,
15978
 
+that 3to2 is not a high-quality project.
15979
 
+
15980
 
+
15981
 
+.. _3to2: https://bitbucket.org/amentajo/lib3to2/overview
15982
 
+
15983
 
+
15984
 
+.. _use_2to3:
15985
 
+
15986
 
+Python 2 and 2to3
15987
 
+=================
15988
 
+
15989
 
+Included with Python since 2.6, the 2to3_ tool (and :mod:`lib2to3` module)
15990
 
+helps with porting Python 2 to Python 3 by performing various source
15991
 
+translations. This is a perfect solution for projects which wish to branch
15992
 
+their Python 3 code from their Python 2 codebase and maintain them as
15993
 
+independent codebases. You can even begin preparing to use this approach
15994
 
+today by writing future-compatible Python code which works cleanly in
15995
 
+Python 2 in conjunction with 2to3; all steps outlined below will work
15996
 
+with Python 2 code up to the point when the actual use of 2to3 occurs.
15997
 
+
15998
 
+Use of 2to3 as an on-demand translation step at install time is also possible,
15999
 
+preventing the need to maintain a separate Python 3 codebase, but this approach
16000
 
+does come with some drawbacks. While users will only have to pay the
16001
 
+translation cost once at installation, you as a developer will need to pay the
16002
 
+cost regularly during development. If your codebase is sufficiently large
16003
 
+enough then the translation step ends up acting like a compilation step,
16004
 
+robbing you of the rapid development process you are used to with Python.
16005
 
+Obviously the time required to translate a project will vary, so do an
16006
 
+experimental translation just to see how long it takes to evaluate whether you
16007
 
+prefer this approach compared to using :ref:`use_same_source` or simply keeping
16008
 
+a separate Python 3 codebase.
16009
 
+
16010
 
+Below are the typical steps taken by a project which uses a 2to3-based approach
16011
 
+to supporting Python 2 & 3.
16012
 
+
16013
 
+
16014
 
+Support Python 2.7
16015
 
+------------------
16016
 
+
16017
 
+As a first step, make sure that your project is compatible with `Python 2.7`_.
16018
 
+This is just good to do as Python 2.7 is the last release of Python 2 and thus
16019
 
+will be used for a rather long time. It also allows for use of the ``-3`` flag
16020
 
+to Python to help discover places in your code which 2to3 cannot handle but are
16021
 
+known to cause issues.
16022
 
+
16023
 
+Try to Support `Python 2.6`_ and Newer Only
16024
 
+-------------------------------------------
16025
 
+
16026
 
+While not possible for all projects, if you can support `Python 2.6`_ and newer
16027
 
+**only**, your life will be much easier. Various future statements, stdlib
16028
 
+additions, etc. exist only in Python 2.6 and later which greatly assist in
16029
 
+porting to Python 3. But if you project must keep support for `Python 2.5`_ (or
16030
 
+even `Python 2.4`_) then it is still possible to port to Python 3.
16031
 
+
16032
 
+Below are the benefits you gain if you only have to support Python 2.6 and
16033
 
+newer. Some of these options are personal choice while others are
16034
 
+**strongly** recommended (the ones that are more for personal choice are
16035
 
+labeled as such).  If you continue to support older versions of Python then you
16036
 
+at least need to watch out for situations that these solutions fix.
16037
 
+
16038
 
+
16039
 
+``from __future__ import print_function``
16040
 
+'''''''''''''''''''''''''''''''''''''''''
16041
 
+
16042
 
+This is a personal choice. 2to3 handles the translation from the print
16043
 
+statement to the print function rather well so this is an optional step. This
16044
 
+future statement does help, though, with getting used to typing
16045
 
+``print('Hello, World')`` instead of ``print 'Hello, World'``.
16046
 
+
16047
 
+
16048
 
+``from __future__ import unicode_literals``
16049
 
+'''''''''''''''''''''''''''''''''''''''''''
16050
 
+
16051
 
+Another personal choice. You can always mark what you want to be a (unicode)
16052
 
+string with a ``u`` prefix to get the same effect. But regardless of whether
16053
 
+you use this future statement or not, you **must** make sure you know exactly
16054
 
+which Python 2 strings you want to be bytes, and which are to be strings. This
16055
 
+means you should, **at minimum** mark all strings that are meant to be text
16056
 
+strings with a ``u`` prefix if you do not use this future statement.
16057
 
+
16058
 
+
16059
 
+Bytes literals
16060
 
+''''''''''''''
16061
 
+
16062
 
+This is a **very** important one. The ability to prefix Python 2 strings that
16063
 
+are meant to contain bytes with a ``b`` prefix help to very clearly delineate
16064
 
+what is and is not a Python 3 string. When you run 2to3 on code, all Python 2
16065
 
+strings become Python 3 strings **unless** they are prefixed with ``b``.
16066
 
+
16067
 
+There are some differences between byte literals in Python 2 and those in
16068
 
+Python 3 thanks to the bytes type just being an alias to ``str`` in Python 2.
16069
 
+Probably the biggest "gotcha" is that indexing results in different values. In
16070
 
+Python 2, the value of ``b'py'[1]`` is ``'y'``, while in Python 3 it's ``121``.
16071
 
+You can avoid this disparity by always slicing at the size of a single element:
16072
 
+``b'py'[1:2]`` is ``'y'`` in Python 2 and ``b'y'`` in Python 3 (i.e., close
16073
 
+enough).
16074
 
+
16075
 
+You cannot concatenate bytes and strings in Python 3. But since in Python
16076
 
+2 has bytes aliased to ``str``, it will succeed: ``b'a' + u'b'`` works in
16077
 
+Python 2, but ``b'a' + 'b'`` in Python 3 is a :exc:`TypeError`. A similar issue
16078
 
+also comes about when doing comparisons between bytes and strings.
16079
 
+
16080
 
+
16081
 
+Supporting `Python 2.5`_ and Newer Only
16082
 
+---------------------------------------
16083
 
+
16084
 
+If you are supporting `Python 2.5`_ and newer there are still some features of
16085
 
+Python that you can utilize.
16086
 
+
16087
 
+
16088
 
+``from __future__ import absolute_import``
16089
 
+''''''''''''''''''''''''''''''''''''''''''
16090
 
+
16091
 
+Implicit relative imports (e.g., importing ``spam.bacon`` from within
16092
 
+``spam.eggs`` with the statement ``import bacon``) does not work in Python 3.
16093
 
+This future statement moves away from that and allows the use of explicit
16094
 
+relative imports (e.g., ``from . import bacon``).
16095
 
+
16096
 
+In `Python 2.5`_ you must use
16097
 
+the __future__ statement to get to use explicit relative imports and prevent
16098
 
+implicit ones. In `Python 2.6`_ explicit relative imports are available without
16099
 
+the statement, but you still want the __future__ statement to prevent implicit
16100
 
+relative imports. In `Python 2.7`_ the __future__ statement is not needed. In
16101
 
+other words, unless you are only supporting Python 2.7 or a version earlier
16102
 
+than Python 2.5, use the __future__ statement.
16103
 
+
16104
 
+
16105
 
+
16106
 
+Handle Common "Gotchas"
16107
 
+-----------------------
16108
 
+
16109
 
+There are a few things that just consistently come up as sticking points for
16110
 
+people which 2to3 cannot handle automatically or can easily be done in Python 2
16111
 
+to help modernize your code.
16112
 
+
16113
 
+
16114
 
+``from __future__ import division``
16115
 
+'''''''''''''''''''''''''''''''''''
16116
 
+
16117
 
+While the exact same outcome can be had by using the ``-Qnew`` argument to
16118
 
+Python, using this future statement lifts the requirement that your users use
16119
 
+the flag to get the expected behavior of division in Python 3
16120
 
+(e.g., ``1/2 == 0.5; 1//2 == 0``).
16121
 
+
16122
 
+
16123
 
+
16124
 
+Specify when opening a file as binary
16125
 
+'''''''''''''''''''''''''''''''''''''
16126
 
+
16127
 
+Unless you have been working on Windows, there is a chance you have not always
16128
 
+bothered to add the ``b`` mode when opening a binary file (e.g., ``rb`` for
16129
 
+binary reading).  Under Python 3, binary files and text files are clearly
16130
 
+distinct and mutually incompatible; see the :mod:`io` module for details.
16131
 
+Therefore, you **must** make a decision of whether a file will be used for
16132
 
+binary access (allowing to read and/or write bytes data) or text access
16133
 
+(allowing to read and/or write unicode data).
16134
 
+
16135
 
+Text files
16136
 
+''''''''''
16137
 
+
16138
 
+Text files created using ``open()`` under Python 2 return byte strings,
16139
 
+while under Python 3 they return unicode strings.  Depending on your porting
16140
 
+strategy, this can be an issue.
16141
 
+
16142
 
+If you want text files to return unicode strings in Python 2, you have two
16143
 
+possibilities:
16144
 
+
16145
 
+* Under Python 2.6 and higher, use :func:`io.open`.  Since :func:`io.open`
16146
 
+  is essentially the same function in both Python 2 and Python 3, it will
16147
 
+  help iron out any issues that might arise.
16148
 
+
16149
 
+* If pre-2.6 compatibility is needed, then you should use :func:`codecs.open`
16150
 
+  instead.  This will make sure that you get back unicode strings in Python 2.
16151
 
+
16152
 
+Subclass ``object``
16153
 
+'''''''''''''''''''
16154
 
+
16155
 
+New-style classes have been around since `Python 2.2`_. You need to make sure
16156
 
+you are subclassing from ``object`` to avoid odd edge cases involving method
16157
 
+resolution order, etc. This continues to be totally valid in Python 3 (although
16158
 
+unneeded as all classes implicitly inherit from ``object``).
16159
 
+
16160
 
+
16161
 
+Deal With the Bytes/String Dichotomy
16162
 
+''''''''''''''''''''''''''''''''''''
16163
 
+
16164
 
+One of the biggest issues people have when porting code to Python 3 is handling
16165
 
+the bytes/string dichotomy. Because Python 2 allowed the ``str`` type to hold
16166
 
+textual data, people have over the years been rather loose in their delineation
16167
 
+of what ``str`` instances held text compared to bytes. In Python 3 you cannot
16168
 
+be so care-free anymore and need to properly handle the difference. The key
16169
 
+handling this issue to make sure that **every** string literal in your
16170
 
+Python 2 code is either syntactically of functionally marked as either bytes or
16171
 
+text data. After this is done you then need to make sure your APIs are designed
16172
 
+to either handle a specific type or made to be properly polymorphic.
16173
 
+
16174
 
+
16175
 
+Mark Up Python 2 String Literals
16176
 
+********************************
16177
 
+
16178
 
+First thing you must do is designate every single string literal in Python 2
16179
 
+as either textual or bytes data. If you are only supporting Python 2.6 or
16180
 
+newer, this can be accomplished by marking bytes literals with a ``b`` prefix
16181
 
+and then designating textual data with a ``u`` prefix or using the
16182
 
+``unicode_literals`` future statement.
16183
 
+
16184
 
+If your project supports versions of Python pre-dating 2.6, then you should use
16185
 
+the six_ project and its ``b()`` function to denote bytes literals. For text
16186
 
+literals you can either use six's ``u()`` function or use a ``u`` prefix.
16187
 
+
16188
 
+
16189
 
+Decide what APIs Will Accept
16190
 
+****************************
16191
 
+
16192
 
+In Python 2 it was very easy to accidentally create an API that accepted both
16193
 
+bytes and textual data. But in Python 3, thanks to the more strict handling of
16194
 
+disparate types, this loose usage of bytes and text together tends to fail.
16195
 
+
16196
 
+Take the dict ``{b'a': 'bytes', u'a': 'text'}`` in Python 2.6. It creates the
16197
 
+dict ``{u'a': 'text'}`` since ``b'a' == u'a'``. But in Python 3 the equivalent
16198
 
+dict creates ``{b'a': 'bytes', 'a': 'text'}``, i.e., no lost data. Similar
16199
 
+issues can crop up when transitioning Python 2 code to Python 3.
16200
 
+
16201
 
+This means you need to choose what an API is going to accept and create and
16202
 
+consistently stick to that API in both Python 2 and 3.
16203
 
+
16204
 
+
16205
 
+Bytes / Unicode Comparison
16206
 
+**************************
16207
 
+
16208
 
+In Python 3, mixing bytes and unicode is forbidden in most situations; it
16209
 
+will raise a :class:`TypeError` where Python 2 would have attempted an implicit
16210
 
+coercion between types.  However, there is one case where it doesn't and
16211
 
+it can be very misleading::
16212
 
+
16213
 
+   >>> b"" == ""
16214
 
+   False
16215
 
+
16216
 
+This is because an equality comparison is required by the language to always
16217
 
+succeed (and return ``False`` for incompatible types).  However, this also
16218
 
+means that code incorrectly ported to Python 3 can display buggy behaviour
16219
 
+if such comparisons are silently executed.  To detect such situations,
16220
 
+Python 3 has a ``-b`` flag that will display a warning::
16221
 
+
16222
 
+   $ python3 -b
16223
 
+   >>> b"" == ""
16224
 
+   __main__:1: BytesWarning: Comparison between bytes and string
16225
 
+   False
16226
 
+
16227
 
+To turn the warning into an exception, use the ``-bb`` flag instead::
16228
 
+
16229
 
+   $ python3 -bb
16230
 
+   >>> b"" == ""
16231
 
+   Traceback (most recent call last):
16232
 
+     File "<stdin>", line 1, in <module>
16233
 
+   BytesWarning: Comparison between bytes and string
16234
 
+
16235
 
+
16236
 
+Indexing bytes objects
16237
 
+''''''''''''''''''''''
16238
 
+
16239
 
+Another potentially surprising change is the indexing behaviour of bytes
16240
 
+objects in Python 3::
16241
 
+
16242
 
+   >>> b"xyz"[0]
16243
 
+   120
16244
 
+
16245
 
+Indeed, Python 3 bytes objects (as well as :class:`bytearray` objects)
16246
 
+are sequences of integers.  But code converted from Python 2 will often
16247
 
+assume that indexing a bytestring produces another bytestring, not an
16248
 
+integer.  To reconcile both behaviours, use slicing::
16249
 
+
16250
 
+   >>> b"xyz"[0:1]
16251
 
+   b'x'
16252
 
+   >>> n = 1
16253
 
+   >>> b"xyz"[n:n+1]
16254
 
+   b'y'
16255
 
+
16256
 
+The only remaining gotcha is that an out-of-bounds slice returns an empty
16257
 
+bytes object instead of raising ``IndexError``:
16258
 
+
16259
 
+   >>> b"xyz"[3]
16260
 
+   Traceback (most recent call last):
16261
 
+     File "<stdin>", line 1, in <module>
16262
 
+   IndexError: index out of range
16263
 
+   >>> b"xyz"[3:4]
16264
 
+   b''
16265
 
+
16266
 
+
16267
 
+``__str__()``/``__unicode__()``
16268
 
+'''''''''''''''''''''''''''''''
16269
 
+
16270
 
+In Python 2, objects can specify both a string and unicode representation of
16271
 
+themselves. In Python 3, though, there is only a string representation. This
16272
 
+becomes an issue as people can inadvertently do things in their ``__str__()``
16273
 
+methods which have unpredictable results (e.g., infinite recursion if you
16274
 
+happen to use the ``unicode(self).encode('utf8')`` idiom as the body of your
16275
 
+``__str__()`` method).
16276
 
+
16277
 
+There are two ways to solve this issue. One is to use a custom 2to3 fixer. The
16278
 
+blog post at http://lucumr.pocoo.org/2011/1/22/forwards-compatible-python/
16279
 
+specifies how to do this. That will allow 2to3 to change all instances of ``def
16280
 
+__unicode(self): ...`` to ``def __str__(self): ...``. This does require you
16281
 
+define your ``__str__()`` method in Python 2 before your ``__unicode__()``
16282
 
+method.
16283
 
+
16284
 
+The other option is to use a mixin class. This allows you to only define a
16285
 
+``__unicode__()`` method for your class and let the mixin derive
16286
 
+``__str__()`` for you (code from
16287
 
+http://lucumr.pocoo.org/2011/1/22/forwards-compatible-python/)::
16288
 
+
16289
 
+   import sys
16290
 
+
16291
 
+   class UnicodeMixin(object):
16292
 
+
16293
 
+     """Mixin class to handle defining the proper __str__/__unicode__
16294
 
+     methods in Python 2 or 3."""
16295
 
+
16296
 
+     if sys.version_info[0] >= 3: # Python 3
16297
 
+         def __str__(self):
16298
 
+             return self.__unicode__()
16299
 
+     else:  # Python 2
16300
 
+         def __str__(self):
16301
 
+             return self.__unicode__().encode('utf8')
16302
 
+
16303
 
+
16304
 
+   class Spam(UnicodeMixin):
16305
 
+
16306
 
+     def __unicode__(self):
16307
 
+         return u'spam-spam-bacon-spam'  # 2to3 will remove the 'u' prefix
16308
 
+
16309
 
+
16310
 
+Don't Index on Exceptions
16311
 
+'''''''''''''''''''''''''
16312
 
+
16313
 
+In Python 2, the following worked::
16314
 
+
16315
 
+   >>> exc = Exception(1, 2, 3)
16316
 
+   >>> exc.args[1]
16317
 
+   2
16318
 
+   >>> exc[1]  # Python 2 only!
16319
 
+   2
16320
 
+
16321
 
+But in Python 3, indexing directly on an exception is an error. You need to
16322
 
+make sure to only index on the :attr:`BaseException.args` attribute which is a
16323
 
+sequence containing all arguments passed to the :meth:`__init__` method.
16324
 
+
16325
 
+Even better is to use the documented attributes the exception provides.
16326
 
+
16327
 
+Don't use ``__getslice__`` & Friends
16328
 
+''''''''''''''''''''''''''''''''''''
16329
 
+
16330
 
+Been deprecated for a while, but Python 3 finally drops support for
16331
 
+``__getslice__()``, etc. Move completely over to :meth:`__getitem__` and
16332
 
+friends.
16333
 
+
16334
 
+
16335
 
+Updating doctests
16336
 
+'''''''''''''''''
16337
 
+
16338
 
+2to3_ will attempt to generate fixes for doctests that it comes across. It's
16339
 
+not perfect, though. If you wrote a monolithic set of doctests (e.g., a single
16340
 
+docstring containing all of your doctests), you should at least consider
16341
 
+breaking the doctests up into smaller pieces to make it more manageable to fix.
16342
 
+Otherwise it might very well be worth your time and effort to port your tests
16343
 
+to :mod:`unittest`.
16344
 
+
16345
 
+
16346
 
+Eliminate ``-3`` Warnings
16347
 
+-------------------------
16348
 
+
16349
 
+When you run your application's test suite, run it using the ``-3`` flag passed
16350
 
+to Python. This will cause various warnings to be raised during execution about
16351
 
+things that 2to3 cannot handle automatically (e.g., modules that have been
16352
 
+removed). Try to eliminate those warnings to make your code even more portable
16353
 
+to Python 3.
16354
 
+
16355
 
+
16356
 
+Run 2to3
16357
 
+--------
16358
 
+
16359
 
+Once you have made your Python 2 code future-compatible with Python 3, it's
16360
 
+time to use 2to3_ to actually port your code.
16361
 
+
16362
 
+
16363
 
+Manually
16364
 
+''''''''
16365
 
+
16366
 
+To manually convert source code using 2to3_, you use the ``2to3`` script that
16367
 
+is installed with Python 2.6 and later.::
16368
 
+
16369
 
+   2to3 <directory or file to convert>
16370
 
+
16371
 
+This will cause 2to3 to write out a diff with all of the fixers applied for the
16372
 
+converted source code. If you would like 2to3 to go ahead and apply the changes
16373
 
+you can pass it the ``-w`` flag::
16374
 
+
16375
 
+   2to3 -w <stuff to convert>
16376
 
+
16377
 
+There are other flags available to control exactly which fixers are applied,
16378
 
+etc.
16379
 
+
16380
 
+
16381
 
+During Installation
16382
 
+'''''''''''''''''''
16383
 
+
16384
 
+When a user installs your project for Python 3, you can have either
16385
 
+:mod:`distutils` or Distribute_ run 2to3_ on your behalf.
16386
 
+For distutils, use the following idiom::
16387
 
+
16388
 
+   try:  # Python 3
16389
 
+     from distutils.command.build_py import build_py_2to3 as build_py
16390
 
+   except ImportError:  # Python 2
16391
 
+     from distutils.command.build_py import build_py
16392
 
+
16393
 
+   setup(cmdclass = {'build_py': build_py},
16394
 
+     # ...
16395
 
+   )
16396
 
+
16397
 
+For Distribute::
16398
 
+
16399
 
+   setup(use_2to3=True,
16400
 
+     # ...
16401
 
+   )
16402
 
+
16403
 
+This will allow you to not have to distribute a separate Python 3 version of
16404
 
+your project. It does require, though, that when you perform development that
16405
 
+you at least build your project and use the built Python 3 source for testing.
16406
 
+
16407
 
+
16408
 
+Verify & Test
16409
 
+-------------
16410
 
+
16411
 
+At this point you should (hopefully) have your project converted in such a way
16412
 
+that it works in Python 3. Verify it by running your unit tests and making sure
16413
 
+nothing has gone awry. If you miss something then figure out how to fix it in
16414
 
+Python 3, backport to your Python 2 code, and run your code through 2to3 again
16415
 
+to verify the fix transforms properly.
16416
 
+
16417
 
+
16418
 
+.. _2to3: http://docs.python.org/py3k/library/2to3.html
16419
 
+.. _Distribute: http://packages.python.org/distribute/
16420
 
+
16421
 
+
16422
 
+.. _use_same_source:
16423
 
+
16424
 
+Python 2/3 Compatible Source
16425
 
+============================
16426
 
+
16427
 
+While it may seem counter-intuitive, you can write Python code which is
16428
 
+source-compatible between Python 2 & 3. It does lead to code that is not
16429
 
+entirely idiomatic Python (e.g., having to extract the currently raised
16430
 
+exception from ``sys.exc_info()[1]``), but it can be run under Python 2
16431
 
+**and** Python 3 without using 2to3_ as a translation step (although the tool
16432
 
+should be used to help find potential portability problems). This allows you to
16433
 
+continue to have a rapid development process regardless of whether you are
16434
 
+developing under Python 2 or Python 3. Whether this approach or using
16435
 
+:ref:`use_2to3` works best for you will be a per-project decision.
16436
 
+
16437
 
+To get a complete idea of what issues you will need to deal with, see the
16438
 
+`What's New in Python 3.0`_. Others have reorganized the data in other formats
16439
 
+such as http://docs.pythonsprints.com/python3_porting/py-porting.html .
16440
 
+
16441
 
+The following are some steps to take to try to support both Python 2 & 3 from
16442
 
+the same source code.
16443
 
+
16444
 
+
16445
 
+.. _What's New in Python 3.0: http://docs.python.org/release/3.0/whatsnew/3.0.html
16446
 
+
16447
 
+
16448
 
+Follow The Steps for Using 2to3_
16449
 
+--------------------------------
16450
 
+
16451
 
+All of the steps outlined in how to
16452
 
+:ref:`port Python 2 code with 2to3 <use_2to3>` apply
16453
 
+to creating a Python 2/3 codebase. This includes trying only support Python 2.6
16454
 
+or newer (the :mod:`__future__` statements work in Python 3 without issue),
16455
 
+eliminating warnings that are triggered by ``-3``, etc.
16456
 
+
16457
 
+You should even consider running 2to3_ over your code (without committing the
16458
 
+changes). This will let you know where potential pain points are within your
16459
 
+code so that you can fix them properly before they become an issue.
16460
 
+
16461
 
+
16462
 
+Use six_
16463
 
+--------
16464
 
+
16465
 
+The six_ project contains many things to help you write portable Python code.
16466
 
+You should make sure to read its documentation from beginning to end and use
16467
 
+any and all features it provides. That way you will minimize any mistakes you
16468
 
+might make in writing cross-version code.
16469
 
+
16470
 
+
16471
 
+Capturing the Currently Raised Exception
16472
 
+----------------------------------------
16473
 
+
16474
 
+One change between Python 2 and 3 that will require changing how you code (if
16475
 
+you support `Python 2.5`_ and earlier) is
16476
 
+accessing the currently raised exception.  In Python 2.5 and earlier the syntax
16477
 
+to access the current exception is::
16478
 
+
16479
 
+   try:
16480
 
+     raise Exception()
16481
 
+   except Exception, exc:
16482
 
+     # Current exception is 'exc'
16483
 
+     pass
16484
 
+
16485
 
+This syntax changed in Python 3 (and backported to `Python 2.6`_ and later)
16486
 
+to::
16487
 
+
16488
 
+   try:
16489
 
+     raise Exception()
16490
 
+   except Exception as exc:
16491
 
+     # Current exception is 'exc'
16492
 
+     # In Python 3, 'exc' is restricted to the block; Python 2.6 will "leak"
16493
 
+     pass
16494
 
+
16495
 
+Because of this syntax change you must change to capturing the current
16496
 
+exception to::
16497
 
+
16498
 
+   try:
16499
 
+     raise Exception()
16500
 
+   except Exception:
16501
 
+     import sys
16502
 
+     exc = sys.exc_info()[1]
16503
 
+     # Current exception is 'exc'
16504
 
+     pass
16505
 
+
16506
 
+You can get more information about the raised exception from
16507
 
+:func:`sys.exc_info` than simply the current exception instance, but you most
16508
 
+likely don't need it.
16509
 
+
16510
 
+.. note::
16511
 
+   In Python 3, the traceback is attached to the exception instance
16512
 
+   through the ``__traceback__`` attribute. If the instance is saved in
16513
 
+   a local variable that persists outside of the ``except`` block, the
16514
 
+   traceback will create a reference cycle with the current frame and its
16515
 
+   dictionary of local variables.  This will delay reclaiming dead
16516
 
+   resources until the next cyclic :term:`garbage collection` pass.
16517
 
+
16518
 
+   In Python 2, this problem only occurs if you save the traceback itself
16519
 
+   (e.g. the third element of the tuple returned by :func:`sys.exc_info`)
16520
 
+   in a variable.
16521
 
+
16522
 
+
16523
 
+Other Resources
16524
 
+===============
16525
 
+
16526
 
+The authors of the following blog posts, wiki pages, and books deserve special
16527
 
+thanks for making public their tips for porting Python 2 code to Python 3 (and
16528
 
+thus helping provide information for this document):
16529
 
+
16530
 
+* http://python3porting.com/
16531
 
+* http://docs.pythonsprints.com/python3_porting/py-porting.html
16532
 
+* http://techspot.zzzeek.org/2011/01/24/zzzeek-s-guide-to-python-3-porting/
16533
 
+* http://dabeaz.blogspot.com/2011/01/porting-py65-and-my-superboard-to.html
16534
 
+* http://lucumr.pocoo.org/2011/1/22/forwards-compatible-python/
16535
 
+* http://lucumr.pocoo.org/2010/2/11/porting-to-python-3-a-guide/
16536
 
+* http://wiki.python.org/moin/PortingPythonToPy3k
16537
 
+
16538
 
+If you feel there is something missing from this document that should be added,
16539
 
+please email the python-porting_ mailing list.
16540
 
+
16541
 
+.. _python-porting: http://mail.python.org/mailman/listinfo/python-porting
16542
 
diff -r 8527427914a2 Doc/howto/sockets.rst
16543
 
--- a/Doc/howto/sockets.rst
16544
 
+++ b/Doc/howto/sockets.rst
16545
 
@@ -1,3 +1,5 @@
16546
 
+.. _socket-howto:
16547
 
+
16548
 
 ****************************
16549
 
   Socket Programming HOWTO
16550
 
 ****************************
16551
 
diff -r 8527427914a2 Doc/howto/sorting.rst
16552
 
--- a/Doc/howto/sorting.rst
16553
 
+++ b/Doc/howto/sorting.rst
16554
 
@@ -111,6 +111,15 @@
16555
 
     >>> sorted(student_objects, key=attrgetter('grade', 'age'))
16556
 
     [('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]
16557
 
 
16558
 
+The :func:`operator.methodcaller` function makes method calls with fixed
16559
 
+parameters for each object being sorted.  For example, the :meth:`str.count`
16560
 
+method could be used to compute message priority by counting the
16561
 
+number of exclamation marks in a message:
16562
 
+
16563
 
+    >>> messages = ['critical!!!', 'hurry!', 'standby', 'immediate!!']
16564
 
+    >>> sorted(messages, key=methodcaller('count', '!'))
16565
 
+    ['standby', 'hurry!', 'immediate!!', 'critical!!!']
16566
 
+
16567
 
 Ascending and Descending
16568
 
 ========================
16569
 
 
16570
 
@@ -259,28 +268,36 @@
16571
 
 * For locale aware sorting, use :func:`locale.strxfrm` for a key function or
16572
 
   :func:`locale.strcoll` for a comparison function.
16573
 
 
16574
 
-* The *reverse* parameter still maintains sort stability (i.e. records with
16575
 
-  equal keys retain the original order). Interestingly, that effect can be
16576
 
+* The *reverse* parameter still maintains sort stability (so that records with
16577
 
+  equal keys retain their original order). Interestingly, that effect can be
16578
 
   simulated without the parameter by using the builtin :func:`reversed` function
16579
 
   twice:
16580
 
 
16581
 
     >>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)]
16582
 
     >>> assert sorted(data, reverse=True) == list(reversed(sorted(reversed(data))))
16583
 
 
16584
 
-* The sort routines are guaranteed to use :meth:`__lt__` when making comparisons
16585
 
-  between two objects. So, it is easy to add a standard sort order to a class by
16586
 
-  defining an :meth:`__lt__` method::
16587
 
+* To create a standard sort order for a class, just add the appropriate rich
16588
 
+  comparison methods:
16589
 
 
16590
 
+    >>> Student.__eq__ = lambda self, other: self.age == other.age
16591
 
+    >>> Student.__ne__ = lambda self, other: self.age != other.age
16592
 
     >>> Student.__lt__ = lambda self, other: self.age < other.age
16593
 
+    >>> Student.__le__ = lambda self, other: self.age <= other.age
16594
 
+    >>> Student.__gt__ = lambda self, other: self.age > other.age
16595
 
+    >>> Student.__ge__ = lambda self, other: self.age >= other.age
16596
 
     >>> sorted(student_objects)
16597
 
     [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]
16598
 
 
16599
 
+  For general purpose comparisons, the recommended approach is to define all six
16600
 
+  rich comparison operators.  The :func:`functools.total_ordering` class
16601
 
+  decorator makes this easy to implement.
16602
 
+
16603
 
 * Key functions need not depend directly on the objects being sorted. A key
16604
 
   function can also access external resources. For instance, if the student grades
16605
 
   are stored in a dictionary, they can be used to sort a separate list of student
16606
 
   names:
16607
 
 
16608
 
     >>> students = ['dave', 'john', 'jane']
16609
 
-    >>> newgrades = {'john': 'F', 'jane':'A', 'dave': 'C'}
16610
 
-    >>> sorted(students, key=newgrades.__getitem__)
16611
 
+    >>> grades = {'john': 'F', 'jane':'A', 'dave': 'C'}
16612
 
+    >>> sorted(students, key=grades.__getitem__)
16613
 
     ['jane', 'dave', 'john']
16614
 
diff -r 8527427914a2 Doc/howto/urllib2.rst
16615
 
--- a/Doc/howto/urllib2.rst
16616
 
+++ b/Doc/howto/urllib2.rst
16617
 
@@ -138,7 +138,7 @@
16618
 
     name=Somebody+Here&language=Python&location=Northampton
16619
 
     >>> url = 'http://www.example.com/example.cgi'
16620
 
     >>> full_url = url + '?' + url_values
16621
 
-    >>> data = urllib2.open(full_url)
16622
 
+    >>> data = urllib2.urlopen(full_url)
16623
 
 
16624
 
 Notice that the full URL is created by adding a ``?`` to the URL, followed by
16625
 
 the encoded values.
16626
 
diff -r 8527427914a2 Doc/howto/webservers.rst
16627
 
--- a/Doc/howto/webservers.rst
16628
 
+++ b/Doc/howto/webservers.rst
16629
 
@@ -264,7 +264,7 @@
16630
 
 
16631
 
    * `FastCGI, SCGI, and Apache: Background and Future
16632
 
      <http://www.vmunix.com/mark/blog/archives/2006/01/02/fastcgi-scgi-and-apache-background-and-future/>`_
16633
 
-     is a discussion on why the concept of FastCGI and SCGI is better that that
16634
 
+     is a discussion on why the concept of FastCGI and SCGI is better than that
16635
 
      of mod_python.
16636
 
 
16637
 
 
16638
 
@@ -274,7 +274,7 @@
16639
 
 Each web server requires a specific module.
16640
 
 
16641
 
 * Apache has both `mod_fastcgi <http://www.fastcgi.com/drupal/>`_ and `mod_fcgid
16642
 
-  <http://fastcgi.coremail.cn/>`_.  ``mod_fastcgi`` is the original one, but it
16643
 
+  <http://httpd.apache.org/mod_fcgid/>`_.  ``mod_fastcgi`` is the original one, but it
16644
 
   has some licensing issues, which is why it is sometimes considered non-free.
16645
 
   ``mod_fcgid`` is a smaller, compatible alternative.  One of these modules needs
16646
 
   to be loaded by Apache.
16647
 
@@ -364,7 +364,7 @@
16648
 
 
16649
 
 A really great WSGI feature is middleware.  Middleware is a layer around your
16650
 
 program which can add various functionality to it.  There is quite a bit of
16651
 
-`middleware <http://wsgi.org/wsgi/Middleware_and_Utilities>`_ already
16652
 
+`middleware <http://www.wsgi.org/en/latest/libraries.html>`_ already
16653
 
 available.  For example, instead of writing your own session management (HTTP
16654
 
 is a stateless protocol, so to associate multiple HTTP requests with a single
16655
 
 user your application must create and manage such state via a session), you can
16656
 
@@ -395,9 +395,9 @@
16657
 
 
16658
 
 .. seealso::
16659
 
 
16660
 
-   A good overview of WSGI-related code can be found in the `WSGI wiki
16661
 
-   <http://wsgi.org/wsgi>`_, which contains an extensive list of `WSGI servers
16662
 
-   <http://wsgi.org/wsgi/Servers>`_ which can be used by *any* application
16663
 
+   A good overview of WSGI-related code can be found in the `WSGI homepage
16664
 
+   <http://www.wsgi.org/en/latest/index.html>`_, which contains an extensive list of `WSGI servers
16665
 
+   <http://www.wsgi.org/en/latest/servers.html>`_ which can be used by *any* application
16666
 
    supporting WSGI.
16667
 
 
16668
 
    You might be interested in some WSGI-supporting modules already contained in
16669
 
diff -r 8527427914a2 Doc/includes/capsulethunk.h
16670
 
--- /dev/null
16671
 
+++ b/Doc/includes/capsulethunk.h
16672
 
@@ -0,0 +1,134 @@
16673
 
+#ifndef __CAPSULETHUNK_H
16674
 
+#define __CAPSULETHUNK_H
16675
 
+
16676
 
+#if (    (PY_VERSION_HEX <  0x02070000) \
16677
 
+     || ((PY_VERSION_HEX >= 0x03000000) \
16678
 
+      && (PY_VERSION_HEX <  0x03010000)) )
16679
 
+
16680
 
+#define __PyCapsule_GetField(capsule, field, default_value) \
16681
 
+    ( PyCapsule_CheckExact(capsule) \
16682
 
+        ? (((PyCObject *)capsule)->field) \
16683
 
+        : (default_value) \
16684
 
+    ) \
16685
 
+
16686
 
+#define __PyCapsule_SetField(capsule, field, value) \
16687
 
+    ( PyCapsule_CheckExact(capsule) \
16688
 
+        ? (((PyCObject *)capsule)->field = value), 1 \
16689
 
+        : 0 \
16690
 
+    ) \
16691
 
+
16692
 
+
16693
 
+#define PyCapsule_Type PyCObject_Type
16694
 
+
16695
 
+#define PyCapsule_CheckExact(capsule) (PyCObject_Check(capsule))
16696
 
+#define PyCapsule_IsValid(capsule, name) (PyCObject_Check(capsule))
16697
 
+
16698
 
+
16699
 
+#define PyCapsule_New(pointer, name, destructor) \
16700
 
+    (PyCObject_FromVoidPtr(pointer, destructor))
16701
 
+
16702
 
+
16703
 
+#define PyCapsule_GetPointer(capsule, name) \
16704
 
+    (PyCObject_AsVoidPtr(capsule))
16705
 
+
16706
 
+/* Don't call PyCObject_SetPointer here, it fails if there's a destructor */
16707
 
+#define PyCapsule_SetPointer(capsule, pointer) \
16708
 
+    __PyCapsule_SetField(capsule, cobject, pointer)
16709
 
+
16710
 
+
16711
 
+#define PyCapsule_GetDestructor(capsule) \
16712
 
+    __PyCapsule_GetField(capsule, destructor)
16713
 
+
16714
 
+#define PyCapsule_SetDestructor(capsule, dtor) \
16715
 
+    __PyCapsule_SetField(capsule, destructor, dtor)
16716
 
+
16717
 
+
16718
 
+/*
16719
 
+ * Sorry, there's simply no place
16720
 
+ * to store a Capsule "name" in a CObject.
16721
 
+ */
16722
 
+#define PyCapsule_GetName(capsule) NULL
16723
 
+
16724
 
+static int
16725
 
+PyCapsule_SetName(PyObject *capsule, const char *unused)
16726
 
+{
16727
 
+    unused = unused;
16728
 
+    PyErr_SetString(PyExc_NotImplementedError,
16729
 
+        "can't use PyCapsule_SetName with CObjects");
16730
 
+    return 1;
16731
 
+}
16732
 
+
16733
 
+
16734
 
+
16735
 
+#define PyCapsule_GetContext(capsule) \
16736
 
+    __PyCapsule_GetField(capsule, descr)
16737
 
+
16738
 
+#define PyCapsule_SetContext(capsule, context) \
16739
 
+    __PyCapsule_SetField(capsule, descr, context)
16740
 
+
16741
 
+
16742
 
+static void *
16743
 
+PyCapsule_Import(const char *name, int no_block)
16744
 
+{
16745
 
+    PyObject *object = NULL;
16746
 
+    void *return_value = NULL;
16747
 
+    char *trace;
16748
 
+    size_t name_length = (strlen(name) + 1) * sizeof(char);
16749
 
+    char *name_dup = (char *)PyMem_MALLOC(name_length);
16750
 
+
16751
 
+    if (!name_dup) {
16752
 
+        return NULL;
16753
 
+    }
16754
 
+
16755
 
+    memcpy(name_dup, name, name_length);
16756
 
+
16757
 
+    trace = name_dup;
16758
 
+    while (trace) {
16759
 
+        char *dot = strchr(trace, '.');
16760
 
+        if (dot) {
16761
 
+            *dot++ = '\0';
16762
 
+        }
16763
 
+
16764
 
+        if (object == NULL) {
16765
 
+            if (no_block) {
16766
 
+                object = PyImport_ImportModuleNoBlock(trace);
16767
 
+            } else {
16768
 
+                object = PyImport_ImportModule(trace);
16769
 
+                if (!object) {
16770
 
+                    PyErr_Format(PyExc_ImportError,
16771
 
+                        "PyCapsule_Import could not "
16772
 
+                        "import module \"%s\"", trace);
16773
 
+                }
16774
 
+            }
16775
 
+        } else {
16776
 
+            PyObject *object2 = PyObject_GetAttrString(object, trace);
16777
 
+            Py_DECREF(object);
16778
 
+            object = object2;
16779
 
+        }
16780
 
+        if (!object) {
16781
 
+            goto EXIT;
16782
 
+        }
16783
 
+
16784
 
+        trace = dot;
16785
 
+    }
16786
 
+
16787
 
+    if (PyCObject_Check(object)) {
16788
 
+        PyCObject *cobject = (PyCObject *)object;
16789
 
+        return_value = cobject->cobject;
16790
 
+    } else {
16791
 
+        PyErr_Format(PyExc_AttributeError,
16792
 
+            "PyCapsule_Import \"%s\" is not valid",
16793
 
+            name);
16794
 
+    }
16795
 
+
16796
 
+EXIT:
16797
 
+    Py_XDECREF(object);
16798
 
+    if (name_dup) {
16799
 
+        PyMem_FREE(name_dup);
16800
 
+    }
16801
 
+    return return_value;
16802
 
+}
16803
 
+
16804
 
+#endif /* #if PY_VERSION_HEX < 0x02070000 */
16805
 
+
16806
 
+#endif /* __CAPSULETHUNK_H */
16807
 
diff -r 8527427914a2 Doc/includes/sqlite3/ctx_manager.py
16808
 
--- a/Doc/includes/sqlite3/ctx_manager.py
16809
 
+++ b/Doc/includes/sqlite3/ctx_manager.py
16810
 
@@ -8,7 +8,7 @@
16811
 
     con.execute("insert into person(firstname) values (?)", ("Joe",))
16812
 
 
16813
 
 # con.rollback() is called after the with block finishes with an exception, the
16814
 
-# exception is still raised and must be catched
16815
 
+# exception is still raised and must be caught
16816
 
 try:
16817
 
     with con:
16818
 
         con.execute("insert into person(firstname) values (?)", ("Joe",))
16819
 
diff -r 8527427914a2 Doc/install/index.rst
16820
 
--- a/Doc/install/index.rst
16821
 
+++ b/Doc/install/index.rst
16822
 
@@ -72,7 +72,7 @@
16823
 
 do the obvious thing with it: run it if it's an executable installer, ``rpm
16824
 
 --install`` it if it's an RPM, etc.  You don't need to run Python or a setup
16825
 
 script, you don't need to compile anything---you might not even need to read any
16826
 
-instructions (although it's always a good idea to do so anyways).
16827
 
+instructions (although it's always a good idea to do so anyway).
16828
 
 
16829
 
 Of course, things will not always be that easy.  You might be interested in a
16830
 
 module distribution that doesn't have an easy-to-use installer for your
16831
 
@@ -96,10 +96,16 @@
16832
 
 directory: :file:`foo-1.0` or :file:`widget-0.9.7`.  Additionally, the
16833
 
 distribution will contain a setup script :file:`setup.py`, and a file named
16834
 
 :file:`README.txt` or possibly just :file:`README`, which should explain that
16835
 
-building and installing the module distribution is a simple matter of running ::
16836
 
+building and installing the module distribution is a simple matter of running
16837
 
+one command from a terminal::
16838
 
 
16839
 
    python setup.py install
16840
 
 
16841
 
+For Windows, this command should be run from a command prompt window
16842
 
+(:menuselection:`Start --> Accessories`)::
16843
 
+
16844
 
+   setup.py install
16845
 
+
16846
 
 If all these things are true, then you already know how to build and install the
16847
 
 modules you've just downloaded:  Run the command above. Unless you need to
16848
 
 install things in a non-standard way or customize the build process, you don't
16849
 
@@ -113,14 +119,11 @@
16850
 
 ==========================
16851
 
 
16852
 
 As described in section :ref:`inst-new-standard`, building and installing a module
16853
 
-distribution using the Distutils is usually one simple command::
16854
 
+distribution using the Distutils is usually one simple command to run from a
16855
 
+terminal::
16856
 
 
16857
 
    python setup.py install
16858
 
 
16859
 
-On Unix, you'd run this command from a shell prompt; on Windows, you have to
16860
 
-open a command prompt window ("DOS box") and do it there; on Mac OS X, you open
16861
 
-a :command:`Terminal` window to get a shell prompt.
16862
 
-
16863
 
 
16864
 
 .. _inst-platform-variations:
16865
 
 
16866
 
@@ -141,7 +144,7 @@
16867
 
 :file:`C:\\Temp\\foo-1.0`; you can use either a archive manipulator with a
16868
 
 graphical user interface (such as WinZip) or a command-line tool (such as
16869
 
 :program:`unzip` or :program:`pkunzip`) to unpack the archive.  Then, open a
16870
 
-command prompt window ("DOS box"), and run::
16871
 
+command prompt window and run::
16872
 
 
16873
 
    cd c:\Temp\foo-1.0
16874
 
    python setup.py install
16875
 
@@ -276,6 +279,12 @@
16876
 
    >>> sys.exec_prefix
16877
 
    '/usr'
16878
 
 
16879
 
+A few other placeholders are used in this document: :file:`{X.Y}` stands for the
16880
 
+version of Python, for example ``2.7``; :file:`{distname}` will be replaced by
16881
 
+the name of the module distribution being installed.  Dots and capitalization
16882
 
+are important in the paths; for example, a value that uses ``python2.7`` on UNIX
16883
 
+will typically use ``Python27`` on Windows.
16884
 
+
16885
 
 If you don't want to install modules to the standard location, or if you don't
16886
 
 have permission to write there, then you need to read about alternate
16887
 
 installations in section :ref:`inst-alt-install`.  If you want to customize your
16888
 
@@ -304,8 +313,61 @@
16889
 
 differ across platforms, so read whichever of the following sections applies to
16890
 
 you.
16891
 
 
16892
 
+Note that the various alternate installation schemes are mutually exclusive: you
16893
 
+can pass ``--user``, or ``--home``, or ``--prefix`` and ``--exec-prefix``, or
16894
 
+``--install-base`` and ``--install-platbase``, but you can't mix from these
16895
 
+groups.
16896
 
 
16897
 
-.. _inst-alt-install-prefix:
16898
 
+
16899
 
+.. _inst-alt-install-user:
16900
 
+
16901
 
+Alternate installation: the user scheme
16902
 
+---------------------------------------
16903
 
+
16904
 
+This scheme is designed to be the most convenient solution for users that don't
16905
 
+have write permission to the global site-packages directory or don't want to
16906
 
+install into it.  It is enabled with a simple option::
16907
 
+
16908
 
+   python setup.py install --user
16909
 
+
16910
 
+Files will be installed into subdirectories of :data:`site.USER_BASE` (written
16911
 
+as :file:`{userbase}` hereafter).  This scheme installs pure Python modules and
16912
 
+extension modules in the same location (also known as :data:`site.USER_SITE`).
16913
 
+Here are the values for UNIX, including Mac OS X:
16914
 
+
16915
 
+=============== ===========================================================
16916
 
+Type of file    Installation directory
16917
 
+=============== ===========================================================
16918
 
+modules         :file:`{userbase}/lib/python{X.Y}/site-packages`
16919
 
+scripts         :file:`{userbase}/bin`
16920
 
+data            :file:`{userbase}`
16921
 
+C headers       :file:`{userbase}/include/python{X.Y}/{distname}`
16922
 
+=============== ===========================================================
16923
 
+
16924
 
+And here are the values used on Windows:
16925
 
+
16926
 
+=============== ===========================================================
16927
 
+Type of file    Installation directory
16928
 
+=============== ===========================================================
16929
 
+modules         :file:`{userbase}\\Python{XY}\\site-packages`
16930
 
+scripts         :file:`{userbase}\\Scripts`
16931
 
+data            :file:`{userbase}`
16932
 
+C headers       :file:`{userbase}\\Python{XY}\\Include\\{distname}`
16933
 
+=============== ===========================================================
16934
 
+
16935
 
+The advantage of using this scheme compared to the other ones described below is
16936
 
+that the user site-packages directory is under normal conditions always included
16937
 
+in :data:`sys.path` (see :mod:`site` for more information), which means that
16938
 
+there is no additional step to perform after running the :file:`setup.py` script
16939
 
+to finalize the installation.
16940
 
+
16941
 
+The :command:`build_ext` command also has a ``--user`` option to add
16942
 
+:file:`{userbase}/include` to the compiler search path for header files and
16943
 
+:file:`{userbase}/lib` to the compiler search path for libraries as well as to
16944
 
+the runtime search path for shared C libraries (rpath).
16945
 
+
16946
 
+
16947
 
+.. _inst-alt-install-home:
16948
 
 
16949
 
 Alternate installation: the home scheme
16950
 
 ---------------------------------------
16951
 
@@ -327,26 +389,30 @@
16952
 
 
16953
 
    python setup.py install --home=~
16954
 
 
16955
 
+To make Python find the distributions installed with this scheme, you may have
16956
 
+to :ref:`modify Python's search path <inst-search-path>` or edit
16957
 
+:mod:`sitecustomize` (see :mod:`site`) to call :func:`site.addsitedir` or edit
16958
 
+:data:`sys.path`.
16959
 
+
16960
 
 The :option:`--home` option defines the installation base directory.  Files are
16961
 
 installed to the following directories under the installation base as follows:
16962
 
 
16963
 
-+------------------------------+---------------------------+-----------------------------+
16964
 
-| Type of file                 | Installation Directory    | Override option             |
16965
 
-+==============================+===========================+=============================+
16966
 
-| pure module distribution     | :file:`{home}/lib/python` | :option:`--install-purelib` |
16967
 
-+------------------------------+---------------------------+-----------------------------+
16968
 
-| non-pure module distribution | :file:`{home}/lib/python` | :option:`--install-platlib` |
16969
 
-+------------------------------+---------------------------+-----------------------------+
16970
 
-| scripts                      | :file:`{home}/bin`        | :option:`--install-scripts` |
16971
 
-+------------------------------+---------------------------+-----------------------------+
16972
 
-| data                         | :file:`{home}/share`      | :option:`--install-data`    |
16973
 
-+------------------------------+---------------------------+-----------------------------+
16974
 
+=============== ===========================================================
16975
 
+Type of file    Installation directory
16976
 
+=============== ===========================================================
16977
 
+modules         :file:`{home}/lib/python`
16978
 
+scripts         :file:`{home}/bin`
16979
 
+data            :file:`{home}`
16980
 
+C headers       :file:`{home}/include/python/{distname}`
16981
 
+=============== ===========================================================
16982
 
+
16983
 
+(Mentally replace slashes with backslashes if you're on Windows.)
16984
 
 
16985
 
 .. versionchanged:: 2.4
16986
 
    The :option:`--home` option used to be supported only on Unix.
16987
 
 
16988
 
 
16989
 
-.. _inst-alt-install-home:
16990
 
+.. _inst-alt-install-prefix-unix:
16991
 
 
16992
 
 Alternate installation: Unix (the prefix scheme)
16993
 
 ------------------------------------------------
16994
 
@@ -355,7 +421,7 @@
16995
 
 perform the build/install (i.e., to run the setup script), but install modules
16996
 
 into the third-party module directory of a different Python installation (or
16997
 
 something that looks like a different Python installation).  If this sounds a
16998
 
-trifle unusual, it is---that's why the "home scheme" comes first.  However,
16999
 
+trifle unusual, it is---that's why the user and home schemes come before.  However,
17000
 
 there are at least two known cases where the prefix scheme will be useful.
17001
 
 
17002
 
 First, consider that many Linux distributions put Python in :file:`/usr`, rather
17003
 
@@ -383,17 +449,15 @@
17004
 
 executables, etc.)  If :option:`--exec-prefix` is not supplied, it defaults to
17005
 
 :option:`--prefix`.  Files are installed as follows:
17006
 
 
17007
 
-+------------------------------+-----------------------------------------------------+-----------------------------+
17008
 
-| Type of file                 | Installation Directory                              | Override option             |
17009
 
-+==============================+=====================================================+=============================+
17010
 
-| pure module distribution     | :file:`{prefix}/lib/python{X.Y}/site-packages`      | :option:`--install-purelib` |
17011
 
-+------------------------------+-----------------------------------------------------+-----------------------------+
17012
 
-| non-pure module distribution | :file:`{exec-prefix}/lib/python{X.Y}/site-packages` | :option:`--install-platlib` |
17013
 
-+------------------------------+-----------------------------------------------------+-----------------------------+
17014
 
-| scripts                      | :file:`{prefix}/bin`                                | :option:`--install-scripts` |
17015
 
-+------------------------------+-----------------------------------------------------+-----------------------------+
17016
 
-| data                         | :file:`{prefix}/share`                              | :option:`--install-data`    |
17017
 
-+------------------------------+-----------------------------------------------------+-----------------------------+
17018
 
+================= ==========================================================
17019
 
+Type of file      Installation directory
17020
 
+================= ==========================================================
17021
 
+Python modules    :file:`{prefix}/lib/python{X.Y}/site-packages`
17022
 
+extension modules :file:`{exec-prefix}/lib/python{X.Y}/site-packages`
17023
 
+scripts           :file:`{prefix}/bin`
17024
 
+data              :file:`{prefix}`
17025
 
+C headers         :file:`{prefix}/include/python{X.Y}/{distname}`
17026
 
+================= ==========================================================
17027
 
 
17028
 
 There is no requirement that :option:`--prefix` or :option:`--exec-prefix`
17029
 
 actually point to an alternate Python installation; if the directories listed
17030
 
@@ -418,7 +482,7 @@
17031
 
 alternate Python installation, this is immaterial.)
17032
 
 
17033
 
 
17034
 
-.. _inst-alt-install-windows:
17035
 
+.. _inst-alt-install-prefix-windows:
17036
 
 
17037
 
 Alternate installation: Windows (the prefix scheme)
17038
 
 ---------------------------------------------------
17039
 
@@ -433,20 +497,18 @@
17040
 
 to install modules to the :file:`\\Temp\\Python` directory on the current drive.
17041
 
 
17042
 
 The installation base is defined by the :option:`--prefix` option; the
17043
 
-:option:`--exec-prefix` option is not supported under Windows. Files are
17044
 
-installed as follows:
17045
 
+:option:`--exec-prefix` option is not supported under Windows, which means that
17046
 
+pure Python modules and extension modules are installed into the same location.
17047
 
+Files are installed as follows:
17048
 
 
17049
 
-+------------------------------+---------------------------+-----------------------------+
17050
 
-| Type of file                 | Installation Directory    | Override option             |
17051
 
-+==============================+===========================+=============================+
17052
 
-| pure module distribution     | :file:`{prefix}`          | :option:`--install-purelib` |
17053
 
-+------------------------------+---------------------------+-----------------------------+
17054
 
-| non-pure module distribution | :file:`{prefix}`          | :option:`--install-platlib` |
17055
 
-+------------------------------+---------------------------+-----------------------------+
17056
 
-| scripts                      | :file:`{prefix}\\Scripts` | :option:`--install-scripts` |
17057
 
-+------------------------------+---------------------------+-----------------------------+
17058
 
-| data                         | :file:`{prefix}\\Data`    | :option:`--install-data`    |
17059
 
-+------------------------------+---------------------------+-----------------------------+
17060
 
+=============== ==========================================================
17061
 
+Type of file    Installation directory
17062
 
+=============== ==========================================================
17063
 
+modules         :file:`{prefix}\\Lib\\site-packages`
17064
 
+scripts         :file:`{prefix}\\Scripts`
17065
 
+data            :file:`{prefix}`
17066
 
+C headers       :file:`{prefix}\\Include\\{distname}`
17067
 
+=============== ==========================================================
17068
 
 
17069
 
 
17070
 
 .. _inst-custom-install:
17071
 
@@ -460,13 +522,29 @@
17072
 
 or you might want to completely redefine the installation scheme.  In either
17073
 
 case, you're creating a *custom installation scheme*.
17074
 
 
17075
 
-You probably noticed the column of "override options" in the tables describing
17076
 
-the alternate installation schemes above.  Those options are how you define a
17077
 
-custom installation scheme.  These override options can be relative, absolute,
17078
 
+To create a custom installation scheme, you start with one of the alternate
17079
 
+schemes and override some of the installation directories used for the various
17080
 
+types of files, using these options:
17081
 
+
17082
 
+====================== =======================
17083
 
+Type of file           Override option
17084
 
+====================== =======================
17085
 
+Python modules         ``--install-purelib``
17086
 
+extension modules      ``--install-platlib``
17087
 
+all modules            ``--install-lib``
17088
 
+scripts                ``--install-scripts``
17089
 
+data                   ``--install-data``
17090
 
+C headers              ``--install-headers``
17091
 
+====================== =======================
17092
 
+
17093
 
+These override options can be relative, absolute,
17094
 
 or explicitly defined in terms of one of the installation base directories.
17095
 
 (There are two installation base directories, and they are normally the same---
17096
 
 they only differ when you use the Unix "prefix scheme" and supply different
17097
 
-:option:`--prefix` and :option:`--exec-prefix` options.)
17098
 
+``--prefix`` and ``--exec-prefix`` options; using ``--install-lib`` will
17099
 
+override values computed or given for ``--install-purelib`` and
17100
 
+``--install-platlib``, and is recommended for schemes that don't make a
17101
 
+difference between Python and extension modules.)
17102
 
 
17103
 
 For example, say you're installing a module distribution to your home directory
17104
 
 under Unix---but you want scripts to go in :file:`~/scripts` rather than
17105
 
@@ -493,15 +571,16 @@
17106
 
 a subdirectory of :file:`{prefix}`, rather than right in :file:`{prefix}`
17107
 
 itself.  This is almost as easy as customizing the script installation directory
17108
 
 ---you just have to remember that there are two types of modules to worry about,
17109
 
-pure modules and non-pure modules (i.e., modules from a non-pure distribution).
17110
 
-For example::
17111
 
+Python and extension modules, which can conveniently be both controlled by one
17112
 
+option::
17113
 
 
17114
 
-   python setup.py install --install-purelib=Site --install-platlib=Site
17115
 
+   python setup.py install --install-lib=Site
17116
 
 
17117
 
-The specified installation directories are relative to :file:`{prefix}`.  Of
17118
 
-course, you also have to ensure that these directories are in Python's module
17119
 
-search path, such as by putting a :file:`.pth` file in :file:`{prefix}`.  See
17120
 
-section :ref:`inst-search-path` to find out how to modify Python's search path.
17121
 
+The specified installation directory is relative to :file:`{prefix}`.  Of
17122
 
+course, you also have to ensure that this directory is in Python's module
17123
 
+search path, such as by putting a :file:`.pth` file in a site directory (see
17124
 
+:mod:`site`).  See section :ref:`inst-search-path` to find out how to modify
17125
 
+Python's search path.
17126
 
 
17127
 
 If you want to define an entire installation scheme, you just have to supply all
17128
 
 of the installation directory options.  The recommended way to do this is to
17129
 
@@ -553,8 +632,8 @@
17130
 
 
17131
 
    python setup.py install --install-base=/tmp
17132
 
 
17133
 
-would install pure modules to :file:`{/tmp/python/lib}` in the first case, and
17134
 
-to :file:`{/tmp/lib}` in the second case.  (For the second case, you probably
17135
 
+would install pure modules to :file:`/tmp/python/lib` in the first case, and
17136
 
+to :file:`/tmp/lib` in the second case.  (For the second case, you probably
17137
 
 want to supply an installation base of :file:`/tmp/python`.)
17138
 
 
17139
 
 You probably noticed the use of ``$HOME`` and ``$PLAT`` in the sample
17140
 
@@ -571,7 +650,7 @@
17141
 
    needed on those platforms?
17142
 
 
17143
 
 
17144
 
-.. XXX I'm not sure where this section should go.
17145
 
+.. XXX Move this to Doc/using
17146
 
 
17147
 
 .. _inst-search-path:
17148
 
 
17149
 
diff -r 8527427914a2 Doc/library/2to3.rst
17150
 
--- a/Doc/library/2to3.rst
17151
 
+++ b/Doc/library/2to3.rst
17152
 
@@ -94,6 +94,38 @@
17153
 
 :option:`-p` to run fixers on code that already has had its print statements
17154
 
 converted.
17155
 
 
17156
 
+The :option:`-o` or :option:`--output-dir` option allows specification of an
17157
 
+alternate directory for processed output files to be written to.  The
17158
 
+:option:`-n` flag is required when using this as backup files do not make sense
17159
 
+when not overwriting the input files.
17160
 
+
17161
 
+.. versionadded:: 2.7.3
17162
 
+   The :option:`-o` option was added.
17163
 
+
17164
 
+The :option:`-W` or :option:`--write-unchanged-files` flag tells 2to3 to always
17165
 
+write output files even if no changes were required to the file.  This is most
17166
 
+useful with :option:`-o` so that an entire Python source tree is copied with
17167
 
+translation from one directory to another.
17168
 
+This option implies the :option:`-w` flag as it would not make sense otherwise.
17169
 
+
17170
 
+.. versionadded:: 2.7.3
17171
 
+   The :option:`-W` flag was added.
17172
 
+
17173
 
+The :option:`--add-suffix` option specifies a string to append to all output
17174
 
+filenames.  The :option:`-n` flag is required when specifying this as backups
17175
 
+are not necessary when writing to different filenames.  Example::
17176
 
+
17177
 
+   $ 2to3 -n -W --add-suffix=3 example.py
17178
 
+
17179
 
+Will cause a converted file named ``example.py3`` to be written.
17180
 
+
17181
 
+.. versionadded:: 2.7.3
17182
 
+   The :option:`--add-suffix` option was added.
17183
 
+
17184
 
+To translate an entire project from one directory tree to another use::
17185
 
+
17186
 
+   $ 2to3 --output-dir=python3-version/mycode -W -n python2-version/mycode
17187
 
+
17188
 
 
17189
 
 .. _2to3-fixers:
17190
 
 
17191
 
@@ -123,7 +155,9 @@
17192
 
 .. 2to3fixer:: callable
17193
 
 
17194
 
    Converts ``callable(x)`` to ``isinstance(x, collections.Callable)``, adding
17195
 
-   an import to :mod:`collections` if needed.
17196
 
+   an import to :mod:`collections` if needed. Note ``callable(x)`` has returned
17197
 
+   in Python 3.2, so if you do not intend to support Python 3.1, you can disable
17198
 
+   this fixer.
17199
 
 
17200
 
 .. 2to3fixer:: dict
17201
 
 
17202
 
@@ -230,7 +264,7 @@
17203
 
 
17204
 
 .. 2to3fixer:: long
17205
 
 
17206
 
-   Strips the ``L`` prefix on long literals and renames :class:`long` to
17207
 
+   Strips the ``L`` suffix on long literals and renames :class:`long` to
17208
 
    :class:`int`.
17209
 
 
17210
 
 .. 2to3fixer:: map
17211
 
diff -r 8527427914a2 Doc/library/__builtin__.rst
17212
 
--- a/Doc/library/__builtin__.rst
17213
 
+++ b/Doc/library/__builtin__.rst
17214
 
@@ -8,7 +8,9 @@
17215
 
 
17216
 
 This module provides direct access to all 'built-in' identifiers of Python; for
17217
 
 example, ``__builtin__.open`` is the full name for the built-in function
17218
 
-:func:`open`.
17219
 
+:func:`open`.  See :ref:`built-in-funcs` and :ref:`built-in-consts` for
17220
 
+documentation.
17221
 
+
17222
 
 
17223
 
 This module is not normally accessed explicitly by most applications, but can be
17224
 
 useful in modules that provide objects with the same name as a built-in value,
17225
 
diff -r 8527427914a2 Doc/library/__future__.rst
17226
 
--- a/Doc/library/__future__.rst
17227
 
+++ b/Doc/library/__future__.rst
17228
 
@@ -4,6 +4,9 @@
17229
 
 .. module:: __future__
17230
 
    :synopsis: Future statement definitions
17231
 
 
17232
 
+**Source code:** :source:`Lib/__future__.py`
17233
 
+
17234
 
+--------------
17235
 
 
17236
 
 :mod:`__future__` is a real module, and serves three purposes:
17237
 
 
17238
 
diff -r 8527427914a2 Doc/library/abc.rst
17239
 
--- a/Doc/library/abc.rst
17240
 
+++ b/Doc/library/abc.rst
17241
 
@@ -9,8 +9,12 @@
17242
 
 
17243
 
 .. versionadded:: 2.6
17244
 
 
17245
 
-This module provides the infrastructure for defining an :term:`abstract base
17246
 
-class` (ABCs) in Python, as outlined in :pep:`3119`; see the PEP for why this
17247
 
+**Source code:** :source:`Lib/abc.py`
17248
 
+
17249
 
+--------------
17250
 
+
17251
 
+This module provides the infrastructure for defining :term:`abstract base
17252
 
+classes <abstract base class>` (ABCs) in Python, as outlined in :pep:`3119`; see the PEP for why this
17253
 
 was added to Python. (See also :pep:`3141` and the :mod:`numbers` module
17254
 
 regarding a type hierarchy for numbers based on ABCs.)
17255
 
 
17256
 
diff -r 8527427914a2 Doc/library/aifc.rst
17257
 
--- a/Doc/library/aifc.rst
17258
 
+++ b/Doc/library/aifc.rst
17259
 
@@ -10,6 +10,10 @@
17260
 
    single: AIFF
17261
 
    single: AIFF-C
17262
 
 
17263
 
+**Source code:** :source:`Lib/aifc.py`
17264
 
+
17265
 
+--------------
17266
 
+
17267
 
 This module provides support for reading and writing AIFF and AIFF-C files.
17268
 
 AIFF is Audio Interchange File Format, a format for storing digital audio
17269
 
 samples in a file.  AIFF-C is a newer version of the format that includes the
17270
 
diff -r 8527427914a2 Doc/library/al.rst
17271
 
--- a/Doc/library/al.rst
17272
 
+++ b/Doc/library/al.rst
17273
 
@@ -53,7 +53,7 @@
17274
 
 .. function:: queryparams(device)
17275
 
 
17276
 
    The device argument is an integer.  The return value is a list of integers
17277
 
-   containing the data returned by :cfunc:`ALqueryparams`.
17278
 
+   containing the data returned by :c:func:`ALqueryparams`.
17279
 
 
17280
 
 
17281
 
 .. function:: getparams(device, list)
17282
 
diff -r 8527427914a2 Doc/library/argparse.rst
17283
 
--- a/Doc/library/argparse.rst
17284
 
+++ b/Doc/library/argparse.rst
17285
 
@@ -2,11 +2,15 @@
17286
 
 ===============================================================================
17287
 
 
17288
 
 .. module:: argparse
17289
 
-   :synopsis: Command-line option and argument-parsing library.
17290
 
+   :synopsis: Command-line option and argument parsing library.
17291
 
 .. moduleauthor:: Steven Bethard <steven.bethard@gmail.com>
17292
 
-.. versionadded:: 2.7
17293
 
 .. sectionauthor:: Steven Bethard <steven.bethard@gmail.com>
17294
 
 
17295
 
+.. versionadded:: 2.7
17296
 
+
17297
 
+**Source code:** :source:`Lib/argparse.py`
17298
 
+
17299
 
+--------------
17300
 
 
17301
 
 The :mod:`argparse` module makes it easy to write user-friendly command-line
17302
 
 interfaces. The program defines what arguments it requires, and :mod:`argparse`
17303
 
@@ -103,10 +107,10 @@
17304
 
 Parsing arguments
17305
 
 ^^^^^^^^^^^^^^^^^
17306
 
 
17307
 
-:class:`ArgumentParser` parses args through the
17308
 
+:class:`ArgumentParser` parses arguments through the
17309
 
 :meth:`~ArgumentParser.parse_args` method.  This will inspect the command line,
17310
 
-convert each arg to the appropriate type and then invoke the appropriate action.
17311
 
-In most cases, this means a simple namespace object will be built up from
17312
 
+convert each argument to the appropriate type and then invoke the appropriate action.
17313
 
+In most cases, this means a simple :class:`Namespace` object will be built up from
17314
 
 attributes parsed out of the command line::
17315
 
 
17316
 
    >>> parser.parse_args(['--sum', '7', '-1', '42'])
17317
 
@@ -114,7 +118,7 @@
17318
 
 
17319
 
 In a script, :meth:`~ArgumentParser.parse_args` will typically be called with no
17320
 
 arguments, and the :class:`ArgumentParser` will automatically determine the
17321
 
-command-line args from :data:`sys.argv`.
17322
 
+command-line arguments from :data:`sys.argv`.
17323
 
 
17324
 
 
17325
 
 ArgumentParser objects
17326
 
@@ -149,7 +153,7 @@
17327
 
      conflicting optionals.
17328
 
 
17329
 
    * prog_ - The name of the program (default:
17330
 
-     :data:`sys.argv[0]`)
17331
 
+     ``sys.argv[0]``)
17332
 
 
17333
 
    * usage_ - The string describing the program usage (default: generated)
17334
 
 
17335
 
@@ -238,7 +242,7 @@
17336
 
     --foo FOO  foo help
17337
 
 
17338
 
 The help option is typically ``-h/--help``. The exception to this is
17339
 
-if the ``prefix_chars=`` is specified and does not include ``'-'``, in
17340
 
+if the ``prefix_chars=`` is specified and does not include ``-``, in
17341
 
 which case ``-h`` and ``--help`` are not valid options.  In
17342
 
 this case, the first character in ``prefix_chars`` is used to prefix
17343
 
 the help options::
17344
 
@@ -254,7 +258,7 @@
17345
 
 prefix_chars
17346
 
 ^^^^^^^^^^^^
17347
 
 
17348
 
-Most command-line options will use ``'-'`` as the prefix, e.g. ``-f/--foo``.
17349
 
+Most command-line options will use ``-`` as the prefix, e.g. ``-f/--foo``.
17350
 
 Parsers that need to support different or additional prefix
17351
 
 characters, e.g. for options
17352
 
 like ``+f`` or ``/foo``, may specify them using the ``prefix_chars=`` argument
17353
 
@@ -267,7 +271,7 @@
17354
 
    Namespace(bar='Y', f='X')
17355
 
 
17356
 
 The ``prefix_chars=`` argument defaults to ``'-'``. Supplying a set of
17357
 
-characters that does not include ``'-'`` will cause ``-f/--foo`` options to be
17358
 
+characters that does not include ``-`` will cause ``-f/--foo`` options to be
17359
 
 disallowed.
17360
 
 
17361
 
 
17362
 
@@ -389,7 +393,7 @@
17363
 
    likewise for this epilog whose whitespace will be cleaned up and whose words
17364
 
    will be wrapped across a couple lines
17365
 
 
17366
 
-Passing :class:`~argparse.RawDescriptionHelpFormatter` as ``formatter_class=``
17367
 
+Passing :class:`RawDescriptionHelpFormatter` as ``formatter_class=``
17368
 
 indicates that description_ and epilog_ are already correctly formatted and
17369
 
 should not be line-wrapped::
17370
 
 
17371
 
@@ -415,7 +419,7 @@
17372
 
    optional arguments:
17373
 
     -h, --help  show this help message and exit
17374
 
 
17375
 
-:class:`RawTextHelpFormatter` maintains whitespace for all sorts of help text
17376
 
+:class:`RawTextHelpFormatter` maintains whitespace for all sorts of help text,
17377
 
 including argument descriptions.
17378
 
 
17379
 
 The other formatter class available, :class:`ArgumentDefaultsHelpFormatter`,
17380
 
@@ -642,11 +646,11 @@
17381
 
 action
17382
 
 ^^^^^^
17383
 
 
17384
 
-:class:`ArgumentParser` objects associate command-line args with actions.  These
17385
 
-actions can do just about anything with the command-line args associated with
17386
 
+:class:`ArgumentParser` objects associate command-line arguments with actions.  These
17387
 
+actions can do just about anything with the command-line arguments associated with
17388
 
 them, though most actions simply add an attribute to the object returned by
17389
 
 :meth:`~ArgumentParser.parse_args`.  The ``action`` keyword argument specifies
17390
 
-how the command-line args should be handled. The supported actions are:
17391
 
+how the command-line arguments should be handled. The supported actions are:
17392
 
 
17393
 
 * ``'store'`` - This just stores the argument's value.  This is the default
17394
 
   action. For example::
17395
 
@@ -666,15 +670,17 @@
17396
 
     >>> parser.parse_args('--foo'.split())
17397
 
     Namespace(foo=42)
17398
 
 
17399
 
-* ``'store_true'`` and ``'store_false'`` - These store the values ``True`` and
17400
 
-  ``False`` respectively.  These are special cases of ``'store_const'``.  For
17401
 
-  example::
17402
 
+* ``'store_true'`` and ``'store_false'`` - These are special cases of
17403
 
+  ``'store_const'`` using for storing the values ``True`` and ``False``
17404
 
+  respectively.  In addition, they create default values of *False* and *True*
17405
 
+  respectively.  For example::
17406
 
 
17407
 
     >>> parser = argparse.ArgumentParser()
17408
 
     >>> parser.add_argument('--foo', action='store_true')
17409
 
     >>> parser.add_argument('--bar', action='store_false')
17410
 
+    >>> parser.add_argument('--baz', action='store_false')
17411
 
     >>> parser.parse_args('--foo --bar'.split())
17412
 
-    Namespace(bar=False, foo=True)
17413
 
+    Namespace(bar=False, baz=True, foo=True)
17414
 
 
17415
 
 * ``'append'`` - This stores a list, and appends each argument value to the
17416
 
   list.  This is useful to allow an option to be specified multiple times.
17417
 
@@ -697,6 +703,19 @@
17418
 
     >>> parser.parse_args('--str --int'.split())
17419
 
     Namespace(types=[<type 'str'>, <type 'int'>])
17420
 
 
17421
 
+* ``'count'`` - This counts the number of times a keyword argument occurs. For
17422
 
+  example, this is useful for increasing verbosity levels::
17423
 
+
17424
 
+    >>> parser = argparse.ArgumentParser()
17425
 
+    >>> parser.add_argument('--verbose', '-v', action='count')
17426
 
+    >>> parser.parse_args('-vvv'.split())
17427
 
+    Namespace(verbose=3)
17428
 
+
17429
 
+* ``'help'`` - This prints a complete help message for all the options in the
17430
 
+  current parser and then exits. By default a help action is automatically
17431
 
+  added to the parser. See :class:`ArgumentParser` for details of how the
17432
 
+  output is created.
17433
 
+
17434
 
 * ``'version'`` - This expects a ``version=`` keyword argument in the
17435
 
   :meth:`~ArgumentParser.add_argument` call, and prints version information
17436
 
   and exits when invoked.
17437
 
@@ -714,12 +733,12 @@
17438
 
 
17439
 
 * ``parser`` - The ArgumentParser object which contains this action.
17440
 
 
17441
 
-* ``namespace`` - The namespace object that will be returned by
17442
 
+* ``namespace`` - The :class:`Namespace` object that will be returned by
17443
 
   :meth:`~ArgumentParser.parse_args`.  Most actions add an attribute to this
17444
 
   object.
17445
 
 
17446
 
-* ``values`` - The associated command-line args, with any type-conversions
17447
 
-  applied.  (Type-conversions are specified with the type_ keyword argument to
17448
 
+* ``values`` - The associated command-line arguments, with any type conversions
17449
 
+  applied.  (Type conversions are specified with the type_ keyword argument to
17450
 
   :meth:`~ArgumentParser.add_argument`.
17451
 
 
17452
 
 * ``option_string`` - The option string that was used to invoke this action.
17453
 
@@ -751,7 +770,7 @@
17454
 
 different number of command-line arguments with a single action.  The supported
17455
 
 values are:
17456
 
 
17457
 
-* N (an integer).  N args from the command line will be gathered together into a
17458
 
+* ``N`` (an integer).  ``N`` arguments from the command line will be gathered together into a
17459
 
   list.  For example::
17460
 
 
17461
 
      >>> parser = argparse.ArgumentParser()
17462
 
@@ -763,11 +782,11 @@
17463
 
   Note that ``nargs=1`` produces a list of one item.  This is different from
17464
 
   the default, in which the item is produced by itself.
17465
 
 
17466
 
-* ``'?'``. One arg will be consumed from the command line if possible, and
17467
 
-  produced as a single item.  If no command-line arg is present, the value from
17468
 
+* ``'?'``. One argument will be consumed from the command line if possible, and
17469
 
+  produced as a single item.  If no command-line argument is present, the value from
17470
 
   default_ will be produced.  Note that for optional arguments, there is an
17471
 
   additional case - the option string is present but not followed by a
17472
 
-  command-line arg.  In this case the value from const_ will be produced.  Some
17473
 
+  command-line argument.  In this case the value from const_ will be produced.  Some
17474
 
   examples to illustrate this::
17475
 
 
17476
 
      >>> parser = argparse.ArgumentParser()
17477
 
@@ -795,7 +814,7 @@
17478
 
      Namespace(infile=<open file '<stdin>', mode 'r' at 0x...>,
17479
 
                outfile=<open file '<stdout>', mode 'w' at 0x...>)
17480
 
 
17481
 
-* ``'*'``.  All command-line args present are gathered into a list.  Note that
17482
 
+* ``'*'``.  All command-line arguments present are gathered into a list.  Note that
17483
 
   it generally doesn't make much sense to have more than one positional argument
17484
 
   with ``nargs='*'``, but multiple optional arguments with ``nargs='*'`` is
17485
 
   possible.  For example::
17486
 
@@ -809,7 +828,7 @@
17487
 
 
17488
 
 * ``'+'``. Just like ``'*'``, all command-line args present are gathered into a
17489
 
   list.  Additionally, an error message will be generated if there wasn't at
17490
 
-  least one command-line arg present.  For example::
17491
 
+  least one command-line argument present.  For example::
17492
 
 
17493
 
      >>> parser = argparse.ArgumentParser(prog='PROG')
17494
 
      >>> parser.add_argument('foo', nargs='+')
17495
 
@@ -819,8 +838,19 @@
17496
 
      usage: PROG [-h] foo [foo ...]
17497
 
      PROG: error: too few arguments
17498
 
 
17499
 
-If the ``nargs`` keyword argument is not provided, the number of args consumed
17500
 
-is determined by the action_.  Generally this means a single command-line arg
17501
 
+* ``argparse.REMAINDER``.  All the remaining command-line arguments are gathered
17502
 
+  into a list.  This is commonly useful for command line utilities that dispatch
17503
 
+  to other command line utilities.
17504
 
+
17505
 
+     >>> parser = argparse.ArgumentParser(prog='PROG')
17506
 
+     >>> parser.add_argument('--foo')
17507
 
+     >>> parser.add_argument('command')
17508
 
+     >>> parser.add_argument('args', nargs=argparse.REMAINDER)
17509
 
+     >>> print parser.parse_args('--foo B cmd --arg1 XX ZZ'.split())
17510
 
+     Namespace(args=['--arg1', 'XX', 'ZZ'], command='cmd', foo='B')
17511
 
+
17512
 
+If the ``nargs`` keyword argument is not provided, the number of arguments consumed
17513
 
+is determined by the action_.  Generally this means a single command-line argument
17514
 
 will be consumed and a single item (not a list) will be produced.
17515
 
 
17516
 
 
17517
 
@@ -837,9 +867,9 @@
17518
 
 
17519
 
 * When :meth:`~ArgumentParser.add_argument` is called with option strings
17520
 
   (like ``-f`` or ``--foo``) and ``nargs='?'``.  This creates an optional
17521
 
-  argument that can be followed by zero or one command-line args.
17522
 
+  argument that can be followed by zero or one command-line arguments.
17523
 
   When parsing the command line, if the option string is encountered with no
17524
 
-  command-line arg following it, the value of ``const`` will be assumed instead.
17525
 
+  command-line argument following it, the value of ``const`` will be assumed instead.
17526
 
   See the nargs_ description for examples.
17527
 
 
17528
 
 The ``const`` keyword argument defaults to ``None``.
17529
 
@@ -851,7 +881,7 @@
17530
 
 All optional arguments and some positional arguments may be omitted at the
17531
 
 command line.  The ``default`` keyword argument of
17532
 
 :meth:`~ArgumentParser.add_argument`, whose value defaults to ``None``,
17533
 
-specifies what value should be used if the command-line arg is not present.
17534
 
+specifies what value should be used if the command-line argument is not present.
17535
 
 For optional arguments, the ``default`` value is used when the option string
17536
 
 was not present at the command line::
17537
 
 
17538
 
@@ -862,8 +892,8 @@
17539
 
    >>> parser.parse_args(''.split())
17540
 
    Namespace(foo=42)
17541
 
 
17542
 
-For positional arguments with nargs_ ``='?'`` or ``'*'``, the ``default`` value
17543
 
-is used when no command-line arg was present::
17544
 
+For positional arguments with nargs_ equal to ``?`` or ``*``, the ``default`` value
17545
 
+is used when no command-line argument was present::
17546
 
 
17547
 
    >>> parser = argparse.ArgumentParser()
17548
 
    >>> parser.add_argument('foo', nargs='?', default=42)
17549
 
@@ -887,12 +917,12 @@
17550
 
 type
17551
 
 ^^^^
17552
 
 
17553
 
-By default, ArgumentParser objects read command-line args in as simple strings.
17554
 
-However, quite often the command-line string should instead be interpreted as
17555
 
-another type, like a :class:`float`, :class:`int` or :class:`file`.  The
17556
 
+By default, :class:`ArgumentParser` objects read command-line arguments in as simple
17557
 
+strings. However, quite often the command-line string should instead be
17558
 
+interpreted as another type, like a :class:`float` or :class:`int`.  The
17559
 
 ``type`` keyword argument of :meth:`~ArgumentParser.add_argument` allows any
17560
 
-necessary type-checking and type-conversions to be performed.  Many common
17561
 
-built-in types can be used directly as the value of the ``type`` argument::
17562
 
+necessary type-checking and type conversions to be performed.  Common built-in
17563
 
+types and functions can be used directly as the value of the ``type`` argument::
17564
 
 
17565
 
    >>> parser = argparse.ArgumentParser()
17566
 
    >>> parser.add_argument('foo', type=int)
17567
 
@@ -911,7 +941,7 @@
17568
 
    Namespace(bar=<open file 'out.txt', mode 'w' at 0x...>)
17569
 
 
17570
 
 ``type=`` can take any callable that takes a single string argument and returns
17571
 
-the type-converted value::
17572
 
+the converted value::
17573
 
 
17574
 
    >>> def perfect_square(string):
17575
 
    ...     value = int(string)
17576
 
@@ -946,11 +976,11 @@
17577
 
 choices
17578
 
 ^^^^^^^
17579
 
 
17580
 
-Some command-line args should be selected from a restricted set of values.
17581
 
+Some command-line arguments should be selected from a restricted set of values.
17582
 
 These can be handled by passing a container object as the ``choices`` keyword
17583
 
 argument to :meth:`~ArgumentParser.add_argument`.  When the command line is
17584
 
-parsed, arg values will be checked, and an error message will be displayed if
17585
 
-the arg was not one of the acceptable values::
17586
 
+parsed, argument values will be checked, and an error message will be displayed if
17587
 
+the argument was not one of the acceptable values::
17588
 
 
17589
 
    >>> parser = argparse.ArgumentParser(prog='PROG')
17590
 
    >>> parser.add_argument('foo', choices='abc')
17591
 
@@ -1043,6 +1073,17 @@
17592
 
    optional arguments:
17593
 
     -h, --help  show this help message and exit
17594
 
 
17595
 
+:mod:`argparse` supports silencing the help entry for certain options, by
17596
 
+setting the ``help`` value to ``argparse.SUPPRESS``::
17597
 
+
17598
 
+   >>> parser = argparse.ArgumentParser(prog='frobble')
17599
 
+   >>> parser.add_argument('--foo', help=argparse.SUPPRESS)
17600
 
+   >>> parser.print_help()
17601
 
+   usage: frobble [-h]
17602
 
+
17603
 
+   optional arguments:
17604
 
+     -h, --help  show this help message and exit
17605
 
+
17606
 
 
17607
 
 metavar
17608
 
 ^^^^^^^
17609
 
@@ -1052,8 +1093,8 @@
17610
 
 value as the "name" of each object.  By default, for positional argument
17611
 
 actions, the dest_ value is used directly, and for optional argument actions,
17612
 
 the dest_ value is uppercased.  So, a single positional argument with
17613
 
-``dest='bar'`` will that argument will be referred to as ``bar``. A single
17614
 
-optional argument ``--foo`` that should be followed by a single command-line arg
17615
 
+``dest='bar'`` will be referred to as ``bar``. A single
17616
 
+optional argument ``--foo`` that should be followed by a single command-line argument
17617
 
 will be referred to as ``FOO``.  An example::
17618
 
 
17619
 
    >>> parser = argparse.ArgumentParser()
17620
 
@@ -1125,10 +1166,10 @@
17621
 
 
17622
 
 For optional argument actions, the value of ``dest`` is normally inferred from
17623
 
 the option strings.  :class:`ArgumentParser` generates the value of ``dest`` by
17624
 
-taking the first long option string and stripping away the initial ``'--'``
17625
 
+taking the first long option string and stripping away the initial ``--``
17626
 
 string.  If no long option strings were supplied, ``dest`` will be derived from
17627
 
-the first short option string by stripping the initial ``'-'`` character.  Any
17628
 
-internal ``'-'`` characters will be converted to ``'_'`` characters to make sure
17629
 
+the first short option string by stripping the initial ``-`` character.  Any
17630
 
+internal ``-`` characters will be converted to ``_`` characters to make sure
17631
 
 the string is a valid attribute name.  The examples below illustrate this
17632
 
 behavior::
17633
 
 
17634
 
@@ -1160,7 +1201,7 @@
17635
 
    created and how they are assigned. See the documentation for
17636
 
    :meth:`add_argument` for details.
17637
 
 
17638
 
-   By default, the arg strings are taken from :data:`sys.argv`, and a new empty
17639
 
+   By default, the argument strings are taken from :data:`sys.argv`, and a new empty
17640
 
    :class:`Namespace` object is created for the attributes.
17641
 
 
17642
 
 
17643
 
@@ -1231,15 +1272,15 @@
17644
 
    PROG: error: extra arguments found: badger
17645
 
 
17646
 
 
17647
 
-Arguments containing ``"-"``
17648
 
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17649
 
+Arguments containing ``-``
17650
 
+^^^^^^^^^^^^^^^^^^^^^^^^^^
17651
 
 
17652
 
 The :meth:`~ArgumentParser.parse_args` method attempts to give errors whenever
17653
 
 the user has clearly made a mistake, but some situations are inherently
17654
 
-ambiguous.  For example, the command-line arg ``'-1'`` could either be an
17655
 
+ambiguous.  For example, the command-line argument ``-1`` could either be an
17656
 
 attempt to specify an option or an attempt to provide a positional argument.
17657
 
 The :meth:`~ArgumentParser.parse_args` method is cautious here: positional
17658
 
-arguments may only begin with ``'-'`` if they look like negative numbers and
17659
 
+arguments may only begin with ``-`` if they look like negative numbers and
17660
 
 there are no options in the parser that look like negative numbers::
17661
 
 
17662
 
    >>> parser = argparse.ArgumentParser(prog='PROG')
17663
 
@@ -1272,7 +1313,7 @@
17664
 
    usage: PROG [-h] [-1 ONE] [foo]
17665
 
    PROG: error: argument -1: expected one argument
17666
 
 
17667
 
-If you have positional arguments that must begin with ``'-'`` and don't look
17668
 
+If you have positional arguments that must begin with ``-`` and don't look
17669
 
 like negative numbers, you can insert the pseudo-argument ``'--'`` which tells
17670
 
 :meth:`~ArgumentParser.parse_args` that everything after that is a positional
17671
 
 argument::
17672
 
@@ -1304,7 +1345,7 @@
17673
 
 Beyond ``sys.argv``
17674
 
 ^^^^^^^^^^^^^^^^^^^
17675
 
 
17676
 
-Sometimes it may be useful to have an ArgumentParser parse args other than those
17677
 
+Sometimes it may be useful to have an ArgumentParser parse arguments other than those
17678
 
 of :data:`sys.argv`.  This can be accomplished by passing a list of strings to
17679
 
 :meth:`~ArgumentParser.parse_args`.  This is useful for testing at the
17680
 
 interactive prompt::
17681
 
@@ -1325,11 +1366,14 @@
17682
 
 The Namespace object
17683
 
 ^^^^^^^^^^^^^^^^^^^^
17684
 
 
17685
 
-By default, :meth:`~ArgumentParser.parse_args` will return a new object of type
17686
 
-:class:`Namespace` where the necessary attributes have been set. This class is
17687
 
-deliberately simple, just an :class:`object` subclass with a readable string
17688
 
-representation. If you prefer to have dict-like view of the attributes, you
17689
 
-can use the standard Python idiom via :func:`vars`::
17690
 
+.. class:: Namespace
17691
 
+
17692
 
+   Simple class used by default by :meth:`~ArgumentParser.parse_args` to create
17693
 
+   an object holding attributes and return it.
17694
 
+
17695
 
+This class is deliberately simple, just an :class:`object` subclass with a
17696
 
+readable string representation. If you prefer to have dict-like view of the
17697
 
+attributes, you can use the standard Python idiom, :func:`vars`::
17698
 
 
17699
 
    >>> parser = argparse.ArgumentParser()
17700
 
    >>> parser.add_argument('--foo')
17701
 
@@ -1387,7 +1431,7 @@
17702
 
      >>> parser_b = subparsers.add_parser('b', help='b help')
17703
 
      >>> parser_b.add_argument('--baz', choices='XYZ', help='baz help')
17704
 
      >>>
17705
 
-     >>> # parse some arg lists
17706
 
+     >>> # parse some argument lists
17707
 
      >>> parser.parse_args(['a', '12'])
17708
 
      Namespace(bar=12, foo=False)
17709
 
      >>> parser.parse_args(['--foo', 'b', '--baz', 'Z'])
17710
 
@@ -1396,8 +1440,8 @@
17711
 
    Note that the object returned by :meth:`parse_args` will only contain
17712
 
    attributes for the main parser and the subparser that was selected by the
17713
 
    command line (and not any other subparsers).  So in the example above, when
17714
 
-   the ``"a"`` command is specified, only the ``foo`` and ``bar`` attributes are
17715
 
-   present, and when the ``"b"`` command is specified, only the ``foo`` and
17716
 
+   the ``a`` command is specified, only the ``foo`` and ``bar`` attributes are
17717
 
+   present, and when the ``b`` command is specified, only the ``foo`` and
17718
 
    ``baz`` attributes are present.
17719
 
 
17720
 
    Similarly, when a help message is requested from a subparser, only the help
17721
 
@@ -1519,7 +1563,7 @@
17722
 
 
17723
 
    The :class:`FileType` factory creates objects that can be passed to the type
17724
 
    argument of :meth:`ArgumentParser.add_argument`.  Arguments that have
17725
 
-   :class:`FileType` objects as their type will open command-line args as files
17726
 
+   :class:`FileType` objects as their type will open command-line arguments as files
17727
 
    with the requested modes and buffer sizes:
17728
 
 
17729
 
    >>> parser = argparse.ArgumentParser()
17730
 
@@ -1633,7 +1677,7 @@
17731
 
 .. method:: ArgumentParser.set_defaults(**kwargs)
17732
 
 
17733
 
    Most of the time, the attributes of the object returned by :meth:`parse_args`
17734
 
-   will be fully determined by inspecting the command-line args and the argument
17735
 
+   will be fully determined by inspecting the command-line arguments and the argument
17736
 
    actions.  :meth:`set_defaults` allows some additional
17737
 
    attributes that are determined without any inspection of the command line to
17738
 
    be added::
17739
 
@@ -1757,7 +1801,7 @@
17740
 
 .. method:: ArgumentParser.error(message)
17741
 
 
17742
 
    This method prints a usage message including the *message* to the
17743
 
-   standard output and terminates the program with a status code of 2.
17744
 
+   standard error and terminates the program with a status code of 2.
17745
 
 
17746
 
 
17747
 
 .. _argparse-from-optparse:
17748
 
diff -r 8527427914a2 Doc/library/array.rst
17749
 
--- a/Doc/library/array.rst
17750
 
+++ b/Doc/library/array.rst
17751
 
@@ -107,7 +107,7 @@
17752
 
    memory buffer in bytes can be computed as ``array.buffer_info()[1] *
17753
 
    array.itemsize``.  This is occasionally useful when working with low-level (and
17754
 
    inherently unsafe) I/O interfaces that require memory addresses, such as certain
17755
 
-   :cfunc:`ioctl` operations.  The returned numbers are valid as long as the array
17756
 
+   :c:func:`ioctl` operations.  The returned numbers are valid as long as the array
17757
 
    exists and no length-changing operations are applied to it.
17758
 
 
17759
 
    .. note::
17760
 
diff -r 8527427914a2 Doc/library/ast.rst
17761
 
--- a/Doc/library/ast.rst
17762
 
+++ b/Doc/library/ast.rst
17763
 
@@ -1,7 +1,5 @@
17764
 
-.. _ast:
17765
 
-
17766
 
-Abstract Syntax Trees
17767
 
-=====================
17768
 
+:mod:`ast` --- Abstract Syntax Trees
17769
 
+====================================
17770
 
 
17771
 
 .. module:: ast
17772
 
    :synopsis: Abstract Syntax Tree classes and manipulation.
17773
 
@@ -15,6 +13,9 @@
17774
 
 .. versionadded:: 2.6
17775
 
    The high-level ``ast`` module containing all helpers.
17776
 
 
17777
 
+**Source code:** :source:`Lib/ast.py`
17778
 
+
17779
 
+--------------
17780
 
 
17781
 
 The :mod:`ast` module helps Python applications to process trees of the Python
17782
 
 abstract syntax grammar.  The abstract syntax itself might change with each
17783
 
@@ -28,11 +29,6 @@
17784
 
 compiled into a Python code object using the built-in :func:`compile` function.
17785
 
 
17786
 
 
17787
 
-.. seealso::
17788
 
-
17789
 
-   Latest version of the `ast module Python source code
17790
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/ast.py?view=markup>`_
17791
 
-
17792
 
 Node classes
17793
 
 ------------
17794
 
 
17795
 
diff -r 8527427914a2 Doc/library/asynchat.rst
17796
 
--- a/Doc/library/asynchat.rst
17797
 
+++ b/Doc/library/asynchat.rst
17798
 
@@ -1,4 +1,3 @@
17799
 
-
17800
 
 :mod:`asynchat` --- Asynchronous socket command/response handler
17801
 
 ================================================================
17802
 
 
17803
 
@@ -7,6 +6,9 @@
17804
 
 .. moduleauthor:: Sam Rushing <rushing@nightmare.com>
17805
 
 .. sectionauthor:: Steve Holden <sholden@holdenweb.com>
17806
 
 
17807
 
+**Source code:** :source:`Lib/asynchat.py`
17808
 
+
17809
 
+--------------
17810
 
 
17811
 
 This module builds on the :mod:`asyncore` infrastructure, simplifying
17812
 
 asynchronous clients and servers and making it easier to handle protocols
17813
 
@@ -32,7 +34,7 @@
17814
 
 
17815
 
    Like :class:`asyncore.dispatcher`, :class:`async_chat` defines a set of
17816
 
    events that are generated by an analysis of socket conditions after a
17817
 
-   :cfunc:`select` call. Once the polling loop has been started the
17818
 
+   :c:func:`select` call. Once the polling loop has been started the
17819
 
    :class:`async_chat` object's methods are called by the event-processing
17820
 
    framework with no action on the part of the programmer.
17821
 
 
17822
 
diff -r 8527427914a2 Doc/library/asyncore.rst
17823
 
--- a/Doc/library/asyncore.rst
17824
 
+++ b/Doc/library/asyncore.rst
17825
 
@@ -1,4 +1,3 @@
17826
 
-
17827
 
 :mod:`asyncore` --- Asynchronous socket handler
17828
 
 ===============================================
17829
 
 
17830
 
@@ -10,6 +9,9 @@
17831
 
 .. sectionauthor:: Steve Holden <sholden@holdenweb.com>
17832
 
 .. heavily adapted from original documentation by Sam Rushing
17833
 
 
17834
 
+**Source code:** :source:`Lib/asyncore.py`
17835
 
+
17836
 
+--------------
17837
 
 
17838
 
 This module provides the basic infrastructure for writing asynchronous  socket
17839
 
 service clients and servers.
17840
 
@@ -23,7 +25,7 @@
17841
 
 are probably what you really need.  Network servers are rarely processor
17842
 
 bound, however.
17843
 
 
17844
 
-If your operating system supports the :cfunc:`select` system call in its I/O
17845
 
+If your operating system supports the :c:func:`select` system call in its I/O
17846
 
 library (and nearly all do), then you can use it to juggle multiple
17847
 
 communication channels at once; doing other work while your I/O is taking
17848
 
 place in the "background."  Although this strategy can seem strange and
17849
 
@@ -93,8 +95,8 @@
17850
 
 
17851
 
    During asynchronous processing, each mapped channel's :meth:`readable` and
17852
 
    :meth:`writable` methods are used to determine whether the channel's socket
17853
 
-   should be added to the list of channels :cfunc:`select`\ ed or
17854
 
-   :cfunc:`poll`\ ed for read and write events.
17855
 
+   should be added to the list of channels :c:func:`select`\ ed or
17856
 
+   :c:func:`poll`\ ed for read and write events.
17857
 
 
17858
 
    Thus, the set of channel events is larger than the basic socket events.  The
17859
 
    full set of methods that can be overridden in your subclass follows:
17860
 
@@ -236,9 +238,9 @@
17861
 
 .. class:: file_dispatcher()
17862
 
 
17863
 
    A file_dispatcher takes a file descriptor or file object along with an
17864
 
-   optional map argument and wraps it for use with the :cfunc:`poll` or
17865
 
-   :cfunc:`loop` functions.  If provided a file object or anything with a
17866
 
-   :cfunc:`fileno` method, that method will be called and passed to the
17867
 
+   optional map argument and wraps it for use with the :c:func:`poll` or
17868
 
+   :c:func:`loop` functions.  If provided a file object or anything with a
17869
 
+   :c:func:`fileno` method, that method will be called and passed to the
17870
 
    :class:`file_wrapper` constructor.  Availability: UNIX.
17871
 
 
17872
 
 .. class:: file_wrapper()
17873
 
diff -r 8527427914a2 Doc/library/atexit.rst
17874
 
--- a/Doc/library/atexit.rst
17875
 
+++ b/Doc/library/atexit.rst
17876
 
@@ -1,4 +1,3 @@
17877
 
-
17878
 
 :mod:`atexit` --- Exit handlers
17879
 
 ===============================
17880
 
 
17881
 
@@ -10,14 +9,15 @@
17882
 
 
17883
 
 .. versionadded:: 2.0
17884
 
 
17885
 
+**Source code:** :source:`Lib/atexit.py`
17886
 
+
17887
 
+--------------
17888
 
+
17889
 
 The :mod:`atexit` module defines a single function to register cleanup
17890
 
 functions.  Functions thus registered are automatically executed upon normal
17891
 
-interpreter termination.
17892
 
-
17893
 
-.. seealso::
17894
 
-
17895
 
-   Latest version of the `atexit Python source code
17896
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/atexit.py?view=markup>`_
17897
 
+interpreter termination.  The order in which the functions are called is not
17898
 
+defined; if you have cleanup operations that depend on each other, you should
17899
 
+wrap them in a function and register that one.  This keeps :mod:`atexit` simple.
17900
 
 
17901
 
 Note: the functions registered via this module are not called when the program
17902
 
 is killed by a signal not handled by Python, when a Python fatal internal error
17903
 
@@ -26,7 +26,7 @@
17904
 
 .. index:: single: exitfunc (in sys)
17905
 
 
17906
 
 This is an alternate interface to the functionality provided by the
17907
 
-``sys.exitfunc`` variable.
17908
 
+:func:`sys.exitfunc` variable.
17909
 
 
17910
 
 Note: This module is unlikely to work correctly when used with other code that
17911
 
 sets ``sys.exitfunc``.  In particular, other core Python modules are free to use
17912
 
@@ -40,7 +40,8 @@
17913
 
 
17914
 
    Register *func* as a function to be executed at termination.  Any optional
17915
 
    arguments that are to be passed to *func* must be passed as arguments to
17916
 
-   :func:`register`.
17917
 
+   :func:`register`.  It is possible to register the same function and arguments
17918
 
+   more than once.
17919
 
 
17920
 
    At normal program termination (for instance, if :func:`sys.exit` is called or
17921
 
    the main module's execution completes), all functions registered are called in
17922
 
@@ -54,8 +55,8 @@
17923
 
    be raised is re-raised.
17924
 
 
17925
 
    .. versionchanged:: 2.6
17926
 
-      This function now returns *func* which makes it possible to use it as a
17927
 
-      decorator without binding the original name to ``None``.
17928
 
+      This function now returns *func*, which makes it possible to use it as a
17929
 
+      decorator.
17930
 
 
17931
 
 
17932
 
 .. seealso::
17933
 
@@ -109,5 +110,4 @@
17934
 
    def goodbye():
17935
 
        print "You are now leaving the Python sector."
17936
 
 
17937
 
-This obviously only works with functions that don't take arguments.
17938
 
-
17939
 
+This only works with functions that can be called without arguments.
17940
 
diff -r 8527427914a2 Doc/library/basehttpserver.rst
17941
 
--- a/Doc/library/basehttpserver.rst
17942
 
+++ b/Doc/library/basehttpserver.rst
17943
 
@@ -18,6 +18,10 @@
17944
 
    module: SimpleHTTPServer
17945
 
    module: CGIHTTPServer
17946
 
 
17947
 
+**Source code:** :source:`Lib/BaseHTTPServer.py`
17948
 
+
17949
 
+--------------
17950
 
+
17951
 
 This module defines two classes for implementing HTTP servers (Web servers).
17952
 
 Usually, this module isn't used directly, but is used as a basis for building
17953
 
 functioning Web servers. See the :mod:`SimpleHTTPServer` and
17954
 
diff -r 8527427914a2 Doc/library/bdb.rst
17955
 
--- a/Doc/library/bdb.rst
17956
 
+++ b/Doc/library/bdb.rst
17957
 
@@ -4,6 +4,10 @@
17958
 
 .. module:: bdb
17959
 
    :synopsis: Debugger framework.
17960
 
 
17961
 
+**Source code:** :source:`Lib/bdb.py`
17962
 
+
17963
 
+--------------
17964
 
+
17965
 
 The :mod:`bdb` module handles basic debugger functions, like setting breakpoints
17966
 
 or managing execution via the debugger.
17967
 
 
17968
 
diff -r 8527427914a2 Doc/library/bisect.rst
17969
 
--- a/Doc/library/bisect.rst
17970
 
+++ b/Doc/library/bisect.rst
17971
 
@@ -7,6 +7,12 @@
17972
 
 .. sectionauthor:: Raymond Hettinger <python at rcn.com>
17973
 
 .. example based on the PyModules FAQ entry by Aaron Watters <arw@pythonpros.com>
17974
 
 
17975
 
+.. versionadded:: 2.1
17976
 
+
17977
 
+**Source code:** :source:`Lib/bisect.py`
17978
 
+
17979
 
+--------------
17980
 
+
17981
 
 This module provides support for maintaining a list in sorted order without
17982
 
 having to sort the list after each insertion.  For long lists of items with
17983
 
 expensive comparison operations, this can be an improvement over the more common
17984
 
@@ -14,13 +20,6 @@
17985
 
 algorithm to do its work.  The source code may be most useful as a working
17986
 
 example of the algorithm (the boundary conditions are already right!).
17987
 
 
17988
 
-.. versionadded:: 2.1
17989
 
-
17990
 
-.. seealso::
17991
 
-
17992
 
-   Latest version of the `bisect module Python source code
17993
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/bisect.py?view=markup>`_
17994
 
-
17995
 
 The following functions are provided:
17996
 
 
17997
 
 
17998
 
diff -r 8527427914a2 Doc/library/bsddb.rst
17999
 
--- a/Doc/library/bsddb.rst
18000
 
+++ b/Doc/library/bsddb.rst
18001
 
@@ -54,7 +54,7 @@
18002
 
    optional *flag* identifies the mode used to open the file.  It may be ``'r'``
18003
 
    (read only), ``'w'`` (read-write) , ``'c'`` (read-write - create if necessary;
18004
 
    the default) or ``'n'`` (read-write - truncate to zero length).  The other
18005
 
-   arguments are rarely used and are just passed to the low-level :cfunc:`dbopen`
18006
 
+   arguments are rarely used and are just passed to the low-level :c:func:`dbopen`
18007
 
    function.  Consult the Berkeley DB documentation for their use and
18008
 
    interpretation.
18009
 
 
18010
 
diff -r 8527427914a2 Doc/library/bz2.rst
18011
 
--- a/Doc/library/bz2.rst
18012
 
+++ b/Doc/library/bz2.rst
18013
 
@@ -67,6 +67,18 @@
18014
 
       Support for the :keyword:`with` statement was added.
18015
 
 
18016
 
 
18017
 
+   .. note::
18018
 
+
18019
 
+      This class does not support input files containing multiple streams (such
18020
 
+      as those produced by the :program:`pbzip2` tool). When reading such an
18021
 
+      input file, only the first stream will be accessible. If you require
18022
 
+      support for multi-stream files, consider using the third-party
18023
 
+      :mod:`bz2file` module (available from
18024
 
+      `PyPI <http://pypi.python.org/pypi/bz2file>`_). This module provides a
18025
 
+      backport of Python 3.3's :class:`BZ2File` class, which does support
18026
 
+      multi-stream files.
18027
 
+
18028
 
+
18029
 
    .. method:: close()
18030
 
 
18031
 
       Close the file. Sets data attribute :attr:`closed` to true. A closed file
18032
 
diff -r 8527427914a2 Doc/library/calendar.rst
18033
 
--- a/Doc/library/calendar.rst
18034
 
+++ b/Doc/library/calendar.rst
18035
 
@@ -1,4 +1,3 @@
18036
 
-
18037
 
 :mod:`calendar` --- General calendar-related functions
18038
 
 ======================================================
18039
 
 
18040
 
@@ -7,6 +6,9 @@
18041
 
               program.
18042
 
 .. sectionauthor:: Drew Csillag <drew_csillag@geocities.com>
18043
 
 
18044
 
+**Source code:** :source:`Lib/calendar.py`
18045
 
+
18046
 
+--------------
18047
 
 
18048
 
 This module allows you to output calendars like the Unix :program:`cal` program,
18049
 
 and provides additional useful functions related to the calendar. By default,
18050
 
@@ -22,10 +24,6 @@
18051
 
 calendar in Dershowitz and Reingold's book "Calendrical Calculations", where
18052
 
 it's the base calendar for all computations.
18053
 
 
18054
 
-.. seealso::
18055
 
-
18056
 
-   Latest version of the `calendar module Python source code
18057
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/calendar.py?view=markup>`_
18058
 
 
18059
 
 .. class:: Calendar([firstweekday])
18060
 
 
18061
 
diff -r 8527427914a2 Doc/library/carbon.rst
18062
 
--- a/Doc/library/carbon.rst
18063
 
+++ b/Doc/library/carbon.rst
18064
 
@@ -14,7 +14,7 @@
18065
 
 in Python (input and output buffers, especially).  All methods and functions
18066
 
 have a :attr:`__doc__` string describing their arguments and return values, and
18067
 
 for additional description you are referred to `Inside Macintosh
18068
 
-<http://developer.apple.com/documentation/macos8/mac8.html>`_ or similar works.
18069
 
+<http://developer.apple.com/legacy/mac/library/#documentation/macos8/mac8.html>`_ or similar works.
18070
 
 
18071
 
 These modules all live in a package called :mod:`Carbon`. Despite that name they
18072
 
 are not all part of the Carbon framework: CF is really in the CoreFoundation
18073
 
@@ -515,7 +515,7 @@
18074
 
 
18075
 
 .. seealso::
18076
 
 
18077
 
-   `Scrap Manager <http://developer.apple.com/documentation/mac/MoreToolbox/MoreToolbox-109.html>`_
18078
 
+   `Scrap Manager <http://developer.apple.com/legacy/mac/library/documentation/mac/MoreToolbox/MoreToolbox-109.html>`_
18079
 
       Apple's documentation for the Scrap Manager gives a lot of useful information
18080
 
       about using the Scrap Manager in applications.
18081
 
 
18082
 
diff -r 8527427914a2 Doc/library/cgi.rst
18083
 
--- a/Doc/library/cgi.rst
18084
 
+++ b/Doc/library/cgi.rst
18085
 
@@ -13,6 +13,10 @@
18086
 
    single: URL
18087
 
    single: Common Gateway Interface
18088
 
 
18089
 
+**Source code:** :source:`Lib/cgi.py`
18090
 
+
18091
 
+--------------
18092
 
+
18093
 
 Support module for Common Gateway Interface (CGI) scripts.
18094
 
 
18095
 
 This module defines a number of utilities for use by CGI scripts written in
18096
 
diff -r 8527427914a2 Doc/library/cmd.rst
18097
 
--- a/Doc/library/cmd.rst
18098
 
+++ b/Doc/library/cmd.rst
18099
 
@@ -1,4 +1,3 @@
18100
 
-
18101
 
 :mod:`cmd` --- Support for line-oriented command interpreters
18102
 
 =============================================================
18103
 
 
18104
 
@@ -6,17 +5,15 @@
18105
 
    :synopsis: Build line-oriented command interpreters.
18106
 
 .. sectionauthor:: Eric S. Raymond <esr@snark.thyrsus.com>
18107
 
 
18108
 
+**Source code:** :source:`Lib/cmd.py`
18109
 
+
18110
 
+--------------
18111
 
 
18112
 
 The :class:`Cmd` class provides a simple framework for writing line-oriented
18113
 
 command interpreters.  These are often useful for test harnesses, administrative
18114
 
 tools, and prototypes that will later be wrapped in a more sophisticated
18115
 
 interface.
18116
 
 
18117
 
-.. seealso::
18118
 
-
18119
 
-   Latest version of the `cmd module Python source code
18120
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/cmd.py?view=markup>`_
18121
 
-
18122
 
 .. class:: Cmd([completekey[, stdin[, stdout]]])
18123
 
 
18124
 
    A :class:`Cmd` instance or subclass instance is a line-oriented interpreter
18125
 
@@ -56,7 +53,7 @@
18126
 
    the line as argument.
18127
 
 
18128
 
    The optional argument is a banner or intro string to be issued before the first
18129
 
-   prompt (this overrides the :attr:`intro` class member).
18130
 
+   prompt (this overrides the :attr:`intro` class attribute).
18131
 
 
18132
 
    If the :mod:`readline` module is loaded, input will automatically inherit
18133
 
    :program:`bash`\ -like history-list editing (e.g. :kbd:`Control-P` scrolls back
18134
 
diff -r 8527427914a2 Doc/library/codecs.rst
18135
 
--- a/Doc/library/codecs.rst
18136
 
+++ b/Doc/library/codecs.rst
18137
 
@@ -759,9 +759,9 @@
18138
 
 ---------------------
18139
 
 
18140
 
 Unicode strings are stored internally as sequences of codepoints (to be precise
18141
 
-as :ctype:`Py_UNICODE` arrays). Depending on the way Python is compiled (either
18142
 
+as :c:type:`Py_UNICODE` arrays). Depending on the way Python is compiled (either
18143
 
 via ``--enable-unicode=ucs2`` or ``--enable-unicode=ucs4``, with the
18144
 
-former being the default) :ctype:`Py_UNICODE` is either a 16-bit or 32-bit data
18145
 
+former being the default) :c:type:`Py_UNICODE` is either a 16-bit or 32-bit data
18146
 
 type. Once a Unicode object is used outside of CPU and memory, CPU endianness
18147
 
 and how these arrays are stored as bytes become an issue.  Transforming a
18148
 
 unicode object into a sequence of bytes is called encoding and recreating the
18149
 
@@ -782,27 +782,28 @@
18150
 
 Windows). There's a string constant with 256 characters that shows you which
18151
 
 character is mapped to which byte value.
18152
 
 
18153
 
-All of these encodings can only encode 256 of the 65536 (or 1114111) codepoints
18154
 
+All of these encodings can only encode 256 of the 1114112 codepoints
18155
 
 defined in unicode. A simple and straightforward way that can store each Unicode
18156
 
-code point, is to store each codepoint as two consecutive bytes. There are two
18157
 
-possibilities: Store the bytes in big endian or in little endian order. These
18158
 
-two encodings are called UTF-16-BE and UTF-16-LE respectively. Their
18159
 
-disadvantage is that if e.g. you use UTF-16-BE on a little endian machine you
18160
 
-will always have to swap bytes on encoding and decoding. UTF-16 avoids this
18161
 
-problem: Bytes will always be in natural endianness. When these bytes are read
18162
 
+code point, is to store each codepoint as four consecutive bytes. There are two
18163
 
+possibilities: store the bytes in big endian or in little endian order. These
18164
 
+two encodings are called ``UTF-32-BE`` and ``UTF-32-LE`` respectively. Their
18165
 
+disadvantage is that if e.g. you use ``UTF-32-BE`` on a little endian machine you
18166
 
+will always have to swap bytes on encoding and decoding. ``UTF-32`` avoids this
18167
 
+problem: bytes will always be in natural endianness. When these bytes are read
18168
 
 by a CPU with a different endianness, then bytes have to be swapped though. To
18169
 
-be able to detect the endianness of a UTF-16 byte sequence, there's the so
18170
 
-called BOM (the "Byte Order Mark"). This is the Unicode character ``U+FEFF``.
18171
 
-This character will be prepended to every UTF-16 byte sequence. The byte swapped
18172
 
-version of this character (``0xFFFE``) is an illegal character that may not
18173
 
-appear in a Unicode text. So when the first character in an UTF-16 byte sequence
18174
 
+be able to detect the endianness of a ``UTF-16`` or ``UTF-32`` byte sequence,
18175
 
+there's the so called BOM ("Byte Order Mark"). This is the Unicode character
18176
 
+``U+FEFF``. This character can be prepended to every ``UTF-16`` or ``UTF-32``
18177
 
+byte sequence. The byte swapped version of this character (``0xFFFE``) is an
18178
 
+illegal character that may not appear in a Unicode text. So when the
18179
 
+first character in an ``UTF-16`` or ``UTF-32`` byte sequence
18180
 
 appears to be a ``U+FFFE`` the bytes have to be swapped on decoding.
18181
 
-Unfortunately upto Unicode 4.0 the character ``U+FEFF`` had a second purpose as
18182
 
-a ``ZERO WIDTH NO-BREAK SPACE``: A character that has no width and doesn't allow
18183
 
+Unfortunately the character ``U+FEFF`` had a second purpose as
18184
 
+a ``ZERO WIDTH NO-BREAK SPACE``: a character that has no width and doesn't allow
18185
 
 a word to be split. It can e.g. be used to give hints to a ligature algorithm.
18186
 
 With Unicode 4.0 using ``U+FEFF`` as a ``ZERO WIDTH NO-BREAK SPACE`` has been
18187
 
 deprecated (with ``U+2060`` (``WORD JOINER``) assuming this role). Nevertheless
18188
 
-Unicode software still must be able to handle ``U+FEFF`` in both roles: As a BOM
18189
 
+Unicode software still must be able to handle ``U+FEFF`` in both roles: as a BOM
18190
 
 it's a device to determine the storage layout of the encoded bytes, and vanishes
18191
 
 once the byte sequence has been decoded into a Unicode string; as a ``ZERO WIDTH
18192
 
 NO-BREAK SPACE`` it's a normal character that will be decoded like any other.
18193
 
@@ -810,8 +811,8 @@
18194
 
 There's another encoding that is able to encoding the full range of Unicode
18195
 
 characters: UTF-8. UTF-8 is an 8-bit encoding, which means there are no issues
18196
 
 with byte order in UTF-8. Each byte in a UTF-8 byte sequence consists of two
18197
 
-parts: Marker bits (the most significant bits) and payload bits. The marker bits
18198
 
-are a sequence of zero to six 1 bits followed by a 0 bit. Unicode characters are
18199
 
+parts: marker bits (the most significant bits) and payload bits. The marker bits
18200
 
+are a sequence of zero to four ``1`` bits followed by a ``0`` bit. Unicode characters are
18201
 
 encoded like this (with x being payload bits, which when concatenated give the
18202
 
 Unicode character):
18203
 
 
18204
 
@@ -824,12 +825,7 @@
18205
 
 +-----------------------------------+----------------------------------------------+
18206
 
 | ``U-00000800`` ... ``U-0000FFFF`` | 1110xxxx 10xxxxxx 10xxxxxx                   |
18207
 
 +-----------------------------------+----------------------------------------------+
18208
 
-| ``U-00010000`` ... ``U-001FFFFF`` | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx          |
18209
 
-+-----------------------------------+----------------------------------------------+
18210
 
-| ``U-00200000`` ... ``U-03FFFFFF`` | 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx |
18211
 
-+-----------------------------------+----------------------------------------------+
18212
 
-| ``U-04000000`` ... ``U-7FFFFFFF`` | 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx |
18213
 
-|                                   | 10xxxxxx                                     |
18214
 
+| ``U-00010000`` ... ``U-0010FFFF`` | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx          |
18215
 
 +-----------------------------------+----------------------------------------------+
18216
 
 
18217
 
 The least significant bit of the Unicode character is the rightmost x bit.
18218
 
@@ -854,13 +850,14 @@
18219
 
    | RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
18220
 
    | INVERTED QUESTION MARK
18221
 
 
18222
 
-in iso-8859-1), this increases the probability that a utf-8-sig encoding can be
18223
 
+in iso-8859-1), this increases the probability that a ``utf-8-sig`` encoding can be
18224
 
 correctly guessed from the byte sequence. So here the BOM is not used to be able
18225
 
 to determine the byte order used for generating the byte sequence, but as a
18226
 
 signature that helps in guessing the encoding. On encoding the utf-8-sig codec
18227
 
 will write ``0xef``, ``0xbb``, ``0xbf`` as the first three bytes to the file. On
18228
 
-decoding utf-8-sig will skip those three bytes if they appear as the first three
18229
 
-bytes in the file.
18230
 
+decoding ``utf-8-sig`` will skip those three bytes if they appear as the first
18231
 
+three bytes in the file.  In UTF-8, the use of the BOM is discouraged and
18232
 
+should generally be avoided.
18233
 
 
18234
 
 
18235
 
 .. _standard-encodings:
18236
 
diff -r 8527427914a2 Doc/library/collections.rst
18237
 
--- a/Doc/library/collections.rst
18238
 
+++ b/Doc/library/collections.rst
18239
 
@@ -1,4 +1,3 @@
18240
 
-
18241
 
 :mod:`collections` --- High-performance container datatypes
18242
 
 ===========================================================
18243
 
 
18244
 
@@ -15,6 +14,10 @@
18245
 
    import itertools
18246
 
    __name__ = '<doctest>'
18247
 
 
18248
 
+**Source code:** :source:`Lib/collections.py` and :source:`Lib/_abcoll.py`
18249
 
+
18250
 
+--------------
18251
 
+
18252
 
 This module implements specialized container datatypes providing alternatives to
18253
 
 Python's general purpose built-in containers, :class:`dict`, :class:`list`,
18254
 
 :class:`set`, and :class:`tuple`.
18255
 
@@ -28,13 +31,10 @@
18256
 
 =====================   ====================================================================  ===========================
18257
 
 
18258
 
 In addition to the concrete container classes, the collections module provides
18259
 
-:ref:`abstract-base-classes` that can be used to test whether a class provides a
18260
 
-particular interface, for example, whether it is hashable or a mapping.
18261
 
+:ref:`abstract base classes <collections-abstract-base-classes>` that can be
18262
 
+used to test whether a class provides a particular interface, for example,
18263
 
+whether it is hashable or a mapping.
18264
 
 
18265
 
-.. seealso::
18266
 
-
18267
 
-   Latest version of the `collections module Python source code
18268
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/collections.py?view=markup>`_
18269
 
 
18270
 
 :class:`Counter` objects
18271
 
 ------------------------
18272
 
@@ -188,7 +188,7 @@
18273
 
    * The multiset methods are designed only for use cases with positive values.
18274
 
      The inputs may be negative or zero, but only outputs with positive values
18275
 
      are created.  There are no type restrictions, but the value type needs to
18276
 
-     support support addition, subtraction, and comparison.
18277
 
+     support addition, subtraction, and comparison.
18278
 
 
18279
 
    * The :meth:`elements` method requires integer counts.  It ignores zero and
18280
 
      negative counts.
18281
 
@@ -202,14 +202,14 @@
18282
 
     * `Bag class <http://www.gnu.org/software/smalltalk/manual-base/html_node/Bag.html>`_
18283
 
       in Smalltalk.
18284
 
 
18285
 
-    * Wikipedia entry for `Multisets <http://en.wikipedia.org/wiki/Multiset>`_\.
18286
 
+    * Wikipedia entry for `Multisets <http://en.wikipedia.org/wiki/Multiset>`_.
18287
 
 
18288
 
     * `C++ multisets <http://www.demo2s.com/Tutorial/Cpp/0380__set-multiset/Catalog0380__set-multiset.htm>`_
18289
 
       tutorial with examples.
18290
 
 
18291
 
     * For mathematical operations on multisets and their use cases, see
18292
 
       *Knuth, Donald. The Art of Computer Programming Volume II,
18293
 
-      Section 4.6.3, Exercise 19*\.
18294
 
+      Section 4.6.3, Exercise 19*.
18295
 
 
18296
 
     * To enumerate all distinct multisets of a given size over a given set of
18297
 
       elements, see :func:`itertools.combinations_with_replacement`.
18298
 
@@ -453,8 +453,7 @@
18299
 
    :class:`defaultdict` objects support the following method in addition to the
18300
 
    standard :class:`dict` operations:
18301
 
 
18302
 
-
18303
 
-   .. method:: defaultdict.__missing__(key)
18304
 
+   .. method:: __missing__(key)
18305
 
 
18306
 
       If the :attr:`default_factory` attribute is ``None``, this raises a
18307
 
       :exc:`KeyError` exception with the *key* as argument.
18308
 
@@ -470,11 +469,16 @@
18309
 
       :class:`dict` class when the requested key is not found; whatever it
18310
 
       returns or raises is then returned or raised by :meth:`__getitem__`.
18311
 
 
18312
 
+      Note that :meth:`__missing__` is *not* called for any operations besides
18313
 
+      :meth:`__getitem__`. This means that :meth:`get` will, like normal
18314
 
+      dictionaries, return ``None`` as a default rather than using
18315
 
+      :attr:`default_factory`.
18316
 
+
18317
 
 
18318
 
    :class:`defaultdict` objects support the following instance variable:
18319
 
 
18320
 
 
18321
 
-   .. attribute:: defaultdict.default_factory
18322
 
+   .. attribute:: default_factory
18323
 
 
18324
 
       This attribute is used by the :meth:`__missing__` method; it is
18325
 
       initialized from the first argument to the constructor, if present, or to
18326
 
@@ -623,7 +627,9 @@
18327
 
                'Return a new OrderedDict which maps field names to their values'
18328
 
                return OrderedDict(zip(self._fields, self))
18329
 
    <BLANKLINE>
18330
 
-           def _replace(_self, **kwds):
18331
 
+          __dict__ = property(_asdict)
18332
 
+   <BLANKLINE>
18333
 
+          def _replace(_self, **kwds):
18334
 
                'Return a new Point object replacing specified fields with new values'
18335
 
                result = _self._make(map(kwds.pop, ('x', 'y'), _self))
18336
 
                if kwds:
18337
 
@@ -849,14 +855,14 @@
18338
 
 original insertion position is changed and moved to the end::
18339
 
 
18340
 
     class LastUpdatedOrderedDict(OrderedDict):
18341
 
+        'Store items in the order the keys were last added'
18342
 
 
18343
 
-        'Store items in the order the keys were last added'
18344
 
         def __setitem__(self, key, value):
18345
 
             if key in self:
18346
 
                 del self[key]
18347
 
             OrderedDict.__setitem__(self, key, value)
18348
 
 
18349
 
-An ordered dictionary can combined with the :class:`Counter` class
18350
 
+An ordered dictionary can be combined with the :class:`Counter` class
18351
 
 so that the counter remembers the order elements are first encountered::
18352
 
 
18353
 
    class OrderedCounter(Counter, OrderedDict):
18354
 
@@ -869,10 +875,10 @@
18355
 
             return self.__class__, (OrderedDict(self),)
18356
 
 
18357
 
 
18358
 
-.. _abstract-base-classes:
18359
 
+.. _collections-abstract-base-classes:
18360
 
 
18361
 
-ABCs - abstract base classes
18362
 
-----------------------------
18363
 
+Collections Abstract Base Classes
18364
 
+---------------------------------
18365
 
 
18366
 
 The collections module offers the following :term:`ABCs <abstract base class>`:
18367
 
 
18368
 
@@ -886,7 +892,7 @@
18369
 
 :class:`Sized`                                    ``__len__``
18370
 
 :class:`Callable`                                 ``__call__``
18371
 
 
18372
 
-:class:`Sequence`          :class:`Sized`,        ``__getitem__``         ``__contains__``. ``__iter__``, ``__reversed__``,
18373
 
+:class:`Sequence`          :class:`Sized`,        ``__getitem__``         ``__contains__``, ``__iter__``, ``__reversed__``,
18374
 
                            :class:`Iterable`,                             ``index``, and ``count``
18375
 
                            :class:`Container`
18376
 
 
18377
 
@@ -1021,9 +1027,6 @@
18378
 
 
18379
 
 .. seealso::
18380
 
 
18381
 
-   * Latest version of the `Python source code for the collections abstract base classes
18382
 
-     <http://svn.python.org/view/python/branches/release27-maint/Lib/_abcoll.py?view=markup>`_
18383
 
-
18384
 
    * `OrderedSet recipe <http://code.activestate.com/recipes/576694/>`_ for an
18385
 
      example built on :class:`MutableSet`.
18386
 
 
18387
 
diff -r 8527427914a2 Doc/library/colorsys.rst
18388
 
--- a/Doc/library/colorsys.rst
18389
 
+++ b/Doc/library/colorsys.rst
18390
 
@@ -5,6 +5,9 @@
18391
 
    :synopsis: Conversion functions between RGB and other color systems.
18392
 
 .. sectionauthor:: David Ascher <da@python.net>
18393
 
 
18394
 
+**Source code:** :source:`Lib/colorsys.py`
18395
 
+
18396
 
+--------------
18397
 
 
18398
 
 The :mod:`colorsys` module defines bidirectional conversions of color values
18399
 
 between colors expressed in the RGB (Red Green Blue) color space used in
18400
 
diff -r 8527427914a2 Doc/library/commands.rst
18401
 
--- a/Doc/library/commands.rst
18402
 
+++ b/Doc/library/commands.rst
18403
 
@@ -38,7 +38,7 @@
18404
 
    ``(status, output)``.  *cmd* is actually run as ``{ cmd ; } 2>&1``, so that the
18405
 
    returned output will contain output or error messages. A trailing newline is
18406
 
    stripped from the output. The exit status for the command can be interpreted
18407
 
-   according to the rules for the C function :cfunc:`wait`.
18408
 
+   according to the rules for the C function :c:func:`wait`.
18409
 
 
18410
 
 
18411
 
 .. function:: getoutput(cmd)
18412
 
diff -r 8527427914a2 Doc/library/constants.rst
18413
 
--- a/Doc/library/constants.rst
18414
 
+++ b/Doc/library/constants.rst
18415
 
@@ -1,3 +1,5 @@
18416
 
+.. _built-in-consts:
18417
 
+
18418
 
 Built-in Constants
18419
 
 ==================
18420
 
 
18421
 
diff -r 8527427914a2 Doc/library/contextlib.rst
18422
 
--- a/Doc/library/contextlib.rst
18423
 
+++ b/Doc/library/contextlib.rst
18424
 
@@ -7,15 +7,14 @@
18425
 
 
18426
 
 .. versionadded:: 2.5
18427
 
 
18428
 
+**Source code:** :source:`Lib/contextlib.py`
18429
 
+
18430
 
+--------------
18431
 
+
18432
 
 This module provides utilities for common tasks involving the :keyword:`with`
18433
 
 statement. For more information see also :ref:`typecontextmanager` and
18434
 
 :ref:`context-managers`.
18435
 
 
18436
 
-.. seealso::
18437
 
-
18438
 
-   Latest version of the `contextlib Python source code
18439
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/contextlib.py?view=markup>`_
18440
 
-
18441
 
 Functions provided:
18442
 
 
18443
 
 
18444
 
diff -r 8527427914a2 Doc/library/cookie.rst
18445
 
--- a/Doc/library/cookie.rst
18446
 
+++ b/Doc/library/cookie.rst
18447
 
@@ -11,6 +11,9 @@
18448
 
    3.0.  The :term:`2to3` tool will automatically adapt imports when converting
18449
 
    your sources to 3.0.
18450
 
 
18451
 
+**Source code:** :source:`Lib/Cookie.py`
18452
 
+
18453
 
+--------------
18454
 
 
18455
 
 The :mod:`Cookie` module defines classes for abstracting the concept of
18456
 
 cookies, an HTTP state management mechanism. It supports both simple string-only
18457
 
@@ -191,7 +194,7 @@
18458
 
 
18459
 
 .. method:: Morsel.set(key, value, coded_value)
18460
 
 
18461
 
-   Set the *key*, *value* and *coded_value* members.
18462
 
+   Set the *key*, *value* and *coded_value* attributes.
18463
 
 
18464
 
 
18465
 
 .. method:: Morsel.isReservedKey(K)
18466
 
diff -r 8527427914a2 Doc/library/cookielib.rst
18467
 
--- a/Doc/library/cookielib.rst
18468
 
+++ b/Doc/library/cookielib.rst
18469
 
@@ -11,10 +11,11 @@
18470
 
    Python 3.0.  The :term:`2to3` tool will automatically adapt imports when
18471
 
    converting your sources to 3.0.
18472
 
 
18473
 
-
18474
 
 .. versionadded:: 2.4
18475
 
 
18476
 
+**Source code:** :source:`Lib/cookielib.py`
18477
 
 
18478
 
+--------------
18479
 
 
18480
 
 The :mod:`cookielib` module defines classes for automatic handling of HTTP
18481
 
 cookies.  It is useful for accessing web sites that require small pieces of data
18482
 
diff -r 8527427914a2 Doc/library/copy.rst
18483
 
--- a/Doc/library/copy.rst
18484
 
+++ b/Doc/library/copy.rst
18485
 
@@ -4,7 +4,11 @@
18486
 
 .. module:: copy
18487
 
    :synopsis: Shallow and deep copy operations.
18488
 
 
18489
 
-This module provides generic (shallow and deep) copying operations.
18490
 
+Assignment statements in Python do not copy objects, they create bindings
18491
 
+between a target and an object. For collections that are mutable or contain
18492
 
+mutable items, a copy is sometimes needed so one can change one copy without
18493
 
+changing the other. This module provides generic shallow and deep copy
18494
 
+operations (explained below).
18495
 
 
18496
 
 
18497
 
 Interface summary:
18498
 
diff -r 8527427914a2 Doc/library/crypto.rst
18499
 
--- a/Doc/library/crypto.rst
18500
 
+++ b/Doc/library/crypto.rst
18501
 
@@ -27,5 +27,5 @@
18502
 
 A.M. Kuchling of further interest; the package contains modules for various
18503
 
 encryption algorithms, most notably AES.  These modules are not distributed with
18504
 
 Python but available separately.  See the URL
18505
 
-http://www.amk.ca/python/code/crypto.html  for more information.
18506
 
+http://www.pycrypto.org  for more information.
18507
 
 
18508
 
diff -r 8527427914a2 Doc/library/ctypes.rst
18509
 
--- a/Doc/library/ctypes.rst
18510
 
+++ b/Doc/library/ctypes.rst
18511
 
@@ -40,7 +40,7 @@
18512
 
 loads libraries which export functions using the standard ``cdecl`` calling
18513
 
 convention, while *windll* libraries call functions using the ``stdcall``
18514
 
 calling convention. *oledll* also uses the ``stdcall`` calling convention, and
18515
 
-assumes the functions return a Windows :ctype:`HRESULT` error code. The error
18516
 
+assumes the functions return a Windows :c:type:`HRESULT` error code. The error
18517
 
 code is used to automatically raise a :class:`WindowsError` exception when the
18518
 
 function call fails.
18519
 
 
18520
 
@@ -201,9 +201,9 @@
18521
 
 ``None``, integers, longs, byte strings and unicode strings are the only native
18522
 
 Python objects that can directly be used as parameters in these function calls.
18523
 
 ``None`` is passed as a C ``NULL`` pointer, byte strings and unicode strings are
18524
 
-passed as pointer to the memory block that contains their data (:ctype:`char *`
18525
 
-or :ctype:`wchar_t *`).  Python integers and Python longs are passed as the
18526
 
-platforms default C :ctype:`int` type, their value is masked to fit into the C
18527
 
+passed as pointer to the memory block that contains their data (:c:type:`char *`
18528
 
+or :c:type:`wchar_t *`).  Python integers and Python longs are passed as the
18529
 
+platforms default C :c:type:`int` type, their value is masked to fit into the C
18530
 
 type.
18531
 
 
18532
 
 Before we move on calling functions with other parameter types, we have to learn
18533
 
@@ -217,48 +217,48 @@
18534
 
 
18535
 
 :mod:`ctypes` defines a number of primitive C compatible data types :
18536
 
 
18537
 
-+----------------------+----------------------------------------+----------------------------+
18538
 
-| ctypes type          | C type                                 | Python type                |
18539
 
-+======================+========================================+============================+
18540
 
-| :class:`c_bool`      | :ctype:`_Bool`                         | bool (1)                   |
18541
 
-+----------------------+----------------------------------------+----------------------------+
18542
 
-| :class:`c_char`      | :ctype:`char`                          | 1-character string         |
18543
 
-+----------------------+----------------------------------------+----------------------------+
18544
 
-| :class:`c_wchar`     | :ctype:`wchar_t`                       | 1-character unicode string |
18545
 
-+----------------------+----------------------------------------+----------------------------+
18546
 
-| :class:`c_byte`      | :ctype:`char`                          | int/long                   |
18547
 
-+----------------------+----------------------------------------+----------------------------+
18548
 
-| :class:`c_ubyte`     | :ctype:`unsigned char`                 | int/long                   |
18549
 
-+----------------------+----------------------------------------+----------------------------+
18550
 
-| :class:`c_short`     | :ctype:`short`                         | int/long                   |
18551
 
-+----------------------+----------------------------------------+----------------------------+
18552
 
-| :class:`c_ushort`    | :ctype:`unsigned short`                | int/long                   |
18553
 
-+----------------------+----------------------------------------+----------------------------+
18554
 
-| :class:`c_int`       | :ctype:`int`                           | int/long                   |
18555
 
-+----------------------+----------------------------------------+----------------------------+
18556
 
-| :class:`c_uint`      | :ctype:`unsigned int`                  | int/long                   |
18557
 
-+----------------------+----------------------------------------+----------------------------+
18558
 
-| :class:`c_long`      | :ctype:`long`                          | int/long                   |
18559
 
-+----------------------+----------------------------------------+----------------------------+
18560
 
-| :class:`c_ulong`     | :ctype:`unsigned long`                 | int/long                   |
18561
 
-+----------------------+----------------------------------------+----------------------------+
18562
 
-| :class:`c_longlong`  | :ctype:`__int64` or :ctype:`long long` | int/long                   |
18563
 
-+----------------------+----------------------------------------+----------------------------+
18564
 
-| :class:`c_ulonglong` | :ctype:`unsigned __int64` or           | int/long                   |
18565
 
-|                      | :ctype:`unsigned long long`            |                            |
18566
 
-+----------------------+----------------------------------------+----------------------------+
18567
 
-| :class:`c_float`     | :ctype:`float`                         | float                      |
18568
 
-+----------------------+----------------------------------------+----------------------------+
18569
 
-| :class:`c_double`    | :ctype:`double`                        | float                      |
18570
 
-+----------------------+----------------------------------------+----------------------------+
18571
 
-| :class:`c_longdouble`| :ctype:`long double`                   | float                      |
18572
 
-+----------------------+----------------------------------------+----------------------------+
18573
 
-| :class:`c_char_p`    | :ctype:`char *` (NUL terminated)       | string or ``None``         |
18574
 
-+----------------------+----------------------------------------+----------------------------+
18575
 
-| :class:`c_wchar_p`   | :ctype:`wchar_t *` (NUL terminated)    | unicode or ``None``        |
18576
 
-+----------------------+----------------------------------------+----------------------------+
18577
 
-| :class:`c_void_p`    | :ctype:`void *`                        | int/long or ``None``       |
18578
 
-+----------------------+----------------------------------------+----------------------------+
18579
 
++----------------------+------------------------------------------+----------------------------+
18580
 
+| ctypes type          | C type                                   | Python type                |
18581
 
++======================+==========================================+============================+
18582
 
+| :class:`c_bool`      | :c:type:`_Bool`                          | bool (1)                   |
18583
 
++----------------------+------------------------------------------+----------------------------+
18584
 
+| :class:`c_char`      | :c:type:`char`                           | 1-character string         |
18585
 
++----------------------+------------------------------------------+----------------------------+
18586
 
+| :class:`c_wchar`     | :c:type:`wchar_t`                        | 1-character unicode string |
18587
 
++----------------------+------------------------------------------+----------------------------+
18588
 
+| :class:`c_byte`      | :c:type:`char`                           | int/long                   |
18589
 
++----------------------+------------------------------------------+----------------------------+
18590
 
+| :class:`c_ubyte`     | :c:type:`unsigned char`                  | int/long                   |
18591
 
++----------------------+------------------------------------------+----------------------------+
18592
 
+| :class:`c_short`     | :c:type:`short`                          | int/long                   |
18593
 
++----------------------+------------------------------------------+----------------------------+
18594
 
+| :class:`c_ushort`    | :c:type:`unsigned short`                 | int/long                   |
18595
 
++----------------------+------------------------------------------+----------------------------+
18596
 
+| :class:`c_int`       | :c:type:`int`                            | int/long                   |
18597
 
++----------------------+------------------------------------------+----------------------------+
18598
 
+| :class:`c_uint`      | :c:type:`unsigned int`                   | int/long                   |
18599
 
++----------------------+------------------------------------------+----------------------------+
18600
 
+| :class:`c_long`      | :c:type:`long`                           | int/long                   |
18601
 
++----------------------+------------------------------------------+----------------------------+
18602
 
+| :class:`c_ulong`     | :c:type:`unsigned long`                  | int/long                   |
18603
 
++----------------------+------------------------------------------+----------------------------+
18604
 
+| :class:`c_longlong`  | :c:type:`__int64` or :c:type:`long long` | int/long                   |
18605
 
++----------------------+------------------------------------------+----------------------------+
18606
 
+| :class:`c_ulonglong` | :c:type:`unsigned __int64` or            | int/long                   |
18607
 
+|                      | :c:type:`unsigned long long`             |                            |
18608
 
++----------------------+------------------------------------------+----------------------------+
18609
 
+| :class:`c_float`     | :c:type:`float`                          | float                      |
18610
 
++----------------------+------------------------------------------+----------------------------+
18611
 
+| :class:`c_double`    | :c:type:`double`                         | float                      |
18612
 
++----------------------+------------------------------------------+----------------------------+
18613
 
+| :class:`c_longdouble`| :c:type:`long double`                    | float                      |
18614
 
++----------------------+------------------------------------------+----------------------------+
18615
 
+| :class:`c_char_p`    | :c:type:`char *` (NUL terminated)        | string or ``None``         |
18616
 
++----------------------+------------------------------------------+----------------------------+
18617
 
+| :class:`c_wchar_p`   | :c:type:`wchar_t *` (NUL terminated)     | unicode or ``None``        |
18618
 
++----------------------+------------------------------------------+----------------------------+
18619
 
+| :class:`c_void_p`    | :c:type:`void *`                         | int/long or ``None``       |
18620
 
++----------------------+------------------------------------------+----------------------------+
18621
 
 
18622
 
 (1)
18623
 
    The constructor accepts any object with a truth value.
18624
 
@@ -329,7 +329,7 @@
18625
 
 The :func:`create_string_buffer` function replaces the :func:`c_buffer` function
18626
 
 (which is still available as an alias), as well as the :func:`c_string` function
18627
 
 from earlier ctypes releases.  To create a mutable memory block containing
18628
 
-unicode characters of the C type :ctype:`wchar_t` use the
18629
 
+unicode characters of the C type :c:type:`wchar_t` use the
18630
 
 :func:`create_unicode_buffer` function.
18631
 
 
18632
 
 
18633
 
@@ -440,7 +440,7 @@
18634
 
 Return types
18635
 
 ^^^^^^^^^^^^
18636
 
 
18637
 
-By default functions are assumed to return the C :ctype:`int` type.  Other
18638
 
+By default functions are assumed to return the C :c:type:`int` type.  Other
18639
 
 return types can be specified by setting the :attr:`restype` attribute of the
18640
 
 function object.
18641
 
 
18642
 
@@ -869,10 +869,10 @@
18643
 
 
18644
 
    struct cell; /* forward declaration */
18645
 
 
18646
 
-   struct {
18647
 
+   struct cell {
18648
 
        char *name;
18649
 
        struct cell *next;
18650
 
-   } cell;
18651
 
+   };
18652
 
 
18653
 
 The straightforward translation into ctypes code would be this, but it does not
18654
 
 work::
18655
 
@@ -1338,7 +1338,7 @@
18656
 
 
18657
 
    Instances of this class represent loaded shared libraries. Functions in these
18658
 
    libraries use the standard C calling convention, and are assumed to return
18659
 
-   :ctype:`int`.
18660
 
+   :c:type:`int`.
18661
 
 
18662
 
 
18663
 
 .. class:: OleDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, use_last_error=False)
18664
 
@@ -1355,7 +1355,7 @@
18665
 
 
18666
 
    Windows only: Instances of this class represent loaded shared libraries,
18667
 
    functions in these libraries use the ``stdcall`` calling convention, and are
18668
 
-   assumed to return :ctype:`int` by default.
18669
 
+   assumed to return :c:type:`int` by default.
18670
 
 
18671
 
    On Windows CE only the standard calling convention is used, for convenience the
18672
 
    :class:`WinDLL` and :class:`OleDLL` use the standard calling convention on this
18673
 
@@ -1500,7 +1500,7 @@
18674
 
 
18675
 
    An instance of :class:`PyDLL` that exposes Python C API functions as
18676
 
    attributes.  Note that all these functions are assumed to return C
18677
 
-   :ctype:`int`, which is of course not always the truth, so you have to assign
18678
 
+   :c:type:`int`, which is of course not always the truth, so you have to assign
18679
 
    the correct :attr:`restype` attribute to use these functions.
18680
 
 
18681
 
 
18682
 
@@ -1530,10 +1530,10 @@
18683
 
    .. attribute:: restype
18684
 
 
18685
 
       Assign a ctypes type to specify the result type of the foreign function.
18686
 
-      Use ``None`` for :ctype:`void`, a function not returning anything.
18687
 
+      Use ``None`` for :c:type:`void`, a function not returning anything.
18688
 
 
18689
 
       It is possible to assign a callable Python object that is not a ctypes
18690
 
-      type, in this case the function is assumed to return a C :ctype:`int`, and
18691
 
+      type, in this case the function is assumed to return a C :c:type:`int`, and
18692
 
       the callable will be called with this integer, allowing to do further
18693
 
       processing or error checking.  Using this is deprecated, for more flexible
18694
 
       post processing or error checking use a ctypes data type as
18695
 
@@ -2000,7 +2000,7 @@
18696
 
 
18697
 
 .. function:: string_at(address[, size])
18698
 
 
18699
 
-   This function returns the string starting at memory address address. If size
18700
 
+   This function returns the string starting at memory address *address*. If size
18701
 
    is specified, it is used as size, otherwise the string is assumed to be
18702
 
    zero-terminated.
18703
 
 
18704
 
@@ -2159,21 +2159,21 @@
18705
 
 
18706
 
 .. class:: c_byte
18707
 
 
18708
 
-   Represents the C :ctype:`signed char` datatype, and interprets the value as
18709
 
+   Represents the C :c:type:`signed char` datatype, and interprets the value as
18710
 
    small integer.  The constructor accepts an optional integer initializer; no
18711
 
    overflow checking is done.
18712
 
 
18713
 
 
18714
 
 .. class:: c_char
18715
 
 
18716
 
-   Represents the C :ctype:`char` datatype, and interprets the value as a single
18717
 
+   Represents the C :c:type:`char` datatype, and interprets the value as a single
18718
 
    character.  The constructor accepts an optional string initializer, the
18719
 
    length of the string must be exactly one character.
18720
 
 
18721
 
 
18722
 
 .. class:: c_char_p
18723
 
 
18724
 
-   Represents the C :ctype:`char *` datatype when it points to a zero-terminated
18725
 
+   Represents the C :c:type:`char *` datatype when it points to a zero-terminated
18726
 
    string.  For a general character pointer that may also point to binary data,
18727
 
    ``POINTER(c_char)`` must be used.  The constructor accepts an integer
18728
 
    address, or a string.
18729
 
@@ -2181,13 +2181,13 @@
18730
 
 
18731
 
 .. class:: c_double
18732
 
 
18733
 
-   Represents the C :ctype:`double` datatype.  The constructor accepts an
18734
 
+   Represents the C :c:type:`double` datatype.  The constructor accepts an
18735
 
    optional float initializer.
18736
 
 
18737
 
 
18738
 
 .. class:: c_longdouble
18739
 
 
18740
 
-   Represents the C :ctype:`long double` datatype.  The constructor accepts an
18741
 
+   Represents the C :c:type:`long double` datatype.  The constructor accepts an
18742
 
    optional float initializer.  On platforms where ``sizeof(long double) ==
18743
 
    sizeof(double)`` it is an alias to :class:`c_double`.
18744
 
 
18745
 
@@ -2195,150 +2195,150 @@
18746
 
 
18747
 
 .. class:: c_float
18748
 
 
18749
 
-   Represents the C :ctype:`float` datatype.  The constructor accepts an
18750
 
+   Represents the C :c:type:`float` datatype.  The constructor accepts an
18751
 
    optional float initializer.
18752
 
 
18753
 
 
18754
 
 .. class:: c_int
18755
 
 
18756
 
-   Represents the C :ctype:`signed int` datatype.  The constructor accepts an
18757
 
+   Represents the C :c:type:`signed int` datatype.  The constructor accepts an
18758
 
    optional integer initializer; no overflow checking is done.  On platforms
18759
 
    where ``sizeof(int) == sizeof(long)`` it is an alias to :class:`c_long`.
18760
 
 
18761
 
 
18762
 
 .. class:: c_int8
18763
 
 
18764
 
-   Represents the C 8-bit :ctype:`signed int` datatype.  Usually an alias for
18765
 
+   Represents the C 8-bit :c:type:`signed int` datatype.  Usually an alias for
18766
 
    :class:`c_byte`.
18767
 
 
18768
 
 
18769
 
 .. class:: c_int16
18770
 
 
18771
 
-   Represents the C 16-bit :ctype:`signed int` datatype.  Usually an alias for
18772
 
+   Represents the C 16-bit :c:type:`signed int` datatype.  Usually an alias for
18773
 
    :class:`c_short`.
18774
 
 
18775
 
 
18776
 
 .. class:: c_int32
18777
 
 
18778
 
-   Represents the C 32-bit :ctype:`signed int` datatype.  Usually an alias for
18779
 
+   Represents the C 32-bit :c:type:`signed int` datatype.  Usually an alias for
18780
 
    :class:`c_int`.
18781
 
 
18782
 
 
18783
 
 .. class:: c_int64
18784
 
 
18785
 
-   Represents the C 64-bit :ctype:`signed int` datatype.  Usually an alias for
18786
 
+   Represents the C 64-bit :c:type:`signed int` datatype.  Usually an alias for
18787
 
    :class:`c_longlong`.
18788
 
 
18789
 
 
18790
 
 .. class:: c_long
18791
 
 
18792
 
-   Represents the C :ctype:`signed long` datatype.  The constructor accepts an
18793
 
+   Represents the C :c:type:`signed long` datatype.  The constructor accepts an
18794
 
    optional integer initializer; no overflow checking is done.
18795
 
 
18796
 
 
18797
 
 .. class:: c_longlong
18798
 
 
18799
 
-   Represents the C :ctype:`signed long long` datatype.  The constructor accepts
18800
 
+   Represents the C :c:type:`signed long long` datatype.  The constructor accepts
18801
 
    an optional integer initializer; no overflow checking is done.
18802
 
 
18803
 
 
18804
 
 .. class:: c_short
18805
 
 
18806
 
-   Represents the C :ctype:`signed short` datatype.  The constructor accepts an
18807
 
+   Represents the C :c:type:`signed short` datatype.  The constructor accepts an
18808
 
    optional integer initializer; no overflow checking is done.
18809
 
 
18810
 
 
18811
 
 .. class:: c_size_t
18812
 
 
18813
 
-   Represents the C :ctype:`size_t` datatype.
18814
 
+   Represents the C :c:type:`size_t` datatype.
18815
 
 
18816
 
 
18817
 
 .. class:: c_ssize_t
18818
 
 
18819
 
-   Represents the C :ctype:`ssize_t` datatype.
18820
 
+   Represents the C :c:type:`ssize_t` datatype.
18821
 
 
18822
 
    .. versionadded:: 2.7
18823
 
 
18824
 
 
18825
 
 .. class:: c_ubyte
18826
 
 
18827
 
-   Represents the C :ctype:`unsigned char` datatype, it interprets the value as
18828
 
+   Represents the C :c:type:`unsigned char` datatype, it interprets the value as
18829
 
    small integer.  The constructor accepts an optional integer initializer; no
18830
 
    overflow checking is done.
18831
 
 
18832
 
 
18833
 
 .. class:: c_uint
18834
 
 
18835
 
-   Represents the C :ctype:`unsigned int` datatype.  The constructor accepts an
18836
 
+   Represents the C :c:type:`unsigned int` datatype.  The constructor accepts an
18837
 
    optional integer initializer; no overflow checking is done.  On platforms
18838
 
    where ``sizeof(int) == sizeof(long)`` it is an alias for :class:`c_ulong`.
18839
 
 
18840
 
 
18841
 
 .. class:: c_uint8
18842
 
 
18843
 
-   Represents the C 8-bit :ctype:`unsigned int` datatype.  Usually an alias for
18844
 
+   Represents the C 8-bit :c:type:`unsigned int` datatype.  Usually an alias for
18845
 
    :class:`c_ubyte`.
18846
 
 
18847
 
 
18848
 
 .. class:: c_uint16
18849
 
 
18850
 
-   Represents the C 16-bit :ctype:`unsigned int` datatype.  Usually an alias for
18851
 
+   Represents the C 16-bit :c:type:`unsigned int` datatype.  Usually an alias for
18852
 
    :class:`c_ushort`.
18853
 
 
18854
 
 
18855
 
 .. class:: c_uint32
18856
 
 
18857
 
-   Represents the C 32-bit :ctype:`unsigned int` datatype.  Usually an alias for
18858
 
+   Represents the C 32-bit :c:type:`unsigned int` datatype.  Usually an alias for
18859
 
    :class:`c_uint`.
18860
 
 
18861
 
 
18862
 
 .. class:: c_uint64
18863
 
 
18864
 
-   Represents the C 64-bit :ctype:`unsigned int` datatype.  Usually an alias for
18865
 
+   Represents the C 64-bit :c:type:`unsigned int` datatype.  Usually an alias for
18866
 
    :class:`c_ulonglong`.
18867
 
 
18868
 
 
18869
 
 .. class:: c_ulong
18870
 
 
18871
 
-   Represents the C :ctype:`unsigned long` datatype.  The constructor accepts an
18872
 
+   Represents the C :c:type:`unsigned long` datatype.  The constructor accepts an
18873
 
    optional integer initializer; no overflow checking is done.
18874
 
 
18875
 
 
18876
 
 .. class:: c_ulonglong
18877
 
 
18878
 
-   Represents the C :ctype:`unsigned long long` datatype.  The constructor
18879
 
+   Represents the C :c:type:`unsigned long long` datatype.  The constructor
18880
 
    accepts an optional integer initializer; no overflow checking is done.
18881
 
 
18882
 
 
18883
 
 .. class:: c_ushort
18884
 
 
18885
 
-   Represents the C :ctype:`unsigned short` datatype.  The constructor accepts
18886
 
+   Represents the C :c:type:`unsigned short` datatype.  The constructor accepts
18887
 
    an optional integer initializer; no overflow checking is done.
18888
 
 
18889
 
 
18890
 
 .. class:: c_void_p
18891
 
 
18892
 
-   Represents the C :ctype:`void *` type.  The value is represented as integer.
18893
 
+   Represents the C :c:type:`void *` type.  The value is represented as integer.
18894
 
    The constructor accepts an optional integer initializer.
18895
 
 
18896
 
 
18897
 
 .. class:: c_wchar
18898
 
 
18899
 
-   Represents the C :ctype:`wchar_t` datatype, and interprets the value as a
18900
 
+   Represents the C :c:type:`wchar_t` datatype, and interprets the value as a
18901
 
    single character unicode string.  The constructor accepts an optional string
18902
 
    initializer, the length of the string must be exactly one character.
18903
 
 
18904
 
 
18905
 
 .. class:: c_wchar_p
18906
 
 
18907
 
-   Represents the C :ctype:`wchar_t *` datatype, which must be a pointer to a
18908
 
+   Represents the C :c:type:`wchar_t *` datatype, which must be a pointer to a
18909
 
    zero-terminated wide character string.  The constructor accepts an integer
18910
 
    address, or a string.
18911
 
 
18912
 
 
18913
 
 .. class:: c_bool
18914
 
 
18915
 
-   Represent the C :ctype:`bool` datatype (more accurately, :ctype:`_Bool` from
18916
 
+   Represent the C :c:type:`bool` datatype (more accurately, :c:type:`_Bool` from
18917
 
    C99).  Its value can be True or False, and the constructor accepts any object
18918
 
    that has a truth value.
18919
 
 
18920
 
@@ -2347,18 +2347,18 @@
18921
 
 
18922
 
 .. class:: HRESULT
18923
 
 
18924
 
-   Windows only: Represents a :ctype:`HRESULT` value, which contains success or
18925
 
+   Windows only: Represents a :c:type:`HRESULT` value, which contains success or
18926
 
    error information for a function or method call.
18927
 
 
18928
 
 
18929
 
 .. class:: py_object
18930
 
 
18931
 
-   Represents the C :ctype:`PyObject *` datatype.  Calling this without an
18932
 
-   argument creates a ``NULL`` :ctype:`PyObject *` pointer.
18933
 
+   Represents the C :c:type:`PyObject *` datatype.  Calling this without an
18934
 
+   argument creates a ``NULL`` :c:type:`PyObject *` pointer.
18935
 
 
18936
 
 The :mod:`ctypes.wintypes` module provides quite some other Windows specific
18937
 
-data types, for example :ctype:`HWND`, :ctype:`WPARAM`, or :ctype:`DWORD`.  Some
18938
 
-useful structures like :ctype:`MSG` or :ctype:`RECT` are also defined.
18939
 
+data types, for example :c:type:`HWND`, :c:type:`WPARAM`, or :c:type:`DWORD`.  Some
18940
 
+useful structures like :c:type:`MSG` or :c:type:`RECT` are also defined.
18941
 
 
18942
 
 
18943
 
 .. _ctypes-structured-data-types:
18944
 
diff -r 8527427914a2 Doc/library/curses.rst
18945
 
--- a/Doc/library/curses.rst
18946
 
+++ b/Doc/library/curses.rst
18947
 
@@ -44,10 +44,6 @@
18948
 
    Module :mod:`curses.textpad`
18949
 
       Editable text widget for curses supporting  :program:`Emacs`\ -like bindings.
18950
 
 
18951
 
-   Module :mod:`curses.wrapper`
18952
 
-      Convenience function to ensure proper terminal setup and resetting on
18953
 
-      application entry and exit.
18954
 
-
18955
 
    :ref:`curses-howto`
18956
 
       Tutorial material on using curses with Python, by Andrew Kuchling and Eric
18957
 
       Raymond.
18958
 
@@ -79,7 +75,7 @@
18959
 
 
18960
 
 .. function:: baudrate()
18961
 
 
18962
 
-   Returns the output speed of the terminal in bits per second.  On software
18963
 
+   Return the output speed of the terminal in bits per second.  On software
18964
 
    terminal emulators it will have a fixed high value. Included for historical
18965
 
    reasons; in former times, it was used to  write output loops for time delays and
18966
 
    occasionally to change interfaces depending on the line speed.
18967
 
@@ -92,7 +88,7 @@
18968
 
 
18969
 
 .. function:: can_change_color()
18970
 
 
18971
 
-   Returns true or false, depending on whether the programmer can change the colors
18972
 
+   Return ``True`` or ``False``, depending on whether the programmer can change the colors
18973
 
    displayed by the terminal.
18974
 
 
18975
 
 
18976
 
@@ -107,7 +103,7 @@
18977
 
 
18978
 
 .. function:: color_content(color_number)
18979
 
 
18980
 
-   Returns the intensity of the red, green, and blue (RGB) components in the color
18981
 
+   Return the intensity of the red, green, and blue (RGB) components in the color
18982
 
    *color_number*, which must be between ``0`` and :const:`COLORS`.  A 3-tuple is
18983
 
    returned, containing the R,G,B values for the given color, which will be between
18984
 
    ``0`` (no component) and ``1000`` (maximum amount of component).
18985
 
@@ -115,7 +111,7 @@
18986
 
 
18987
 
 .. function:: color_pair(color_number)
18988
 
 
18989
 
-   Returns the attribute value for displaying text in the specified color.  This
18990
 
+   Return the attribute value for displaying text in the specified color.  This
18991
 
    attribute value can be combined with :const:`A_STANDOUT`, :const:`A_REVERSE`,
18992
 
    and the other :const:`A_\*` attributes.  :func:`pair_number` is the counterpart
18993
 
    to this function.
18994
 
@@ -123,7 +119,7 @@
18995
 
 
18996
 
 .. function:: curs_set(visibility)
18997
 
 
18998
 
-   Sets the cursor state.  *visibility* can be set to 0, 1, or 2, for invisible,
18999
 
+   Set the cursor state.  *visibility* can be set to 0, 1, or 2, for invisible,
19000
 
    normal, or very visible.  If the terminal supports the visibility requested, the
19001
 
    previous cursor state is returned; otherwise, an exception is raised.  On many
19002
 
    terminals, the "visible" mode is an underline cursor and the "very visible" mode
19003
 
@@ -132,7 +128,7 @@
19004
 
 
19005
 
 .. function:: def_prog_mode()
19006
 
 
19007
 
-   Saves the current terminal mode as the "program" mode, the mode when the running
19008
 
+   Save the current terminal mode as the "program" mode, the mode when the running
19009
 
    program is using curses.  (Its counterpart is the "shell" mode, for when the
19010
 
    program is not in curses.)  Subsequent calls to :func:`reset_prog_mode` will
19011
 
    restore this mode.
19012
 
@@ -140,7 +136,7 @@
19013
 
 
19014
 
 .. function:: def_shell_mode()
19015
 
 
19016
 
-   Saves the current terminal mode as the "shell" mode, the mode when the running
19017
 
+   Save the current terminal mode as the "shell" mode, the mode when the running
19018
 
    program is not using curses.  (Its counterpart is the "program" mode, when the
19019
 
    program is using curses capabilities.) Subsequent calls to
19020
 
    :func:`reset_shell_mode` will restore this mode.
19021
 
@@ -148,7 +144,7 @@
19022
 
 
19023
 
 .. function:: delay_output(ms)
19024
 
 
19025
 
-   Inserts an *ms* millisecond pause in output.
19026
 
+   Insert an *ms* millisecond pause in output.
19027
 
 
19028
 
 
19029
 
 .. function:: doupdate()
19030
 
@@ -179,7 +175,7 @@
19031
 
 
19032
 
 .. function:: erasechar()
19033
 
 
19034
 
-   Returns the user's current erase character.  Under Unix operating systems this
19035
 
+   Return the user's current erase character.  Under Unix operating systems this
19036
 
    is a property of the controlling tty of the curses program, and is not set by
19037
 
    the curses library itself.
19038
 
 
19039
 
@@ -187,7 +183,7 @@
19040
 
 .. function:: filter()
19041
 
 
19042
 
    The :func:`.filter` routine, if used, must be called before :func:`initscr` is
19043
 
-   called.  The effect is that, during those calls, LINES is set to 1; the
19044
 
+   called.  The effect is that, during those calls, :envvar:`LINES` is set to 1; the
19045
 
    capabilities clear, cup, cud, cud1, cuu1, cuu, vpa are disabled; and the home
19046
 
    string is set to the value of cr. The effect is that the cursor is confined to
19047
 
    the current line, and so are screen updates.  This may be used for enabling
19048
 
@@ -213,7 +209,7 @@
19049
 
    method should be call to retrieve the queued mouse event, represented as a
19050
 
    5-tuple ``(id, x, y, z, bstate)``. *id* is an ID value used to distinguish
19051
 
    multiple devices, and *x*, *y*, *z* are the event's coordinates.  (*z* is
19052
 
-   currently unused.).  *bstate* is an integer value whose bits will be set to
19053
 
+   currently unused.)  *bstate* is an integer value whose bits will be set to
19054
 
    indicate the type of event, and will be the bitwise OR of one or more of the
19055
 
    following constants, where *n* is the button number from 1 to 4:
19056
 
    :const:`BUTTONn_PRESSED`, :const:`BUTTONn_RELEASED`, :const:`BUTTONn_CLICKED`,
19057
 
@@ -223,32 +219,32 @@
19058
 
 
19059
 
 .. function:: getsyx()
19060
 
 
19061
 
-   Returns the current coordinates of the virtual screen cursor in y and x.  If
19062
 
+   Return the current coordinates of the virtual screen cursor in y and x.  If
19063
 
    leaveok is currently true, then -1,-1 is returned.
19064
 
 
19065
 
 
19066
 
 .. function:: getwin(file)
19067
 
 
19068
 
-   Reads window related data stored in the file by an earlier :func:`putwin` call.
19069
 
+   Read window related data stored in the file by an earlier :func:`putwin` call.
19070
 
    The routine then creates and initializes a new window using that data, returning
19071
 
    the new window object.
19072
 
 
19073
 
 
19074
 
 .. function:: has_colors()
19075
 
 
19076
 
-   Returns true if the terminal can display colors; otherwise, it returns false.
19077
 
+   Return ``True`` if the terminal can display colors; otherwise, return ``False``.
19078
 
 
19079
 
 
19080
 
 .. function:: has_ic()
19081
 
 
19082
 
-   Returns true if the terminal has insert- and delete- character capabilities.
19083
 
+   Return ``True`` if the terminal has insert- and delete-character capabilities.
19084
 
    This function is included for historical reasons only, as all modern software
19085
 
    terminal emulators have such capabilities.
19086
 
 
19087
 
 
19088
 
 .. function:: has_il()
19089
 
 
19090
 
-   Returns true if the terminal has insert- and delete-line  capabilities,  or  can
19091
 
+   Return ``True`` if the terminal has insert- and delete-line capabilities, or can
19092
 
    simulate  them  using scrolling regions. This function is included for
19093
 
    historical reasons only, as all modern software terminal emulators have such
19094
 
    capabilities.
19095
 
@@ -256,7 +252,7 @@
19096
 
 
19097
 
 .. function:: has_key(ch)
19098
 
 
19099
 
-   Takes a key value *ch*, and returns true if the current terminal type recognizes
19100
 
+   Take a key value *ch*, and return ``True`` if the current terminal type recognizes
19101
 
    a key with that value.
19102
 
 
19103
 
 
19104
 
@@ -265,13 +261,13 @@
19105
 
    Used for half-delay mode, which is similar to cbreak mode in that characters
19106
 
    typed by the user are immediately available to the program. However, after
19107
 
    blocking for *tenths* tenths of seconds, an exception is raised if nothing has
19108
 
-   been typed.  The value of *tenths* must be a number between 1 and 255.  Use
19109
 
+   been typed.  The value of *tenths* must be a number between ``1`` and ``255``.  Use
19110
 
    :func:`nocbreak` to leave half-delay mode.
19111
 
 
19112
 
 
19113
 
 .. function:: init_color(color_number, r, g, b)
19114
 
 
19115
 
-   Changes the definition of a color, taking the number of the color to be changed
19116
 
+   Change the definition of a color, taking the number of the color to be changed
19117
 
    followed by three RGB values (for the amounts of red, green, and blue
19118
 
    components).  The value of *color_number* must be between ``0`` and
19119
 
    :const:`COLORS`.  Each of *r*, *g*, *b*, must be a value between ``0`` and
19120
 
@@ -282,7 +278,7 @@
19121
 
 
19122
 
 .. function:: init_pair(pair_number, fg, bg)
19123
 
 
19124
 
-   Changes the definition of a color-pair.  It takes three arguments: the number of
19125
 
+   Change the definition of a color-pair.  It takes three arguments: the number of
19126
 
    the color-pair to be changed, the foreground color number, and the background
19127
 
    color number.  The value of *pair_number* must be between ``1`` and
19128
 
    ``COLOR_PAIRS - 1`` (the ``0`` color pair is wired to white on black and cannot
19129
 
@@ -294,7 +290,7 @@
19130
 
 
19131
 
 .. function:: initscr()
19132
 
 
19133
 
-   Initialize the library. Returns a :class:`WindowObject` which represents the
19134
 
+   Initialize the library. Return a :class:`WindowObject` which represents the
19135
 
    whole screen.
19136
 
 
19137
 
    .. note::
19138
 
@@ -303,9 +299,15 @@
19139
 
       cause the interpreter to exit.
19140
 
 
19141
 
 
19142
 
+.. function:: is_term_resized(nlines, ncols)
19143
 
+
19144
 
+   Return ``True`` if :func:`resize_term` would modify the window structure,
19145
 
+   ``False`` otherwise.
19146
 
+
19147
 
+
19148
 
 .. function:: isendwin()
19149
 
 
19150
 
-   Returns true if :func:`endwin` has been called (that is, the  curses library has
19151
 
+   Return ``True`` if :func:`endwin` has been called (that is, the  curses library has
19152
 
    been deinitialized).
19153
 
 
19154
 
 
19155
 
@@ -321,14 +323,14 @@
19156
 
 
19157
 
 .. function:: killchar()
19158
 
 
19159
 
-   Returns the user's current line kill character. Under Unix operating systems
19160
 
+   Return the user's current line kill character. Under Unix operating systems
19161
 
    this is a property of the controlling tty of the curses program, and is not set
19162
 
    by the curses library itself.
19163
 
 
19164
 
 
19165
 
 .. function:: longname()
19166
 
 
19167
 
-   Returns a string containing the terminfo long name field describing the current
19168
 
+   Return a string containing the terminfo long name field describing the current
19169
 
    terminal.  The maximum length of a verbose description is 128 characters.  It is
19170
 
    defined only after the call to :func:`initscr`.
19171
 
 
19172
 
@@ -341,14 +343,14 @@
19173
 
 
19174
 
 .. function:: mouseinterval(interval)
19175
 
 
19176
 
-   Sets the maximum time in milliseconds that can elapse between press and release
19177
 
-   events in order for them to be recognized as a click, and returns the previous
19178
 
+   Set the maximum time in milliseconds that can elapse between press and release
19179
 
+   events in order for them to be recognized as a click, and return the previous
19180
 
    interval value.  The default value is 200 msec, or one fifth of a second.
19181
 
 
19182
 
 
19183
 
 .. function:: mousemask(mousemask)
19184
 
 
19185
 
-   Sets the mouse events to be reported, and returns a tuple ``(availmask,
19186
 
+   Set the mouse events to be reported, and return a tuple ``(availmask,
19187
 
    oldmask)``.   *availmask* indicates which of the specified mouse events can be
19188
 
    reported; on complete failure it returns 0.  *oldmask* is the previous value of
19189
 
    the given window's mouse event mask.  If this function is never called, no mouse
19190
 
@@ -362,7 +364,7 @@
19191
 
 
19192
 
 .. function:: newpad(nlines, ncols)
19193
 
 
19194
 
-   Creates and returns a pointer to a new pad data structure with the given number
19195
 
+   Create and return a pointer to a new pad data structure with the given number
19196
 
    of lines and columns.  A pad is returned as a window object.
19197
 
 
19198
 
    A pad is like a window, except that it is not restricted by the screen size, and
19199
 
@@ -372,9 +374,9 @@
19200
 
    echoing of input) do not occur.  The :meth:`refresh` and :meth:`noutrefresh`
19201
 
    methods of a pad require 6 arguments to specify the part of the pad to be
19202
 
    displayed and the location on the screen to be used for the display. The
19203
 
-   arguments are pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol; the p
19204
 
+   arguments are *pminrow*, *pmincol*, *sminrow*, *smincol*, *smaxrow*, *smaxcol*; the *p*
19205
 
    arguments refer to the upper left corner of the pad region to be displayed and
19206
 
-   the s arguments define a clipping box on the screen within which the pad region
19207
 
+   the *s* arguments define a clipping box on the screen within which the pad region
19208
 
    is to be displayed.
19209
 
 
19210
 
 
19211
 
@@ -416,7 +418,7 @@
19212
 
 
19213
 
 .. function:: noqiflush()
19214
 
 
19215
 
-   When the noqiflush routine is used, normal flush of input and output queues
19216
 
+   When the :func:`noqiflush` routine is used, normal flush of input and output queues
19217
 
    associated with the INTR, QUIT and SUSP characters will not be done.  You may
19218
 
    want to call :func:`noqiflush` in a signal handler if you want output to
19219
 
    continue as though the interrupt had not occurred, after the handler exits.
19220
 
@@ -429,27 +431,27 @@
19221
 
 
19222
 
 .. function:: pair_content(pair_number)
19223
 
 
19224
 
-   Returns a tuple ``(fg, bg)`` containing the colors for the requested color pair.
19225
 
+   Return a tuple ``(fg, bg)`` containing the colors for the requested color pair.
19226
 
    The value of *pair_number* must be between ``1`` and ``COLOR_PAIRS - 1``.
19227
 
 
19228
 
 
19229
 
 .. function:: pair_number(attr)
19230
 
 
19231
 
-   Returns the number of the color-pair set by the attribute value *attr*.
19232
 
+   Return the number of the color-pair set by the attribute value *attr*.
19233
 
    :func:`color_pair` is the counterpart to this function.
19234
 
 
19235
 
 
19236
 
 .. function:: putp(string)
19237
 
 
19238
 
-   Equivalent to ``tputs(str, 1, putchar)``; emits the value of a specified
19239
 
-   terminfo capability for the current terminal.  Note that the output of putp
19240
 
+   Equivalent to ``tputs(str, 1, putchar)``; emit the value of a specified
19241
 
+   terminfo capability for the current terminal.  Note that the output of :func:`putp`
19242
 
    always goes to standard output.
19243
 
 
19244
 
 
19245
 
 .. function:: qiflush( [flag] )
19246
 
 
19247
 
-   If *flag* is false, the effect is the same as calling :func:`noqiflush`. If
19248
 
-   *flag* is true, or no argument is provided, the queues will be flushed when
19249
 
+   If *flag* is ``False``, the effect is the same as calling :func:`noqiflush`. If
19250
 
+   *flag* is ``True``, or no argument is provided, the queues will be flushed when
19251
 
    these control characters are read.
19252
 
 
19253
 
 
19254
 
@@ -462,26 +464,55 @@
19255
 
 
19256
 
 .. function:: reset_prog_mode()
19257
 
 
19258
 
-   Restores the  terminal  to "program" mode, as previously saved  by
19259
 
+   Restore the  terminal  to "program" mode, as previously saved  by
19260
 
    :func:`def_prog_mode`.
19261
 
 
19262
 
 
19263
 
 .. function:: reset_shell_mode()
19264
 
 
19265
 
-   Restores the  terminal  to "shell" mode, as previously saved  by
19266
 
+   Restore the  terminal  to "shell" mode, as previously saved  by
19267
 
    :func:`def_shell_mode`.
19268
 
 
19269
 
 
19270
 
+.. function:: resetty()
19271
 
+
19272
 
+   Restore the state of the terminal modes to what it was at the last call to
19273
 
+   :func:`savetty`.
19274
 
+
19275
 
+
19276
 
+.. function:: resize_term(nlines, ncols)
19277
 
+
19278
 
+   Backend function used by :func:`resizeterm`, performing most of the work;
19279
 
+   when resizing the windows, :func:`resize_term` blank-fills the areas that are
19280
 
+   extended.  The calling application should fill in these areas with
19281
 
+   appropriate data.  The :func:`resize_term` function attempts to resize all
19282
 
+   windows.  However, due to the calling convention of pads, it is not possible
19283
 
+   to resize these without additional interaction with the application.
19284
 
+
19285
 
+
19286
 
+.. function:: resizeterm(nlines, ncols)
19287
 
+
19288
 
+   Resize the standard and current windows to the specified dimensions, and
19289
 
+   adjusts other bookkeeping data used by the curses library that record the
19290
 
+   window dimensions (in particular the SIGWINCH handler).
19291
 
+
19292
 
+
19293
 
+.. function:: savetty()
19294
 
+
19295
 
+   Save the current state of the terminal modes in a buffer, usable by
19296
 
+   :func:`resetty`.
19297
 
+
19298
 
+
19299
 
 .. function:: setsyx(y, x)
19300
 
 
19301
 
-   Sets the virtual screen cursor to *y*, *x*. If *y* and *x* are both -1, then
19302
 
+   Set the virtual screen cursor to *y*, *x*. If *y* and *x* are both -1, then
19303
 
    leaveok is set.
19304
 
 
19305
 
 
19306
 
 .. function:: setupterm([termstr, fd])
19307
 
 
19308
 
-   Initializes the terminal.  *termstr* is a string giving the terminal name; if
19309
 
-   omitted, the value of the TERM environment variable will be used.  *fd* is the
19310
 
+   Initialize the terminal.  *termstr* is a string giving the terminal name; if
19311
 
+   omitted, the value of the :envvar:`TERM` environment variable will be used.  *fd* is the
19312
 
    file descriptor to which any initialization sequences will be sent; if not
19313
 
    supplied, the file descriptor for ``sys.stdout`` will be used.
19314
 
 
19315
 
@@ -501,19 +532,19 @@
19316
 
 
19317
 
 .. function:: termattrs()
19318
 
 
19319
 
-   Returns a logical OR of all video attributes supported by the terminal.  This
19320
 
+   Return a logical OR of all video attributes supported by the terminal.  This
19321
 
    information is useful when a curses program needs complete control over the
19322
 
    appearance of the screen.
19323
 
 
19324
 
 
19325
 
 .. function:: termname()
19326
 
 
19327
 
-   Returns the value of the environment variable TERM, truncated to 14 characters.
19328
 
+   Return the value of the environment variable :envvar:`TERM`, truncated to 14 characters.
19329
 
 
19330
 
 
19331
 
 .. function:: tigetflag(capname)
19332
 
 
19333
 
-   Returns the value of the Boolean capability corresponding to the terminfo
19334
 
+   Return the value of the Boolean capability corresponding to the terminfo
19335
 
    capability name *capname*.  The value ``-1`` is returned if *capname* is not a
19336
 
    Boolean capability, or ``0`` if it is canceled or absent from the terminal
19337
 
    description.
19338
 
@@ -521,7 +552,7 @@
19339
 
 
19340
 
 .. function:: tigetnum(capname)
19341
 
 
19342
 
-   Returns the value of the numeric capability corresponding to the terminfo
19343
 
+   Return the value of the numeric capability corresponding to the terminfo
19344
 
    capability name *capname*.  The value ``-2`` is returned if *capname* is not a
19345
 
    numeric capability, or ``-1`` if it is canceled or absent from the terminal
19346
 
    description.
19347
 
@@ -529,22 +560,22 @@
19348
 
 
19349
 
 .. function:: tigetstr(capname)
19350
 
 
19351
 
-   Returns the value of the string capability corresponding to the terminfo
19352
 
+   Return the value of the string capability corresponding to the terminfo
19353
 
    capability name *capname*.  ``None`` is returned if *capname* is not a string
19354
 
    capability, or is canceled or absent from the terminal description.
19355
 
 
19356
 
 
19357
 
 .. function:: tparm(str[,...])
19358
 
 
19359
 
-   Instantiates the string *str* with the supplied parameters, where  *str* should
19360
 
-   be a parameterized string obtained from the terminfo  database.  E.g.
19361
 
-   ``tparm(tigetstr("cup"), 5, 3)`` could result in  ``'\033[6;4H'``, the exact
19362
 
+   Instantiate the string *str* with the supplied parameters, where *str* should
19363
 
+   be a parameterized string obtained from the terminfo database.  E.g.
19364
 
+   ``tparm(tigetstr("cup"), 5, 3)`` could result in ``'\033[6;4H'``, the exact
19365
 
    result depending on terminal type.
19366
 
 
19367
 
 
19368
 
 .. function:: typeahead(fd)
19369
 
 
19370
 
-   Specifies that the file descriptor *fd* be used for typeahead checking.  If *fd*
19371
 
+   Specify that the file descriptor *fd* be used for typeahead checking.  If *fd*
19372
 
    is ``-1``, then no typeahead checking is done.
19373
 
 
19374
 
    The curses library does "line-breakout optimization" by looking for typeahead
19375
 
@@ -556,7 +587,7 @@
19376
 
 
19377
 
 .. function:: unctrl(ch)
19378
 
 
19379
 
-   Returns a string which is a printable representation of the character *ch*.
19380
 
+   Return a string which is a printable representation of the character *ch*.
19381
 
    Control characters are displayed as a caret followed by the character, for
19382
 
    example as ``^C``. Printing characters are left as they are.
19383
 
 
19384
 
@@ -579,7 +610,7 @@
19385
 
 .. function:: use_env(flag)
19386
 
 
19387
 
    If used, this function should be called before :func:`initscr` or newterm are
19388
 
-   called.  When *flag* is false, the values of lines and columns specified in the
19389
 
+   called.  When *flag* is ``False``, the values of lines and columns specified in the
19390
 
    terminfo database will be used, even if environment variables :envvar:`LINES`
19391
 
    and :envvar:`COLUMNS` (used by default) are set, or if curses is running in a
19392
 
    window (in which case default behavior would be to use the window size if
19393
 
@@ -595,6 +626,19 @@
19394
 
    foreground color on the default background.
19395
 
 
19396
 
 
19397
 
+.. function:: wrapper(func, ...)
19398
 
+
19399
 
+   Initialize curses and call another callable object, *func*, which should be the
19400
 
+   rest of your curses-using application.  If the application raises an exception,
19401
 
+   this function will restore the terminal to a sane state before re-raising the
19402
 
+   exception and generating a traceback.  The callable object *func* is then passed
19403
 
+   the main window 'stdscr' as its first argument, followed by any other arguments
19404
 
+   passed to :func:`wrapper`.  Before calling *func*, :func:`wrapper` turns on
19405
 
+   cbreak mode, turns off echo, enables the terminal keypad, and initializes colors
19406
 
+   if the terminal has color support.  On exit (whether normally or by exception)
19407
 
+   it restores cooked mode, turns on echo, and disables the terminal keypad.
19408
 
+
19409
 
+
19410
 
 .. _curses-window-objects:
19411
 
 
19412
 
 Window Objects
19413
 
@@ -608,7 +652,7 @@
19414
 
 
19415
 
    .. note::
19416
 
 
19417
 
-      A *character* means a C character (an ASCII code), rather then a Python
19418
 
+      A *character* means a C character (an ASCII code), rather than a Python
19419
 
       character (a string of length 1). (This note is true whenever the
19420
 
       documentation mentions a character.) The built-in :func:`ord` is handy for
19421
 
       conveying strings to codes.
19422
 
@@ -650,7 +694,7 @@
19423
 
 
19424
 
 .. method:: window.bkgd(ch[, attr])
19425
 
 
19426
 
-   Sets the background property of the window to the character *ch*, with
19427
 
+   Set the background property of the window to the character *ch*, with
19428
 
    attributes *attr*.  The change is then applied to every character position in
19429
 
    that window:
19430
 
 
19431
 
@@ -663,7 +707,7 @@
19432
 
 
19433
 
 .. method:: window.bkgdset(ch[, attr])
19434
 
 
19435
 
-   Sets the window's background.  A window's background consists of a character and
19436
 
+   Set the window's background.  A window's background consists of a character and
19437
 
    any combination of attributes.  The attribute part of the background is combined
19438
 
    (OR'ed) with all non-blank characters that are written into the window.  Both
19439
 
    the character and attribute parts of the background are combined with the blank
19440
 
@@ -708,12 +752,12 @@
19441
 
 .. method:: window.box([vertch, horch])
19442
 
 
19443
 
    Similar to :meth:`border`, but both *ls* and *rs* are *vertch* and both *ts* and
19444
 
-   bs are *horch*.  The default corner characters are always used by this function.
19445
 
+   *bs* are *horch*.  The default corner characters are always used by this function.
19446
 
 
19447
 
 
19448
 
 .. method:: window.chgat([y, x, ] [num,] attr)
19449
 
 
19450
 
-   Sets the attributes of *num* characters at the current cursor position, or at
19451
 
+   Set the attributes of *num* characters at the current cursor position, or at
19452
 
    position ``(y, x)`` if supplied. If no value of *num* is given or *num* = -1,
19453
 
    the attribute will  be set on all the characters to the end of the line.  This
19454
 
    function does not move the cursor. The changed line will be touched using the
19455
 
@@ -723,7 +767,7 @@
19456
 
 
19457
 
 .. method:: window.clear()
19458
 
 
19459
 
-   Like :meth:`erase`, but also causes the whole window to be repainted upon next
19460
 
+   Like :meth:`erase`, but also cause the whole window to be repainted upon next
19461
 
    call to :meth:`refresh`.
19462
 
 
19463
 
 
19464
 
@@ -746,7 +790,7 @@
19465
 
 
19466
 
 .. method:: window.cursyncup()
19467
 
 
19468
 
-   Updates the current cursor position of all the ancestors of the window to
19469
 
+   Update the current cursor position of all the ancestors of the window to
19470
 
    reflect the current cursor position of the window.
19471
 
 
19472
 
 
19473
 
@@ -757,14 +801,14 @@
19474
 
 
19475
 
 .. method:: window.deleteln()
19476
 
 
19477
 
-   Delete the line under the cursor. All following lines are moved up by 1 line.
19478
 
+   Delete the line under the cursor. All following lines are moved up by one line.
19479
 
 
19480
 
 
19481
 
 .. method:: window.derwin([nlines, ncols,] begin_y, begin_x)
19482
 
 
19483
 
    An abbreviation for "derive window", :meth:`derwin` is the same as calling
19484
 
    :meth:`subwin`, except that *begin_y* and *begin_x* are relative to the origin
19485
 
-   of the window, rather than relative to the entire screen.  Returns a window
19486
 
+   of the window, rather than relative to the entire screen.  Return a window
19487
 
    object for the derived window.
19488
 
 
19489
 
 
19490
 
@@ -776,8 +820,8 @@
19491
 
 
19492
 
 .. method:: window.enclose(y, x)
19493
 
 
19494
 
-   Tests whether the given pair of screen-relative character-cell coordinates are
19495
 
-   enclosed by the given window, returning true or false.  It is useful for
19496
 
+   Test whether the given pair of screen-relative character-cell coordinates are
19497
 
+   enclosed by the given window, returning ``True`` or ``False``.  It is useful for
19498
 
    determining what subset of the screen windows enclose the location of a mouse
19499
 
    event.
19500
 
 
19501
 
@@ -792,6 +836,11 @@
19502
 
    Return a tuple ``(y, x)`` of co-ordinates of upper-left corner.
19503
 
 
19504
 
 
19505
 
+.. method:: window.getbkgd()
19506
 
+
19507
 
+   Return the given window's current background character/attribute pair.
19508
 
+
19509
 
+
19510
 
 .. method:: window.getch([y, x])
19511
 
 
19512
 
    Get a character. Note that the integer returned does *not* have to be in ASCII
19513
 
@@ -814,8 +863,8 @@
19514
 
 
19515
 
 .. method:: window.getparyx()
19516
 
 
19517
 
-   Returns the beginning coordinates of this window relative to its parent window
19518
 
-   into two integer variables y and x.  Returns ``-1,-1`` if this window has no
19519
 
+   Return the beginning coordinates of this window relative to its parent window
19520
 
+   into two integer variables y and x.  Return ``-1, -1`` if this window has no
19521
 
    parent.
19522
 
 
19523
 
 
19524
 
@@ -838,8 +887,8 @@
19525
 
 
19526
 
 .. method:: window.idcok(flag)
19527
 
 
19528
 
-   If *flag* is false, curses no longer considers using the hardware insert/delete
19529
 
-   character feature of the terminal; if *flag* is true, use of character insertion
19530
 
+   If *flag* is ``False``, curses no longer considers using the hardware insert/delete
19531
 
+   character feature of the terminal; if *flag* is ``True``, use of character insertion
19532
 
    and deletion is enabled.  When curses is first initialized, use of character
19533
 
    insert/delete is enabled by default.
19534
 
 
19535
 
@@ -852,7 +901,7 @@
19536
 
 
19537
 
 .. method:: window.immedok(flag)
19538
 
 
19539
 
-   If *flag* is true, any change in the window image automatically causes the
19540
 
+   If *flag* is ``True``, any change in the window image automatically causes the
19541
 
    window to be refreshed; you no longer have to call :meth:`refresh` yourself.
19542
 
    However, it may degrade performance considerably, due to repeated calls to
19543
 
    wrefresh.  This option is disabled by default.
19544
 
@@ -872,7 +921,7 @@
19545
 
 
19546
 
 .. method:: window.insdelln(nlines)
19547
 
 
19548
 
-   Inserts *nlines* lines into the specified window above the current line.  The
19549
 
+   Insert *nlines* lines into the specified window above the current line.  The
19550
 
    *nlines* bottom lines are lost.  For negative *nlines*, delete *nlines* lines
19551
 
    starting with the one under the cursor, and move the remaining lines up.  The
19552
 
    bottom *nlines* lines are cleared.  The current cursor position remains the
19553
 
@@ -881,7 +930,7 @@
19554
 
 
19555
 
 .. method:: window.insertln()
19556
 
 
19557
 
-   Insert a blank line under the cursor. All following lines are moved down by 1
19558
 
+   Insert a blank line under the cursor. All following lines are moved down by one
19559
 
    line.
19560
 
 
19561
 
 
19562
 
@@ -904,23 +953,23 @@
19563
 
 
19564
 
 .. method:: window.instr([y, x] [, n])
19565
 
 
19566
 
-   Returns a string of characters, extracted from the window starting at the
19567
 
+   Return a string of characters, extracted from the window starting at the
19568
 
    current cursor position, or at *y*, *x* if specified. Attributes are stripped
19569
 
-   from the characters.  If *n* is specified, :meth:`instr` returns return a string
19570
 
+   from the characters.  If *n* is specified, :meth:`instr` returns a string
19571
 
    at most *n* characters long (exclusive of the trailing NUL).
19572
 
 
19573
 
 
19574
 
 .. method:: window.is_linetouched(line)
19575
 
 
19576
 
-   Returns true if the specified line was modified since the last call to
19577
 
-   :meth:`refresh`; otherwise returns false.  Raises a :exc:`curses.error`
19578
 
+   Return ``True`` if the specified line was modified since the last call to
19579
 
+   :meth:`refresh`; otherwise return ``False``.  Raise a :exc:`curses.error`
19580
 
    exception if *line* is not valid for the given window.
19581
 
 
19582
 
 
19583
 
 .. method:: window.is_wintouched()
19584
 
 
19585
 
-   Returns true if the specified window was modified since the last call to
19586
 
-   :meth:`refresh`; otherwise returns false.
19587
 
+   Return ``True`` if the specified window was modified since the last call to
19588
 
+   :meth:`refresh`; otherwise return ``False``.
19589
 
 
19590
 
 
19591
 
 .. method:: window.keypad(yes)
19592
 
@@ -946,7 +995,7 @@
19593
 
 
19594
 
 .. method:: window.mvderwin(y, x)
19595
 
 
19596
 
-   Moves the window inside its parent window.  The screen-relative parameters of
19597
 
+   Move the window inside its parent window.  The screen-relative parameters of
19598
 
    the window are not changed.  This routine is used to display different parts of
19599
 
    the parent window at the same physical position on the screen.
19600
 
 
19601
 
@@ -1004,19 +1053,19 @@
19602
 
 
19603
 
 .. method:: window.putwin(file)
19604
 
 
19605
 
-   Writes all data associated with the window into the provided file object.  This
19606
 
+   Write all data associated with the window into the provided file object.  This
19607
 
    information can be later retrieved using the :func:`getwin` function.
19608
 
 
19609
 
 
19610
 
 .. method:: window.redrawln(beg, num)
19611
 
 
19612
 
-   Indicates that the *num* screen lines, starting at line *beg*, are corrupted and
19613
 
+   Indicate that the *num* screen lines, starting at line *beg*, are corrupted and
19614
 
    should be completely redrawn on the next :meth:`refresh` call.
19615
 
 
19616
 
 
19617
 
 .. method:: window.redrawwin()
19618
 
 
19619
 
-   Touches the entire window, causing it to be completely redrawn on the next
19620
 
+   Touch the entire window, causing it to be completely redrawn on the next
19621
 
    :meth:`refresh` call.
19622
 
 
19623
 
 
19624
 
@@ -1037,6 +1086,14 @@
19625
 
    *sminrow*, or *smincol* are treated as if they were zero.
19626
 
 
19627
 
 
19628
 
+.. method:: window.resize(nlines, ncols)
19629
 
+
19630
 
+   Reallocate storage for a curses window to adjust its dimensions to the
19631
 
+   specified values.  If either dimension is larger than the current values, the
19632
 
+   window's data is filled with blanks that have the current background
19633
 
+   rendition (as set by :meth:`bkgdset`) merged into them.
19634
 
+
19635
 
+
19636
 
 .. method:: window.scroll([lines=1])
19637
 
 
19638
 
    Scroll the screen or scrolling region upward by *lines* lines.
19639
 
@@ -1044,7 +1101,7 @@
19640
 
 
19641
 
 .. method:: window.scrollok(flag)
19642
 
 
19643
 
-   Controls what happens when the cursor of a window is moved off the edge of the
19644
 
+   Control what happens when the cursor of a window is moved off the edge of the
19645
 
    window or scrolling region, either as a result of a newline action on the bottom
19646
 
    line, or typing the last character of the last line.  If *flag* is false, the
19647
 
    cursor is left on the bottom line.  If *flag* is true, the window is scrolled up
19648
 
@@ -1086,26 +1143,26 @@
19649
 
 
19650
 
 .. method:: window.syncdown()
19651
 
 
19652
 
-   Touches each location in the window that has been touched in any of its ancestor
19653
 
+   Touch each location in the window that has been touched in any of its ancestor
19654
 
    windows.  This routine is called by :meth:`refresh`, so it should almost never
19655
 
    be necessary to call it manually.
19656
 
 
19657
 
 
19658
 
 .. method:: window.syncok(flag)
19659
 
 
19660
 
-   If called with *flag* set to true, then :meth:`syncup` is called automatically
19661
 
+   If called with *flag* set to ``True``, then :meth:`syncup` is called automatically
19662
 
    whenever there is a change in the window.
19663
 
 
19664
 
 
19665
 
 .. method:: window.syncup()
19666
 
 
19667
 
-   Touches all locations in ancestors of the window that have been changed in  the
19668
 
+   Touch all locations in ancestors of the window that have been changed in  the
19669
 
    window.
19670
 
 
19671
 
 
19672
 
 .. method:: window.timeout(delay)
19673
 
 
19674
 
-   Sets blocking or non-blocking read behavior for the window.  If *delay* is
19675
 
+   Set blocking or non-blocking read behavior for the window.  If *delay* is
19676
 
    negative, blocking read is used (which will wait indefinitely for input).  If
19677
 
    *delay* is zero, then non-blocking read is used, and -1 will be returned by
19678
 
    :meth:`getch` if no input is waiting.  If *delay* is positive, then
19679
 
@@ -1128,7 +1185,7 @@
19680
 
 
19681
 
 .. method:: window.untouchwin()
19682
 
 
19683
 
-   Marks all lines in  the  window  as unchanged since the last call to
19684
 
+   Mark all lines in  the  window  as unchanged since the last call to
19685
 
    :meth:`refresh`.
19686
 
 
19687
 
 
19688
 
@@ -1587,7 +1644,7 @@
19689
 
       each keystroke entered with the keystroke as a parameter; command dispatch
19690
 
       is done on the result. This method returns the window contents as a
19691
 
       string; whether blanks in the window are included is affected by the
19692
 
-      :attr:`stripspaces` member.
19693
 
+      :attr:`stripspaces` attribute.
19694
 
 
19695
 
 
19696
 
    .. method:: do_command(ch)
19697
 
@@ -1653,45 +1710,15 @@
19698
 
 
19699
 
    .. method:: gather()
19700
 
 
19701
 
-      This method returns the window contents as a string; whether blanks in the
19702
 
+      Return the window contents as a string; whether blanks in the
19703
 
       window are included is affected by the :attr:`stripspaces` member.
19704
 
 
19705
 
 
19706
 
    .. attribute:: stripspaces
19707
 
 
19708
 
-      This data member is a flag which controls the interpretation of blanks in
19709
 
+      This attribute is a flag which controls the interpretation of blanks in
19710
 
       the window.  When it is on, trailing blanks on each line are ignored; any
19711
 
       cursor motion that would land the cursor on a trailing blank goes to the
19712
 
       end of that line instead, and trailing blanks are stripped when the window
19713
 
       contents are gathered.
19714
 
 
19715
 
-
19716
 
-:mod:`curses.wrapper` --- Terminal handler for curses programs
19717
 
-==============================================================
19718
 
-
19719
 
-.. module:: curses.wrapper
19720
 
-   :synopsis: Terminal configuration wrapper for curses programs.
19721
 
-.. moduleauthor:: Eric Raymond <esr@thyrsus.com>
19722
 
-.. sectionauthor:: Eric Raymond <esr@thyrsus.com>
19723
 
-
19724
 
-
19725
 
-.. versionadded:: 1.6
19726
 
-
19727
 
-This module supplies one function, :func:`wrapper`, which runs another function
19728
 
-which should be the rest of your curses-using application.  If the application
19729
 
-raises an exception, :func:`wrapper` will restore the terminal to a sane state
19730
 
-before re-raising the exception and generating a traceback.
19731
 
-
19732
 
-
19733
 
-.. function:: wrapper(func, ...)
19734
 
-
19735
 
-   Wrapper function that initializes curses and calls another function, *func*,
19736
 
-   restoring normal keyboard/screen behavior on error. The callable object *func*
19737
 
-   is then passed the main window 'stdscr' as its first argument, followed by any
19738
 
-   other arguments passed to :func:`wrapper`.
19739
 
-
19740
 
-Before calling the hook function, :func:`wrapper` turns on cbreak mode, turns
19741
 
-off echo, enables the terminal keypad, and initializes colors if the terminal
19742
 
-has color support.  On exit (whether normally or by exception) it restores
19743
 
-cooked mode, turns on echo, and disables the terminal keypad.
19744
 
-
19745
 
diff -r 8527427914a2 Doc/library/datetime.rst
19746
 
--- a/Doc/library/datetime.rst
19747
 
+++ b/Doc/library/datetime.rst
19748
 
@@ -13,7 +13,7 @@
19749
 
 
19750
 
 The :mod:`datetime` module supplies classes for manipulating dates and times in
19751
 
 both simple and complex ways.  While date and time arithmetic is supported, the
19752
 
-focus of the implementation is on efficient member extraction for output
19753
 
+focus of the implementation is on efficient attribute extraction for output
19754
 
 formatting and manipulation. For related
19755
 
 functionality, see also the :mod:`time` and :mod:`calendar` modules.
19756
 
 
19757
 
@@ -27,8 +27,8 @@
19758
 
 work with, at the cost of ignoring some aspects of reality.
19759
 
 
19760
 
 For applications requiring more, :class:`datetime` and :class:`time` objects
19761
 
-have an optional time zone information member, :attr:`tzinfo`, that can contain
19762
 
-an instance of a subclass of the abstract :class:`tzinfo` class.  These
19763
 
+have an optional time zone information attribute, :attr:`tzinfo`, that can be
19764
 
+set to an instance of a subclass of the abstract :class:`tzinfo` class.  These
19765
 
 :class:`tzinfo` objects capture information about the offset from UTC time, the
19766
 
 time zone name, and whether Daylight Saving Time is in effect.  Note that no
19767
 
 concrete :class:`tzinfo` classes are supplied by the :mod:`datetime` module.
19768
 
@@ -360,7 +360,7 @@
19769
 
 
19770
 
    Return the local date corresponding to the POSIX timestamp, such as is returned
19771
 
    by :func:`time.time`.  This may raise :exc:`ValueError`, if the timestamp is out
19772
 
-   of the range of values supported by the platform C :cfunc:`localtime` function.
19773
 
+   of the range of values supported by the platform C :c:func:`localtime` function.
19774
 
    It's common for this to be restricted to years from 1970 through 2038.  Note
19775
 
    that on non-POSIX systems that include leap seconds in their notion of a
19776
 
    timestamp, leap seconds are ignored by :meth:`fromtimestamp`.
19777
 
@@ -463,9 +463,9 @@
19778
 
 
19779
 
 .. method:: date.replace(year, month, day)
19780
 
 
19781
 
-   Return a date with the same value, except for those members given new values by
19782
 
-   whichever keyword arguments are specified.  For example, if ``d == date(2002,
19783
 
-   12, 31)``, then ``d.replace(day=26) == date(2002, 12, 26)``.
19784
 
+   Return a date with the same value, except for those parameters given new
19785
 
+   values by whichever keyword arguments are specified.  For example, if ``d ==
19786
 
+   date(2002, 12, 31)``, then ``d.replace(day=26) == date(2002, 12, 26)``.
19787
 
 
19788
 
 
19789
 
 .. method:: date.timetuple()
19790
 
@@ -534,7 +534,7 @@
19791
 
    Return a string representing the date, for example ``date(2002, 12,
19792
 
    4).ctime() == 'Wed Dec 4 00:00:00 2002'``. ``d.ctime()`` is equivalent to
19793
 
    ``time.ctime(time.mktime(d.timetuple()))`` on platforms where the native C
19794
 
-   :cfunc:`ctime` function (which :func:`time.ctime` invokes, but which
19795
 
+   :c:func:`ctime` function (which :func:`time.ctime` invokes, but which
19796
 
    :meth:`date.ctime` does not invoke) conforms to the C standard.
19797
 
 
19798
 
 
19799
 
@@ -641,7 +641,7 @@
19800
 
    or not specified, this is like :meth:`today`, but, if possible, supplies more
19801
 
    precision than can be gotten from going through a :func:`time.time` timestamp
19802
 
    (for example, this may be possible on platforms supplying the C
19803
 
-   :cfunc:`gettimeofday` function).
19804
 
+   :c:func:`gettimeofday` function).
19805
 
 
19806
 
    Else *tz* must be an instance of a class :class:`tzinfo` subclass, and the
19807
 
    current date and time are converted to *tz*'s time zone.  In this case the
19808
 
@@ -669,8 +669,8 @@
19809
 
    ``tz.fromutc(datetime.utcfromtimestamp(timestamp).replace(tzinfo=tz))``.
19810
 
 
19811
 
    :meth:`fromtimestamp` may raise :exc:`ValueError`, if the timestamp is out of
19812
 
-   the range of values supported by the platform C :cfunc:`localtime` or
19813
 
-   :cfunc:`gmtime` functions.  It's common for this to be restricted to years in
19814
 
+   the range of values supported by the platform C :c:func:`localtime` or
19815
 
+   :c:func:`gmtime` functions.  It's common for this to be restricted to years in
19816
 
    1970 through 2038. Note that on non-POSIX systems that include leap seconds in
19817
 
    their notion of a timestamp, leap seconds are ignored by :meth:`fromtimestamp`,
19818
 
    and then it's possible to have two timestamps differing by a second that yield
19819
 
@@ -681,7 +681,7 @@
19820
 
 
19821
 
    Return the UTC :class:`datetime` corresponding to the POSIX timestamp, with
19822
 
    :attr:`tzinfo` ``None``. This may raise :exc:`ValueError`, if the timestamp is
19823
 
-   out of the range of values supported by the platform C :cfunc:`gmtime` function.
19824
 
+   out of the range of values supported by the platform C :c:func:`gmtime` function.
19825
 
    It's common for this to be restricted to years in 1970 through 2038. See also
19826
 
    :meth:`fromtimestamp`.
19827
 
 
19828
 
@@ -696,11 +696,13 @@
19829
 
 
19830
 
 .. classmethod:: datetime.combine(date, time)
19831
 
 
19832
 
-   Return a new :class:`datetime` object whose date members are equal to the given
19833
 
-   :class:`date` object's, and whose time and :attr:`tzinfo` members are equal to
19834
 
-   the given :class:`time` object's. For any :class:`datetime` object *d*, ``d ==
19835
 
-   datetime.combine(d.date(), d.timetz())``.  If date is a :class:`datetime`
19836
 
-   object, its time and :attr:`tzinfo` members are ignored.
19837
 
+   Return a new :class:`datetime` object whose date components are equal to the
19838
 
+   given :class:`date` object's, and whose time components and :attr:`tzinfo`
19839
 
+   attributes are equal to the given :class:`time` object's. For any
19840
 
+   :class:`datetime` object *d*,
19841
 
+   ``d == datetime.combine(d.date(), d.timetz())``.  If date is a
19842
 
+   :class:`datetime` object, its time components and :attr:`tzinfo` attributes
19843
 
+   are ignored.
19844
 
 
19845
 
 
19846
 
 .. classmethod:: datetime.strptime(date_string, format)
19847
 
@@ -795,43 +797,44 @@
19848
 
 (1)
19849
 
    datetime2 is a duration of timedelta removed from datetime1, moving forward in
19850
 
    time if ``timedelta.days`` > 0, or backward if ``timedelta.days`` < 0.  The
19851
 
-   result has the same :attr:`tzinfo` member as the input datetime, and datetime2 -
19852
 
-   datetime1 == timedelta after. :exc:`OverflowError` is raised if datetime2.year
19853
 
-   would be smaller than :const:`MINYEAR` or larger than :const:`MAXYEAR`. Note
19854
 
-   that no time zone adjustments are done even if the input is an aware object.
19855
 
+   result has the same :attr:`tzinfo` attribute as the input datetime, and
19856
 
+   datetime2 - datetime1 == timedelta after. :exc:`OverflowError` is raised if
19857
 
+   datetime2.year would be smaller than :const:`MINYEAR` or larger than
19858
 
+   :const:`MAXYEAR`. Note that no time zone adjustments are done even if the
19859
 
+   input is an aware object.
19860
 
 
19861
 
 (2)
19862
 
    Computes the datetime2 such that datetime2 + timedelta == datetime1. As for
19863
 
-   addition, the result has the same :attr:`tzinfo` member as the input datetime,
19864
 
-   and no time zone adjustments are done even if the input is aware. This isn't
19865
 
-   quite equivalent to datetime1 + (-timedelta), because -timedelta in isolation
19866
 
-   can overflow in cases where datetime1 - timedelta does not.
19867
 
+   addition, the result has the same :attr:`tzinfo` attribute as the input
19868
 
+   datetime, and no time zone adjustments are done even if the input is aware.
19869
 
+   This isn't quite equivalent to datetime1 + (-timedelta), because -timedelta
19870
 
+   in isolation can overflow in cases where datetime1 - timedelta does not.
19871
 
 
19872
 
 (3)
19873
 
    Subtraction of a :class:`datetime` from a :class:`datetime` is defined only if
19874
 
    both operands are naive, or if both are aware.  If one is aware and the other is
19875
 
    naive, :exc:`TypeError` is raised.
19876
 
 
19877
 
-   If both are naive, or both are aware and have the same :attr:`tzinfo` member,
19878
 
-   the :attr:`tzinfo` members are ignored, and the result is a :class:`timedelta`
19879
 
+   If both are naive, or both are aware and have the same :attr:`tzinfo` attribute,
19880
 
+   the :attr:`tzinfo` attributes are ignored, and the result is a :class:`timedelta`
19881
 
    object *t* such that ``datetime2 + t == datetime1``.  No time zone adjustments
19882
 
    are done in this case.
19883
 
 
19884
 
-   If both are aware and have different :attr:`tzinfo` members, ``a-b`` acts as if
19885
 
-   *a* and *b* were first converted to naive UTC datetimes first.  The result is
19886
 
-   ``(a.replace(tzinfo=None) - a.utcoffset()) - (b.replace(tzinfo=None) -
19887
 
-   b.utcoffset())`` except that the implementation never overflows.
19888
 
+   If both are aware and have different :attr:`tzinfo` attributes, ``a-b`` acts
19889
 
+   as if *a* and *b* were first converted to naive UTC datetimes first.  The
19890
 
+   result is ``(a.replace(tzinfo=None) - a.utcoffset()) - (b.replace(tzinfo=None)
19891
 
+   - b.utcoffset())`` except that the implementation never overflows.
19892
 
 
19893
 
 (4)
19894
 
    *datetime1* is considered less than *datetime2* when *datetime1* precedes
19895
 
    *datetime2* in time.
19896
 
 
19897
 
    If one comparand is naive and the other is aware, :exc:`TypeError` is raised.
19898
 
-   If both comparands are aware, and have the same :attr:`tzinfo` member, the
19899
 
-   common :attr:`tzinfo` member is ignored and the base datetimes are compared.  If
19900
 
-   both comparands are aware and have different :attr:`tzinfo` members, the
19901
 
-   comparands are first adjusted by subtracting their UTC offsets (obtained from
19902
 
-   ``self.utcoffset()``).
19903
 
+   If both comparands are aware, and have the same :attr:`tzinfo` attribute, the
19904
 
+   common :attr:`tzinfo` attribute is ignored and the base datetimes are
19905
 
+   compared.  If both comparands are aware and have different :attr:`tzinfo`
19906
 
+   attributes, the comparands are first adjusted by subtracting their UTC
19907
 
+   offsets (obtained from ``self.utcoffset()``).
19908
 
 
19909
 
    .. note::
19910
 
 
19911
 
@@ -864,22 +867,22 @@
19912
 
 .. method:: datetime.timetz()
19913
 
 
19914
 
    Return :class:`time` object with same hour, minute, second, microsecond, and
19915
 
-   tzinfo members.  See also method :meth:`time`.
19916
 
+   tzinfo attributes.  See also method :meth:`time`.
19917
 
 
19918
 
 
19919
 
 .. method:: datetime.replace([year[, month[, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]]]]])
19920
 
 
19921
 
-   Return a datetime with the same members, except for those members given new
19922
 
-   values by whichever keyword arguments are specified.  Note that ``tzinfo=None``
19923
 
-   can be specified to create a naive datetime from an aware datetime with no
19924
 
-   conversion of date and time members.
19925
 
+   Return a datetime with the same attributes, except for those attributes given
19926
 
+   new values by whichever keyword arguments are specified.  Note that
19927
 
+   ``tzinfo=None`` can be specified to create a naive datetime from an aware
19928
 
+   datetime with no conversion of date and time data.
19929
 
 
19930
 
 
19931
 
 .. method:: datetime.astimezone(tz)
19932
 
 
19933
 
-   Return a :class:`datetime` object with new :attr:`tzinfo` member *tz*, adjusting
19934
 
-   the date and time members so the result is the same UTC time as *self*, but in
19935
 
-   *tz*'s local time.
19936
 
+   Return a :class:`datetime` object with new :attr:`tzinfo` attribute *tz*,
19937
 
+   adjusting the date and time data so the result is the same UTC time as
19938
 
+   *self*, but in *tz*'s local time.
19939
 
 
19940
 
    *tz* must be an instance of a :class:`tzinfo` subclass, and its
19941
 
    :meth:`utcoffset` and :meth:`dst` methods must not return ``None``.  *self* must
19942
 
@@ -887,18 +890,18 @@
19943
 
    not return ``None``).
19944
 
 
19945
 
    If ``self.tzinfo`` is *tz*, ``self.astimezone(tz)`` is equal to *self*:  no
19946
 
-   adjustment of date or time members is performed. Else the result is local time
19947
 
-   in time zone *tz*, representing the same UTC time as *self*:  after ``astz =
19948
 
-   dt.astimezone(tz)``, ``astz - astz.utcoffset()`` will usually have the same date
19949
 
-   and time members as ``dt - dt.utcoffset()``. The discussion of class
19950
 
-   :class:`tzinfo` explains the cases at Daylight Saving Time transition boundaries
19951
 
-   where this cannot be achieved (an issue only if *tz* models both standard and
19952
 
-   daylight time).
19953
 
+   adjustment of date or time data is performed. Else the result is local
19954
 
+   time in time zone *tz*, representing the same UTC time as *self*:  after
19955
 
+   ``astz = dt.astimezone(tz)``, ``astz - astz.utcoffset()`` will usually have
19956
 
+   the same date and time data as ``dt - dt.utcoffset()``. The discussion
19957
 
+   of class :class:`tzinfo` explains the cases at Daylight Saving Time transition
19958
 
+   boundaries where this cannot be achieved (an issue only if *tz* models both
19959
 
+   standard and daylight time).
19960
 
 
19961
 
    If you merely want to attach a time zone object *tz* to a datetime *dt* without
19962
 
-   adjustment of date and time members, use ``dt.replace(tzinfo=tz)``.  If you
19963
 
+   adjustment of date and time data, use ``dt.replace(tzinfo=tz)``.  If you
19964
 
    merely want to remove the time zone object from an aware datetime *dt* without
19965
 
-   conversion of date and time members, use ``dt.replace(tzinfo=None)``.
19966
 
+   conversion of date and time data, use ``dt.replace(tzinfo=None)``.
19967
 
 
19968
 
    Note that the default :meth:`tzinfo.fromutc` method can be overridden in a
19969
 
    :class:`tzinfo` subclass to affect the result returned by :meth:`astimezone`.
19970
 
@@ -1021,7 +1024,7 @@
19971
 
    Return a string representing the date and time, for example ``datetime(2002, 12,
19972
 
    4, 20, 30, 40).ctime() == 'Wed Dec  4 20:30:40 2002'``. ``d.ctime()`` is
19973
 
    equivalent to ``time.ctime(time.mktime(d.timetuple()))`` on platforms where the
19974
 
-   native C :cfunc:`ctime` function (which :func:`time.ctime` invokes, but which
19975
 
+   native C :c:func:`ctime` function (which :func:`time.ctime` invokes, but which
19976
 
    :meth:`datetime.ctime` does not invoke) conforms to the C standard.
19977
 
 
19978
 
 
19979
 
@@ -1161,19 +1164,19 @@
19980
 
 
19981
 
 .. attribute:: time.min
19982
 
 
19983
 
-   The earliest representable :class:`time`, ``time(0, 0, 0, 0)``.
19984
 
+   The earliest representable :class:`.time`, ``time(0, 0, 0, 0)``.
19985
 
 
19986
 
 
19987
 
 .. attribute:: time.max
19988
 
 
19989
 
-   The latest representable :class:`time`, ``time(23, 59, 59, 999999)``.
19990
 
+   The latest representable :class:`.time`, ``time(23, 59, 59, 999999)``.
19991
 
 
19992
 
 
19993
 
 .. attribute:: time.resolution
19994
 
 
19995
 
-   The smallest possible difference between non-equal :class:`time` objects,
19996
 
-   ``timedelta(microseconds=1)``, although note that arithmetic on :class:`time`
19997
 
-   objects is not supported.
19998
 
+   The smallest possible difference between non-equal :class:`.time` objects,
19999
 
+   ``timedelta(microseconds=1)``, although note that arithmetic on
20000
 
+   :class:`.time` objects is not supported.
20001
 
 
20002
 
 
20003
 
 Instance attributes (read-only):
20004
 
@@ -1200,7 +1203,7 @@
20005
 
 
20006
 
 .. attribute:: time.tzinfo
20007
 
 
20008
 
-   The object passed as the tzinfo argument to the :class:`time` constructor, or
20009
 
+   The object passed as the tzinfo argument to the :class:`.time` constructor, or
20010
 
    ``None`` if none was passed.
20011
 
 
20012
 
 
20013
 
@@ -1209,14 +1212,14 @@
20014
 
 * comparison of :class:`time` to :class:`time`, where *a* is considered less
20015
 
   than *b* when *a* precedes *b* in time.  If one comparand is naive and the other
20016
 
   is aware, :exc:`TypeError` is raised.  If both comparands are aware, and have
20017
 
-  the same :attr:`tzinfo` member, the common :attr:`tzinfo` member is ignored and
20018
 
-  the base times are compared.  If both comparands are aware and have different
20019
 
-  :attr:`tzinfo` members, the comparands are first adjusted by subtracting their
20020
 
-  UTC offsets (obtained from ``self.utcoffset()``). In order to stop mixed-type
20021
 
-  comparisons from falling back to the default comparison by object address, when
20022
 
-  a :class:`time` object is compared to an object of a different type,
20023
 
-  :exc:`TypeError` is raised unless the comparison is ``==`` or ``!=``.  The
20024
 
-  latter cases return :const:`False` or :const:`True`, respectively.
20025
 
+  the same :attr:`tzinfo` attribute, the common :attr:`tzinfo` attribute is
20026
 
+  ignored and the base times are compared.  If both comparands are aware and
20027
 
+  have different :attr:`tzinfo` attributes, the comparands are first adjusted by
20028
 
+  subtracting their UTC offsets (obtained from ``self.utcoffset()``). In order
20029
 
+  to stop mixed-type comparisons from falling back to the default comparison by
20030
 
+  object address, when a :class:`time` object is compared to an object of a
20031
 
+  different type, :exc:`TypeError` is raised unless the comparison is ``==`` or
20032
 
+  ``!=``.  The latter cases return :const:`False` or :const:`True`, respectively.
20033
 
 
20034
 
 * hash, use as dict key
20035
 
 
20036
 
@@ -1231,10 +1234,10 @@
20037
 
 
20038
 
 .. method:: time.replace([hour[, minute[, second[, microsecond[, tzinfo]]]]])
20039
 
 
20040
 
-   Return a :class:`time` with the same value, except for those members given new
20041
 
-   values by whichever keyword arguments are specified.  Note that ``tzinfo=None``
20042
 
-   can be specified to create a naive :class:`time` from an aware :class:`time`,
20043
 
-   without conversion of the time members.
20044
 
+   Return a :class:`.time` with the same value, except for those attributes given
20045
 
+   new values by whichever keyword arguments are specified.  Note that
20046
 
+   ``tzinfo=None`` can be specified to create a naive :class:`.time` from an
20047
 
+   aware :class:`.time`, without conversion of the time data.
20048
 
 
20049
 
 
20050
 
 .. method:: time.isoformat()
20051
 
@@ -1317,7 +1320,7 @@
20052
 
 
20053
 
 An instance of (a concrete subclass of) :class:`tzinfo` can be passed to the
20054
 
 constructors for :class:`datetime` and :class:`time` objects. The latter objects
20055
 
-view their members as being in local time, and the :class:`tzinfo` object
20056
 
+view their attributes as being in local time, and the :class:`tzinfo` object
20057
 
 supports methods revealing offset of local time from UTC, the name of the time
20058
 
 zone, and DST offset, all relative to a date or time object passed to them.
20059
 
 
20060
 
@@ -1362,9 +1365,9 @@
20061
 
    already been added to the UTC offset returned by :meth:`utcoffset`, so there's
20062
 
    no need to consult :meth:`dst` unless you're interested in obtaining DST info
20063
 
    separately.  For example, :meth:`datetime.timetuple` calls its :attr:`tzinfo`
20064
 
-   member's :meth:`dst` method to determine how the :attr:`tm_isdst` flag should be
20065
 
-   set, and :meth:`tzinfo.fromutc` calls :meth:`dst` to account for DST changes
20066
 
-   when crossing time zones.
20067
 
+   attribute's :meth:`dst` method to determine how the :attr:`tm_isdst` flag
20068
 
+   should be set, and :meth:`tzinfo.fromutc` calls :meth:`dst` to account for
20069
 
+   DST changes when crossing time zones.
20070
 
 
20071
 
    An instance *tz* of a :class:`tzinfo` subclass that models both standard and
20072
 
    daylight times must be consistent in this sense:
20073
 
@@ -1382,13 +1385,13 @@
20074
 
 
20075
 
    Most implementations of :meth:`dst` will probably look like one of these two::
20076
 
 
20077
 
-      def dst(self):
20078
 
+      def dst(self, dt):
20079
 
           # a fixed-offset class:  doesn't account for DST
20080
 
           return timedelta(0)
20081
 
 
20082
 
    or ::
20083
 
 
20084
 
-      def dst(self):
20085
 
+      def dst(self, dt):
20086
 
           # Code to set dston and dstoff to the time zone's DST
20087
 
           # transition times based on the input dt.year, and expressed
20088
 
           # in standard local time.  Then
20089
 
@@ -1439,11 +1442,11 @@
20090
 
 
20091
 
 .. method:: tzinfo.fromutc(self, dt)
20092
 
 
20093
 
-   This is called from the default :class:`datetime.astimezone()` implementation.
20094
 
-   When called from that, ``dt.tzinfo`` is *self*, and *dt*'s date and time members
20095
 
-   are to be viewed as expressing a UTC time.  The purpose of :meth:`fromutc` is to
20096
 
-   adjust the date and time members, returning an equivalent datetime in *self*'s
20097
 
-   local time.
20098
 
+   This is called from the default :class:`datetime.astimezone()`
20099
 
+   implementation.  When called from that, ``dt.tzinfo`` is *self*, and *dt*'s
20100
 
+   date and time data are to be viewed as expressing a UTC time.  The purpose
20101
 
+   of :meth:`fromutc` is to adjust the date and time data, returning an
20102
 
+   equivalent datetime in *self*'s local time.
20103
 
 
20104
 
    Most :class:`tzinfo` subclasses should be able to inherit the default
20105
 
    :meth:`fromutc` implementation without problems.  It's strong enough to handle
20106
 
diff -r 8527427914a2 Doc/library/decimal.rst
20107
 
--- a/Doc/library/decimal.rst
20108
 
+++ b/Doc/library/decimal.rst
20109
 
@@ -35,7 +35,7 @@
20110
 
   people learn at school." -- excerpt from the decimal arithmetic specification.
20111
 
 
20112
 
 * Decimal numbers can be represented exactly.  In contrast, numbers like
20113
 
-  :const:`1.1` and :const:`2.2` do not have an exact representations in binary
20114
 
+  :const:`1.1` and :const:`2.2` do not have exact representations in binary
20115
 
   floating point.  End users typically would not expect ``1.1 + 2.2`` to display
20116
 
   as :const:`3.3000000000000003` as it does with binary floating point.
20117
 
 
20118
 
@@ -742,7 +742,7 @@
20119
 
 
20120
 
       Normalize the number by stripping the rightmost trailing zeros and
20121
 
       converting any result equal to :const:`Decimal('0')` to
20122
 
-      :const:`Decimal('0e0')`. Used for producing canonical values for members
20123
 
+      :const:`Decimal('0e0')`. Used for producing canonical values for attributes
20124
 
       of an equivalence class. For example, ``Decimal('32.100')`` and
20125
 
       ``Decimal('0.321000e+2')`` both normalize to the equivalent value
20126
 
       ``Decimal('32.1')``.
20127
 
diff -r 8527427914a2 Doc/library/dis.rst
20128
 
--- a/Doc/library/dis.rst
20129
 
+++ b/Doc/library/dis.rst
20130
 
@@ -1,21 +1,18 @@
20131
 
-
20132
 
 :mod:`dis` --- Disassembler for Python bytecode
20133
 
 ===============================================
20134
 
 
20135
 
 .. module:: dis
20136
 
    :synopsis: Disassembler for Python bytecode.
20137
 
 
20138
 
+**Source code:** :source:`Lib/dis.py`
20139
 
+
20140
 
+--------------
20141
 
 
20142
 
 The :mod:`dis` module supports the analysis of CPython :term:`bytecode` by
20143
 
 disassembling it. The CPython bytecode which this module takes as an
20144
 
 input is defined in the file :file:`Include/opcode.h` and used by the compiler
20145
 
 and the interpreter.
20146
 
 
20147
 
-.. seealso::
20148
 
-
20149
 
-   Latest version of the `dis module Python source code
20150
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/dis.py?view=markup>`_
20151
 
-
20152
 
 .. impl-detail::
20153
 
 
20154
 
    Bytecode is an implementation detail of the CPython interpreter!  No
20155
 
diff -r 8527427914a2 Doc/library/dl.rst
20156
 
--- a/Doc/library/dl.rst
20157
 
+++ b/Doc/library/dl.rst
20158
 
@@ -13,7 +13,7 @@
20159
 
 
20160
 
 .. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
20161
 
 
20162
 
-The :mod:`dl` module defines an interface to the :cfunc:`dlopen` function, which
20163
 
+The :mod:`dl` module defines an interface to the :c:func:`dlopen` function, which
20164
 
 is the most common interface on Unix platforms for handling dynamically linked
20165
 
 libraries. It allows the program to call arbitrary functions in such a library.
20166
 
 
20167
 
@@ -105,10 +105,10 @@
20168
 
    Call the function named *name* in the referenced shared object. The arguments
20169
 
    must be either Python integers, which will be  passed as is, Python strings, to
20170
 
    which a pointer will be passed,  or ``None``, which will be passed as *NULL*.
20171
 
-   Note that  strings should only be passed to functions as :ctype:`const char\*`,
20172
 
+   Note that  strings should only be passed to functions as :c:type:`const char\*`,
20173
 
    as Python will not like its string mutated.
20174
 
 
20175
 
    There must be at most 10 arguments, and arguments not given will be treated as
20176
 
-   ``None``. The function's return value must be a C :ctype:`long`, which is a
20177
 
+   ``None``. The function's return value must be a C :c:type:`long`, which is a
20178
 
    Python integer.
20179
 
 
20180
 
diff -r 8527427914a2 Doc/library/doctest.rst
20181
 
--- a/Doc/library/doctest.rst
20182
 
+++ b/Doc/library/doctest.rst
20183
 
@@ -1199,12 +1199,11 @@
20184
 
 .. class:: DocTest(examples, globs, name, filename, lineno, docstring)
20185
 
 
20186
 
    A collection of doctest examples that should be run in a single namespace.  The
20187
 
-   constructor arguments are used to initialize the member variables of the same
20188
 
-   names.
20189
 
+   constructor arguments are used to initialize the attributes of the same names.
20190
 
 
20191
 
    .. versionadded:: 2.4
20192
 
 
20193
 
-   :class:`DocTest` defines the following member variables.  They are initialized by
20194
 
+   :class:`DocTest` defines the following attributes.  They are initialized by
20195
 
    the constructor, and should not be modified directly.
20196
 
 
20197
 
 
20198
 
@@ -1257,12 +1256,12 @@
20199
 
 .. class:: Example(source, want[, exc_msg][, lineno][, indent][, options])
20200
 
 
20201
 
    A single interactive example, consisting of a Python statement and its expected
20202
 
-   output.  The constructor arguments are used to initialize the member variables
20203
 
-   of the same names.
20204
 
+   output.  The constructor arguments are used to initialize the attributes of the
20205
 
+   same names.
20206
 
 
20207
 
    .. versionadded:: 2.4
20208
 
 
20209
 
-   :class:`Example` defines the following member variables.  They are initialized by
20210
 
+   :class:`Example` defines the following attributes.  They are initialized by
20211
 
    the constructor, and should not be modified directly.
20212
 
 
20213
 
 
20214
 
@@ -1770,9 +1769,9 @@
20215
 
 
20216
 
    An exception raised by :class:`DocTestRunner` to signal that a doctest example's
20217
 
    actual output did not match its expected output. The constructor arguments are
20218
 
-   used to initialize the member variables of the same names.
20219
 
-
20220
 
-:exc:`DocTestFailure` defines the following member variables:
20221
 
+   used to initialize the attributes of the same names.
20222
 
+
20223
 
+:exc:`DocTestFailure` defines the following attributes:
20224
 
 
20225
 
 
20226
 
 .. attribute:: DocTestFailure.test
20227
 
@@ -1794,9 +1793,9 @@
20228
 
 
20229
 
    An exception raised by :class:`DocTestRunner` to signal that a doctest
20230
 
    example raised an unexpected exception.  The constructor arguments are used
20231
 
-   to initialize the member variables of the same names.
20232
 
-
20233
 
-:exc:`UnexpectedException` defines the following member variables:
20234
 
+   to initialize the attributes of the same names.
20235
 
+
20236
 
+:exc:`UnexpectedException` defines the following attributes:
20237
 
 
20238
 
 
20239
 
 .. attribute:: UnexpectedException.test
20240
 
diff -r 8527427914a2 Doc/library/dummy_thread.rst
20241
 
--- a/Doc/library/dummy_thread.rst
20242
 
+++ b/Doc/library/dummy_thread.rst
20243
 
@@ -10,6 +10,9 @@
20244
 
    converting your sources to 3.0; however, you should consider using the
20245
 
    high-lever :mod:`dummy_threading` module instead.
20246
 
 
20247
 
+**Source code:** :source:`Lib/dummy_thread.py`
20248
 
+
20249
 
+--------------
20250
 
 
20251
 
 This module provides a duplicate interface to the :mod:`thread` module.  It is
20252
 
 meant to be imported when the :mod:`thread` module is not provided on a
20253
 
diff -r 8527427914a2 Doc/library/dummy_threading.rst
20254
 
--- a/Doc/library/dummy_threading.rst
20255
 
+++ b/Doc/library/dummy_threading.rst
20256
 
@@ -1,10 +1,12 @@
20257
 
-
20258
 
 :mod:`dummy_threading` --- Drop-in replacement for the :mod:`threading` module
20259
 
 ==============================================================================
20260
 
 
20261
 
 .. module:: dummy_threading
20262
 
    :synopsis: Drop-in replacement for the threading module.
20263
 
 
20264
 
+**Source code:** :source:`Lib/dummy_threading.py`
20265
 
+
20266
 
+--------------
20267
 
 
20268
 
 This module provides a duplicate interface to the :mod:`threading` module.  It
20269
 
 is meant to be imported when the :mod:`thread` module is not provided on a
20270
 
diff -r 8527427914a2 Doc/library/easydialogs.rst
20271
 
--- a/Doc/library/easydialogs.rst
20272
 
+++ b/Doc/library/easydialogs.rst
20273
 
@@ -143,7 +143,7 @@
20274
 
 
20275
 
 .. seealso::
20276
 
 
20277
 
-   `Navigation Services Reference <http://developer.apple.com/documentation/Carbon/Reference/Navigation_Services_Ref/>`_
20278
 
+   `Navigation Services Reference <http://developer.apple.com/legacy/mac/library/#documentation/Carbon/Conceptual/NavServicesIntro/ns_intro_carb/ns_into_carb.html>`_
20279
 
       Programmer's reference documentation for the Navigation Services, a part of the
20280
 
       Carbon framework.
20281
 
 
20282
 
diff -r 8527427914a2 Doc/library/email.message.rst
20283
 
--- a/Doc/library/email.message.rst
20284
 
+++ b/Doc/library/email.message.rst
20285
 
@@ -295,7 +295,7 @@
20286
 
 
20287
 
          Content-Disposition: attachment; filename="bud.gif"
20288
 
 
20289
 
-      An example with with non-ASCII characters::
20290
 
+      An example with non-ASCII characters::
20291
 
 
20292
 
          msg.add_header('Content-Disposition', 'attachment',
20293
 
                         filename=('iso-8859-1', '', 'Fußballer.ppt'))
20294
 
diff -r 8527427914a2 Doc/library/email.mime.rst
20295
 
--- a/Doc/library/email.mime.rst
20296
 
+++ b/Doc/library/email.mime.rst
20297
 
@@ -196,6 +196,6 @@
20298
 
 
20299
 
    .. versionchanged:: 2.4
20300
 
       The previously deprecated *_encoding* argument has been removed.  Content
20301
 
-      Transfer Encoding now happens happens implicitly based on the *_charset*
20302
 
+      Transfer Encoding now happens implicitly based on the *_charset*
20303
 
       argument.
20304
 
 
20305
 
diff -r 8527427914a2 Doc/library/email.parser.rst
20306
 
--- a/Doc/library/email.parser.rst
20307
 
+++ b/Doc/library/email.parser.rst
20308
 
@@ -135,7 +135,9 @@
20309
 
       data or by a blank line.  Following the header block is the body of the
20310
 
       message (which may contain MIME-encoded subparts).
20311
 
 
20312
 
-      Optional *headersonly* is as with the :meth:`parse` method.
20313
 
+      Optional *headersonly* is a flag specifying whether to stop parsing after
20314
 
+      reading the headers or not.  The default is ``False``, meaning it parses
20315
 
+      the entire contents of the file.
20316
 
 
20317
 
       .. versionchanged:: 2.2.2
20318
 
          The *headersonly* flag was added.
20319
 
@@ -148,9 +150,7 @@
20320
 
       equivalent to wrapping *text* in a :class:`StringIO` instance first and
20321
 
       calling :meth:`parse`.
20322
 
 
20323
 
-      Optional *headersonly* is a flag specifying whether to stop parsing after
20324
 
-      reading the headers or not.  The default is ``False``, meaning it parses
20325
 
-      the entire contents of the file.
20326
 
+      Optional *headersonly* is as with the :meth:`parse` method.
20327
 
 
20328
 
       .. versionchanged:: 2.2.2
20329
 
          The *headersonly* flag was added.
20330
 
diff -r 8527427914a2 Doc/library/exceptions.rst
20331
 
--- a/Doc/library/exceptions.rst
20332
 
+++ b/Doc/library/exceptions.rst
20333
 
@@ -220,7 +220,7 @@
20334
 
    Raised when an operation runs out of memory but the situation may still be
20335
 
    rescued (by deleting some objects).  The associated value is a string indicating
20336
 
    what kind of (internal) operation ran out of memory. Note that because of the
20337
 
-   underlying memory management architecture (C's :cfunc:`malloc` function), the
20338
 
+   underlying memory management architecture (C's :c:func:`malloc` function), the
20339
 
    interpreter may not always be able to completely recover from this situation; it
20340
 
    nevertheless raises an exception so that a stack traceback can be printed, in
20341
 
    case a run-away program was the cause.
20342
 
@@ -249,8 +249,8 @@
20343
 
    This exception is derived from :exc:`EnvironmentError`.  It is raised when a
20344
 
    function returns a system-related error (not for illegal argument types or
20345
 
    other incidental errors).  The :attr:`errno` attribute is a numeric error
20346
 
-   code from :cdata:`errno`, and the :attr:`strerror` attribute is the
20347
 
-   corresponding string, as would be printed by the C function :cfunc:`perror`.
20348
 
+   code from :c:data:`errno`, and the :attr:`strerror` attribute is the
20349
 
+   corresponding string, as would be printed by the C function :c:func:`perror`.
20350
 
    See the module :mod:`errno`, which contains names for the error codes defined
20351
 
    by the underlying operating system.
20352
 
 
20353
 
@@ -342,7 +342,7 @@
20354
 
    This exception is raised by the :func:`sys.exit` function.  When it is not
20355
 
    handled, the Python interpreter exits; no stack traceback is printed.  If the
20356
 
    associated value is a plain integer, it specifies the system exit status (passed
20357
 
-   to C's :cfunc:`exit` function); if it is ``None``, the exit status is zero; if
20358
 
+   to C's :c:func:`exit` function); if it is ``None``, the exit status is zero; if
20359
 
    it has another type (such as a string), the object's value is printed and the
20360
 
    exit status is one.
20361
 
 
20362
 
@@ -429,16 +429,16 @@
20363
 
 .. exception:: WindowsError
20364
 
 
20365
 
    Raised when a Windows-specific error occurs or when the error number does not
20366
 
-   correspond to an :cdata:`errno` value.  The :attr:`winerror` and
20367
 
+   correspond to an :c:data:`errno` value.  The :attr:`winerror` and
20368
 
    :attr:`strerror` values are created from the return values of the
20369
 
-   :cfunc:`GetLastError` and :cfunc:`FormatMessage` functions from the Windows
20370
 
+   :c:func:`GetLastError` and :c:func:`FormatMessage` functions from the Windows
20371
 
    Platform API. The :attr:`errno` value maps the :attr:`winerror` value to
20372
 
    corresponding ``errno.h`` values. This is a subclass of :exc:`OSError`.
20373
 
 
20374
 
    .. versionadded:: 2.0
20375
 
 
20376
 
    .. versionchanged:: 2.5
20377
 
-      Previous versions put the :cfunc:`GetLastError` codes into :attr:`errno`.
20378
 
+      Previous versions put the :c:func:`GetLastError` codes into :attr:`errno`.
20379
 
 
20380
 
 
20381
 
 .. exception:: ZeroDivisionError
20382
 
diff -r 8527427914a2 Doc/library/fcntl.rst
20383
 
--- a/Doc/library/fcntl.rst
20384
 
+++ b/Doc/library/fcntl.rst
20385
 
@@ -13,7 +13,7 @@
20386
 
    pair: UNIX; I/O control
20387
 
 
20388
 
 This module performs file control and I/O control on file descriptors. It is an
20389
 
-interface to the :cfunc:`fcntl` and :cfunc:`ioctl` Unix routines.
20390
 
+interface to the :c:func:`fcntl` and :c:func:`ioctl` Unix routines.
20391
 
 
20392
 
 All functions in this module take a file descriptor *fd* as their first
20393
 
 argument.  This can be an integer file descriptor, such as returned by
20394
 
@@ -31,17 +31,17 @@
20395
 
    :mod:`fcntl` module. The argument *arg* is optional, and defaults to the integer
20396
 
    value ``0``.  When present, it can either be an integer value, or a string.
20397
 
    With the argument missing or an integer value, the return value of this function
20398
 
-   is the integer return value of the C :cfunc:`fcntl` call.  When the argument is
20399
 
+   is the integer return value of the C :c:func:`fcntl` call.  When the argument is
20400
 
    a string it represents a binary structure, e.g. created by :func:`struct.pack`.
20401
 
    The binary data is copied to a buffer whose address is passed to the C
20402
 
-   :cfunc:`fcntl` call.  The return value after a successful call is the contents
20403
 
+   :c:func:`fcntl` call.  The return value after a successful call is the contents
20404
 
    of the buffer, converted to a string object.  The length of the returned string
20405
 
    will be the same as the length of the *arg* argument.  This is limited to 1024
20406
 
    bytes.  If the information returned in the buffer by the operating system is
20407
 
    larger than 1024 bytes, this is most likely to result in a segmentation
20408
 
    violation or a more subtle data corruption.
20409
 
 
20410
 
-   If the :cfunc:`fcntl` fails, an :exc:`IOError` is raised.
20411
 
+   If the :c:func:`fcntl` fails, an :exc:`IOError` is raised.
20412
 
 
20413
 
 
20414
 
 .. function:: ioctl(fd, op[, arg[, mutate_flag]])
20415
 
@@ -97,7 +97,7 @@
20416
 
    Perform the lock operation *op* on file descriptor *fd* (file objects providing
20417
 
    a :meth:`fileno` method are accepted as well). See the Unix manual
20418
 
    :manpage:`flock(2)` for details.  (On some systems, this function is emulated
20419
 
-   using :cfunc:`fcntl`.)
20420
 
+   using :c:func:`fcntl`.)
20421
 
 
20422
 
 
20423
 
 .. function:: lockf(fd, operation, [length, [start, [whence]]])
20424
 
diff -r 8527427914a2 Doc/library/filecmp.rst
20425
 
--- a/Doc/library/filecmp.rst
20426
 
+++ b/Doc/library/filecmp.rst
20427
 
@@ -1,4 +1,3 @@
20428
 
-
20429
 
 :mod:`filecmp` --- File and Directory Comparisons
20430
 
 =================================================
20431
 
 
20432
 
@@ -6,16 +5,14 @@
20433
 
    :synopsis: Compare files efficiently.
20434
 
 .. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
20435
 
 
20436
 
+**Source code:** :source:`Lib/filecmp.py`
20437
 
+
20438
 
+--------------
20439
 
 
20440
 
 The :mod:`filecmp` module defines functions to compare files and directories,
20441
 
 with various optional time/correctness trade-offs. For comparing files,
20442
 
 see also the :mod:`difflib` module.
20443
 
 
20444
 
-.. seealso::
20445
 
-
20446
 
-   Latest version of the `filecmp Python source code
20447
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/filecmp.py?view=markup>`_
20448
 
-
20449
 
 The :mod:`filecmp` module defines the following functions:
20450
 
 
20451
 
 
20452
 
diff -r 8527427914a2 Doc/library/fileinput.rst
20453
 
--- a/Doc/library/fileinput.rst
20454
 
+++ b/Doc/library/fileinput.rst
20455
 
@@ -6,6 +6,9 @@
20456
 
 .. moduleauthor:: Guido van Rossum <guido@python.org>
20457
 
 .. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
20458
 
 
20459
 
+**Source code:** :source:`Lib/fileinput.py`
20460
 
+
20461
 
+--------------
20462
 
 
20463
 
 This module implements a helper class and functions to quickly write a
20464
 
 loop over standard input or a list of files. If you just want to read or
20465
 
@@ -44,11 +47,6 @@
20466
 
 returns an accordingly opened file-like object. Two useful hooks are already
20467
 
 provided by this module.
20468
 
 
20469
 
-.. seealso::
20470
 
-
20471
 
-   Latest version of the `fileinput Python source code
20472
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/fileinput.py?view=markup>`_
20473
 
-
20474
 
 The following function is the primary interface of this module:
20475
 
 
20476
 
 
20477
 
diff -r 8527427914a2 Doc/library/fl.rst
20478
 
--- a/Doc/library/fl.rst
20479
 
+++ b/Doc/library/fl.rst
20480
 
@@ -29,8 +29,8 @@
20481
 
 the 'current form' maintained by the library to which new FORMS objects are
20482
 
 added, all functions that add a FORMS object to a form are methods of the Python
20483
 
 object representing the form. Consequently, there are no Python equivalents for
20484
 
-the C functions :cfunc:`fl_addto_form` and :cfunc:`fl_end_form`, and the
20485
 
-equivalent of :cfunc:`fl_bgn_form` is called :func:`fl.make_form`.
20486
 
+the C functions :c:func:`fl_addto_form` and :c:func:`fl_end_form`, and the
20487
 
+equivalent of :c:func:`fl_bgn_form` is called :func:`fl.make_form`.
20488
 
 
20489
 
 Watch out for the somewhat confusing terminology: FORMS uses the word
20490
 
 :dfn:`object` for the buttons, sliders etc. that you can place in a form. In
20491
 
@@ -44,7 +44,7 @@
20492
 
 event handling is available, though, so you can mix FORMS with pure GL windows.
20493
 
 
20494
 
 **Please note:** importing :mod:`fl` implies a call to the GL function
20495
 
-:cfunc:`foreground` and to the FORMS routine :cfunc:`fl_init`.
20496
 
+:c:func:`foreground` and to the FORMS routine :c:func:`fl_init`.
20497
 
 
20498
 
 
20499
 
 .. _fl-functions:
20500
 
@@ -88,7 +88,7 @@
20501
 
 .. function:: get_rgbmode()
20502
 
 
20503
 
    Return the current rgb mode.  This is the value of the C global variable
20504
 
-   :cdata:`fl_rgbmode`.
20505
 
+   :c:data:`fl_rgbmode`.
20506
 
 
20507
 
 
20508
 
 .. function:: show_message(str1, str2, str3)
20509
 
@@ -153,8 +153,8 @@
20510
 
               mapcolor()
20511
 
               getmcolor()
20512
 
 
20513
 
-   See the description in the FORMS documentation of :cfunc:`fl_color`,
20514
 
-   :cfunc:`fl_mapcolor` and :cfunc:`fl_getmcolor`.
20515
 
+   See the description in the FORMS documentation of :c:func:`fl_color`,
20516
 
+   :c:func:`fl_mapcolor` and :c:func:`fl_getmcolor`.
20517
 
 
20518
 
 
20519
 
 .. _form-objects:
20520
 
diff -r 8527427914a2 Doc/library/fm.rst
20521
 
--- a/Doc/library/fm.rst
20522
 
+++ b/Doc/library/fm.rst
20523
 
@@ -30,7 +30,7 @@
20524
 
 
20525
 
 .. function:: init()
20526
 
 
20527
 
-   Initialization function. Calls :cfunc:`fminit`. It is normally not necessary to
20528
 
+   Initialization function. Calls :c:func:`fminit`. It is normally not necessary to
20529
 
    call this function, since it is called automatically the first time the
20530
 
    :mod:`fm` module is imported.
20531
 
 
20532
 
@@ -43,7 +43,7 @@
20533
 
 .. function:: enumerate()
20534
 
 
20535
 
    Returns a list of available font names. This is an interface to
20536
 
-   :cfunc:`fmenumerate`.
20537
 
+   :c:func:`fmenumerate`.
20538
 
 
20539
 
 
20540
 
 .. function:: prstr(string)
20541
 
diff -r 8527427914a2 Doc/library/fnmatch.rst
20542
 
--- a/Doc/library/fnmatch.rst
20543
 
+++ b/Doc/library/fnmatch.rst
20544
 
@@ -1,4 +1,3 @@
20545
 
-
20546
 
 :mod:`fnmatch` --- Unix filename pattern matching
20547
 
 =================================================
20548
 
 
20549
 
@@ -10,6 +9,10 @@
20550
 
 
20551
 
 .. index:: module: re
20552
 
 
20553
 
+**Source code:** :source:`Lib/fnmatch.py`
20554
 
+
20555
 
+--------------
20556
 
+
20557
 
 This module provides support for Unix shell-style wildcards, which are *not* the
20558
 
 same as regular expressions (which are documented in the :mod:`re` module).  The
20559
 
 special characters used in shell-style wildcards are:
20560
 
@@ -34,10 +37,6 @@
20561
 
 a period are not special for this module, and are matched by the ``*`` and ``?``
20562
 
 patterns.
20563
 
 
20564
 
-.. seealso::
20565
 
-
20566
 
-   Latest version of the `fnmatch Python source code
20567
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/fnmatch.py?view=markup>`_
20568
 
 
20569
 
 .. function:: fnmatch(filename, pattern)
20570
 
 
20571
 
@@ -95,4 +94,3 @@
20572
 
 
20573
 
    Module :mod:`glob`
20574
 
       Unix shell-style path expansion.
20575
 
-
20576
 
diff -r 8527427914a2 Doc/library/fractions.rst
20577
 
--- a/Doc/library/fractions.rst
20578
 
+++ b/Doc/library/fractions.rst
20579
 
@@ -1,4 +1,3 @@
20580
 
-
20581
 
 :mod:`fractions` --- Rational numbers
20582
 
 =====================================
20583
 
 
20584
 
@@ -8,6 +7,9 @@
20585
 
 .. sectionauthor:: Jeffrey Yasskin <jyasskin at gmail.com>
20586
 
 .. versionadded:: 2.6
20587
 
 
20588
 
+**Source code:** :source:`Lib/fractions.py`
20589
 
+
20590
 
+--------------
20591
 
 
20592
 
 The :mod:`fractions` module provides support for rational number arithmetic.
20593
 
 
20594
 
diff -r 8527427914a2 Doc/library/ftplib.rst
20595
 
--- a/Doc/library/ftplib.rst
20596
 
+++ b/Doc/library/ftplib.rst
20597
 
@@ -9,6 +9,10 @@
20598
 
    pair: FTP; protocol
20599
 
    single: FTP; ftplib (standard module)
20600
 
 
20601
 
+**Source code:** :source:`Lib/ftplib.py`
20602
 
+
20603
 
+--------------
20604
 
+
20605
 
 This module defines the class :class:`FTP` and a few related items. The
20606
 
 :class:`FTP` class implements the client side of the FTP protocol.  You can use
20607
 
 this to write Python programs that perform a variety of automated FTP jobs, such
20608
 
diff -r 8527427914a2 Doc/library/functions.rst
20609
 
--- a/Doc/library/functions.rst
20610
 
+++ b/Doc/library/functions.rst
20611
 
@@ -123,6 +123,8 @@
20612
 
 
20613
 
    Without an argument, an array of size 0 is created.
20614
 
 
20615
 
+   .. versionadded:: 2.6
20616
 
+
20617
 
 
20618
 
 .. function:: callable(object)
20619
 
 
20620
 
@@ -298,19 +300,18 @@
20621
 
    The resulting list is sorted alphabetically.  For example:
20622
 
 
20623
 
       >>> import struct
20624
 
-      >>> dir()   # doctest: +SKIP
20625
 
+      >>> dir()   # show the names in the module namespace
20626
 
       ['__builtins__', '__doc__', '__name__', 'struct']
20627
 
-      >>> dir(struct)   # doctest: +NORMALIZE_WHITESPACE
20628
 
+      >>> dir(struct)   # show the names in the struct module
20629
 
       ['Struct', '__builtins__', '__doc__', '__file__', '__name__',
20630
 
        '__package__', '_clearcache', 'calcsize', 'error', 'pack', 'pack_into',
20631
 
        'unpack', 'unpack_from']
20632
 
-      >>> class Foo(object):
20633
 
-      ...     def __dir__(self):
20634
 
-      ...         return ["kan", "ga", "roo"]
20635
 
-      ...
20636
 
-      >>> f = Foo()
20637
 
-      >>> dir(f)
20638
 
-      ['ga', 'kan', 'roo']
20639
 
+      >>> class Shape(object):
20640
 
+              def __dir__(self):
20641
 
+                  return ['area', 'perimeter', 'location']
20642
 
+      >>> s = Shape()
20643
 
+      >>> dir(s)
20644
 
+      ['area', 'perimeter', 'location']
20645
 
 
20646
 
    .. note::
20647
 
 
20648
 
@@ -342,20 +343,25 @@
20649
 
    :term:`iterator`, or some other object which supports iteration.  The
20650
 
    :meth:`!next` method of the iterator returned by :func:`enumerate` returns a
20651
 
    tuple containing a count (from *start* which defaults to 0) and the
20652
 
-   corresponding value obtained from iterating over *iterable*.
20653
 
-   :func:`enumerate` is useful for obtaining an indexed series: ``(0, seq[0])``,
20654
 
-   ``(1, seq[1])``, ``(2, seq[2])``, .... For example:
20655
 
+   values obtained from iterating over *sequence*::
20656
 
 
20657
 
-      >>> for i, season in enumerate(['Spring', 'Summer', 'Fall', 'Winter']):
20658
 
-      ...     print i, season
20659
 
-      0 Spring
20660
 
-      1 Summer
20661
 
-      2 Fall
20662
 
-      3 Winter
20663
 
+      >>> seasons = ['Spring', 'Summer', 'Fall', 'Winter']
20664
 
+      >>> list(enumerate(seasons))
20665
 
+      [(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')]
20666
 
+      >>> list(enumerate(seasons, start=1))
20667
 
+      [(1, 'Spring'), (2, 'Summer'), (3, 'Fall'), (4, 'Winter')]
20668
 
+
20669
 
+   Equivalent to::
20670
 
+
20671
 
+      def enumerate(sequence, start=0):
20672
 
+          n = start
20673
 
+          for elem in sequence:
20674
 
+              yield n, elem
20675
 
+              n += 1
20676
 
 
20677
 
    .. versionadded:: 2.3
20678
 
-   .. versionadded:: 2.6
20679
 
-      The *start* parameter.
20680
 
+   .. versionchanged:: 2.6
20681
 
+      The *start* parameter was added.
20682
 
 
20683
 
 
20684
 
 .. function:: eval(expression[, globals[, locals]])
20685
 
@@ -579,20 +585,16 @@
20686
 
    Two objects with non-overlapping lifetimes may have the same :func:`id`
20687
 
    value.
20688
 
 
20689
 
-   .. impl-detail:: This is the address of the object.
20690
 
+   .. impl-detail:: This is the address of the object in memory.
20691
 
 
20692
 
 
20693
 
 .. function:: input([prompt])
20694
 
 
20695
 
    Equivalent to ``eval(raw_input(prompt))``.
20696
 
 
20697
 
-   .. warning::
20698
 
-
20699
 
-      This function is not safe from user errors!  It expects a valid Python
20700
 
-      expression as input; if the input is not syntactically valid, a
20701
 
-      :exc:`SyntaxError` will be raised. Other exceptions may be raised if there is an
20702
 
-      error during evaluation.  (On the other hand, sometimes this is exactly what you
20703
 
-      need when writing a quick script for expert use.)
20704
 
+   This function does not catch user errors. If the input is not syntactically
20705
 
+   valid, a :exc:`SyntaxError` will be raised. Other exceptions may be raised if
20706
 
+   there is an error during evaluation.
20707
 
 
20708
 
    If the :mod:`readline` module was loaded, then :func:`input` will use it to
20709
 
    provide elaborate line editing and history features.
20710
 
@@ -621,9 +623,11 @@
20711
 
 .. function:: isinstance(object, classinfo)
20712
 
 
20713
 
    Return true if the *object* argument is an instance of the *classinfo* argument,
20714
 
-   or of a (direct or indirect) subclass thereof.  Also return true if *classinfo*
20715
 
+   or of a (direct, indirect or :term:`virtual <abstract base class>`) subclass
20716
 
+   thereof.  Also return true if *classinfo*
20717
 
    is a type object (new-style class) and *object* is an object of that type or of
20718
 
-   a (direct or indirect) subclass thereof.  If *object* is not a class instance or
20719
 
+   a (direct, indirect or :term:`virtual <abstract base class>`) subclass
20720
 
+   thereof.  If *object* is not a class instance or
20721
 
    an object of the given type, the function always returns false.  If *classinfo*
20722
 
    is neither a class object nor a type object, it may be a tuple of class or type
20723
 
    objects, or may recursively contain other such tuples (other sequence types are
20724
 
@@ -636,7 +640,8 @@
20725
 
 
20726
 
 .. function:: issubclass(class, classinfo)
20727
 
 
20728
 
-   Return true if *class* is a subclass (direct or indirect) of *classinfo*.  A
20729
 
+   Return true if *class* is a subclass (direct, indirect or :term:`virtual
20730
 
+   <abstract base class>`) of *classinfo*.  A
20731
 
    class is considered a subclass of itself. *classinfo* may be a tuple of class
20732
 
    objects, in which case every entry in *classinfo* will be checked. In any other
20733
 
    case, a :exc:`TypeError` exception is raised.
20734
 
@@ -660,10 +665,10 @@
20735
 
 
20736
 
    One useful application of the second form of :func:`iter` is to read lines of
20737
 
    a file until a certain line is reached.  The following example reads a file
20738
 
-   until ``"STOP"`` is reached: ::
20739
 
+   until the :meth:`readline` method returns an empty string::
20740
 
 
20741
 
-      with open("mydata.txt") as fp:
20742
 
-          for line in iter(fp.readline, "STOP"):
20743
 
+      with open('mydata.txt') as fp:
20744
 
+          for line in iter(fp.readline, ''):
20745
 
               process_line(line)
20746
 
 
20747
 
    .. versionadded:: 2.2
20748
 
@@ -793,15 +798,15 @@
20749
 
       Formerly only returned an unsigned literal.
20750
 
 
20751
 
 
20752
 
-.. function:: open(filename[, mode[, bufsize]])
20753
 
+.. function:: open(name[, mode[, buffering]])
20754
 
 
20755
 
    Open a file, returning an object of the :class:`file` type described in
20756
 
    section :ref:`bltin-file-objects`.  If the file cannot be opened,
20757
 
    :exc:`IOError` is raised.  When opening a file, it's preferable to use
20758
 
    :func:`open` instead of invoking the :class:`file` constructor directly.
20759
 
 
20760
 
-   The first two arguments are the same as for ``stdio``'s :cfunc:`fopen`:
20761
 
-   *filename* is the file name to be opened, and *mode* is a string indicating how
20762
 
+   The first two arguments are the same as for ``stdio``'s :c:func:`fopen`:
20763
 
+   *name* is the file name to be opened, and *mode* is a string indicating how
20764
 
    the file is to be opened.
20765
 
 
20766
 
    The most commonly-used values of *mode* are ``'r'`` for reading, ``'w'`` for
20767
 
@@ -822,9 +827,9 @@
20768
 
       single: buffer size, I/O
20769
 
       single: I/O control; buffering
20770
 
 
20771
 
-   The optional *bufsize* argument specifies the file's desired buffer size: 0
20772
 
+   The optional *buffering* argument specifies the file's desired buffer size: 0
20773
 
    means unbuffered, 1 means line buffered, any other positive value means use a
20774
 
-   buffer of (approximately) that size.  A negative *bufsize* means to use the
20775
 
+   buffer of (approximately) that size.  A negative *buffering* means to use the
20776
 
    system default, which is usually line buffered for tty devices and fully
20777
 
    buffered for other files.  If omitted, the system default is used. [#]_
20778
 
 
20779
 
@@ -833,7 +838,7 @@
20780
 
    binary mode, on systems that differentiate between binary and text files; on
20781
 
    systems that don't have this distinction, adding the ``'b'`` has no effect.
20782
 
 
20783
 
-   In addition to the standard :cfunc:`fopen` values *mode* may be ``'U'`` or
20784
 
+   In addition to the standard :c:func:`fopen` values *mode* may be ``'U'`` or
20785
 
    ``'rU'``.  Python is usually built with universal newline support; supplying
20786
 
    ``'U'`` opens the file as a text file, but lines may be terminated by any of the
20787
 
    following: the Unix end-of-line convention ``'\n'``,  the Macintosh convention
20788
 
@@ -902,7 +907,9 @@
20789
 
    *end*.
20790
 
 
20791
 
    The *file* argument must be an object with a ``write(string)`` method; if it
20792
 
-   is not present or ``None``, :data:`sys.stdout` will be used.
20793
 
+   is not present or ``None``, :data:`sys.stdout` will be used.  Output buffering
20794
 
+   is determined by *file*.  Use ``file.flush()`` to ensure, for instance,
20795
 
+   immediate appearance on a screen.
20796
 
 
20797
 
    .. note::
20798
 
 
20799
 
@@ -1048,7 +1055,19 @@
20800
 
    it is placed before the items of the iterable in the calculation, and serves as
20801
 
    a default when the iterable is empty.  If *initializer* is not given and
20802
 
    *iterable* contains only one item, the first item is returned.
20803
 
+   Roughly equivalent to::
20804
 
 
20805
 
+      def reduce(function, iterable, initializer=None):
20806
 
+          it = iter(iterable)
20807
 
+          if initializer is None:
20808
 
+              try:
20809
 
+                  initializer = next(it)
20810
 
+              except StopIteration:
20811
 
+                  raise TypeError('reduce() of empty sequence with no initial value')
20812
 
+          accum_value = initializer
20813
 
+          for x in iterable:
20814
 
+              accum_value = function(accum_value, x)
20815
 
+          return accum_value
20816
 
 
20817
 
 .. function:: reload(module)
20818
 
 
20819
 
@@ -1241,8 +1260,9 @@
20820
 
    It can be called either on the class (such as ``C.f()``) or on an instance (such
20821
 
    as ``C().f()``).  The instance is ignored except for its class.
20822
 
 
20823
 
-   Static methods in Python are similar to those found in Java or C++. For a more
20824
 
-   advanced concept, see :func:`classmethod` in this section.
20825
 
+   Static methods in Python are similar to those found in Java or C++. Also see
20826
 
+   :func:`classmethod` for a variant that is useful for creating alternate
20827
 
+   class constructors.
20828
 
 
20829
 
    For more information on static methods, consult the documentation on the
20830
 
    standard type hierarchy in :ref:`types`.
20831
 
@@ -1335,6 +1355,10 @@
20832
 
    argument form specifies the arguments exactly and makes the appropriate
20833
 
    references.
20834
 
 
20835
 
+   For practical suggestions on how to design cooperative classes using
20836
 
+   :func:`super`, see `guide to using super()
20837
 
+   <http://rhettinger.wordpress.com/2011/05/26/super-considered-super/>`_.
20838
 
+
20839
 
    .. versionadded:: 2.2
20840
 
 
20841
 
 
20842
 
@@ -1434,15 +1458,17 @@
20843
 
 
20844
 
 .. function:: vars([object])
20845
 
 
20846
 
-   Without an argument, act like :func:`locals`.
20847
 
+   Return the :attr:`__dict__` attribute for a module, class, instance,
20848
 
+   or any other object with a :attr:`__dict__` attribute.
20849
 
 
20850
 
-   With a module, class or class instance object as argument (or anything else that
20851
 
-   has a :attr:`__dict__` attribute), return that attribute.
20852
 
+   Objects such as modules and instances have an updateable :attr:`__dict__`
20853
 
+   attribute; however, other objects may have write restrictions on their
20854
 
+   :attr:`__dict__` attributes (for example, new-style classes use a
20855
 
+   dictproxy to prevent direct dictionary updates).
20856
 
 
20857
 
-   .. note::
20858
 
-
20859
 
-      The returned dictionary should not be modified:
20860
 
-      the effects on the corresponding symbol table are undefined. [#]_
20861
 
+   Without an argument, :func:`vars` acts like :func:`locals`.  Note, the
20862
 
+   locals dictionary is only useful for reads since updates to the locals
20863
 
+   dictionary are ignored.
20864
 
 
20865
 
 
20866
 
 .. function:: xrange([start,] stop[, step])
20867
 
@@ -1645,8 +1671,8 @@
20868
 
 .. [#] It is used relatively rarely so does not warrant being made into a statement.
20869
 
 
20870
 
 .. [#] Specifying a buffer size currently has no effect on systems that don't have
20871
 
-   :cfunc:`setvbuf`.  The interface to specify the buffer size is not done using a
20872
 
-   method that calls :cfunc:`setvbuf`, because that may dump core when called after
20873
 
+   :c:func:`setvbuf`.  The interface to specify the buffer size is not done using a
20874
 
+   method that calls :c:func:`setvbuf`, because that may dump core when called after
20875
 
    any I/O has been performed, and there's no reliable way to determine whether
20876
 
    this is the case.
20877
 
 
20878
 
diff -r 8527427914a2 Doc/library/functools.rst
20879
 
--- a/Doc/library/functools.rst
20880
 
+++ b/Doc/library/functools.rst
20881
 
@@ -1,37 +1,35 @@
20882
 
-:mod:`functools` --- Higher order functions and operations on callable objects
20883
 
+:mod:`functools` --- Higher-order functions and operations on callable objects
20884
 
 ==============================================================================
20885
 
 
20886
 
 .. module:: functools
20887
 
-   :synopsis: Higher order functions and operations on callable objects.
20888
 
+   :synopsis: Higher-order functions and operations on callable objects.
20889
 
 .. moduleauthor:: Peter Harris <scav@blueyonder.co.uk>
20890
 
 .. moduleauthor:: Raymond Hettinger <python@rcn.com>
20891
 
 .. moduleauthor:: Nick Coghlan <ncoghlan@gmail.com>
20892
 
 .. sectionauthor:: Peter Harris <scav@blueyonder.co.uk>
20893
 
 
20894
 
+.. versionadded:: 2.5
20895
 
 
20896
 
-.. versionadded:: 2.5
20897
 
+**Source code:** :source:`Lib/functools.py`
20898
 
+
20899
 
+--------------
20900
 
 
20901
 
 The :mod:`functools` module is for higher-order functions: functions that act on
20902
 
 or return other functions. In general, any callable object can be treated as a
20903
 
 function for the purposes of this module.
20904
 
 
20905
 
-.. seealso::
20906
 
-
20907
 
-   Latest version of the `functools Python source code
20908
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/functools.py?view=markup>`_
20909
 
-
20910
 
 The :mod:`functools` module defines the following functions:
20911
 
 
20912
 
 ..  function:: cmp_to_key(func)
20913
 
 
20914
 
-   Transform an old-style comparison function to a key-function.  Used with
20915
 
+   Transform an old-style comparison function to a key function.  Used with
20916
 
    tools that accept key functions (such as :func:`sorted`, :func:`min`,
20917
 
    :func:`max`, :func:`heapq.nlargest`, :func:`heapq.nsmallest`,
20918
 
    :func:`itertools.groupby`).  This function is primarily used as a transition
20919
 
-   tool for programs being converted to Py3.x where comparison functions are no
20920
 
-   longer supported.
20921
 
+   tool for programs being converted to Python 3 where comparison functions are
20922
 
+   no longer supported.
20923
 
 
20924
 
-   A compare function is any callable that accept two arguments, compares them,
20925
 
+   A comparison function is any callable that accept two arguments, compares them,
20926
 
    and returns a negative number for less-than, zero for equality, or a positive
20927
 
    number for greater-than.  A key function is a callable that accepts one
20928
 
    argument and returns another value that indicates the position in the desired
20929
 
diff -r 8527427914a2 Doc/library/getopt.rst
20930
 
--- a/Doc/library/getopt.rst
20931
 
+++ b/Doc/library/getopt.rst
20932
 
@@ -1,4 +1,3 @@
20933
 
-
20934
 
 :mod:`getopt` --- C-style parser for command line options
20935
 
 =========================================================
20936
 
 
20937
 
@@ -6,22 +5,23 @@
20938
 
    :synopsis: Portable parser for command line options; support both short and long option
20939
 
               names.
20940
 
 
20941
 
+**Source code:** :source:`Lib/getopt.py`
20942
 
+
20943
 
+--------------
20944
 
+
20945
 
 .. note::
20946
 
    The :mod:`getopt` module is a parser for command line options whose API is
20947
 
-   designed to be familiar to users of the C :cfunc:`getopt` function. Users who
20948
 
-   are unfamiliar with the C :cfunc:`getopt` function or who would like to write
20949
 
+   designed to be familiar to users of the C :c:func:`getopt` function. Users who
20950
 
+   are unfamiliar with the C :c:func:`getopt` function or who would like to write
20951
 
    less code and get better help and error messages should consider using the
20952
 
    :mod:`argparse` module instead.
20953
 
 
20954
 
 This module helps scripts to parse the command line arguments in ``sys.argv``.
20955
 
-It supports the same conventions as the Unix :cfunc:`getopt` function (including
20956
 
+It supports the same conventions as the Unix :c:func:`getopt` function (including
20957
 
 the special meanings of arguments of the form '``-``' and '``--``').  Long
20958
 
 options similar to those supported by GNU software may be used as well via an
20959
 
 optional third argument.
20960
 
 
20961
 
-A more convenient, flexible, and powerful alternative is the
20962
 
-:mod:`optparse` module.
20963
 
-
20964
 
 This module provides two functions and an
20965
 
 exception:
20966
 
 
20967
 
@@ -32,11 +32,11 @@
20968
 
    be parsed, without the leading reference to the running program. Typically, this
20969
 
    means ``sys.argv[1:]``. *options* is the string of option letters that the
20970
 
    script wants to recognize, with options that require an argument followed by a
20971
 
-   colon (``':'``; i.e., the same format that Unix :cfunc:`getopt` uses).
20972
 
+   colon (``':'``; i.e., the same format that Unix :c:func:`getopt` uses).
20973
 
 
20974
 
    .. note::
20975
 
 
20976
 
-      Unlike GNU :cfunc:`getopt`, after a non-option argument, all further
20977
 
+      Unlike GNU :c:func:`getopt`, after a non-option argument, all further
20978
 
       arguments are considered also non-options. This is similar to the way
20979
 
       non-GNU Unix systems work.
20980
 
 
20981
 
diff -r 8527427914a2 Doc/library/gettext.rst
20982
 
--- a/Doc/library/gettext.rst
20983
 
+++ b/Doc/library/gettext.rst
20984
 
@@ -1,4 +1,3 @@
20985
 
-
20986
 
 :mod:`gettext` --- Multilingual internationalization services
20987
 
 =============================================================
20988
 
 
20989
 
@@ -7,6 +6,9 @@
20990
 
 .. moduleauthor:: Barry A. Warsaw <barry@zope.com>
20991
 
 .. sectionauthor:: Barry A. Warsaw <barry@zope.com>
20992
 
 
20993
 
+**Source code:** :source:`Lib/gettext.py`
20994
 
+
20995
 
+--------------
20996
 
 
20997
 
 The :mod:`gettext` module provides internationalization (I18N) and localization
20998
 
 (L10N) services for your Python modules and applications. It supports both the
20999
 
@@ -298,7 +300,7 @@
21000
 
 
21001
 
    .. method:: lngettext(singular, plural, n)
21002
 
 
21003
 
-      If a fallback has been set, forward :meth:`ngettext` to the
21004
 
+      If a fallback has been set, forward :meth:`lngettext` to the
21005
 
       fallback. Otherwise, return the translated message.  Overridden in derived
21006
 
       classes.
21007
 
 
21008
 
@@ -754,8 +756,8 @@
21009
 
 .. [#] See the footnote for :func:`bindtextdomain` above.
21010
 
 
21011
 
 .. [#] François Pinard has written a program called :program:`xpot` which does a
21012
 
-   similar job.  It is available as part of his :program:`po-utils` package at http
21013
 
-   ://po-utils.progiciels-bpi.ca/.
21014
 
+   similar job.  It is available as part of his `po-utils package
21015
 
+   <http://po-utils.progiciels-bpi.ca/>`_.
21016
 
 
21017
 
 .. [#] :program:`msgfmt.py` is binary compatible with GNU :program:`msgfmt` except that
21018
 
    it provides a simpler, all-Python implementation.  With this and
21019
 
diff -r 8527427914a2 Doc/library/glob.rst
21020
 
--- a/Doc/library/glob.rst
21021
 
+++ b/Doc/library/glob.rst
21022
 
@@ -1,4 +1,3 @@
21023
 
-
21024
 
 :mod:`glob` --- Unix style pathname pattern expansion
21025
 
 =====================================================
21026
 
 
21027
 
@@ -8,6 +7,10 @@
21028
 
 
21029
 
 .. index:: single: filenames; pathname expansion
21030
 
 
21031
 
+**Source code:** :source:`Lib/glob.py`
21032
 
+
21033
 
+--------------
21034
 
+
21035
 
 The :mod:`glob` module finds all the pathnames matching a specified pattern
21036
 
 according to the rules used by the Unix shell.  No tilde expansion is done, but
21037
 
 ``*``, ``?``, and character ranges expressed with ``[]`` will be correctly
21038
 
@@ -16,10 +19,6 @@
21039
 
 subshell.  (For tilde and shell variable expansion, use
21040
 
 :func:`os.path.expanduser` and :func:`os.path.expandvars`.)
21041
 
 
21042
 
-.. seealso::
21043
 
-
21044
 
-   Latest version of the `glob module Python source code
21045
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/glob.py?view=markup>`_
21046
 
 
21047
 
 .. function:: glob(pathname)
21048
 
 
21049
 
diff -r 8527427914a2 Doc/library/gzip.rst
21050
 
--- a/Doc/library/gzip.rst
21051
 
+++ b/Doc/library/gzip.rst
21052
 
@@ -4,6 +4,10 @@
21053
 
 .. module:: gzip
21054
 
    :synopsis: Interfaces for gzip compression and decompression using file objects.
21055
 
 
21056
 
+**Source code:** :source:`Lib/gzip.py`
21057
 
+
21058
 
+--------------
21059
 
+
21060
 
 This module provides a simple interface to compress and decompress files just
21061
 
 like the GNU programs :program:`gzip` and :program:`gunzip` would.
21062
 
 
21063
 
@@ -58,7 +62,7 @@
21064
 
    time is used.  This module ignores the timestamp when decompressing;
21065
 
    however, some programs, such as :program:`gunzip`\ , make use of it.
21066
 
    The format of the timestamp is the same as that of the return value of
21067
 
-   ``time.time()`` and of the ``st_mtime`` member of the object returned
21068
 
+   ``time.time()`` and of the ``st_mtime`` attribute of the object returned
21069
 
    by ``os.stat()``.
21070
 
 
21071
 
    Calling a :class:`GzipFile` object's :meth:`close` method does not close
21072
 
diff -r 8527427914a2 Doc/library/hashlib.rst
21073
 
--- a/Doc/library/hashlib.rst
21074
 
+++ b/Doc/library/hashlib.rst
21075
 
@@ -1,4 +1,3 @@
21076
 
-
21077
 
 :mod:`hashlib` --- Secure hashes and message digests
21078
 
 ====================================================
21079
 
 
21080
 
@@ -14,6 +13,10 @@
21081
 
    single: message digest, MD5
21082
 
    single: secure hash algorithm, SHA1, SHA224, SHA256, SHA384, SHA512
21083
 
 
21084
 
+**Source code:** :source:`Lib/hashlib.py`
21085
 
+
21086
 
+--------------
21087
 
+
21088
 
 This module implements a common interface to many different secure hash and
21089
 
 message digest algorithms.  Included are the FIPS secure hash algorithms SHA1,
21090
 
 SHA224, SHA256, SHA384, and SHA512 (defined in FIPS 180-2) as well as RSA's MD5
21091
 
diff -r 8527427914a2 Doc/library/heapq.rst
21092
 
--- a/Doc/library/heapq.rst
21093
 
+++ b/Doc/library/heapq.rst
21094
 
@@ -10,14 +10,13 @@
21095
 
 
21096
 
 .. versionadded:: 2.3
21097
 
 
21098
 
+**Source code:** :source:`Lib/heapq.py`
21099
 
+
21100
 
+--------------
21101
 
+
21102
 
 This module provides an implementation of the heap queue algorithm, also known
21103
 
 as the priority queue algorithm.
21104
 
 
21105
 
-.. seealso::
21106
 
-
21107
 
-   Latest version of the `heapq Python source code
21108
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/heapq.py?view=markup>`_
21109
 
-
21110
 
 Heaps are binary trees for which every parent node has a value less than or
21111
 
 equal to any of its children.  This implementation uses arrays for which
21112
 
 ``heap[k] <= heap[2*k+1]`` and ``heap[k] <= heap[2*k+2]`` for all *k*, counting
21113
 
@@ -188,36 +187,36 @@
21114
 
 with a dictionary pointing to an entry in the queue.
21115
 
 
21116
 
 Removing the entry or changing its priority is more difficult because it would
21117
 
-break the heap structure invariants.  So, a possible solution is to mark an
21118
 
-entry as invalid and optionally add a new entry with the revised priority::
21119
 
+break the heap structure invariants.  So, a possible solution is to mark the
21120
 
+existing entry as removed and add a new entry with the revised priority::
21121
 
 
21122
 
-    pq = []                         # the priority queue list
21123
 
-    counter = itertools.count(1)    # unique sequence count
21124
 
-    task_finder = {}                # mapping of tasks to entries
21125
 
-    INVALID = 0                     # mark an entry as deleted
21126
 
+    pq = []                         # list of entries arranged in a heap
21127
 
+    entry_finder = {}               # mapping of tasks to entries
21128
 
+    REMOVED = '<removed-task>'      # placeholder for a removed task
21129
 
+    counter = itertools.count()     # unique sequence count
21130
 
 
21131
 
-    def add_task(priority, task, count=None):
21132
 
-        if count is None:
21133
 
-            count = next(counter)
21134
 
+    def add_task(task, priority=0):
21135
 
+        'Add a new task or update the priority of an existing task'
21136
 
+        if task in entry_finder:
21137
 
+            remove_task(task)
21138
 
+        count = next(counter)
21139
 
         entry = [priority, count, task]
21140
 
-        task_finder[task] = entry
21141
 
+        entry_finder[task] = entry
21142
 
         heappush(pq, entry)
21143
 
 
21144
 
-    def get_top_priority():
21145
 
-        while True:
21146
 
+    def remove_task(task):
21147
 
+        'Mark an existing task as REMOVED.  Raise KeyError if not found.'
21148
 
+        entry = entry_finder.pop(task)
21149
 
+        entry[-1] = REMOVED
21150
 
+
21151
 
+    def pop_task():
21152
 
+        'Remove and return the lowest priority task. Raise KeyError if empty.'
21153
 
+        while pq:
21154
 
             priority, count, task = heappop(pq)
21155
 
-            del task_finder[task]
21156
 
-            if count is not INVALID:
21157
 
+            if task is not REMOVED:
21158
 
+                del entry_finder[task]
21159
 
                 return task
21160
 
-
21161
 
-    def delete_task(task):
21162
 
-        entry = task_finder[task]
21163
 
-        entry[1] = INVALID
21164
 
-
21165
 
-    def reprioritize(priority, task):
21166
 
-        entry = task_finder[task]
21167
 
-        add_task(priority, task, entry[1])
21168
 
-        entry[1] = INVALID
21169
 
+        raise KeyError('pop from an empty priority queue')
21170
 
 
21171
 
 
21172
 
 Theory
21173
 
diff -r 8527427914a2 Doc/library/hmac.rst
21174
 
--- a/Doc/library/hmac.rst
21175
 
+++ b/Doc/library/hmac.rst
21176
 
@@ -1,4 +1,3 @@
21177
 
-
21178
 
 :mod:`hmac` --- Keyed-Hashing for Message Authentication
21179
 
 ========================================================
21180
 
 
21181
 
@@ -10,6 +9,10 @@
21182
 
 
21183
 
 .. versionadded:: 2.2
21184
 
 
21185
 
+**Source code:** :source:`Lib/hmac.py`
21186
 
+
21187
 
+--------------
21188
 
+
21189
 
 This module implements the HMAC algorithm as described by :rfc:`2104`.
21190
 
 
21191
 
 
21192
 
@@ -22,29 +25,28 @@
21193
 
 
21194
 
 An HMAC object has the following methods:
21195
 
 
21196
 
-
21197
 
-.. method:: hmac.update(msg)
21198
 
+.. method:: HMAC.update(msg)
21199
 
 
21200
 
    Update the hmac object with the string *msg*.  Repeated calls are equivalent to
21201
 
    a single call with the concatenation of all the arguments: ``m.update(a);
21202
 
    m.update(b)`` is equivalent to ``m.update(a + b)``.
21203
 
 
21204
 
 
21205
 
-.. method:: hmac.digest()
21206
 
+.. method:: HMAC.digest()
21207
 
 
21208
 
    Return the digest of the strings passed to the :meth:`update` method so far.
21209
 
    This string will be the same length as the *digest_size* of the digest given to
21210
 
    the constructor.  It may contain non-ASCII characters, including NUL bytes.
21211
 
 
21212
 
 
21213
 
-.. method:: hmac.hexdigest()
21214
 
+.. method:: HMAC.hexdigest()
21215
 
 
21216
 
    Like :meth:`digest` except the digest is returned as a string twice the length
21217
 
    containing only hexadecimal digits.  This may be used to exchange the value
21218
 
    safely in email or other non-binary environments.
21219
 
 
21220
 
 
21221
 
-.. method:: hmac.copy()
21222
 
+.. method:: HMAC.copy()
21223
 
 
21224
 
    Return a copy ("clone") of the hmac object.  This can be used to efficiently
21225
 
    compute the digests of strings that share a common initial substring.
21226
 
diff -r 8527427914a2 Doc/library/htmllib.rst
21227
 
--- a/Doc/library/htmllib.rst
21228
 
+++ b/Doc/library/htmllib.rst
21229
 
@@ -165,10 +165,13 @@
21230
 
    Python 3.0.  The :term:`2to3` tool will automatically adapt imports when
21231
 
    converting your sources to 3.0.
21232
 
 
21233
 
+**Source code:** :source:`Lib/htmlentitydefs.py`
21234
 
+
21235
 
+--------------
21236
 
 
21237
 
 This module defines three dictionaries, ``name2codepoint``, ``codepoint2name``,
21238
 
 and ``entitydefs``. ``entitydefs`` is used by the :mod:`htmllib` module to
21239
 
-provide the :attr:`entitydefs` member of the :class:`HTMLParser` class.  The
21240
 
+provide the :attr:`entitydefs` attribute of the :class:`HTMLParser` class.  The
21241
 
 definition provided here contains all the entities defined by XHTML 1.0  that
21242
 
 can be handled using simple textual substitution in the Latin-1 character set
21243
 
 (ISO-8859-1).
21244
 
diff -r 8527427914a2 Doc/library/htmlparser.rst
21245
 
--- a/Doc/library/htmlparser.rst
21246
 
+++ b/Doc/library/htmlparser.rst
21247
 
@@ -8,8 +8,8 @@
21248
 
 .. note::
21249
 
 
21250
 
    The :mod:`HTMLParser` module has been renamed to :mod:`html.parser` in Python
21251
 
-   3.0.  The :term:`2to3` tool will automatically adapt imports when converting
21252
 
-   your sources to 3.0.
21253
 
+   3.  The :term:`2to3` tool will automatically adapt imports when converting
21254
 
+   your sources to Python 3.
21255
 
 
21256
 
 
21257
 
 .. versionadded:: 2.2
21258
 
@@ -18,6 +18,10 @@
21259
 
    single: HTML
21260
 
    single: XHTML
21261
 
 
21262
 
+**Source code:** :source:`Lib/HTMLParser.py`
21263
 
+
21264
 
+--------------
21265
 
+
21266
 
 This module defines a class :class:`HTMLParser` which serves as the basis for
21267
 
 parsing text files formatted in HTML (HyperText Mark-up Language) and XHTML.
21268
 
 Unlike the parser in :mod:`htmllib`, this parser is not based on the SGML parser
21269
 
@@ -60,7 +64,8 @@
21270
 
 
21271
 
    Feed some text to the parser.  It is processed insofar as it consists of
21272
 
    complete elements; incomplete data is buffered until more data is fed or
21273
 
-   :meth:`close` is called.
21274
 
+   :meth:`close` is called.  *data* can be either :class:`unicode` or
21275
 
+   :class:`str`, but passing :class:`unicode` is advised.
21276
 
 
21277
 
 
21278
 
 .. method:: HTMLParser.close()
21279
 
@@ -105,9 +110,9 @@
21280
 
 .. method:: HTMLParser.handle_startendtag(tag, attrs)
21281
 
 
21282
 
    Similar to :meth:`handle_starttag`, but called when the parser encounters an
21283
 
-   XHTML-style empty tag (``<a .../>``).  This method may be overridden by
21284
 
+   XHTML-style empty tag (``<img ... />``).  This method may be overridden by
21285
 
    subclasses which require this particular lexical information; the default
21286
 
-   implementation simple calls :meth:`handle_starttag` and :meth:`handle_endtag`.
21287
 
+   implementation simply calls :meth:`handle_starttag` and :meth:`handle_endtag`.
21288
 
 
21289
 
 
21290
 
 .. method:: HTMLParser.handle_endtag(tag)
21291
 
@@ -119,7 +124,8 @@
21292
 
 
21293
 
 .. method:: HTMLParser.handle_data(data)
21294
 
 
21295
 
-   This method is called to process arbitrary data.  It is intended to be
21296
 
+   This method is called to process arbitrary data (e.g. the content of
21297
 
+   ``<script>...</script>`` and ``<style>...</style>``).  It is intended to be
21298
 
    overridden by a derived class; the base class implementation does nothing.
21299
 
 
21300
 
 
21301
 
@@ -182,16 +188,21 @@
21302
 
 Example HTML Parser Application
21303
 
 -------------------------------
21304
 
 
21305
 
-As a basic example, below is a very basic HTML parser that uses the
21306
 
-:class:`HTMLParser` class to print out tags as they are encountered::
21307
 
+As a basic example, below is a simple HTML parser that uses the
21308
 
+:class:`HTMLParser` class to print out start tags, end tags and data
21309
 
+as they are encountered::
21310
 
 
21311
 
    from HTMLParser import HTMLParser
21312
 
 
21313
 
    class MyHTMLParser(HTMLParser):
21314
 
+       def handle_starttag(self, tag, attrs):
21315
 
+           print "Encountered a start tag:", tag
21316
 
+       def handle_endtag(self, tag):
21317
 
+           print "Encountered  an end tag:", tag
21318
 
+       def handle_data(self, data):
21319
 
+           print "Encountered   some data:", data
21320
 
 
21321
 
-       def handle_starttag(self, tag, attrs):
21322
 
-           print "Encountered the beginning of a %s tag" % tag
21323
 
 
21324
 
-       def handle_endtag(self, tag):
21325
 
-           print "Encountered the end of a %s tag" % tag
21326
 
-
21327
 
+   parser = MyHTMLParser()
21328
 
+   parser.feed('<html><head><title>Test</title></head>'
21329
 
+               '<body><h1>Parse me!</h1></body></html>')
21330
 
diff -r 8527427914a2 Doc/library/httplib.rst
21331
 
--- a/Doc/library/httplib.rst
21332
 
+++ b/Doc/library/httplib.rst
21333
 
@@ -16,6 +16,10 @@
21334
 
 
21335
 
 .. index:: module: urllib
21336
 
 
21337
 
+**Source code:** :source:`Lib/httplib.py`
21338
 
+
21339
 
+--------------
21340
 
+
21341
 
 This module defines classes which implement the client side of the HTTP and
21342
 
 HTTPS protocols.  It is normally not used directly --- the module :mod:`urllib`
21343
 
 uses it to handle URLs that use HTTP and HTTPS.
21344
 
@@ -448,7 +452,7 @@
21345
 
    Set the host and the port for HTTP Connect Tunnelling. Normally used when
21346
 
    it is required to do HTTPS Conection through a proxy server.
21347
 
 
21348
 
-   The headers argument should be a mapping of extra HTTP headers to to sent
21349
 
+   The headers argument should be a mapping of extra HTTP headers to send
21350
 
    with the CONNECT request.
21351
 
 
21352
 
    .. versionadded:: 2.7
21353
 
@@ -488,9 +492,16 @@
21354
 
    an argument.
21355
 
 
21356
 
 
21357
 
-.. method:: HTTPConnection.endheaders()
21358
 
+.. method:: HTTPConnection.endheaders(message_body=None)
21359
 
 
21360
 
-   Send a blank line to the server, signalling the end of the headers.
21361
 
+   Send a blank line to the server, signalling the end of the headers. The
21362
 
+   optional *message_body* argument can be used to pass a message body
21363
 
+   associated with the request.  The message body will be sent in the same
21364
 
+   packet as the message headers if it is string, otherwise it is sent in a
21365
 
+   separate packet.
21366
 
+
21367
 
+   .. versionchanged:: 2.7
21368
 
+      *message_body* was added.
21369
 
 
21370
 
 
21371
 
 .. method:: HTTPConnection.send(data)
21372
 
@@ -588,14 +599,16 @@
21373
 
 Here is an example session that shows how to ``POST`` requests::
21374
 
 
21375
 
    >>> import httplib, urllib
21376
 
-   >>> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
21377
 
+   >>> params = urllib.urlencode({'@number': 12524, '@type': 'issue', '@action': 'show'})
21378
 
    >>> headers = {"Content-type": "application/x-www-form-urlencoded",
21379
 
    ...            "Accept": "text/plain"}
21380
 
-   >>> conn = httplib.HTTPConnection("musi-cal.mojam.com:80")
21381
 
-   >>> conn.request("POST", "/cgi-bin/query", params, headers)
21382
 
+   >>> conn = httplib.HTTPConnection("bugs.python.org")
21383
 
+   >>> conn.request("POST", "", params, headers)
21384
 
    >>> response = conn.getresponse()
21385
 
    >>> print response.status, response.reason
21386
 
-   200 OK
21387
 
+   302 Found
21388
 
    >>> data = response.read()
21389
 
+   >>> data
21390
 
+   'Redirecting to <a href="http://bugs.python.org/issue12524">http://bugs.python.org/issue12524</a>'
21391
 
    >>> conn.close()
21392
 
 
21393
 
diff -r 8527427914a2 Doc/library/imaplib.rst
21394
 
--- a/Doc/library/imaplib.rst
21395
 
+++ b/Doc/library/imaplib.rst
21396
 
@@ -16,6 +16,10 @@
21397
 
    pair: IMAP4_SSL; protocol
21398
 
    pair: IMAP4_stream; protocol
21399
 
 
21400
 
+**Source code:** :source:`Lib/imaplib.py`
21401
 
+
21402
 
+--------------
21403
 
+
21404
 
 This module defines three classes, :class:`IMAP4`, :class:`IMAP4_SSL` and
21405
 
 :class:`IMAP4_stream`, which encapsulate a connection to an IMAP4 server and
21406
 
 implement a large subset of the IMAP4rev1 client protocol as defined in
21407
 
diff -r 8527427914a2 Doc/library/imghdr.rst
21408
 
--- a/Doc/library/imghdr.rst
21409
 
+++ b/Doc/library/imghdr.rst
21410
 
@@ -1,10 +1,12 @@
21411
 
-
21412
 
 :mod:`imghdr` --- Determine the type of an image
21413
 
 ================================================
21414
 
 
21415
 
 .. module:: imghdr
21416
 
    :synopsis: Determine the type of image contained in a file or byte stream.
21417
 
 
21418
 
+**Source code:** :source:`Lib/imghdr.py`
21419
 
+
21420
 
+--------------
21421
 
 
21422
 
 The :mod:`imghdr` module determines the type of image contained in a file or
21423
 
 byte stream.
21424
 
diff -r 8527427914a2 Doc/library/inspect.rst
21425
 
--- a/Doc/library/inspect.rst
21426
 
+++ b/Doc/library/inspect.rst
21427
 
@@ -1,4 +1,3 @@
21428
 
-
21429
 
 :mod:`inspect` --- Inspect live objects
21430
 
 =======================================
21431
 
 
21432
 
@@ -10,6 +9,10 @@
21433
 
 
21434
 
 .. versionadded:: 2.1
21435
 
 
21436
 
+**Source code:** :source:`Lib/inspect.py`
21437
 
+
21438
 
+--------------
21439
 
+
21440
 
 The :mod:`inspect` module provides several useful functions to help get
21441
 
 information about live objects such as modules, classes, methods, functions,
21442
 
 tracebacks, frame objects, and code objects.  For example, it can help you
21443
 
@@ -363,7 +366,7 @@
21444
 
    .. impl-detail::
21445
 
 
21446
 
       getsets are attributes defined in extension modules via
21447
 
-      :ctype:`PyGetSetDef` structures.  For Python implementations without such
21448
 
+      :c:type:`PyGetSetDef` structures.  For Python implementations without such
21449
 
       types, this method will always return ``False``.
21450
 
 
21451
 
    .. versionadded:: 2.5
21452
 
@@ -376,7 +379,7 @@
21453
 
    .. impl-detail::
21454
 
 
21455
 
       Member descriptors are attributes defined in extension modules via
21456
 
-      :ctype:`PyMemberDef` structures.  For Python implementations without such
21457
 
+      :c:type:`PyMemberDef` structures.  For Python implementations without such
21458
 
       types, this method will always return ``False``.
21459
 
 
21460
 
    .. versionadded:: 2.5
21461
 
diff -r 8527427914a2 Doc/library/io.rst
21462
 
--- a/Doc/library/io.rst
21463
 
+++ b/Doc/library/io.rst
21464
 
@@ -233,7 +233,7 @@
21465
 
    :class:`IOBase` object can be iterated over yielding the lines in a stream.
21466
 
    Lines are defined slightly differently depending on whether the stream is
21467
 
    a binary stream (yielding :class:`bytes`), or a text stream (yielding
21468
 
-   :class:`unicode` strings).  See :meth:`readline` below.
21469
 
+   :class:`unicode` strings).  See :meth:`~IOBase.readline` below.
21470
 
 
21471
 
    IOBase is also a context manager and therefore supports the
21472
 
    :keyword:`with` statement.  In this example, *file* is closed after the
21473
 
@@ -407,8 +407,8 @@
21474
 
    :class:`RawIOBase` implementation, but wrap one, like
21475
 
    :class:`BufferedWriter` and :class:`BufferedReader` do.
21476
 
 
21477
 
-   :class:`BufferedIOBase` provides or overrides these members in addition to
21478
 
-   those from :class:`IOBase`:
21479
 
+   :class:`BufferedIOBase` provides or overrides these methods and attribute in
21480
 
+   addition to those from :class:`IOBase`:
21481
 
 
21482
 
    .. attribute:: raw
21483
 
 
21484
 
@@ -604,25 +604,6 @@
21485
 
       if the buffer needs to be written out but the raw stream blocks.
21486
 
 
21487
 
 
21488
 
-.. class:: BufferedRWPair(reader, writer, buffer_size=DEFAULT_BUFFER_SIZE)
21489
 
-
21490
 
-   A buffered I/O object giving a combined, higher-level access to two
21491
 
-   sequential :class:`RawIOBase` objects: one readable, the other writeable.
21492
 
-   It is useful for pairs of unidirectional communication channels
21493
 
-   (pipes, for instance).  It inherits :class:`BufferedIOBase`.
21494
 
-
21495
 
-   *reader* and *writer* are :class:`RawIOBase` objects that are readable and
21496
 
-   writeable respectively.  If the *buffer_size* is omitted it defaults to
21497
 
-   :data:`DEFAULT_BUFFER_SIZE`.
21498
 
-
21499
 
-   A fourth argument, *max_buffer_size*, is supported, but unused and
21500
 
-   deprecated.
21501
 
-
21502
 
-   :class:`BufferedRWPair` implements all of :class:`BufferedIOBase`\'s methods
21503
 
-   except for :meth:`~BufferedIOBase.detach`, which raises
21504
 
-   :exc:`UnsupportedOperation`.
21505
 
-
21506
 
-
21507
 
 .. class:: BufferedRandom(raw, buffer_size=DEFAULT_BUFFER_SIZE)
21508
 
 
21509
 
    A buffered interface to random access streams.  It inherits
21510
 
@@ -639,6 +620,29 @@
21511
 
    :class:`BufferedWriter` can do.
21512
 
 
21513
 
 
21514
 
+.. class:: BufferedRWPair(reader, writer, buffer_size=DEFAULT_BUFFER_SIZE)
21515
 
+
21516
 
+   A buffered I/O object combining two unidirectional :class:`RawIOBase`
21517
 
+   objects -- one readable, the other writeable -- into a single bidirectional
21518
 
+   endpoint.  It inherits :class:`BufferedIOBase`.
21519
 
+
21520
 
+   *reader* and *writer* are :class:`RawIOBase` objects that are readable and
21521
 
+   writeable respectively.  If the *buffer_size* is omitted it defaults to
21522
 
+   :data:`DEFAULT_BUFFER_SIZE`.
21523
 
+
21524
 
+   A fourth argument, *max_buffer_size*, is supported, but unused and
21525
 
+   deprecated.
21526
 
+
21527
 
+   :class:`BufferedRWPair` implements all of :class:`BufferedIOBase`\'s methods
21528
 
+   except for :meth:`~BufferedIOBase.detach`, which raises
21529
 
+   :exc:`UnsupportedOperation`.
21530
 
+
21531
 
+   .. warning::
21532
 
+      :class:`BufferedRWPair` does not attempt to synchronize accesses to
21533
 
+      its underlying raw streams.  You should not pass it the same object
21534
 
+      as reader and writer; use :class:`BufferedRandom` instead.
21535
 
+
21536
 
+
21537
 
 Text I/O
21538
 
 --------
21539
 
 
21540
 
@@ -697,6 +701,32 @@
21541
 
       Read until newline or EOF and return a single ``unicode``.  If the
21542
 
       stream is already at EOF, an empty string is returned.
21543
 
 
21544
 
+   .. method:: seek(offset, whence=SEEK_SET)
21545
 
+
21546
 
+      Change the stream position to the given *offset*.  Behaviour depends
21547
 
+      on the *whence* parameter:
21548
 
+
21549
 
+      * :data:`SEEK_SET` or ``0``: seek from the start of the stream
21550
 
+        (the default); *offset* must either be a number returned by
21551
 
+        :meth:`TextIOBase.tell`, or zero.  Any other *offset* value
21552
 
+        produces undefined behaviour.
21553
 
+      * :data:`SEEK_CUR` or ``1``: "seek" to the current position;
21554
 
+        *offset* must be zero, which is a no-operation (all other values
21555
 
+        are unsupported).
21556
 
+      * :data:`SEEK_END` or ``2``: seek to the end of the stream;
21557
 
+        *offset* must be zero (all other values are unsupported).
21558
 
+
21559
 
+      Return the new absolute position as an opaque number.
21560
 
+
21561
 
+      .. versionadded:: 2.7
21562
 
+         The ``SEEK_*`` constants.
21563
 
+
21564
 
+   .. method:: tell()
21565
 
+
21566
 
+      Return the current stream position as an opaque number.  The number
21567
 
+      does not usually represent a number of bytes in the underlying
21568
 
+      binary storage.
21569
 
+
21570
 
    .. method:: write(s)
21571
 
 
21572
 
       Write the :class:`unicode` string *s* to the stream and return the
21573
 
diff -r 8527427914a2 Doc/library/itertools.rst
21574
 
--- a/Doc/library/itertools.rst
21575
 
+++ b/Doc/library/itertools.rst
21576
 
@@ -433,9 +433,9 @@
21577
 
 
21578
 
       def izip(*iterables):
21579
 
           # izip('ABCD', 'xy') --> Ax By
21580
 
-          iterables = map(iter, iterables)
21581
 
-          while iterables:
21582
 
-              yield tuple(map(next, iterables))
21583
 
+          iterators = map(iter, iterables)
21584
 
+          while iterators:
21585
 
+              yield tuple(map(next, iterators))
21586
 
 
21587
 
    .. versionchanged:: 2.4
21588
 
       When no iterables are specified, returns a zero length iterator instead of
21589
 
@@ -456,17 +456,24 @@
21590
 
    iterables are of uneven length, missing values are filled-in with *fillvalue*.
21591
 
    Iteration continues until the longest iterable is exhausted.  Equivalent to::
21592
 
 
21593
 
+      class ZipExhausted(Exception):
21594
 
+          pass
21595
 
+
21596
 
       def izip_longest(*args, **kwds):
21597
 
           # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D-
21598
 
           fillvalue = kwds.get('fillvalue')
21599
 
-          def sentinel(counter = ([fillvalue]*(len(args)-1)).pop):
21600
 
-              yield counter()         # yields the fillvalue, or raises IndexError
21601
 
+          counter = [len(args) - 1]
21602
 
+          def sentinel():
21603
 
+              if not counter[0]:
21604
 
+                  raise ZipExhausted
21605
 
+              counter[0] -= 1
21606
 
+              yield fillvalue
21607
 
           fillers = repeat(fillvalue)
21608
 
-          iters = [chain(it, sentinel(), fillers) for it in args]
21609
 
+          iterators = [chain(it, sentinel(), fillers) for it in args]
21610
 
           try:
21611
 
-              for tup in izip(*iters):
21612
 
-                  yield tup
21613
 
-          except IndexError:
21614
 
+              while iterators:
21615
 
+                  yield tuple(map(next, iterators))
21616
 
+          except ZipExhausted:
21617
 
               pass
21618
 
 
21619
 
    If one of the iterables is potentially infinite, then the
21620
 
@@ -583,6 +590,11 @@
21621
 
               for i in xrange(times):
21622
 
                   yield object
21623
 
 
21624
 
+   A common use for *repeat* is to supply a stream of constant values to *imap*
21625
 
+   or *zip*::
21626
 
+
21627
 
+      >>> list(imap(pow, xrange(10), repeat(2)))
21628
 
+      [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
21629
 
 
21630
 
 .. function:: starmap(function, iterable)
21631
 
 
21632
 
diff -r 8527427914a2 Doc/library/keyword.rst
21633
 
--- a/Doc/library/keyword.rst
21634
 
+++ b/Doc/library/keyword.rst
21635
 
@@ -1,10 +1,12 @@
21636
 
-
21637
 
 :mod:`keyword` --- Testing for Python keywords
21638
 
 ==============================================
21639
 
 
21640
 
 .. module:: keyword
21641
 
    :synopsis: Test whether a string is a keyword in Python.
21642
 
 
21643
 
+**Source code:** :source:`Lib/keyword.py`
21644
 
+
21645
 
+--------------
21646
 
 
21647
 
 This module allows a Python program to determine if a string is a keyword.
21648
 
 
21649
 
@@ -19,9 +21,3 @@
21650
 
    Sequence containing all the keywords defined for the interpreter.  If any
21651
 
    keywords are defined to only be active when particular :mod:`__future__`
21652
 
    statements are in effect, these will be included as well.
21653
 
-
21654
 
-
21655
 
-.. seealso::
21656
 
-
21657
 
-   Latest version of the `keyword module Python source code
21658
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/keyword.py?view=markup>`_
21659
 
diff -r 8527427914a2 Doc/library/linecache.rst
21660
 
--- a/Doc/library/linecache.rst
21661
 
+++ b/Doc/library/linecache.rst
21662
 
@@ -6,17 +6,15 @@
21663
 
    :synopsis: This module provides random access to individual lines from text files.
21664
 
 .. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
21665
 
 
21666
 
+**Source code:** :source:`Lib/linecache.py`
21667
 
+
21668
 
+--------------
21669
 
 
21670
 
 The :mod:`linecache` module allows one to get any line from any file, while
21671
 
 attempting to optimize internally, using a cache, the common case where many
21672
 
 lines are read from a single file.  This is used by the :mod:`traceback` module
21673
 
 to retrieve source lines for inclusion in  the formatted traceback.
21674
 
 
21675
 
-.. seealso::
21676
 
-
21677
 
-   Latest version of the `linecache module Python source code
21678
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/linecache.py?view=markup>`_
21679
 
-
21680
 
 The :mod:`linecache` module defines the following functions:
21681
 
 
21682
 
 
21683
 
diff -r 8527427914a2 Doc/library/locale.rst
21684
 
--- a/Doc/library/locale.rst
21685
 
+++ b/Doc/library/locale.rst
21686
 
@@ -23,19 +23,19 @@
21687
 
 
21688
 
 .. exception:: Error
21689
 
 
21690
 
-   Exception raised when :func:`setlocale` fails.
21691
 
+   Exception raised when the locale passed to :func:`setlocale` is not
21692
 
+   recognized.
21693
 
 
21694
 
 
21695
 
 .. function:: setlocale(category[, locale])
21696
 
 
21697
 
-   If *locale* is specified, it may be a string, a tuple of the form ``(language
21698
 
-   code, encoding)``, or ``None``. If it is a tuple, it is converted to a string
21699
 
-   using the locale aliasing engine.  If *locale* is given and not ``None``,
21700
 
-   :func:`setlocale` modifies the locale setting for the *category*.  The available
21701
 
-   categories are listed in the data description below.  The value is the name of a
21702
 
-   locale.  An empty string specifies the user's default settings. If the
21703
 
-   modification of the locale fails, the exception :exc:`Error` is raised.  If
21704
 
-   successful, the new locale setting is returned.
21705
 
+   If *locale* is given and not ``None``, :func:`setlocale` modifies the locale
21706
 
+   setting for the *category*. The available categories are listed in the data
21707
 
+   description below. *locale* may be a string, or an iterable of two strings
21708
 
+   (language code and encoding). If it's an iterable, it's converted to a locale
21709
 
+   name using the locale aliasing engine. An empty string specifies the user's
21710
 
+   default settings. If the modification of the locale fails, the exception
21711
 
+   :exc:`Error` is raised. If successful, the new locale setting is returned.
21712
 
 
21713
 
    If *locale* is omitted or ``None``, the current setting for *category* is
21714
 
    returned.
21715
 
@@ -51,7 +51,7 @@
21716
 
    changed thereafter, using multithreading should not cause problems.
21717
 
 
21718
 
    .. versionchanged:: 2.0
21719
 
-      Added support for tuple values of the *locale* parameter.
21720
 
+      Added support for iterable values of the *locale* parameter.
21721
 
 
21722
 
 
21723
 
 .. function:: localeconv()
21724
 
@@ -219,7 +219,7 @@
21725
 
 
21726
 
       .. note::
21727
 
 
21728
 
-         The expression is in the syntax suitable for the :cfunc:`regex` function
21729
 
+         The expression is in the syntax suitable for the :c:func:`regex` function
21730
 
          from the C library, which might differ from the syntax used in :mod:`re`.
21731
 
 
21732
 
    .. data:: NOEXPR
21733
 
@@ -560,7 +560,7 @@
21734
 
 Python applications should normally find no need to invoke these functions, and
21735
 
 should use :mod:`gettext` instead.  A known exception to this rule are
21736
 
 applications that link with additional C libraries which internally invoke
21737
 
-:cfunc:`gettext` or :func:`dcgettext`.  For these applications, it may be
21738
 
+:c:func:`gettext` or :func:`dcgettext`.  For these applications, it may be
21739
 
 necessary to bind the text domain, so that the libraries can properly locate
21740
 
 their message catalogs.
21741
 
 
21742
 
diff -r 8527427914a2 Doc/library/logging.config.rst
21743
 
--- a/Doc/library/logging.config.rst
21744
 
+++ b/Doc/library/logging.config.rst
21745
 
@@ -516,6 +516,31 @@
21746
 
 to ``config_dict['handlers']['myhandler']['mykey']['123']`` if that
21747
 
 fails.
21748
 
 
21749
 
+
21750
 
+.. _logging-import-resolution:
21751
 
+
21752
 
+Import resolution and custom importers
21753
 
+""""""""""""""""""""""""""""""""""""""
21754
 
+
21755
 
+Import resolution, by default, uses the builtin :func:`__import__` function
21756
 
+to do its importing. You may want to replace this with your own importing
21757
 
+mechanism: if so, you can replace the :attr:`importer` attribute of the
21758
 
+:class:`DictConfigurator` or its superclass, the
21759
 
+:class:`BaseConfigurator` class. However, you need to be
21760
 
+careful because of the way functions are accessed from classes via
21761
 
+descriptors. If you are using a Python callable to do your imports, and you
21762
 
+want to define it at class level rather than instance level, you need to wrap
21763
 
+it with :func:`staticmethod`. For example::
21764
 
+
21765
 
+   from importlib import import_module
21766
 
+   from logging.config import BaseConfigurator
21767
 
+
21768
 
+   BaseConfigurator.importer = staticmethod(import_module)
21769
 
+
21770
 
+You don't need to wrap with :func:`staticmethod` if you're setting the import
21771
 
+callable on a configurator *instance*.
21772
 
+
21773
 
+
21774
 
 .. _logging-config-fileformat:
21775
 
 
21776
 
 Configuration file format
21777
 
diff -r 8527427914a2 Doc/library/logging.handlers.rst
21778
 
--- a/Doc/library/logging.handlers.rst
21779
 
+++ b/Doc/library/logging.handlers.rst
21780
 
@@ -262,10 +262,7 @@
21781
 
    :meth:`emit`.
21782
 
 
21783
 
    .. versionchanged:: 2.6
21784
 
-      *delay* was added.
21785
 
-
21786
 
-   .. versionchanged:: 2.7
21787
 
-      *utc* was added.
21788
 
+      *delay* and *utc* were added.
21789
 
 
21790
 
 
21791
 
    .. method:: doRollover()
21792
 
@@ -613,8 +610,14 @@
21793
 
    port, use the (host, port) tuple format for the *mailhost* argument. If you
21794
 
    use a string, the standard SMTP port is used. If your SMTP server requires
21795
 
    authentication, you can specify a (username, password) tuple for the
21796
 
-   *credentials* argument. If *secure* is True, then the handler will attempt
21797
 
-   to use TLS for the email transmission.
21798
 
+   *credentials* argument.
21799
 
+
21800
 
+   To specify the use of a secure protocol (TLS), pass in a tuple to the
21801
 
+   *secure* argument. This will only be used when authentication credentials are
21802
 
+   supplied. The tuple should be either an empty tuple, or a single-value tuple
21803
 
+   with the name of a keyfile, or a 2-value tuple with the names of the keyfile
21804
 
+   and certificate file. (This tuple is passed to the
21805
 
+   :meth:`smtplib.SMTP.starttls` method.)
21806
 
 
21807
 
    .. versionchanged:: 2.6
21808
 
       *credentials* was added.
21809
 
diff -r 8527427914a2 Doc/library/logging.rst
21810
 
--- a/Doc/library/logging.rst
21811
 
+++ b/Doc/library/logging.rst
21812
 
@@ -59,9 +59,15 @@
21813
 
 
21814
 
 .. attribute:: Logger.propagate
21815
 
 
21816
 
-   If this evaluates to false, logging messages are not passed by this logger or by
21817
 
-   its child loggers to the handlers of higher level (ancestor) loggers. The
21818
 
-   constructor sets this attribute to 1.
21819
 
+   If this evaluates to true, logging messages are passed by this logger and by
21820
 
+   its child loggers to the handlers of higher level (ancestor) loggers.
21821
 
+   Messages are passed directly to the ancestor loggers' handlers - neither the
21822
 
+   level nor filters of the ancestor loggers in question are considered.
21823
 
+
21824
 
+   If this evaluates to false, logging messages are not passed to the handlers
21825
 
+   of ancestor loggers.
21826
 
+
21827
 
+   The constructor sets this attribute to ``True``.
21828
 
 
21829
 
 
21830
 
 .. method:: Logger.setLevel(lvl)
21831
 
@@ -416,6 +422,13 @@
21832
 
       record. Otherwise, the ISO8601 format is used.  The resulting string is
21833
 
       returned.
21834
 
 
21835
 
+      This function uses a user-configurable function to convert the creation
21836
 
+      time to a tuple. By default, :func:`time.localtime` is used; to change
21837
 
+      this for a particular formatter instance, set the ``converter`` attribute
21838
 
+      to a function with the same signature as :func:`time.localtime` or
21839
 
+      :func:`time.gmtime`. To change it for all formatters, for example if you
21840
 
+      want all logging times to be shown in GMT, set the ``converter``
21841
 
+      attribute in the ``Formatter`` class.
21842
 
 
21843
 
    .. method:: formatException(exc_info)
21844
 
 
21845
 
@@ -491,6 +504,9 @@
21846
 
    :param name:  The name of the logger used to log the event represented by
21847
 
                  this LogRecord.
21848
 
    :param level: The numeric level of the logging event (one of DEBUG, INFO etc.)
21849
 
+                 Note that this is converted to *two* attributes of the LogRecord:
21850
 
+                 ``levelno`` for the numeric value and ``levelname`` for the
21851
 
+                 corresponding level name.
21852
 
    :param pathname: The full pathname of the source file where the logging call
21853
 
                     was made.
21854
 
    :param lineno: The line number in the source file where the logging call was
21855
 
diff -r 8527427914a2 Doc/library/macos.rst
21856
 
--- a/Doc/library/macos.rst
21857
 
+++ b/Doc/library/macos.rst
21858
 
@@ -41,7 +41,7 @@
21859
 
 
21860
 
    This exception is raised on MacOS generated errors, either from functions in
21861
 
    this module or from other mac-specific modules like the toolbox interfaces. The
21862
 
-   arguments are the integer error code (the :cdata:`OSErr` value) and a textual
21863
 
+   arguments are the integer error code (the :c:data:`OSErr` value) and a textual
21864
 
    description of the error code. Symbolic names for all known error codes are
21865
 
    defined in the standard module :mod:`macerrors`.
21866
 
 
21867
 
diff -r 8527427914a2 Doc/library/mailbox.rst
21868
 
--- a/Doc/library/mailbox.rst
21869
 
+++ b/Doc/library/mailbox.rst
21870
 
@@ -459,7 +459,7 @@
21871
 
                unlock()
21872
 
 
21873
 
       Three locking mechanisms are used---dot locking and, if available, the
21874
 
-      :cfunc:`flock` and :cfunc:`lockf` system calls.
21875
 
+      :c:func:`flock` and :c:func:`lockf` system calls.
21876
 
 
21877
 
 
21878
 
 .. seealso::
21879
 
@@ -573,7 +573,7 @@
21880
 
                unlock()
21881
 
 
21882
 
       Three locking mechanisms are used---dot locking and, if available, the
21883
 
-      :cfunc:`flock` and :cfunc:`lockf` system calls. For MH mailboxes, locking
21884
 
+      :c:func:`flock` and :c:func:`lockf` system calls. For MH mailboxes, locking
21885
 
       the mailbox means locking the :file:`.mh_sequences` file and, only for the
21886
 
       duration of any operations that affect them, locking individual message
21887
 
       files.
21888
 
@@ -671,7 +671,7 @@
21889
 
                unlock()
21890
 
 
21891
 
       Three locking mechanisms are used---dot locking and, if available, the
21892
 
-      :cfunc:`flock` and :cfunc:`lockf` system calls.
21893
 
+      :c:func:`flock` and :c:func:`lockf` system calls.
21894
 
 
21895
 
 
21896
 
 .. seealso::
21897
 
@@ -722,7 +722,7 @@
21898
 
                unlock()
21899
 
 
21900
 
       Three locking mechanisms are used---dot locking and, if available, the
21901
 
-      :cfunc:`flock` and :cfunc:`lockf` system calls.
21902
 
+      :c:func:`flock` and :c:func:`lockf` system calls.
21903
 
 
21904
 
 
21905
 
 .. seealso::
21906
 
@@ -765,7 +765,7 @@
21907
 
    There is no requirement that :class:`Message` instances be used to represent
21908
 
    messages retrieved using :class:`Mailbox` instances. In some situations, the
21909
 
    time and memory required to generate :class:`Message` representations might
21910
 
-   not not acceptable. For such situations, :class:`Mailbox` instances also
21911
 
+   not be acceptable. For such situations, :class:`Mailbox` instances also
21912
 
    offer string and file-like representations, and a custom message factory may
21913
 
    be specified when a :class:`Mailbox` instance is initialized.
21914
 
 
21915
 
diff -r 8527427914a2 Doc/library/mailcap.rst
21916
 
--- a/Doc/library/mailcap.rst
21917
 
+++ b/Doc/library/mailcap.rst
21918
 
@@ -4,7 +4,9 @@
21919
 
 .. module:: mailcap
21920
 
    :synopsis: Mailcap file handling.
21921
 
 
21922
 
+**Source code:** :source:`Lib/mailcap.py`
21923
 
 
21924
 
+--------------
21925
 
 
21926
 
 Mailcap files are used to configure how MIME-aware applications such as mail
21927
 
 readers and Web browsers react to files with different MIME types. (The name
21928
 
diff -r 8527427914a2 Doc/library/mimetypes.rst
21929
 
--- a/Doc/library/mimetypes.rst
21930
 
+++ b/Doc/library/mimetypes.rst
21931
 
@@ -1,4 +1,3 @@
21932
 
-
21933
 
 :mod:`mimetypes` --- Map filenames to MIME types
21934
 
 ================================================
21935
 
 
21936
 
@@ -9,6 +8,10 @@
21937
 
 
21938
 
 .. index:: pair: MIME; content type
21939
 
 
21940
 
+**Source code:** :source:`Lib/mimetypes.py`
21941
 
+
21942
 
+--------------
21943
 
+
21944
 
 The :mod:`mimetypes` module converts between a filename or URL and the MIME type
21945
 
 associated with the filename extension.  Conversions are provided from filename
21946
 
 to MIME type and from MIME type to filename extension; encodings are not
21947
 
@@ -23,31 +26,31 @@
21948
 
 the information :func:`init` sets up.
21949
 
 
21950
 
 
21951
 
-.. function:: guess_type(filename[, strict])
21952
 
+.. function:: guess_type(url, strict=True)
21953
 
 
21954
 
    .. index:: pair: MIME; headers
21955
 
 
21956
 
-   Guess the type of a file based on its filename or URL, given by *filename*.  The
21957
 
+   Guess the type of a file based on its filename or URL, given by *url*.  The
21958
 
    return value is a tuple ``(type, encoding)`` where *type* is ``None`` if the
21959
 
    type can't be guessed (missing or unknown suffix) or a string of the form
21960
 
    ``'type/subtype'``, usable for a MIME :mailheader:`content-type` header.
21961
 
 
21962
 
    *encoding* is ``None`` for no encoding or the name of the program used to encode
21963
 
    (e.g. :program:`compress` or :program:`gzip`). The encoding is suitable for use
21964
 
-   as a :mailheader:`Content-Encoding` header, *not* as a
21965
 
+   as a :mailheader:`Content-Encoding` header, **not** as a
21966
 
    :mailheader:`Content-Transfer-Encoding` header. The mappings are table driven.
21967
 
    Encoding suffixes are case sensitive; type suffixes are first tried case
21968
 
    sensitively, then case insensitively.
21969
 
 
21970
 
-   Optional *strict* is a flag specifying whether the list of known MIME types
21971
 
+   The optional *strict* argument is a flag specifying whether the list of known MIME types
21972
 
    is limited to only the official types `registered with IANA
21973
 
-   <http://www.iana.org/assignments/media-types/>`_ are recognized.
21974
 
-   When *strict* is true (the default), only the IANA types are supported; when
21975
 
-   *strict* is false, some additional non-standard but commonly used MIME types
21976
 
+   <http://www.iana.org/assignments/media-types/>`_.
21977
 
+   When *strict* is ``True`` (the default), only the IANA types are supported; when
21978
 
+   *strict* is ``False``, some additional non-standard but commonly used MIME types
21979
 
    are also recognized.
21980
 
 
21981
 
 
21982
 
-.. function:: guess_all_extensions(type[, strict])
21983
 
+.. function:: guess_all_extensions(type, strict=True)
21984
 
 
21985
 
    Guess the extensions for a file based on its MIME type, given by *type*. The
21986
 
    return value is a list of strings giving all possible filename extensions,
21987
 
@@ -55,25 +58,25 @@
21988
 
    been associated with any particular data stream, but would be mapped to the MIME
21989
 
    type *type* by :func:`guess_type`.
21990
 
 
21991
 
-   Optional *strict* has the same meaning as with the :func:`guess_type` function.
21992
 
+   The optional *strict* argument has the same meaning as with the :func:`guess_type` function.
21993
 
 
21994
 
 
21995
 
-.. function:: guess_extension(type[, strict])
21996
 
+.. function:: guess_extension(type, strict=True)
21997
 
 
21998
 
    Guess the extension for a file based on its MIME type, given by *type*. The
21999
 
    return value is a string giving a filename extension, including the leading dot
22000
 
    (``'.'``).  The extension is not guaranteed to have been associated with any
22001
 
-   particular data stream, but would be mapped to the  MIME type *type* by
22002
 
+   particular data stream, but would be mapped to the MIME type *type* by
22003
 
    :func:`guess_type`.  If no extension can be guessed for *type*, ``None`` is
22004
 
    returned.
22005
 
 
22006
 
-   Optional *strict* has the same meaning as with the :func:`guess_type` function.
22007
 
+   The optional *strict* argument has the same meaning as with the :func:`guess_type` function.
22008
 
 
22009
 
 Some additional functions and data items are available for controlling the
22010
 
 behavior of the module.
22011
 
 
22012
 
 
22013
 
-.. function:: init([files])
22014
 
+.. function:: init(files=None)
22015
 
 
22016
 
    Initialize the internal data structures.  If given, *files* must be a sequence
22017
 
    of file names which should be used to augment the default type map.  If omitted,
22018
 
@@ -88,26 +91,26 @@
22019
 
 
22020
 
 .. function:: read_mime_types(filename)
22021
 
 
22022
 
-   Load the type map given in the file *filename*, if it exists.  The  type map is
22023
 
+   Load the type map given in the file *filename*, if it exists.  The type map is
22024
 
    returned as a dictionary mapping filename extensions, including the leading dot
22025
 
    (``'.'``), to strings of the form ``'type/subtype'``.  If the file *filename*
22026
 
    does not exist or cannot be read, ``None`` is returned.
22027
 
 
22028
 
 
22029
 
-.. function:: add_type(type, ext[, strict])
22030
 
+.. function:: add_type(type, ext, strict=True)
22031
 
 
22032
 
-   Add a mapping from the mimetype *type* to the extension *ext*. When the
22033
 
+   Add a mapping from the MIME type *type* to the extension *ext*. When the
22034
 
    extension is already known, the new type will replace the old one. When the type
22035
 
    is already known the extension will be added to the list of known extensions.
22036
 
 
22037
 
-   When *strict* is True (the default), the mapping will added to the official MIME
22038
 
+   When *strict* is ``True`` (the default), the mapping will added to the official MIME
22039
 
    types, otherwise to the non-standard ones.
22040
 
 
22041
 
 
22042
 
 .. data:: inited
22043
 
 
22044
 
    Flag indicating whether or not the global data structures have been initialized.
22045
 
-   This is set to true by :func:`init`.
22046
 
+   This is set to ``True`` by :func:`init`.
22047
 
 
22048
 
 
22049
 
 .. data:: knownfiles
22050
 
@@ -142,23 +145,6 @@
22051
 
    Dictionary mapping filename extensions to non-standard, but commonly found MIME
22052
 
    types.
22053
 
 
22054
 
-The :class:`MimeTypes` class may be useful for applications which may want more
22055
 
-than one MIME-type database:
22056
 
-
22057
 
-
22058
 
-.. class:: MimeTypes([filenames])
22059
 
-
22060
 
-   This class represents a MIME-types database.  By default, it provides access to
22061
 
-   the same database as the rest of this module. The initial database is a copy of
22062
 
-   that provided by the module, and may be extended by loading additional
22063
 
-   :file:`mime.types`\ -style files into the database using the :meth:`read` or
22064
 
-   :meth:`readfp` methods.  The mapping dictionaries may also be cleared before
22065
 
-   loading additional data if the default data is not desired.
22066
 
-
22067
 
-   The optional *filenames* parameter can be used to cause additional files to be
22068
 
-   loaded "on top" of the default database.
22069
 
-
22070
 
-   .. versionadded:: 2.2
22071
 
 
22072
 
 An example usage of the module::
22073
 
 
22074
 
@@ -179,70 +165,96 @@
22075
 
 MimeTypes Objects
22076
 
 -----------------
22077
 
 
22078
 
-:class:`MimeTypes` instances provide an interface which is very like that of the
22079
 
+The :class:`MimeTypes` class may be useful for applications which may want more
22080
 
+than one MIME-type database; it provides an interface similar to the one of the
22081
 
 :mod:`mimetypes` module.
22082
 
 
22083
 
 
22084
 
+.. class:: MimeTypes(filenames=(), strict=True)
22085
 
+
22086
 
+   This class represents a MIME-types database.  By default, it provides access to
22087
 
+   the same database as the rest of this module. The initial database is a copy of
22088
 
+   that provided by the module, and may be extended by loading additional
22089
 
+   :file:`mime.types`\ -style files into the database using the :meth:`read` or
22090
 
+   :meth:`readfp` methods.  The mapping dictionaries may also be cleared before
22091
 
+   loading additional data if the default data is not desired.
22092
 
+
22093
 
+   The optional *filenames* parameter can be used to cause additional files to be
22094
 
+   loaded "on top" of the default database.
22095
 
+
22096
 
+
22097
 
 .. attribute:: MimeTypes.suffix_map
22098
 
 
22099
 
    Dictionary mapping suffixes to suffixes.  This is used to allow recognition of
22100
 
    encoded files for which the encoding and the type are indicated by the same
22101
 
    extension.  For example, the :file:`.tgz` extension is mapped to :file:`.tar.gz`
22102
 
    to allow the encoding and type to be recognized separately.  This is initially a
22103
 
-   copy of the global ``suffix_map`` defined in the module.
22104
 
+   copy of the global :data:`suffix_map` defined in the module.
22105
 
 
22106
 
 
22107
 
 .. attribute:: MimeTypes.encodings_map
22108
 
 
22109
 
    Dictionary mapping filename extensions to encoding types.  This is initially a
22110
 
-   copy of the global ``encodings_map`` defined in the module.
22111
 
+   copy of the global :data:`encodings_map` defined in the module.
22112
 
 
22113
 
 
22114
 
 .. attribute:: MimeTypes.types_map
22115
 
 
22116
 
-   Dictionary mapping filename extensions to MIME types.  This is initially a copy
22117
 
-   of the global ``types_map`` defined in the module.
22118
 
+   Tuple containing two dictionaries, mapping filename extensions to MIME types:
22119
 
+   the first dictionary is for the non-standards types and the second one is for
22120
 
+   the standard types. They are initialized by :data:`common_types` and
22121
 
+   :data:`types_map`.
22122
 
 
22123
 
 
22124
 
-.. attribute:: MimeTypes.common_types
22125
 
+.. attribute:: MimeTypes.types_map_inv
22126
 
 
22127
 
-   Dictionary mapping filename extensions to non-standard, but commonly found MIME
22128
 
-   types.  This is initially a copy of the global ``common_types`` defined in the
22129
 
-   module.
22130
 
+   Tuple containing two dictionaries, mapping MIME types to a list of filename
22131
 
+   extensions: the first dictionary is for the non-standards types and the
22132
 
+   second one is for the standard types. They are initialized by
22133
 
+   :data:`common_types` and :data:`types_map`.
22134
 
 
22135
 
 
22136
 
-.. method:: MimeTypes.guess_extension(type[, strict])
22137
 
+.. method:: MimeTypes.guess_extension(type, strict=True)
22138
 
 
22139
 
    Similar to the :func:`guess_extension` function, using the tables stored as part
22140
 
    of the object.
22141
 
 
22142
 
 
22143
 
-.. method:: MimeTypes.guess_all_extensions(type[, strict])
22144
 
-
22145
 
-   Similar to the :func:`guess_all_extensions` function, using the tables stored as part
22146
 
-   of the object.
22147
 
-
22148
 
-
22149
 
-.. method:: MimeTypes.guess_type(url[, strict])
22150
 
+.. method:: MimeTypes.guess_type(url, strict=True)
22151
 
 
22152
 
    Similar to the :func:`guess_type` function, using the tables stored as part of
22153
 
    the object.
22154
 
 
22155
 
 
22156
 
-.. method:: MimeTypes.read(path)
22157
 
+.. method:: MimeTypes.guess_all_extensions(type, strict=True)
22158
 
 
22159
 
-   Load MIME information from a file named *path*.  This uses :meth:`readfp` to
22160
 
+   Similar to the :func:`guess_all_extensions` function, using the tables stored
22161
 
+   as part of the object.
22162
 
+
22163
 
+
22164
 
+.. method:: MimeTypes.read(filename, strict=True)
22165
 
+
22166
 
+   Load MIME information from a file named *filename*.  This uses :meth:`readfp` to
22167
 
    parse the file.
22168
 
 
22169
 
+   If *strict* is ``True``, information will be added to list of standard types,
22170
 
+   else to the list of non-standard types.
22171
 
 
22172
 
-.. method:: MimeTypes.readfp(file)
22173
 
 
22174
 
-   Load MIME type information from an open file.  The file must have the format of
22175
 
+.. method:: MimeTypes.readfp(fp, strict=True)
22176
 
+
22177
 
+   Load MIME type information from an open file *fp*.  The file must have the format of
22178
 
    the standard :file:`mime.types` files.
22179
 
 
22180
 
+   If *strict* is ``True``, information will be added to the list of standard
22181
 
+   types, else to the list of non-standard types.
22182
 
 
22183
 
-.. method:: MimeTypes.read_windows_registry()
22184
 
+
22185
 
+.. method:: MimeTypes.read_windows_registry(strict=True)
22186
 
 
22187
 
    Load MIME type information from the Windows registry.  Availability: Windows.
22188
 
 
22189
 
+   If *strict* is ``True``, information will be added to the list of standard
22190
 
+   types, else to the list of non-standard types.
22191
 
+
22192
 
    .. versionadded:: 2.7
22193
 
diff -r 8527427914a2 Doc/library/mmap.rst
22194
 
--- a/Doc/library/mmap.rst
22195
 
+++ b/Doc/library/mmap.rst
22196
 
@@ -23,6 +23,12 @@
22197
 
 :func:`os.open` function, which returns a file descriptor directly (the file
22198
 
 still needs to be closed when done).
22199
 
 
22200
 
+.. note::
22201
 
+   If you want to create a memory-mapping for a writable, buffered file, you
22202
 
+   should :func:`~io.IOBase.flush` the file first.  This is necessary to ensure
22203
 
+   that local modifications to the buffers are actually available to the
22204
 
+   mapping.
22205
 
+
22206
 
 For both the Unix and Windows versions of the constructor, *access* may be
22207
 
 specified as an optional keyword parameter. *access* accepts one of three
22208
 
 values: :const:`ACCESS_READ`, :const:`ACCESS_WRITE`, or :const:`ACCESS_COPY`
22209
 
diff -r 8527427914a2 Doc/library/modulefinder.rst
22210
 
--- a/Doc/library/modulefinder.rst
22211
 
+++ b/Doc/library/modulefinder.rst
22212
 
@@ -1,15 +1,16 @@
22213
 
-
22214
 
 :mod:`modulefinder` --- Find modules used by a script
22215
 
 =====================================================
22216
 
 
22217
 
+.. module:: modulefinder
22218
 
+   :synopsis: Find modules used by a script.
22219
 
 .. sectionauthor:: A.M. Kuchling <amk@amk.ca>
22220
 
 
22221
 
 
22222
 
-.. module:: modulefinder
22223
 
-   :synopsis: Find modules used by a script.
22224
 
+.. versionadded:: 2.3
22225
 
 
22226
 
+**Source code:** :source:`Lib/modulefinder.py`
22227
 
 
22228
 
-.. versionadded:: 2.3
22229
 
+--------------
22230
 
 
22231
 
 This module provides a :class:`ModuleFinder` class that can be used to determine
22232
 
 the set of modules imported by a script. ``modulefinder.py`` can also be run as
22233
 
diff -r 8527427914a2 Doc/library/msilib.rst
22234
 
--- a/Doc/library/msilib.rst
22235
 
+++ b/Doc/library/msilib.rst
22236
 
@@ -44,7 +44,7 @@
22237
 
 .. function:: UuidCreate()
22238
 
 
22239
 
    Return the string representation of a new unique identifier. This wraps the
22240
 
-   Windows API functions :cfunc:`UuidCreate` and :cfunc:`UuidToString`.
22241
 
+   Windows API functions :c:func:`UuidCreate` and :c:func:`UuidToString`.
22242
 
 
22243
 
 
22244
 
 .. function:: OpenDatabase(path, persist)
22245
 
@@ -60,7 +60,7 @@
22246
 
 
22247
 
 .. function:: CreateRecord(count)
22248
 
 
22249
 
-   Return a new record object by calling :cfunc:`MSICreateRecord`. *count* is the
22250
 
+   Return a new record object by calling :c:func:`MSICreateRecord`. *count* is the
22251
 
    number of fields of the record.
22252
 
 
22253
 
 
22254
 
@@ -135,20 +135,20 @@
22255
 
 
22256
 
 .. method:: Database.OpenView(sql)
22257
 
 
22258
 
-   Return a view object, by calling :cfunc:`MSIDatabaseOpenView`. *sql* is the SQL
22259
 
+   Return a view object, by calling :c:func:`MSIDatabaseOpenView`. *sql* is the SQL
22260
 
    statement to execute.
22261
 
 
22262
 
 
22263
 
 .. method:: Database.Commit()
22264
 
 
22265
 
    Commit the changes pending in the current transaction, by calling
22266
 
-   :cfunc:`MSIDatabaseCommit`.
22267
 
+   :c:func:`MSIDatabaseCommit`.
22268
 
 
22269
 
 
22270
 
 .. method:: Database.GetSummaryInformation(count)
22271
 
 
22272
 
    Return a new summary information object, by calling
22273
 
-   :cfunc:`MsiGetSummaryInformation`.  *count* is the maximum number of updated
22274
 
+   :c:func:`MsiGetSummaryInformation`.  *count* is the maximum number of updated
22275
 
    values.
22276
 
 
22277
 
 
22278
 
@@ -166,7 +166,7 @@
22279
 
 
22280
 
 .. method:: View.Execute(params)
22281
 
 
22282
 
-   Execute the SQL query of the view, through :cfunc:`MSIViewExecute`. If
22283
 
+   Execute the SQL query of the view, through :c:func:`MSIViewExecute`. If
22284
 
    *params* is not ``None``, it is a record describing actual values of the
22285
 
    parameter tokens in the query.
22286
 
 
22287
 
@@ -174,18 +174,18 @@
22288
 
 .. method:: View.GetColumnInfo(kind)
22289
 
 
22290
 
    Return a record describing the columns of the view, through calling
22291
 
-   :cfunc:`MsiViewGetColumnInfo`. *kind* can be either ``MSICOLINFO_NAMES`` or
22292
 
+   :c:func:`MsiViewGetColumnInfo`. *kind* can be either ``MSICOLINFO_NAMES`` or
22293
 
    ``MSICOLINFO_TYPES``.
22294
 
 
22295
 
 
22296
 
 .. method:: View.Fetch()
22297
 
 
22298
 
-   Return a result record of the query, through calling :cfunc:`MsiViewFetch`.
22299
 
+   Return a result record of the query, through calling :c:func:`MsiViewFetch`.
22300
 
 
22301
 
 
22302
 
 .. method:: View.Modify(kind, data)
22303
 
 
22304
 
-   Modify the view, by calling :cfunc:`MsiViewModify`. *kind* can be one of
22305
 
+   Modify the view, by calling :c:func:`MsiViewModify`. *kind* can be one of
22306
 
    ``MSIMODIFY_SEEK``, ``MSIMODIFY_REFRESH``, ``MSIMODIFY_INSERT``,
22307
 
    ``MSIMODIFY_UPDATE``, ``MSIMODIFY_ASSIGN``, ``MSIMODIFY_REPLACE``,
22308
 
    ``MSIMODIFY_MERGE``, ``MSIMODIFY_DELETE``, ``MSIMODIFY_INSERT_TEMPORARY``,
22309
 
@@ -197,7 +197,7 @@
22310
 
 
22311
 
 .. method:: View.Close()
22312
 
 
22313
 
-   Close the view, through :cfunc:`MsiViewClose`.
22314
 
+   Close the view, through :c:func:`MsiViewClose`.
22315
 
 
22316
 
 
22317
 
 .. seealso::
22318
 
@@ -216,7 +216,7 @@
22319
 
 
22320
 
 .. method:: SummaryInformation.GetProperty(field)
22321
 
 
22322
 
-   Return a property of the summary, through :cfunc:`MsiSummaryInfoGetProperty`.
22323
 
+   Return a property of the summary, through :c:func:`MsiSummaryInfoGetProperty`.
22324
 
    *field* is the name of the property, and can be one of the constants
22325
 
    ``PID_CODEPAGE``, ``PID_TITLE``, ``PID_SUBJECT``, ``PID_AUTHOR``,
22326
 
    ``PID_KEYWORDS``, ``PID_COMMENTS``, ``PID_TEMPLATE``, ``PID_LASTAUTHOR``,
22327
 
@@ -228,12 +228,12 @@
22328
 
 .. method:: SummaryInformation.GetPropertyCount()
22329
 
 
22330
 
    Return the number of summary properties, through
22331
 
-   :cfunc:`MsiSummaryInfoGetPropertyCount`.
22332
 
+   :c:func:`MsiSummaryInfoGetPropertyCount`.
22333
 
 
22334
 
 
22335
 
 .. method:: SummaryInformation.SetProperty(field, value)
22336
 
 
22337
 
-   Set a property through :cfunc:`MsiSummaryInfoSetProperty`. *field* can have the
22338
 
+   Set a property through :c:func:`MsiSummaryInfoSetProperty`. *field* can have the
22339
 
    same values as in :meth:`GetProperty`, *value* is the new value of the property.
22340
 
    Possible value types are integer and string.
22341
 
 
22342
 
@@ -241,7 +241,7 @@
22343
 
 .. method:: SummaryInformation.Persist()
22344
 
 
22345
 
    Write the modified properties to the summary information stream, using
22346
 
-   :cfunc:`MsiSummaryInfoPersist`.
22347
 
+   :c:func:`MsiSummaryInfoPersist`.
22348
 
 
22349
 
 
22350
 
 .. seealso::
22351
 
@@ -260,7 +260,7 @@
22352
 
 .. method:: Record.GetFieldCount()
22353
 
 
22354
 
    Return the number of fields of the record, through
22355
 
-   :cfunc:`MsiRecordGetFieldCount`.
22356
 
+   :c:func:`MsiRecordGetFieldCount`.
22357
 
 
22358
 
 
22359
 
 .. method:: Record.GetInteger(field)
22360
 
@@ -277,25 +277,25 @@
22361
 
 
22362
 
 .. method:: Record.SetString(field, value)
22363
 
 
22364
 
-   Set *field* to *value* through :cfunc:`MsiRecordSetString`. *field* must be an
22365
 
+   Set *field* to *value* through :c:func:`MsiRecordSetString`. *field* must be an
22366
 
    integer; *value* a string.
22367
 
 
22368
 
 
22369
 
 .. method:: Record.SetStream(field, value)
22370
 
 
22371
 
    Set *field* to the contents of the file named *value*, through
22372
 
-   :cfunc:`MsiRecordSetStream`. *field* must be an integer; *value* a string.
22373
 
+   :c:func:`MsiRecordSetStream`. *field* must be an integer; *value* a string.
22374
 
 
22375
 
 
22376
 
 .. method:: Record.SetInteger(field, value)
22377
 
 
22378
 
-   Set *field* to *value* through :cfunc:`MsiRecordSetInteger`. Both *field* and
22379
 
+   Set *field* to *value* through :c:func:`MsiRecordSetInteger`. Both *field* and
22380
 
    *value* must be an integer.
22381
 
 
22382
 
 
22383
 
 .. method:: Record.ClearData()
22384
 
 
22385
 
-   Set all fields of the record to 0, through :cfunc:`MsiRecordClearData`.
22386
 
+   Set all fields of the record to 0, through :c:func:`MsiRecordClearData`.
22387
 
 
22388
 
 
22389
 
 .. seealso::
22390
 
diff -r 8527427914a2 Doc/library/msvcrt.rst
22391
 
--- a/Doc/library/msvcrt.rst
22392
 
+++ b/Doc/library/msvcrt.rst
22393
 
@@ -152,5 +152,5 @@
22394
 
 
22395
 
 .. function:: heapmin()
22396
 
 
22397
 
-   Force the :cfunc:`malloc` heap to clean itself up and return unused blocks to
22398
 
+   Force the :c:func:`malloc` heap to clean itself up and return unused blocks to
22399
 
    the operating system.  On failure, this raises :exc:`IOError`.
22400
 
diff -r 8527427914a2 Doc/library/multiprocessing.rst
22401
 
--- a/Doc/library/multiprocessing.rst
22402
 
+++ b/Doc/library/multiprocessing.rst
22403
 
@@ -282,7 +282,7 @@
22404
 
 
22405
 
    if __name__ == '__main__':
22406
 
        pool = Pool(processes=4)              # start 4 worker processes
22407
 
-       result = pool.apply_async(f, [10])     # evaluate "f(10)" asynchronously
22408
 
+       result = pool.apply_async(f, [10])    # evaluate "f(10)" asynchronously
22409
 
        print result.get(timeout=1)           # prints "100" unless your computer is *very* slow
22410
 
        print pool.map(f, range(10))          # prints "[0, 1, 4,..., 81]"
22411
 
 
22412
 
@@ -408,7 +408,7 @@
22413
 
    .. method:: terminate()
22414
 
 
22415
 
       Terminate the process.  On Unix this is done using the ``SIGTERM`` signal;
22416
 
-      on Windows :cfunc:`TerminateProcess` is used.  Note that exit handlers and
22417
 
+      on Windows :c:func:`TerminateProcess` is used.  Note that exit handlers and
22418
 
       finally clauses, etc., will not be executed.
22419
 
 
22420
 
       Note that descendant processes of the process will *not* be terminated --
22421
 
@@ -464,7 +464,7 @@
22422
 
 For passing messages one can use :func:`Pipe` (for a connection between two
22423
 
 processes) or a queue (which allows multiple producers and consumers).
22424
 
 
22425
 
-The :class:`Queue` and :class:`JoinableQueue` types are multi-producer,
22426
 
+The :class:`Queue`, :class:`multiprocessing.queues.SimpleQueue` and :class:`JoinableQueue` types are multi-producer,
22427
 
 multi-consumer FIFO queues modelled on the :class:`Queue.Queue` class in the
22428
 
 standard library.  They differ in that :class:`Queue` lacks the
22429
 
 :meth:`~Queue.Queue.task_done` and :meth:`~Queue.Queue.join` methods introduced
22430
 
@@ -472,7 +472,7 @@
22431
 
 
22432
 
 If you use :class:`JoinableQueue` then you **must** call
22433
 
 :meth:`JoinableQueue.task_done` for each task removed from the queue or else the
22434
 
-semaphore used to count the number of unfinished tasks may eventually overflow
22435
 
+semaphore used to count the number of unfinished tasks may eventually overflow,
22436
 
 raising an exception.
22437
 
 
22438
 
 Note that one can also create a shared queue by using a manager object -- see
22439
 
@@ -490,7 +490,7 @@
22440
 
 
22441
 
    If a process is killed using :meth:`Process.terminate` or :func:`os.kill`
22442
 
    while it is trying to use a :class:`Queue`, then the data in the queue is
22443
 
-   likely to become corrupted.  This may cause any other processes to get an
22444
 
+   likely to become corrupted.  This may cause any other process to get an
22445
 
    exception when it tries to use the queue later on.
22446
 
 
22447
 
 .. warning::
22448
 
@@ -552,9 +552,9 @@
22449
 
       Return ``True`` if the queue is full, ``False`` otherwise.  Because of
22450
 
       multithreading/multiprocessing semantics, this is not reliable.
22451
 
 
22452
 
-   .. method:: put(item[, block[, timeout]])
22453
 
-
22454
 
-      Put item into the queue.  If the optional argument *block* is ``True``
22455
 
+   .. method:: put(obj[, block[, timeout]])
22456
 
+
22457
 
+      Put obj into the queue.  If the optional argument *block* is ``True``
22458
 
       (the default) and *timeout* is ``None`` (the default), block if necessary until
22459
 
       a free slot is available.  If *timeout* is a positive number, it blocks at
22460
 
       most *timeout* seconds and raises the :exc:`Queue.Full` exception if no
22461
 
@@ -563,9 +563,9 @@
22462
 
       available, else raise the :exc:`Queue.Full` exception (*timeout* is
22463
 
       ignored in that case).
22464
 
 
22465
 
-   .. method:: put_nowait(item)
22466
 
-
22467
 
-      Equivalent to ``put(item, False)``.
22468
 
+   .. method:: put_nowait(obj)
22469
 
+
22470
 
+      Equivalent to ``put(obj, False)``.
22471
 
 
22472
 
    .. method:: get([block[, timeout]])
22473
 
 
22474
 
@@ -610,6 +610,23 @@
22475
 
       exits -- see :meth:`join_thread`.
22476
 
 
22477
 
 
22478
 
+.. class:: multiprocessing.queues.SimpleQueue()
22479
 
+
22480
 
+   It is a simplified :class:`Queue` type, very close to a locked :class:`Pipe`.
22481
 
+
22482
 
+   .. method:: empty()
22483
 
+
22484
 
+      Return ``True`` if the queue is empty, ``False`` otherwise.
22485
 
+
22486
 
+   .. method:: get()
22487
 
+
22488
 
+      Remove and return an item from the queue.
22489
 
+
22490
 
+   .. method:: put(item)
22491
 
+
22492
 
+      Put *item* into the queue.
22493
 
+
22494
 
+
22495
 
 .. class:: JoinableQueue([maxsize])
22496
 
 
22497
 
    :class:`JoinableQueue`, a :class:`Queue` subclass, is a queue which
22498
 
@@ -692,7 +709,7 @@
22499
 
    (By default :data:`sys.executable` is used).  Embedders will probably need to
22500
 
    do some thing like ::
22501
 
 
22502
 
-      setExecutable(os.path.join(sys.exec_prefix, 'pythonw.exe'))
22503
 
+      set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe'))
22504
 
 
22505
 
    before they can create child processes.  (Windows only)
22506
 
 
22507
 
@@ -711,7 +728,7 @@
22508
 
 Connection objects allow the sending and receiving of picklable objects or
22509
 
 strings.  They can be thought of as message oriented connected sockets.
22510
 
 
22511
 
-Connection objects usually created using :func:`Pipe` -- see also
22512
 
+Connection objects are usually created using :func:`Pipe` -- see also
22513
 
 :ref:`multiprocessing-listeners-clients`.
22514
 
 
22515
 
 .. class:: Connection
22516
 
@@ -722,17 +739,18 @@
22517
 
       using :meth:`recv`.
22518
 
 
22519
 
       The object must be picklable.  Very large pickles (approximately 32 MB+,
22520
 
-      though it depends on the OS) may raise a ValueError exception.
22521
 
+      though it depends on the OS) may raise a :exc:`ValueError` exception.
22522
 
 
22523
 
    .. method:: recv()
22524
 
 
22525
 
       Return an object sent from the other end of the connection using
22526
 
-      :meth:`send`.  Raises :exc:`EOFError` if there is nothing left to receive
22527
 
+      :meth:`send`.  Blocks until there its something to receive.  Raises
22528
 
+      :exc:`EOFError` if there is nothing left to receive
22529
 
       and the other end was closed.
22530
 
 
22531
 
    .. method:: fileno()
22532
 
 
22533
 
-      Returns the file descriptor or handle used by the connection.
22534
 
+      Return the file descriptor or handle used by the connection.
22535
 
 
22536
 
    .. method:: close()
22537
 
 
22538
 
@@ -756,12 +774,13 @@
22539
 
       If *offset* is given then data is read from that position in *buffer*.  If
22540
 
       *size* is given then that many bytes will be read from buffer.  Very large
22541
 
       buffers (approximately 32 MB+, though it depends on the OS) may raise a
22542
 
-      ValueError exception
22543
 
+      :exc:`ValueError` exception
22544
 
 
22545
 
    .. method:: recv_bytes([maxlength])
22546
 
 
22547
 
       Return a complete message of byte data sent from the other end of the
22548
 
-      connection as a string.  Raises :exc:`EOFError` if there is nothing left
22549
 
+      connection as a string.  Blocks until there is something to receive.
22550
 
+      Raises :exc:`EOFError` if there is nothing left
22551
 
       to receive and the other end has closed.
22552
 
 
22553
 
       If *maxlength* is specified and the message is longer than *maxlength*
22554
 
@@ -771,7 +790,8 @@
22555
 
    .. method:: recv_bytes_into(buffer[, offset])
22556
 
 
22557
 
       Read into *buffer* a complete message of byte data sent from the other end
22558
 
-      of the connection and return the number of bytes in the message.  Raises
22559
 
+      of the connection and return the number of bytes in the message.  Blocks
22560
 
+      until there is something to receive.  Raises
22561
 
       :exc:`EOFError` if there is nothing left to receive and the other end was
22562
 
       closed.
22563
 
 
22564
 
@@ -1329,7 +1349,7 @@
22565
 
 >>>>>>>>>>>>>>>>>>>
22566
 
 
22567
 
 To create one's own manager, one creates a subclass of :class:`BaseManager` and
22568
 
-use the :meth:`~BaseManager.register` classmethod to register new types or
22569
 
+uses the :meth:`~BaseManager.register` classmethod to register new types or
22570
 
 callables with the manager class.  For example::
22571
 
 
22572
 
    from multiprocessing.managers import BaseManager
22573
 
@@ -1494,7 +1514,7 @@
22574
 
       a new shared object -- see documentation for the *method_to_typeid*
22575
 
       argument of :meth:`BaseManager.register`.
22576
 
 
22577
 
-      If an exception is raised by the call, then then is re-raised by
22578
 
+      If an exception is raised by the call, then is re-raised by
22579
 
       :meth:`_callmethod`.  If some other exception is raised in the manager's
22580
 
       process then this is converted into a :exc:`RemoteError` exception and is
22581
 
       raised by :meth:`_callmethod`.
22582
 
@@ -1579,10 +1599,10 @@
22583
 
 
22584
 
    .. method:: apply(func[, args[, kwds]])
22585
 
 
22586
 
-      Equivalent of the :func:`apply` built-in function.  It blocks till the
22587
 
-      result is ready.  Given this blocks, :meth:`apply_async` is better suited
22588
 
-      for performing work in parallel. Additionally, the passed
22589
 
-      in function is only executed in one of the workers of the pool.
22590
 
+      Equivalent of the :func:`apply` built-in function.  It blocks until the
22591
 
+      result is ready, so :meth:`apply_async` is better suited for performing
22592
 
+      work in parallel. Additionally, *func* is only executed in one of the
22593
 
+      workers of the pool.
22594
 
 
22595
 
    .. method:: apply_async(func[, args[, kwds[, callback]]])
22596
 
 
22597
 
@@ -1596,7 +1616,7 @@
22598
 
    .. method:: map(func, iterable[, chunksize])
22599
 
 
22600
 
       A parallel equivalent of the :func:`map` built-in function (it supports only
22601
 
-      one *iterable* argument though).  It blocks till the result is ready.
22602
 
+      one *iterable* argument though).  It blocks until the result is ready.
22603
 
 
22604
 
       This method chops the iterable into a number of chunks which it submits to
22605
 
       the process pool as separate tasks.  The (approximate) size of these
22606
 
@@ -1617,7 +1637,7 @@
22607
 
 
22608
 
       The *chunksize* argument is the same as the one used by the :meth:`.map`
22609
 
       method.  For very long iterables using a large value for *chunksize* can
22610
 
-      make make the job complete **much** faster than using the default value of
22611
 
+      make the job complete **much** faster than using the default value of
22612
 
       ``1``.
22613
 
 
22614
 
       Also if *chunksize* is ``1`` then the :meth:`!next` method of the iterator
22615
 
@@ -2046,7 +2066,7 @@
22616
 
     On Windows many types from :mod:`multiprocessing` need to be picklable so
22617
 
     that child processes can use them.  However, one should generally avoid
22618
 
     sending shared objects to other processes using pipes or queues.  Instead
22619
 
-    you should arrange the program so that a process which need access to a
22620
 
+    you should arrange the program so that a process which needs access to a
22621
 
     shared resource created elsewhere can inherit it from an ancestor process.
22622
 
 
22623
 
 Avoid terminating processes
22624
 
@@ -2125,7 +2145,7 @@
22625
 
            for i in range(10):
22626
 
                 Process(target=f, args=(lock,)).start()
22627
 
 
22628
 
-Beware replacing sys.stdin with a "file like object"
22629
 
+Beware of replacing :data:`sys.stdin` with a "file like object"
22630
 
 
22631
 
     :mod:`multiprocessing` originally unconditionally called::
22632
 
 
22633
 
@@ -2243,7 +2263,7 @@
22634
 
 
22635
 
 
22636
 
 An example showing how to use queues to feed tasks to a collection of worker
22637
 
-process and collect the results:
22638
 
+processes and collect the results:
22639
 
 
22640
 
 .. literalinclude:: ../includes/mp_workers.py
22641
 
 
22642
 
diff -r 8527427914a2 Doc/library/netrc.rst
22643
 
--- a/Doc/library/netrc.rst
22644
 
+++ b/Doc/library/netrc.rst
22645
 
@@ -10,6 +10,10 @@
22646
 
 
22647
 
 .. versionadded:: 1.5.2
22648
 
 
22649
 
+**Source code:** :source:`Lib/netrc.py`
22650
 
+
22651
 
+--------------
22652
 
+
22653
 
 The :class:`netrc` class parses and encapsulates the netrc file format used by
22654
 
 the Unix :program:`ftp` program and other FTP clients.
22655
 
 
22656
 
diff -r 8527427914a2 Doc/library/new.rst
22657
 
--- a/Doc/library/new.rst
22658
 
+++ b/Doc/library/new.rst
22659
 
@@ -48,7 +48,7 @@
22660
 
 
22661
 
 .. function:: code(argcount, nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, lnotab)
22662
 
 
22663
 
-   This function is an interface to the :cfunc:`PyCode_New` C function.
22664
 
+   This function is an interface to the :c:func:`PyCode_New` C function.
22665
 
 
22666
 
    .. XXX This is still undocumented!
22667
 
 
22668
 
diff -r 8527427914a2 Doc/library/nntplib.rst
22669
 
--- a/Doc/library/nntplib.rst
22670
 
+++ b/Doc/library/nntplib.rst
22671
 
@@ -10,6 +10,10 @@
22672
 
    pair: NNTP; protocol
22673
 
    single: Network News Transfer Protocol
22674
 
 
22675
 
+**Source code:** :source:`Lib/nntplib.py`
22676
 
+
22677
 
+--------------
22678
 
+
22679
 
 This module defines the class :class:`NNTP` which implements the client side of
22680
 
 the NNTP protocol.  It can be used to implement a news reader or poster, or
22681
 
 automated news processors.  For more information on NNTP (Network News Transfer
22682
 
diff -r 8527427914a2 Doc/library/numbers.rst
22683
 
--- a/Doc/library/numbers.rst
22684
 
+++ b/Doc/library/numbers.rst
22685
 
@@ -7,9 +7,9 @@
22686
 
 .. versionadded:: 2.6
22687
 
 
22688
 
 
22689
 
-The :mod:`numbers` module (:pep:`3141`) defines a hierarchy of numeric abstract
22690
 
-base classes which progressively define more operations.  None of the types
22691
 
-defined in this module can be instantiated.
22692
 
+The :mod:`numbers` module (:pep:`3141`) defines a hierarchy of numeric
22693
 
+:term:`abstract base classes <abstract base class>` which progressively define
22694
 
+more operations.  None of the types defined in this module can be instantiated.
22695
 
 
22696
 
 
22697
 
 .. class:: Number
22698
 
diff -r 8527427914a2 Doc/library/operator.rst
22699
 
--- a/Doc/library/operator.rst
22700
 
+++ b/Doc/library/operator.rst
22701
 
@@ -12,11 +12,11 @@
22702
 
    from operator import itemgetter
22703
 
 
22704
 
 
22705
 
-The :mod:`operator` module exports a set of functions implemented in C
22706
 
-corresponding to the intrinsic operators of Python.  For example,
22707
 
-``operator.add(x, y)`` is equivalent to the expression ``x+y``.  The function
22708
 
-names are those used for special class methods; variants without leading and
22709
 
-trailing ``__`` are also provided for convenience.
22710
 
+The :mod:`operator` module exports a set of efficient functions corresponding to
22711
 
+the intrinsic operators of Python.  For example, ``operator.add(x, y)`` is
22712
 
+equivalent to the expression ``x+y``.  The function names are those used for
22713
 
+special class methods; variants without leading and trailing ``__`` are also
22714
 
+provided for convenience.
22715
 
 
22716
 
 The functions fall into categories that perform object comparisons, logical
22717
 
 operations, mathematical operations, sequence operations, and abstract type
22718
 
diff -r 8527427914a2 Doc/library/optparse.rst
22719
 
--- a/Doc/library/optparse.rst
22720
 
+++ b/Doc/library/optparse.rst
22721
 
@@ -4,17 +4,18 @@
22722
 
 .. module:: optparse
22723
 
    :synopsis: Command-line option parsing library.
22724
 
    :deprecated:
22725
 
+.. moduleauthor:: Greg Ward <gward@python.net>
22726
 
+.. sectionauthor:: Greg Ward <gward@python.net>
22727
 
+
22728
 
+.. versionadded:: 2.3
22729
 
 
22730
 
 .. deprecated:: 2.7
22731
 
    The :mod:`optparse` module is deprecated and will not be developed further;
22732
 
    development will continue with the :mod:`argparse` module.
22733
 
 
22734
 
-.. moduleauthor:: Greg Ward <gward@python.net>
22735
 
-
22736
 
-.. versionadded:: 2.3
22737
 
-
22738
 
-.. sectionauthor:: Greg Ward <gward@python.net>
22739
 
-
22740
 
+**Source code:** :source:`Lib/optparse.py`
22741
 
+
22742
 
+--------------
22743
 
 
22744
 
 :mod:`optparse` is a more convenient, flexible, and powerful library for parsing
22745
 
 command-line options than the old :mod:`getopt` module.  :mod:`optparse` uses a
22746
 
@@ -609,8 +610,8 @@
22747
 
 
22748
 
        -g                  Group option.
22749
 
 
22750
 
-A bit more complete example might invole using more than one group: still
22751
 
-extendind the previous example::
22752
 
+A bit more complete example might involve using more than one group: still
22753
 
+extending the previous example::
22754
 
 
22755
 
     group = OptionGroup(parser, "Dangerous Options",
22756
 
                         "Caution: use these options at your own risk.  "
22757
 
@@ -657,8 +658,9 @@
22758
 
 
22759
 
 .. method:: OptionParser.get_option_group(opt_str)
22760
 
 
22761
 
-   Return, if defined, the :class:`OptionGroup` that has the title or the long
22762
 
-   description equals to *opt_str*
22763
 
+   Return the :class:`OptionGroup` to which the short or long option
22764
 
+   string *opt_str* (e.g. ``'-o'`` or ``'--option'``) belongs. If
22765
 
+   there's no such :class:`OptionGroup`, return ``None``.
22766
 
 
22767
 
 .. _optparse-printing-version-string:
22768
 
 
22769
 
diff -r 8527427914a2 Doc/library/os.path.rst
22770
 
--- a/Doc/library/os.path.rst
22771
 
+++ b/Doc/library/os.path.rst
22772
 
@@ -196,10 +196,11 @@
22773
 
    path, all previous components (on Windows, including the previous drive letter,
22774
 
    if there was one) are thrown away, and joining continues.  The return value is
22775
 
    the concatenation of *path1*, and optionally *path2*, etc., with exactly one
22776
 
-   directory separator (``os.sep``) inserted between components, unless *path2* is
22777
 
-   empty.  Note that on Windows, since there is a current directory for each drive,
22778
 
-   ``os.path.join("c:", "foo")`` represents a path relative to the current
22779
 
-   directory on drive :file:`C:` (:file:`c:foo`), not :file:`c:\\foo`.
22780
 
+   directory separator (``os.sep``) following each non-empty part except the last.
22781
 
+   (This means that an empty last part will result in a path that ends with a
22782
 
+   separator.)  Note that on Windows, since there is a current directory for
22783
 
+   each drive, ``os.path.join("c:", "foo")`` represents a path relative to the
22784
 
+   current directory on drive :file:`C:` (:file:`c:foo`), not :file:`c:\\foo`.
22785
 
 
22786
 
 
22787
 
 .. function:: normcase(path)
22788
 
diff -r 8527427914a2 Doc/library/os.rst
22789
 
--- a/Doc/library/os.rst
22790
 
+++ b/Doc/library/os.rst
22791
 
@@ -53,6 +53,13 @@
22792
 
    names have currently been registered: ``'posix'``, ``'nt'``,
22793
 
    ``'os2'``, ``'ce'``, ``'java'``, ``'riscos'``.
22794
 
 
22795
 
+   .. seealso::
22796
 
+      :attr:`sys.platform` has a finer granularity.  :func:`os.uname` gives
22797
 
+      system-dependent version information.
22798
 
+
22799
 
+      The :mod:`platform` module provides detailed checks for the
22800
 
+      system's identity.
22801
 
+
22802
 
 
22803
 
 .. _os-procinfo:
22804
 
 
22805
 
@@ -87,7 +94,7 @@
22806
 
 
22807
 
       On some platforms, including FreeBSD and Mac OS X, setting ``environ`` may
22808
 
       cause memory leaks.  Refer to the system documentation for
22809
 
-      :cfunc:`putenv`.
22810
 
+      :c:func:`putenv`.
22811
 
 
22812
 
    If :func:`putenv` is not provided, a modified copy of this mapping  may be
22813
 
    passed to the appropriate process-creation functions to cause  child processes
22814
 
@@ -302,7 +309,7 @@
22815
 
 
22816
 
 .. function:: setpgrp()
22817
 
 
22818
 
-   Call the system call :cfunc:`setpgrp` or :cfunc:`setpgrp(0, 0)` depending on
22819
 
+   Call the system call :c:func:`setpgrp` or :c:func:`setpgrp(0, 0)` depending on
22820
 
    which version is implemented (if any).  See the Unix manual for the semantics.
22821
 
 
22822
 
    Availability: Unix.
22823
 
@@ -310,7 +317,7 @@
22824
 
 
22825
 
 .. function:: setpgid(pid, pgrp)
22826
 
 
22827
 
-   Call the system call :cfunc:`setpgid` to set the process group id of the
22828
 
+   Call the system call :c:func:`setpgid` to set the process group id of the
22829
 
    process with id *pid* to the process group with id *pgrp*.  See the Unix manual
22830
 
    for the semantics.
22831
 
 
22832
 
@@ -351,7 +358,7 @@
22833
 
 
22834
 
 .. function:: getsid(pid)
22835
 
 
22836
 
-   Call the system call :cfunc:`getsid`.  See the Unix manual for the semantics.
22837
 
+   Call the system call :c:func:`getsid`.  See the Unix manual for the semantics.
22838
 
 
22839
 
    Availability: Unix.
22840
 
 
22841
 
@@ -360,7 +367,7 @@
22842
 
 
22843
 
 .. function:: setsid()
22844
 
 
22845
 
-   Call the system call :cfunc:`setsid`.  See the Unix manual for the semantics.
22846
 
+   Call the system call :c:func:`setsid`.  See the Unix manual for the semantics.
22847
 
 
22848
 
    Availability: Unix.
22849
 
 
22850
 
@@ -378,7 +385,7 @@
22851
 
 .. function:: strerror(code)
22852
 
 
22853
 
    Return the error message corresponding to the error code in *code*.
22854
 
-   On platforms where :cfunc:`strerror` returns ``NULL`` when given an unknown
22855
 
+   On platforms where :c:func:`strerror` returns ``NULL`` when given an unknown
22856
 
    error number, :exc:`ValueError` is raised.
22857
 
 
22858
 
    Availability: Unix, Windows.
22859
 
@@ -447,7 +454,7 @@
22860
 
 
22861
 
    .. versionchanged:: 2.5
22862
 
       On Unix, when the *mode* argument starts with ``'a'``, the *O_APPEND* flag is
22863
 
-      set on the file descriptor (which the :cfunc:`fdopen` implementation already
22864
 
+      set on the file descriptor (which the :c:func:`fdopen` implementation already
22865
 
       does on most platforms).
22866
 
 
22867
 
 
22868
 
@@ -470,7 +477,7 @@
22869
 
 
22870
 
    .. versionchanged:: 2.0
22871
 
       This function worked unreliably under Windows in earlier versions of Python.
22872
 
-      This was due to the use of the :cfunc:`_popen` function from the libraries
22873
 
+      This was due to the use of the :c:func:`_popen` function from the libraries
22874
 
       provided with Windows.  Newer versions of Python do not use the broken
22875
 
       implementation from the Windows libraries.
22876
 
 
22877
 
@@ -690,7 +697,7 @@
22878
 
 .. function:: fsync(fd)
22879
 
 
22880
 
    Force write of file with filedescriptor *fd* to disk.  On Unix, this calls the
22881
 
-   native :cfunc:`fsync` function; on Windows, the MS :cfunc:`_commit` function.
22882
 
+   native :c:func:`fsync` function; on Windows, the MS :c:func:`_commit` function.
22883
 
 
22884
 
    If you're starting with a Python file object *f*, first do ``f.flush()``, and
22885
 
    then do ``os.fsync(f.fileno())``, to ensure that all internal buffers associated
22886
 
@@ -929,7 +936,7 @@
22887
 
          try:
22888
 
              fp = open("myfile")
22889
 
          except IOError as e:
22890
 
-             if e.errno == errno.EACCESS:
22891
 
+             if e.errno == errno.EACCES:
22892
 
                  return "some default data"
22893
 
              # Not a permission error.
22894
 
              raise
22895
 
@@ -1014,6 +1021,8 @@
22896
 
    * :data:`stat.UF_APPEND`
22897
 
    * :data:`stat.UF_OPAQUE`
22898
 
    * :data:`stat.UF_NOUNLINK`
22899
 
+   * :data:`stat.UF_COMPRESSED`
22900
 
+   * :data:`stat.UF_HIDDEN`
22901
 
    * :data:`stat.SF_ARCHIVED`
22902
 
    * :data:`stat.SF_IMMUTABLE`
22903
 
    * :data:`stat.SF_APPEND`
22904
 
@@ -1133,7 +1142,7 @@
22905
 
 
22906
 
 .. function:: lstat(path)
22907
 
 
22908
 
-   Perform the equivalent of an :cfunc:`lstat` system call on the given path.
22909
 
+   Perform the equivalent of an :c:func:`lstat` system call on the given path.
22910
 
    Similar to :func:`~os.stat`, but does not follow symbolic links.  On
22911
 
    platforms that do not support symbolic links, this is an alias for
22912
 
    :func:`~os.stat`.
22913
 
@@ -1171,7 +1180,7 @@
22914
 
 .. function:: major(device)
22915
 
 
22916
 
    Extract the device major number from a raw device number (usually the
22917
 
-   :attr:`st_dev` or :attr:`st_rdev` field from :ctype:`stat`).
22918
 
+   :attr:`st_dev` or :attr:`st_rdev` field from :c:type:`stat`).
22919
 
 
22920
 
    .. versionadded:: 2.3
22921
 
 
22922
 
@@ -1179,7 +1188,7 @@
22923
 
 .. function:: minor(device)
22924
 
 
22925
 
    Extract the device minor number from a raw device number (usually the
22926
 
-   :attr:`st_dev` or :attr:`st_rdev` field from :ctype:`stat`).
22927
 
+   :attr:`st_dev` or :attr:`st_rdev` field from :c:type:`stat`).
22928
 
 
22929
 
    .. versionadded:: 2.3
22930
 
 
22931
 
@@ -1334,11 +1343,11 @@
22932
 
 
22933
 
 .. function:: stat(path)
22934
 
 
22935
 
-   Perform the equivalent of a :cfunc:`stat` system call on the given path.
22936
 
+   Perform the equivalent of a :c:func:`stat` system call on the given path.
22937
 
    (This function follows symlinks; to stat a symlink use :func:`lstat`.)
22938
 
 
22939
 
    The return value is an object whose attributes correspond to the members
22940
 
-   of the :ctype:`stat` structure, namely:
22941
 
+   of the :c:type:`stat` structure, namely:
22942
 
 
22943
 
    * :attr:`st_mode` - protection bits,
22944
 
    * :attr:`st_ino` - inode number,
22945
 
@@ -1386,15 +1395,16 @@
22946
 
 
22947
 
    .. note::
22948
 
 
22949
 
-      The exact meaning and resolution of the :attr:`st_atime`, :attr:`st_mtime`, and
22950
 
-      :attr:`st_ctime` members depends on the operating system and the file system.
22951
 
-      For example, on Windows systems using the FAT or FAT32 file systems,
22952
 
-      :attr:`st_mtime` has 2-second resolution, and :attr:`st_atime` has only 1-day
22953
 
-      resolution.  See your operating system documentation for details.
22954
 
+      The exact meaning and resolution of the :attr:`st_atime`,
22955
 
+      :attr:`st_mtime`, and :attr:`st_ctime` attributes depend on the operating
22956
 
+      system and the file system. For example, on Windows systems using the FAT
22957
 
+      or FAT32 file systems, :attr:`st_mtime` has 2-second resolution, and
22958
 
+      :attr:`st_atime` has only 1-day resolution.  See your operating system
22959
 
+      documentation for details.
22960
 
 
22961
 
    For backward compatibility, the return value of :func:`~os.stat` is also accessible
22962
 
    as a tuple of at least 10 integers giving the most important (and portable)
22963
 
-   members of the :ctype:`stat` structure, in the order :attr:`st_mode`,
22964
 
+   members of the :c:type:`stat` structure, in the order :attr:`st_mode`,
22965
 
    :attr:`st_ino`, :attr:`st_dev`, :attr:`st_nlink`, :attr:`st_uid`,
22966
 
    :attr:`st_gid`, :attr:`st_size`, :attr:`st_atime`, :attr:`st_mtime`,
22967
 
    :attr:`st_ctime`. More items may be added at the end by some implementations.
22968
 
@@ -1402,7 +1412,7 @@
22969
 
    .. index:: module: stat
22970
 
 
22971
 
    The standard module :mod:`stat` defines functions and constants that are useful
22972
 
-   for extracting information from a :ctype:`stat` structure. (On Windows, some
22973
 
+   for extracting information from a :c:type:`stat` structure. (On Windows, some
22974
 
    items are filled with dummy values.)
22975
 
 
22976
 
    Example::
22977
 
@@ -1451,9 +1461,9 @@
22978
 
 
22979
 
 .. function:: statvfs(path)
22980
 
 
22981
 
-   Perform a :cfunc:`statvfs` system call on the given path.  The return value is
22982
 
+   Perform a :c:func:`statvfs` system call on the given path.  The return value is
22983
 
    an object whose attributes describe the filesystem on the given path, and
22984
 
-   correspond to the members of the :ctype:`statvfs` structure, namely:
22985
 
+   correspond to the members of the :c:type:`statvfs` structure, namely:
22986
 
    :attr:`f_bsize`, :attr:`f_frsize`, :attr:`f_blocks`, :attr:`f_bfree`,
22987
 
    :attr:`f_bavail`, :attr:`f_files`, :attr:`f_ffree`, :attr:`f_favail`,
22988
 
    :attr:`f_flag`, :attr:`f_namemax`.
22989
 
@@ -1463,7 +1473,7 @@
22990
 
    For backward compatibility, the return value is also accessible as a tuple whose
22991
 
    values correspond to the attributes, in the order given above. The standard
22992
 
    module :mod:`statvfs` defines constants that are useful for extracting
22993
 
-   information from a :ctype:`statvfs` structure when accessing it as a sequence;
22994
 
+   information from a :c:type:`statvfs` structure when accessing it as a sequence;
22995
 
    this remains useful when writing code that needs to work with versions of Python
22996
 
    that don't support accessing the fields as attributes.
22997
 
 
22998
 
@@ -1588,7 +1598,7 @@
22999
 
    ineffective, because in bottom-up mode the directories in *dirnames* are
23000
 
    generated before *dirpath* itself is generated.
23001
 
 
23002
 
-   By default errors from the :func:`listdir` call are ignored.  If optional
23003
 
+   By default, errors from the :func:`listdir` call are ignored.  If optional
23004
 
    argument *onerror* is specified, it should be a function; it will be called with
23005
 
    one argument, an :exc:`OSError` instance.  It can report the error to continue
23006
 
    with the walk, or raise the exception to abort the walk.  Note that the filename
23007
 
@@ -1654,7 +1664,7 @@
23008
 
 program loaded into the process.  In each case, the first of these arguments is
23009
 
 passed to the new program as its own name rather than as an argument a user may
23010
 
 have typed on a command line.  For the C programmer, this is the ``argv[0]``
23011
 
-passed to a program's :cfunc:`main`.  For example, ``os.execv('/bin/echo',
23012
 
+passed to a program's :c:func:`main`.  For example, ``os.execv('/bin/echo',
23013
 
 ['foo', 'bar'])`` will only print ``bar`` on standard output; ``foo`` will seem
23014
 
 to be ignored.
23015
 
 
23016
 
@@ -1663,8 +1673,9 @@
23017
 
 
23018
 
    Generate a :const:`SIGABRT` signal to the current process.  On Unix, the default
23019
 
    behavior is to produce a core dump; on Windows, the process immediately returns
23020
 
-   an exit code of ``3``.  Be aware that programs which use :func:`signal.signal`
23021
 
-   to register a handler for :const:`SIGABRT` will behave differently.
23022
 
+   an exit code of ``3``.  Be aware that calling this function will not call the
23023
 
+   Python signal handler registered for :const:`SIGABRT` with
23024
 
+   :func:`signal.signal`.
23025
 
 
23026
 
    Availability: Unix, Windows.
23027
 
 
23028
 
@@ -2041,7 +2052,9 @@
23029
 
       os.spawnvpe(os.P_WAIT, 'cp', L, os.environ)
23030
 
 
23031
 
    Availability: Unix, Windows.  :func:`spawnlp`, :func:`spawnlpe`, :func:`spawnvp`
23032
 
-   and :func:`spawnvpe` are not available on Windows.
23033
 
+   and :func:`spawnvpe` are not available on Windows.  :func:`spawnle` and
23034
 
+   :func:`spawnve` are not thread-safe on Windows; we advise you to use the
23035
 
+   :mod:`subprocess` module instead.
23036
 
 
23037
 
    .. versionadded:: 1.6
23038
 
 
23039
 
@@ -2104,7 +2117,7 @@
23040
 
    There is no option to wait for the application to close, and no way to retrieve
23041
 
    the application's exit status.  The *path* parameter is relative to the current
23042
 
    directory.  If you want to use an absolute path, make sure the first character
23043
 
-   is not a slash (``'/'``); the underlying Win32 :cfunc:`ShellExecute` function
23044
 
+   is not a slash (``'/'``); the underlying Win32 :c:func:`ShellExecute` function
23045
 
    doesn't work if it is.  Use the :func:`os.path.normpath` function to ensure that
23046
 
    the path is properly encoded for Win32.
23047
 
 
23048
 
@@ -2119,13 +2132,13 @@
23049
 
 .. function:: system(command)
23050
 
 
23051
 
    Execute the command (a string) in a subshell.  This is implemented by calling
23052
 
-   the Standard C function :cfunc:`system`, and has the same limitations.
23053
 
+   the Standard C function :c:func:`system`, and has the same limitations.
23054
 
    Changes to :data:`sys.stdin`, etc. are not reflected in the environment of the
23055
 
    executed command.
23056
 
 
23057
 
    On Unix, the return value is the exit status of the process encoded in the
23058
 
    format specified for :func:`wait`.  Note that POSIX does not specify the meaning
23059
 
-   of the return value of the C :cfunc:`system` function, so the return value of
23060
 
+   of the return value of the C :c:func:`system` function, so the return value of
23061
 
    the Python function is system-dependent.
23062
 
 
23063
 
    On Windows, the return value is that returned by the system shell after running
23064
 
diff -r 8527427914a2 Doc/library/ossaudiodev.rst
23065
 
--- a/Doc/library/ossaudiodev.rst
23066
 
+++ b/Doc/library/ossaudiodev.rst
23067
 
@@ -17,7 +17,7 @@
23068
 
    ALSA is in the standard kernel as of 2.5.x.  Presumably if you
23069
 
    use ALSA, you'll have to make sure its OSS compatibility layer
23070
 
    is active to use ossaudiodev, but you're gonna need it for the vast
23071
 
-   majority of Linux audio apps anyways.
23072
 
+   majority of Linux audio apps anyway.
23073
 
 
23074
 
    Sounds like things are also complicated for other BSDs.  In response
23075
 
    to my python-dev query, Thomas Wouters said:
23076
 
@@ -59,7 +59,7 @@
23077
 
    what went wrong.
23078
 
 
23079
 
    (If :mod:`ossaudiodev` receives an error from a system call such as
23080
 
-   :cfunc:`open`, :cfunc:`write`, or :cfunc:`ioctl`, it raises :exc:`IOError`.
23081
 
+   :c:func:`open`, :c:func:`write`, or :c:func:`ioctl`, it raises :exc:`IOError`.
23082
 
    Errors detected directly by :mod:`ossaudiodev` result in :exc:`OSSAudioError`.)
23083
 
 
23084
 
    (For backwards compatibility, the exception class is also available as
23085
 
diff -r 8527427914a2 Doc/library/othergui.rst
23086
 
--- a/Doc/library/othergui.rst
23087
 
+++ b/Doc/library/othergui.rst
23088
 
@@ -3,34 +3,8 @@
23089
 
 Other Graphical User Interface Packages
23090
 
 =======================================
23091
 
 
23092
 
-There are an number of extension widget sets to :mod:`Tkinter`.
23093
 
-
23094
 
-.. seealso::
23095
 
-
23096
 
-   `Python megawidgets <http://pmw.sourceforge.net/>`_
23097
 
-      is a toolkit for building high-level compound widgets in Python using the
23098
 
-      :mod:`Tkinter` module.  It consists of a set of base classes and a library of
23099
 
-      flexible and extensible megawidgets built on this foundation. These megawidgets
23100
 
-      include notebooks, comboboxes, selection widgets, paned widgets, scrolled
23101
 
-      widgets, dialog windows, etc.  Also, with the Pmw.Blt interface to BLT, the
23102
 
-      busy, graph, stripchart, tabset and vector commands are be available.
23103
 
-
23104
 
-      The initial ideas for Pmw were taken from the Tk ``itcl`` extensions ``[incr
23105
 
-      Tk]`` by Michael McLennan and ``[incr Widgets]`` by Mark Ulferts. Several of the
23106
 
-      megawidgets are direct translations from the itcl to Python. It offers most of
23107
 
-      the range of widgets that ``[incr Widgets]`` does, and is almost as complete as
23108
 
-      Tix, lacking however Tix's fast :class:`HList` widget for drawing trees.
23109
 
-
23110
 
-   `Tkinter3000 Widget Construction Kit (WCK) <http://tkinter.effbot.org/>`_
23111
 
-      is a library that allows you to write new Tkinter widgets in pure Python.  The
23112
 
-      WCK framework gives you full control over widget creation, configuration, screen
23113
 
-      appearance, and event handling.  WCK widgets can be very fast and light-weight,
23114
 
-      since they can operate directly on Python data structures, without having to
23115
 
-      transfer data through the Tk/Tcl layer.
23116
 
-
23117
 
-
23118
 
-The major cross-platform (Windows, Mac OS X, Unix-like) GUI toolkits that are
23119
 
-also available for Python:
23120
 
+Major cross-platform (Windows, Mac OS X, Unix-like) GUI toolkits are
23121
 
+available for Python:
23122
 
 
23123
 
 .. seealso::
23124
 
 
23125
 
diff -r 8527427914a2 Doc/library/pickle.rst
23126
 
--- a/Doc/library/pickle.rst
23127
 
+++ b/Doc/library/pickle.rst
23128
 
@@ -364,7 +364,7 @@
23129
 
 
23130
 
 Note that functions (built-in and user-defined) are pickled by "fully qualified"
23131
 
 name reference, not by value.  This means that only the function name is
23132
 
-pickled, along with the name of module the function is defined in.  Neither the
23133
 
+pickled, along with the name of the module the function is defined in.  Neither the
23134
 
 function's code, nor any of its function attributes are pickled.  Thus the
23135
 
 defining module must be importable in the unpickling environment, and the module
23136
 
 must contain the named object, otherwise an exception will be raised. [#]_
23137
 
diff -r 8527427914a2 Doc/library/pickletools.rst
23138
 
--- a/Doc/library/pickletools.rst
23139
 
+++ b/Doc/library/pickletools.rst
23140
 
@@ -8,6 +8,10 @@
23141
 
 
23142
 
 .. versionadded:: 2.3
23143
 
 
23144
 
+**Source code:** :source:`Lib/pickletools.py`
23145
 
+
23146
 
+--------------
23147
 
+
23148
 
 This module contains various constants relating to the intimate details of the
23149
 
 :mod:`pickle` module, some lengthy comments about the implementation, and a few
23150
 
 useful functions for analyzing pickled data.  The contents of this module are
23151
 
diff -r 8527427914a2 Doc/library/pipes.rst
23152
 
--- a/Doc/library/pipes.rst
23153
 
+++ b/Doc/library/pipes.rst
23154
 
@@ -1,4 +1,3 @@
23155
 
-
23156
 
 :mod:`pipes` --- Interface to shell pipelines
23157
 
 =============================================
23158
 
 
23159
 
@@ -7,6 +6,9 @@
23160
 
    :synopsis: A Python interface to Unix shell pipelines.
23161
 
 .. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
23162
 
 
23163
 
+**Source code:** :source:`Lib/pipes.py`
23164
 
+
23165
 
+--------------
23166
 
 
23167
 
 The :mod:`pipes` module defines a class to abstract the concept of a *pipeline*
23168
 
 --- a sequence of converters from one file to  another.
23169
 
diff -r 8527427914a2 Doc/library/pkgutil.rst
23170
 
--- a/Doc/library/pkgutil.rst
23171
 
+++ b/Doc/library/pkgutil.rst
23172
 
@@ -1,15 +1,18 @@
23173
 
-
23174
 
 :mod:`pkgutil` --- Package extension utility
23175
 
 ============================================
23176
 
 
23177
 
 .. module:: pkgutil
23178
 
    :synopsis: Utilities for the import system.
23179
 
 
23180
 
+.. versionadded:: 2.3
23181
 
+
23182
 
+**Source code:** :source:`Lib/pkgutil.py`
23183
 
+
23184
 
+--------------
23185
 
+
23186
 
 This module provides utilities for the import system, in particular package
23187
 
 support.
23188
 
 
23189
 
-.. versionadded:: 2.3
23190
 
-
23191
 
 
23192
 
 .. function:: extend_path(path, name)
23193
 
 
23194
 
@@ -187,3 +190,5 @@
23195
 
 
23196
 
    If the package cannot be located or loaded, or it uses a :pep:`302` loader
23197
 
    which does not support :func:`get_data`, then ``None`` is returned.
23198
 
+
23199
 
+   .. versionadded:: 2.6
23200
 
diff -r 8527427914a2 Doc/library/platform.rst
23201
 
--- a/Doc/library/platform.rst
23202
 
+++ b/Doc/library/platform.rst
23203
 
@@ -9,6 +9,10 @@
23204
 
 
23205
 
 .. versionadded:: 2.3
23206
 
 
23207
 
+**Source code:** :source:`Lib/platform.py`
23208
 
+
23209
 
+--------------
23210
 
+
23211
 
 .. note::
23212
 
 
23213
 
    Specific platforms listed alphabetically, with Linux included in the Unix
23214
 
@@ -29,8 +33,8 @@
23215
 
    returned as strings.
23216
 
 
23217
 
    Values that cannot be determined are returned as given by the parameter presets.
23218
 
-   If bits is given as ``''``, the :cfunc:`sizeof(pointer)` (or
23219
 
-   :cfunc:`sizeof(long)` on Python version < 1.5.2) is used as indicator for the
23220
 
+   If bits is given as ``''``, the :c:func:`sizeof(pointer)` (or
23221
 
+   :c:func:`sizeof(long)` on Python version < 1.5.2) is used as indicator for the
23222
 
    supported pointer size.
23223
 
 
23224
 
    The function relies on the system's :file:`file` command to do the actual work.
23225
 
@@ -193,8 +197,8 @@
23226
 
 .. function:: win32_ver(release='', version='', csd='', ptype='')
23227
 
 
23228
 
    Get additional version information from the Windows Registry and return a tuple
23229
 
-   ``(version, csd, ptype)`` referring to version number, CSD level and OS type
23230
 
-   (multi/single processor).
23231
 
+   ``(version, csd, ptype)`` referring to version number, CSD level
23232
 
+   (service pack) and OS type (multi/single processor).
23233
 
 
23234
 
    As a hint: *ptype* is ``'Uniprocessor Free'`` on single processor NT machines
23235
 
    and ``'Multiprocessor Free'`` on multi processor machines. The *'Free'* refers
23236
 
@@ -233,9 +237,6 @@
23237
 
    Entries which cannot be determined are set to ``''``.  All tuple entries are
23238
 
    strings.
23239
 
 
23240
 
-   Documentation for the underlying :cfunc:`gestalt` API is available online at
23241
 
-   http://www.rgaros.nl/gestalt/.
23242
 
-
23243
 
 
23244
 
 Unix Platforms
23245
 
 --------------
23246
 
diff -r 8527427914a2 Doc/library/plistlib.rst
23247
 
--- a/Doc/library/plistlib.rst
23248
 
+++ b/Doc/library/plistlib.rst
23249
 
@@ -15,6 +15,10 @@
23250
 
    pair: plist; file
23251
 
    single: property list
23252
 
 
23253
 
+**Source code:** :source:`Lib/plistlib.py`
23254
 
+
23255
 
+--------------
23256
 
+
23257
 
 This module provides an interface for reading and writing the "property list"
23258
 
 XML files used mainly by Mac OS X.
23259
 
 
23260
 
diff -r 8527427914a2 Doc/library/popen2.rst
23261
 
--- a/Doc/library/popen2.rst
23262
 
+++ b/Doc/library/popen2.rst
23263
 
@@ -104,7 +104,7 @@
23264
 
 
23265
 
    Waits for and returns the status code of the child process.  The status code
23266
 
    encodes both the return code of the process and information about whether it
23267
 
-   exited using the :cfunc:`exit` system call or died due to a signal.  Functions
23268
 
+   exited using the :c:func:`exit` system call or died due to a signal.  Functions
23269
 
    to help interpret the status code are defined in the :mod:`os` module; see
23270
 
    section :ref:`os-process` for the :func:`W\*` family of functions.
23271
 
 
23272
 
diff -r 8527427914a2 Doc/library/poplib.rst
23273
 
--- a/Doc/library/poplib.rst
23274
 
+++ b/Doc/library/poplib.rst
23275
 
@@ -1,4 +1,3 @@
23276
 
-
23277
 
 :mod:`poplib` --- POP3 protocol client
23278
 
 ======================================
23279
 
 
23280
 
@@ -9,6 +8,10 @@
23281
 
 
23282
 
 .. index:: pair: POP3; protocol
23283
 
 
23284
 
+**Source code:** :source:`Lib/poplib.py`
23285
 
+
23286
 
+--------------
23287
 
+
23288
 
 This module defines a class, :class:`POP3`, which encapsulates a connection to a
23289
 
 POP3 server and implements the protocol as defined in :rfc:`1725`.  The
23290
 
 :class:`POP3` class supports both the minimal and optional command sets.
23291
 
diff -r 8527427914a2 Doc/library/posix.rst
23292
 
--- a/Doc/library/posix.rst
23293
 
+++ b/Doc/library/posix.rst
23294
 
@@ -38,13 +38,13 @@
23295
 
 
23296
 
 Several operating systems (including AIX, HP-UX, Irix and Solaris) provide
23297
 
 support for files that are larger than 2 GB from a C programming model where
23298
 
-:ctype:`int` and :ctype:`long` are 32-bit values. This is typically accomplished
23299
 
+:c:type:`int` and :c:type:`long` are 32-bit values. This is typically accomplished
23300
 
 by defining the relevant size and offset types as 64-bit values. Such files are
23301
 
 sometimes referred to as :dfn:`large files`.
23302
 
 
23303
 
-Large file support is enabled in Python when the size of an :ctype:`off_t` is
23304
 
-larger than a :ctype:`long` and the :ctype:`long long` type is available and is
23305
 
-at least as large as an :ctype:`off_t`. Python longs are then used to represent
23306
 
+Large file support is enabled in Python when the size of an :c:type:`off_t` is
23307
 
+larger than a :c:type:`long` and the :c:type:`long long` type is available and is
23308
 
+at least as large as an :c:type:`off_t`. Python longs are then used to represent
23309
 
 file sizes, offsets and other values that can exceed the range of a Python int.
23310
 
 It may be necessary to configure and compile Python with certain compiler flags
23311
 
 to enable this mode. For example, it is enabled by default with recent versions
23312
 
diff -r 8527427914a2 Doc/library/pprint.rst
23313
 
--- a/Doc/library/pprint.rst
23314
 
+++ b/Doc/library/pprint.rst
23315
 
@@ -1,4 +1,3 @@
23316
 
-
23317
 
 :mod:`pprint` --- Data pretty printer
23318
 
 =====================================
23319
 
 
23320
 
@@ -7,6 +6,9 @@
23321
 
 .. moduleauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
23322
 
 .. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
23323
 
 
23324
 
+**Source code:** :source:`Lib/pprint.py`
23325
 
+
23326
 
+--------------
23327
 
 
23328
 
 The :mod:`pprint` module provides a capability to "pretty-print" arbitrary
23329
 
 Python data structures in a form which can be used as input to the interpreter.
23330
 
@@ -28,10 +30,6 @@
23331
 
 .. versionchanged:: 2.6
23332
 
    Added support for :class:`set` and :class:`frozenset`.
23333
 
 
23334
 
-.. seealso::
23335
 
-
23336
 
-   Latest version of the `pprint module Python source code
23337
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/pprint.py?view=markup>`_
23338
 
 
23339
 
 The :mod:`pprint` module defines one class:
23340
 
 
23341
 
diff -r 8527427914a2 Doc/library/profile.rst
23342
 
--- a/Doc/library/profile.rst
23343
 
+++ b/Doc/library/profile.rst
23344
 
@@ -1,4 +1,3 @@
23345
 
-
23346
 
 .. _profile:
23347
 
 
23348
 
 ********************
23349
 
@@ -10,29 +9,9 @@
23350
 
 .. module:: profile
23351
 
    :synopsis: Python source profiler.
23352
 
 
23353
 
-.. index:: single: InfoSeek Corporation
23354
 
+**Source code:** :source:`Lib/profile.py` and :source:`Lib/pstats.py`
23355
 
 
23356
 
-Copyright © 1994, by InfoSeek Corporation, all rights reserved.
23357
 
-
23358
 
-Written by James Roskind. [#]_
23359
 
-
23360
 
-Permission to use, copy, modify, and distribute this Python software and its
23361
 
-associated documentation for any purpose (subject to the restriction in the
23362
 
-following sentence) without fee is hereby granted, provided that the above
23363
 
-copyright notice appears in all copies, and that both that copyright notice and
23364
 
-this permission notice appear in supporting documentation, and that the name of
23365
 
-InfoSeek not be used in advertising or publicity pertaining to distribution of
23366
 
-the software without specific, written prior permission.  This permission is
23367
 
-explicitly restricted to the copying and modification of the software to remain
23368
 
-in Python, compiled Python, or other languages (such as C) wherein the modified
23369
 
-or derived code is exclusively imported into a Python module.
23370
 
-
23371
 
-INFOSEEK CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
23372
 
-INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT
23373
 
-SHALL INFOSEEK CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
23374
 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
23375
 
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
23376
 
-OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23377
 
+--------------
23378
 
 
23379
 
 .. _profiler-introduction:
23380
 
 
23381
 
@@ -65,7 +44,6 @@
23382
 
    :mod:`cProfile`.  Adds significant overhead to profiled programs.
23383
 
    If you're trying to extend
23384
 
    the profiler in some way, the task might be easier with this module.
23385
 
-   Copyright © 1994, by InfoSeek Corporation.
23386
 
 
23387
 
    .. versionchanged:: 2.4
23388
 
       Now also reports the time spent in calls to built-in functions and methods.
23389
 
diff -r 8527427914a2 Doc/library/py_compile.rst
23390
 
--- a/Doc/library/py_compile.rst
23391
 
+++ b/Doc/library/py_compile.rst
23392
 
@@ -8,6 +8,10 @@
23393
 
 
23394
 
 .. index:: pair: file; byte-code
23395
 
 
23396
 
+**Source code:** :source:`Lib/py_compile.py`
23397
 
+
23398
 
+--------------
23399
 
+
23400
 
 The :mod:`py_compile` module provides a function to generate a byte-code file
23401
 
 from a source file, and another function used when the module source file is
23402
 
 invoked as a script.
23403
 
diff -r 8527427914a2 Doc/library/pyclbr.rst
23404
 
--- a/Doc/library/pyclbr.rst
23405
 
+++ b/Doc/library/pyclbr.rst
23406
 
@@ -1,4 +1,3 @@
23407
 
-
23408
 
 :mod:`pyclbr` --- Python class browser support
23409
 
 ==============================================
23410
 
 
23411
 
@@ -6,6 +5,9 @@
23412
 
    :synopsis: Supports information extraction for a Python class browser.
23413
 
 .. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
23414
 
 
23415
 
+**Source code:** :source:`Lib/pyclbr.py`
23416
 
+
23417
 
+--------------
23418
 
 
23419
 
 The :mod:`pyclbr` module can be used to determine some limited information
23420
 
 about the classes, methods and top-level functions defined in a module.  The
23421
 
@@ -43,7 +45,7 @@
23422
 
 
23423
 
 The :class:`Class` objects used as values in the dictionary returned by
23424
 
 :func:`readmodule` and :func:`readmodule_ex` provide the following data
23425
 
-members:
23426
 
+attributes:
23427
 
 
23428
 
 
23429
 
 .. attribute:: Class.module
23430
 
@@ -87,7 +89,7 @@
23431
 
 ----------------
23432
 
 
23433
 
 The :class:`Function` objects used as values in the dictionary returned by
23434
 
-:func:`readmodule_ex` provide the following data members:
23435
 
+:func:`readmodule_ex` provide the following attributes:
23436
 
 
23437
 
 
23438
 
 .. attribute:: Function.module
23439
 
diff -r 8527427914a2 Doc/library/pydoc.rst
23440
 
--- a/Doc/library/pydoc.rst
23441
 
+++ b/Doc/library/pydoc.rst
23442
 
@@ -1,4 +1,3 @@
23443
 
-
23444
 
 :mod:`pydoc` --- Documentation generator and online help system
23445
 
 ===============================================================
23446
 
 
23447
 
@@ -15,6 +14,10 @@
23448
 
    single: documentation; online
23449
 
    single: help; online
23450
 
 
23451
 
+**Source code:** :source:`Lib/pydoc.py`
23452
 
+
23453
 
+--------------
23454
 
+
23455
 
 The :mod:`pydoc` module automatically generates documentation from Python
23456
 
 modules.  The documentation can be presented as pages of text on the console,
23457
 
 served to a Web browser, or saved to HTML files.
23458
 
diff -r 8527427914a2 Doc/library/queue.rst
23459
 
--- a/Doc/library/queue.rst
23460
 
+++ b/Doc/library/queue.rst
23461
 
@@ -1,4 +1,4 @@
23462
 
-:mod:`queue` --- A synchronized queue class
23463
 
+:mod:`Queue` --- A synchronized queue class
23464
 
 ===========================================
23465
 
 
23466
 
 .. module:: Queue
23467
 
@@ -9,6 +9,9 @@
23468
 
    :term:`2to3` tool will automatically adapt imports when converting your
23469
 
    sources to 3.0.
23470
 
 
23471
 
+**Source code:** :source:`Lib/Queue.py`
23472
 
+
23473
 
+--------------
23474
 
 
23475
 
 The :mod:`Queue` module implements multi-producer, multi-consumer queues.
23476
 
 It is especially useful in threaded programming when information must be
23477
 
@@ -24,11 +27,6 @@
23478
 
 the entries are kept sorted (using the :mod:`heapq` module) and the
23479
 
 lowest valued entry is retrieved first.
23480
 
 
23481
 
-.. seealso::
23482
 
-
23483
 
-   Latest version of the `queue module Python source code
23484
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/Queue.py?view=markup>`_.
23485
 
-
23486
 
 The :mod:`Queue` module defines the following classes and exceptions:
23487
 
 
23488
 
 .. class:: Queue(maxsize=0)
23489
 
diff -r 8527427914a2 Doc/library/quopri.rst
23490
 
--- a/Doc/library/quopri.rst
23491
 
+++ b/Doc/library/quopri.rst
23492
 
@@ -1,4 +1,3 @@
23493
 
-
23494
 
 :mod:`quopri` --- Encode and decode MIME quoted-printable data
23495
 
 ==============================================================
23496
 
 
23497
 
@@ -10,6 +9,10 @@
23498
 
    pair: quoted-printable; encoding
23499
 
    single: MIME; quoted-printable encoding
23500
 
 
23501
 
+**Source code:** :source:`Lib/quopri.py`
23502
 
+
23503
 
+--------------
23504
 
+
23505
 
 This module performs quoted-printable transport encoding and decoding, as
23506
 
 defined in :rfc:`1521`: "MIME (Multipurpose Internet Mail Extensions) Part One:
23507
 
 Mechanisms for Specifying and Describing the Format of Internet Message Bodies".
23508
 
@@ -18,11 +21,6 @@
23509
 
 :mod:`base64` module is more compact if there are many such characters, as when
23510
 
 sending a graphics file.
23511
 
 
23512
 
-.. seealso::
23513
 
-
23514
 
-   Latest version of the `quopri module Python source code
23515
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/quopri.py?view=markup>`_
23516
 
-
23517
 
 .. function:: decode(input, output[,header])
23518
 
 
23519
 
    Decode the contents of the *input* file and write the resulting decoded binary
23520
 
diff -r 8527427914a2 Doc/library/random.rst
23521
 
--- a/Doc/library/random.rst
23522
 
+++ b/Doc/library/random.rst
23523
 
@@ -1,19 +1,16 @@
23524
 
-
23525
 
 :mod:`random` --- Generate pseudo-random numbers
23526
 
 ================================================
23527
 
 
23528
 
 .. module:: random
23529
 
    :synopsis: Generate pseudo-random numbers with various common distributions.
23530
 
 
23531
 
+**Source code:** :source:`Lib/random.py`
23532
 
+
23533
 
+--------------
23534
 
 
23535
 
 This module implements pseudo-random number generators for various
23536
 
 distributions.
23537
 
 
23538
 
-.. seealso::
23539
 
-
23540
 
-   Latest version of the `random module Python source code
23541
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/random.py?view=markup>`_
23542
 
-
23543
 
 For integers, uniform selection from a range. For sequences, uniform selection
23544
 
 of a random element, a function to generate a random permutation of a list
23545
 
 in-place, and a function for random sampling without replacement.
23546
 
@@ -199,6 +196,7 @@
23547
 
    The end-point value ``b`` may or may not be included in the range
23548
 
    depending on floating-point rounding in the equation ``a + (b-a) * random()``.
23549
 
 
23550
 
+
23551
 
 .. function:: triangular(low, high, mode)
23552
 
 
23553
 
    Return a random floating point number *N* such that ``low <= N <= high`` and
23554
 
@@ -229,6 +227,12 @@
23555
 
    Gamma distribution.  (*Not* the gamma function!)  Conditions on the
23556
 
    parameters are ``alpha > 0`` and ``beta > 0``.
23557
 
 
23558
 
+   The probability distribution function is::
23559
 
+
23560
 
+                 x ** (alpha - 1) * math.exp(-x / beta)
23561
 
+       pdf(x) =  --------------------------------------
23562
 
+                   math.gamma(alpha) * beta ** alpha
23563
 
+
23564
 
 
23565
 
 .. function:: gauss(mu, sigma)
23566
 
 
23567
 
diff -r 8527427914a2 Doc/library/re.rst
23568
 
--- a/Doc/library/re.rst
23569
 
+++ b/Doc/library/re.rst
23570
 
@@ -156,30 +156,36 @@
23571
 
    raw strings for all but the simplest expressions.
23572
 
 
23573
 
 ``[]``
23574
 
-   Used to indicate a set of characters.  Characters can be listed individually, or
23575
 
-   a range of characters can be indicated by giving two characters and separating
23576
 
-   them by a ``'-'``.  Special characters are not active inside sets.  For example,
23577
 
-   ``[akm$]`` will match any of the characters ``'a'``, ``'k'``,
23578
 
-   ``'m'``, or ``'$'``; ``[a-z]`` will match any lowercase letter, and
23579
 
-   ``[a-zA-Z0-9]`` matches any letter or digit.  Character classes such
23580
 
-   as ``\w`` or ``\S`` (defined below) are also acceptable inside a
23581
 
-   range, although the characters they match depends on whether :const:`LOCALE`
23582
 
-   or  :const:`UNICODE` mode is in force.  If you want to include a
23583
 
-   ``']'`` or a ``'-'`` inside a set, precede it with a backslash, or
23584
 
-   place it as the first character.  The pattern ``[]]`` will match
23585
 
-   ``']'``, for example.
23586
 
+   Used to indicate a set of characters.  In a set:
23587
 
 
23588
 
-   You can match the characters not within a range by :dfn:`complementing` the set.
23589
 
-   This is indicated by including a ``'^'`` as the first character of the set;
23590
 
-   ``'^'`` elsewhere will simply match the ``'^'`` character.  For example,
23591
 
-   ``[^5]`` will match any character except ``'5'``, and ``[^^]`` will match any
23592
 
-   character except ``'^'``.
23593
 
+   * Characters can be listed individually, e.g. ``[amk]`` will match ``'a'``,
23594
 
+     ``'m'``, or ``'k'``.
23595
 
 
23596
 
-   Note that inside ``[]`` the special forms and special characters lose
23597
 
-   their meanings and only the syntaxes described here are valid. For
23598
 
-   example, ``+``, ``*``, ``(``, ``)``, and so on are treated as
23599
 
-   literals inside ``[]``, and backreferences cannot be used inside
23600
 
-   ``[]``.
23601
 
+   * Ranges of characters can be indicated by giving two characters and separating
23602
 
+     them by a ``'-'``, for example ``[a-z]`` will match any lowercase ASCII letter,
23603
 
+     ``[0-5][0-9]`` will match all the two-digits numbers from ``00`` to ``59``, and
23604
 
+     ``[0-9A-Fa-f]`` will match any hexadecimal digit.  If ``-`` is escaped (e.g.
23605
 
+     ``[a\-z]``) or if it's placed as the first or last character (e.g. ``[a-]``),
23606
 
+     it will match a literal ``'-'``.
23607
 
+
23608
 
+   * Special characters lose their special meaning inside sets.  For example,
23609
 
+     ``[(+*)]`` will match any of the literal characters ``'('``, ``'+'``,
23610
 
+     ``'*'``, or ``')'``.
23611
 
+
23612
 
+   * Character classes such as ``\w`` or ``\S`` (defined below) are also accepted
23613
 
+     inside a set, although the characters they match depends on whether
23614
 
+     :const:`LOCALE` or  :const:`UNICODE` mode is in force.
23615
 
+
23616
 
+   * Characters that are not within a range can be matched by :dfn:`complementing`
23617
 
+     the set.  If the first character of the set is ``'^'``, all the characters
23618
 
+     that are *not* in the set will be matched.  For example, ``[^5]`` will match
23619
 
+     any character except ``'5'``, and ``[^^]`` will match any character except
23620
 
+     ``'^'``.  ``^`` has no special meaning if it's not the first character in
23621
 
+     the set.
23622
 
+
23623
 
+   * To match a literal ``']'`` inside a set, precede it with a backslash, or
23624
 
+     place it at the beginning of the set.  For example, both ``[()[\]{}]`` and
23625
 
+     ``[]()[{}]`` will both match a parenthesis.
23626
 
 
23627
 
 ``'|'``
23628
 
    ``A|B``, where A and B can be arbitrary REs, creates a regular expression that
23629
 
@@ -425,7 +431,7 @@
23630
 
 form.
23631
 
 
23632
 
 
23633
 
-.. function:: compile(pattern[, flags])
23634
 
+.. function:: compile(pattern, flags=0)
23635
 
 
23636
 
    Compile a regular expression pattern into a regular expression object, which
23637
 
    can be used for matching using its :func:`match` and :func:`search` methods,
23638
 
@@ -456,6 +462,11 @@
23639
 
       about compiling regular expressions.
23640
 
 
23641
 
 
23642
 
+.. data:: DEBUG
23643
 
+
23644
 
+   Display debug information about compiled expression.
23645
 
+
23646
 
+
23647
 
 .. data:: I
23648
 
           IGNORECASE
23649
 
 
23650
 
@@ -515,7 +526,7 @@
23651
 
       b = re.compile(r"\d+\.\d*")
23652
 
 
23653
 
 
23654
 
-.. function:: search(pattern, string[, flags])
23655
 
+.. function:: search(pattern, string, flags=0)
23656
 
 
23657
 
    Scan through *string* looking for a location where the regular expression
23658
 
    *pattern* produces a match, and return a corresponding :class:`MatchObject`
23659
 
@@ -524,7 +535,7 @@
23660
 
    string.
23661
 
 
23662
 
 
23663
 
-.. function:: match(pattern, string[, flags])
23664
 
+.. function:: match(pattern, string, flags=0)
23665
 
 
23666
 
    If zero or more characters at the beginning of *string* match the regular
23667
 
    expression *pattern*, return a corresponding :class:`MatchObject` instance.
23668
 
@@ -537,7 +548,7 @@
23669
 
       instead.
23670
 
 
23671
 
 
23672
 
-.. function:: split(pattern, string[, maxsplit=0, flags=0])
23673
 
+.. function:: split(pattern, string, maxsplit=0, flags=0)
23674
 
 
23675
 
    Split *string* by the occurrences of *pattern*.  If capturing parentheses are
23676
 
    used in *pattern*, then the text of all groups in the pattern are also returned
23677
 
@@ -578,7 +589,7 @@
23678
 
       Added the optional flags argument.
23679
 
 
23680
 
 
23681
 
-.. function:: findall(pattern, string[, flags])
23682
 
+.. function:: findall(pattern, string, flags=0)
23683
 
 
23684
 
    Return all non-overlapping matches of *pattern* in *string*, as a list of
23685
 
    strings.  The *string* is scanned left-to-right, and matches are returned in
23686
 
@@ -593,7 +604,7 @@
23687
 
       Added the optional flags argument.
23688
 
 
23689
 
 
23690
 
-.. function:: finditer(pattern, string[, flags])
23691
 
+.. function:: finditer(pattern, string, flags=0)
23692
 
 
23693
 
    Return an :term:`iterator` yielding :class:`MatchObject` instances over all
23694
 
    non-overlapping matches for the RE *pattern* in *string*.  The *string* is
23695
 
@@ -607,13 +618,13 @@
23696
 
       Added the optional flags argument.
23697
 
 
23698
 
 
23699
 
-.. function:: sub(pattern, repl, string[, count, flags])
23700
 
+.. function:: sub(pattern, repl, string, count=0, flags=0)
23701
 
 
23702
 
    Return the string obtained by replacing the leftmost non-overlapping occurrences
23703
 
    of *pattern* in *string* by the replacement *repl*.  If the pattern isn't found,
23704
 
    *string* is returned unchanged.  *repl* can be a string or a function; if it is
23705
 
    a string, any backslash escapes in it are processed.  That is, ``\n`` is
23706
 
-   converted to a single newline character, ``\r`` is converted to a linefeed, and
23707
 
+   converted to a single newline character, ``\r`` is converted to a carriage return, and
23708
 
    so forth.  Unknown escapes such as ``\j`` are left alone.  Backreferences, such
23709
 
    as ``\6``, are replaced with the substring matched by group 6 in the pattern.
23710
 
    For example:
23711
 
@@ -656,7 +667,7 @@
23712
 
       Added the optional flags argument.
23713
 
 
23714
 
 
23715
 
-.. function:: subn(pattern, repl, string[, count, flags])
23716
 
+.. function:: subn(pattern, repl, string, count=0, flags=0)
23717
 
 
23718
 
    Perform the same operation as :func:`sub`, but return a tuple ``(new_string,
23719
 
    number_of_subs_made)``.
23720
 
@@ -741,7 +752,7 @@
23721
 
       <_sre.SRE_Match object at ...>
23722
 
 
23723
 
 
23724
 
-   .. method:: RegexObject.split(string[, maxsplit=0])
23725
 
+   .. method:: RegexObject.split(string, maxsplit=0)
23726
 
 
23727
 
       Identical to the :func:`split` function, using the compiled pattern.
23728
 
 
23729
 
@@ -760,12 +771,12 @@
23730
 
       region like for :meth:`match`.
23731
 
 
23732
 
 
23733
 
-   .. method:: RegexObject.sub(repl, string[, count=0])
23734
 
+   .. method:: RegexObject.sub(repl, string, count=0)
23735
 
 
23736
 
       Identical to the :func:`sub` function, using the compiled pattern.
23737
 
 
23738
 
 
23739
 
-   .. method:: RegexObject.subn(repl, string[, count=0])
23740
 
+   .. method:: RegexObject.subn(repl, string, count=0)
23741
 
 
23742
 
       Identical to the :func:`subn` function, using the compiled pattern.
23743
 
 
23744
 
@@ -994,16 +1005,16 @@
23745
 
 
23746
 
 Suppose you are writing a poker program where a player's hand is represented as
23747
 
 a 5-character string with each character representing a card, "a" for ace, "k"
23748
 
-for king, "q" for queen, j for jack, "0" for 10, and "1" through "9"
23749
 
+for king, "q" for queen, "j" for jack, "t" for 10, and "2" through "9"
23750
 
 representing the card with that value.
23751
 
 
23752
 
 To see if a given string is a valid hand, one could do the following:
23753
 
 
23754
 
-   >>> valid = re.compile(r"[0-9akqj]{5}$")
23755
 
-   >>> displaymatch(valid.match("ak05q"))  # Valid.
23756
 
-   "<Match: 'ak05q', groups=()>"
23757
 
-   >>> displaymatch(valid.match("ak05e"))  # Invalid.
23758
 
-   >>> displaymatch(valid.match("ak0"))    # Invalid.
23759
 
+   >>> valid = re.compile(r"^[a2-9tjqk]{5}$")
23760
 
+   >>> displaymatch(valid.match("akt5q"))  # Valid.
23761
 
+   "<Match: 'akt5q', groups=()>"
23762
 
+   >>> displaymatch(valid.match("akt5e"))  # Invalid.
23763
 
+   >>> displaymatch(valid.match("akt"))    # Invalid.
23764
 
    >>> displaymatch(valid.match("727ak"))  # Valid.
23765
 
    "<Match: '727ak', groups=()>"
23766
 
 
23767
 
@@ -1042,14 +1053,14 @@
23768
 
 
23769
 
 .. index:: single: scanf()
23770
 
 
23771
 
-Python does not currently have an equivalent to :cfunc:`scanf`.  Regular
23772
 
+Python does not currently have an equivalent to :c:func:`scanf`.  Regular
23773
 
 expressions are generally more powerful, though also more verbose, than
23774
 
-:cfunc:`scanf` format strings.  The table below offers some more-or-less
23775
 
-equivalent mappings between :cfunc:`scanf` format tokens and regular
23776
 
+:c:func:`scanf` format strings.  The table below offers some more-or-less
23777
 
+equivalent mappings between :c:func:`scanf` format tokens and regular
23778
 
 expressions.
23779
 
 
23780
 
 +--------------------------------+---------------------------------------------+
23781
 
-| :cfunc:`scanf` Token           | Regular Expression                          |
23782
 
+| :c:func:`scanf` Token          | Regular Expression                          |
23783
 
 +================================+=============================================+
23784
 
 | ``%c``                         | ``.``                                       |
23785
 
 +--------------------------------+---------------------------------------------+
23786
 
@@ -1074,7 +1085,7 @@
23787
 
 
23788
 
    /usr/sbin/sendmail - 0 errors, 4 warnings
23789
 
 
23790
 
-you would use a :cfunc:`scanf` format like ::
23791
 
+you would use a :c:func:`scanf` format like ::
23792
 
 
23793
 
    %s - %d errors, %d warnings
23794
 
 
23795
 
diff -r 8527427914a2 Doc/library/repr.rst
23796
 
--- a/Doc/library/repr.rst
23797
 
+++ b/Doc/library/repr.rst
23798
 
@@ -1,4 +1,3 @@
23799
 
-
23800
 
 :mod:`repr` --- Alternate :func:`repr` implementation
23801
 
 =====================================================
23802
 
 
23803
 
@@ -11,15 +10,14 @@
23804
 
    :term:`2to3` tool will automatically adapt imports when converting your
23805
 
    sources to 3.0.
23806
 
 
23807
 
+**Source code:** :source:`Lib/repr.py`
23808
 
+
23809
 
+--------------
23810
 
+
23811
 
 The :mod:`repr` module provides a means for producing object representations
23812
 
 with limits on the size of the resulting strings. This is used in the Python
23813
 
 debugger and may be useful in other contexts as well.
23814
 
 
23815
 
-.. seealso::
23816
 
-
23817
 
-   Latest version of the `repr module Python source code
23818
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/repr.py?view=markup>`_
23819
 
-
23820
 
 This module provides a class, an instance, and a function:
23821
 
 
23822
 
 
23823
 
@@ -49,7 +47,7 @@
23824
 
 Repr Objects
23825
 
 ------------
23826
 
 
23827
 
-:class:`Repr` instances provide several members which can be used to provide
23828
 
+:class:`Repr` instances provide several attributes which can be used to provide
23829
 
 size limits for the representations of different object types,  and methods
23830
 
 which format specific object types.
23831
 
 
23832
 
diff -r 8527427914a2 Doc/library/restricted.rst
23833
 
--- a/Doc/library/restricted.rst
23834
 
+++ b/Doc/library/restricted.rst
23835
 
@@ -31,7 +31,7 @@
23836
 
 might be deemed "safe" for untrusted code to read any file within a specified
23837
 
 directory, but never to write a file.  In this case, the supervisor may redefine
23838
 
 the built-in :func:`open` function so that it raises an exception whenever the
23839
 
-*mode* parameter is ``'w'``.  It might also perform a :cfunc:`chroot`\ -like
23840
 
+*mode* parameter is ``'w'``.  It might also perform a :c:func:`chroot`\ -like
23841
 
 operation on the *filename* parameter, such that root is always relative to some
23842
 
 safe "sandbox" area of the filesystem.  In this case, the untrusted code would
23843
 
 still see an built-in :func:`open` function in its environment, with the same
23844
 
diff -r 8527427914a2 Doc/library/rfc822.rst
23845
 
--- a/Doc/library/rfc822.rst
23846
 
+++ b/Doc/library/rfc822.rst
23847
 
@@ -42,8 +42,8 @@
23848
 
    from a buffered stream.
23849
 
 
23850
 
    The optional *seekable* argument is provided as a workaround for certain stdio
23851
 
-   libraries in which :cfunc:`tell` discards buffered data before discovering that
23852
 
-   the :cfunc:`lseek` system call doesn't work.  For maximum portability, you
23853
 
+   libraries in which :c:func:`tell` discards buffered data before discovering that
23854
 
+   the :c:func:`lseek` system call doesn't work.  For maximum portability, you
23855
 
    should set the seekable argument to zero to prevent that initial :meth:`tell`
23856
 
    when passing in an unseekable object such as a file object created from a socket
23857
 
    object.
23858
 
diff -r 8527427914a2 Doc/library/rlcompleter.rst
23859
 
--- a/Doc/library/rlcompleter.rst
23860
 
+++ b/Doc/library/rlcompleter.rst
23861
 
@@ -1,4 +1,3 @@
23862
 
-
23863
 
 :mod:`rlcompleter` --- Completion function for GNU readline
23864
 
 ===========================================================
23865
 
 
23866
 
@@ -6,6 +5,9 @@
23867
 
    :synopsis: Python identifier completion, suitable for the GNU readline library.
23868
 
 .. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
23869
 
 
23870
 
+**Source code:** :source:`Lib/rlcompleter.py`
23871
 
+
23872
 
+--------------
23873
 
 
23874
 
 The :mod:`rlcompleter` module defines a completion function suitable for the
23875
 
 :mod:`readline` module by completing valid Python identifiers and keywords.
23876
 
diff -r 8527427914a2 Doc/library/runpy.rst
23877
 
--- a/Doc/library/runpy.rst
23878
 
+++ b/Doc/library/runpy.rst
23879
 
@@ -8,6 +8,10 @@
23880
 
 
23881
 
 .. versionadded:: 2.5
23882
 
 
23883
 
+**Source code:** :source:`Lib/runpy.py`
23884
 
+
23885
 
+--------------
23886
 
+
23887
 
 The :mod:`runpy` module is used to locate and run Python modules without
23888
 
 importing them first. Its main use is to implement the :option:`-m` command
23889
 
 line switch that allows scripts to be located using the Python module
23890
 
diff -r 8527427914a2 Doc/library/sched.rst
23891
 
--- a/Doc/library/sched.rst
23892
 
+++ b/Doc/library/sched.rst
23893
 
@@ -7,14 +7,13 @@
23894
 
 
23895
 
 .. index:: single: event scheduling
23896
 
 
23897
 
+**Source code:** :source:`Lib/sched.py`
23898
 
+
23899
 
+--------------
23900
 
+
23901
 
 The :mod:`sched` module defines a class which implements a general purpose event
23902
 
 scheduler:
23903
 
 
23904
 
-.. seealso::
23905
 
-
23906
 
-   Latest version of the `sched module Python source code
23907
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/sched.py?view=markup>`_
23908
 
-
23909
 
 .. class:: scheduler(timefunc, delayfunc)
23910
 
 
23911
 
    The :class:`scheduler` class defines a generic interface to scheduling events.
23912
 
@@ -96,7 +95,7 @@
23913
 
 
23914
 
 .. method:: scheduler.enter(delay, priority, action, argument)
23915
 
 
23916
 
-   Schedule an event for *delay* more time units. Other then the relative time, the
23917
 
+   Schedule an event for *delay* more time units. Other than the relative time, the
23918
 
    other arguments, the effect and the return value are the same as those for
23919
 
    :meth:`enterabs`.
23920
 
 
23921
 
diff -r 8527427914a2 Doc/library/select.rst
23922
 
--- a/Doc/library/select.rst
23923
 
+++ b/Doc/library/select.rst
23924
 
@@ -6,9 +6,9 @@
23925
 
    :synopsis: Wait for I/O completion on multiple streams.
23926
 
 
23927
 
 
23928
 
-This module provides access to the :cfunc:`select` and :cfunc:`poll` functions
23929
 
-available in most operating systems, :cfunc:`epoll` available on Linux 2.5+ and
23930
 
-:cfunc:`kqueue` available on most BSD.
23931
 
+This module provides access to the :c:func:`select` and :c:func:`poll` functions
23932
 
+available in most operating systems, :c:func:`epoll` available on Linux 2.5+ and
23933
 
+:c:func:`kqueue` available on most BSD.
23934
 
 Note that on Windows, it only works for sockets; on other operating systems,
23935
 
 it also works for other file types (in particular, on Unix, it works on pipes).
23936
 
 It cannot be used on regular files to determine whether a file has grown since
23937
 
@@ -20,8 +20,8 @@
23938
 
 .. exception:: error
23939
 
 
23940
 
    The exception raised when an error occurs.  The accompanying value is a pair
23941
 
-   containing the numeric error code from :cdata:`errno` and the corresponding
23942
 
-   string, as would be printed by the C function :cfunc:`perror`.
23943
 
+   containing the numeric error code from :c:data:`errno` and the corresponding
23944
 
+   string, as would be printed by the C function :c:func:`perror`.
23945
 
 
23946
 
 
23947
 
 .. function:: epoll([sizehint=-1])
23948
 
@@ -60,7 +60,7 @@
23949
 
 
23950
 
 .. function:: select(rlist, wlist, xlist[, timeout])
23951
 
 
23952
 
-   This is a straightforward interface to the Unix :cfunc:`select` system call.
23953
 
+   This is a straightforward interface to the Unix :c:func:`select` system call.
23954
 
    The first three arguments are sequences of 'waitable objects': either
23955
 
    integers representing file descriptors or objects with a parameterless method
23956
 
    named :meth:`fileno` returning such an integer:
23957
 
@@ -96,7 +96,7 @@
23958
 
       .. index:: single: WinSock
23959
 
 
23960
 
       File objects on Windows are not acceptable, but sockets are.  On Windows,
23961
 
-      the underlying :cfunc:`select` function is provided by the WinSock
23962
 
+      the underlying :c:func:`select` function is provided by the WinSock
23963
 
       library, and does not handle file descriptors that don't originate from
23964
 
       WinSock.
23965
 
 
23966
 
@@ -195,13 +195,13 @@
23967
 
 Polling Objects
23968
 
 ---------------
23969
 
 
23970
 
-The :cfunc:`poll` system call, supported on most Unix systems, provides better
23971
 
+The :c:func:`poll` system call, supported on most Unix systems, provides better
23972
 
 scalability for network servers that service many, many clients at the same
23973
 
-time. :cfunc:`poll` scales better because the system call only requires listing
23974
 
-the file descriptors of interest, while :cfunc:`select` builds a bitmap, turns
23975
 
+time. :c:func:`poll` scales better because the system call only requires listing
23976
 
+the file descriptors of interest, while :c:func:`select` builds a bitmap, turns
23977
 
 on bits for the fds of interest, and then afterward the whole bitmap has to be
23978
 
-linearly scanned again. :cfunc:`select` is O(highest file descriptor), while
23979
 
-:cfunc:`poll` is O(number of file descriptors).
23980
 
+linearly scanned again. :c:func:`select` is O(highest file descriptor), while
23981
 
+:c:func:`poll` is O(number of file descriptors).
23982
 
 
23983
 
 
23984
 
 .. method:: poll.register(fd[, eventmask])
23985
 
diff -r 8527427914a2 Doc/library/shelve.rst
23986
 
--- a/Doc/library/shelve.rst
23987
 
+++ b/Doc/library/shelve.rst
23988
 
@@ -7,16 +7,16 @@
23989
 
 
23990
 
 .. index:: module: pickle
23991
 
 
23992
 
+**Source code:** :source:`Lib/shelve.py`
23993
 
+
23994
 
+--------------
23995
 
+
23996
 
 A "shelf" is a persistent, dictionary-like object.  The difference with "dbm"
23997
 
 databases is that the values (not the keys!) in a shelf can be essentially
23998
 
 arbitrary Python objects --- anything that the :mod:`pickle` module can handle.
23999
 
 This includes most class instances, recursive data types, and objects containing
24000
 
 lots of shared  sub-objects.  The keys are ordinary strings.
24001
 
 
24002
 
-.. seealso::
24003
 
-
24004
 
-   Latest version of the `shelve module Python source code
24005
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/shelve.py?view=markup>`_
24006
 
 
24007
 
 .. function:: open(filename[, flag='c'[, protocol=None[, writeback=False]]])
24008
 
 
24009
 
@@ -44,17 +44,12 @@
24010
 
    determine which accessed entries are mutable, nor which ones were actually
24011
 
    mutated).
24012
 
 
24013
 
-   .. note::
24014
 
+   Like file objects, shelve objects should be closed explicitly to ensure
24015
 
+   that the persistent data is flushed to disk.
24016
 
 
24017
 
-      Do not rely on the shelf being closed automatically; always call
24018
 
-      :meth:`close` explicitly when you don't need it any more, or use a
24019
 
-      :keyword:`with` statement with :func:`contextlib.closing`.
24020
 
-
24021
 
-.. warning::
24022
 
-
24023
 
-   Because the :mod:`shelve` module is backed by :mod:`pickle`, it is insecure
24024
 
-   to load a shelf from an untrusted source.  Like with pickle, loading a shelf
24025
 
-   can execute arbitrary code.
24026
 
+   Since the :mod:`shelve` module stores objects using :mod:`pickle`, the same
24027
 
+   security precautions apply.  Accordingly, you should avoid loading a shelf
24028
 
+   from an untrusted source.
24029
 
 
24030
 
 Shelf objects support all methods supported by dictionaries.  This eases the
24031
 
 transition from dictionary based scripts to those requiring persistent storage.
24032
 
diff -r 8527427914a2 Doc/library/shlex.rst
24033
 
--- a/Doc/library/shlex.rst
24034
 
+++ b/Doc/library/shlex.rst
24035
 
@@ -1,4 +1,3 @@
24036
 
-
24037
 
 :mod:`shlex` --- Simple lexical analysis
24038
 
 ========================================
24039
 
 
24040
 
@@ -12,14 +11,17 @@
24041
 
 
24042
 
 .. versionadded:: 1.5.2
24043
 
 
24044
 
+**Source code:** :source:`Lib/shlex.py`
24045
 
+
24046
 
+--------------
24047
 
+
24048
 
+
24049
 
 The :class:`shlex` class makes it easy to write lexical analyzers for simple
24050
 
 syntaxes resembling that of the Unix shell.  This will often be useful for
24051
 
 writing minilanguages, (for example, in run control files for Python
24052
 
 applications) or for parsing quoted strings.
24053
 
 
24054
 
-.. note::
24055
 
-
24056
 
-   The :mod:`shlex` module currently does not support Unicode input.
24057
 
+Prior to Python 2.7.3, this module did not support Unicode input.
24058
 
 
24059
 
 The :mod:`shlex` module defines the following functions:
24060
 
 
24061
 
@@ -28,8 +30,8 @@
24062
 
 
24063
 
    Split the string *s* using shell-like syntax. If *comments* is :const:`False`
24064
 
    (the default), the parsing of comments in the given string will be disabled
24065
 
-   (setting the :attr:`commenters` member of the :class:`shlex` instance to the
24066
 
-   empty string).  This function operates in POSIX mode by default, but uses
24067
 
+   (setting the :attr:`commenters` attribute of the :class:`shlex` instance to
24068
 
+   the empty string).  This function operates in POSIX mode by default, but uses
24069
 
    non-POSIX mode if the *posix* argument is false.
24070
 
 
24071
 
    .. versionadded:: 2.3
24072
 
@@ -53,7 +55,7 @@
24073
 
    :meth:`readline` methods, or a string (strings are accepted since Python 2.3).
24074
 
    If no argument is given, input will be taken from ``sys.stdin``.  The second
24075
 
    optional argument is a filename string, which sets the initial value of the
24076
 
-   :attr:`infile` member.  If the *instream* argument is omitted or equal to
24077
 
+   :attr:`infile` attribute.  If the *instream* argument is omitted or equal to
24078
 
    ``sys.stdin``, this second argument defaults to "stdin".  The *posix* argument
24079
 
    was introduced in Python 2.3, and defines the operational mode.  When *posix* is
24080
 
    not true (default), the :class:`shlex` instance will operate in compatibility
24081
 
@@ -221,8 +223,8 @@
24082
 
 
24083
 
 .. attribute:: shlex.source
24084
 
 
24085
 
-   This member is ``None`` by default.  If you assign a string to it, that string
24086
 
-   will be recognized as a lexical-level inclusion request similar to the
24087
 
+   This attribute is ``None`` by default.  If you assign a string to it, that
24088
 
+   string will be recognized as a lexical-level inclusion request similar to the
24089
 
    ``source`` keyword in various shells.  That is, the immediately following token
24090
 
    will opened as a filename and input taken from that stream until EOF, at which
24091
 
    point the :meth:`close` method of that stream will be called and the input
24092
 
@@ -232,7 +234,7 @@
24093
 
 
24094
 
 .. attribute:: shlex.debug
24095
 
 
24096
 
-   If this member is numeric and ``1`` or more, a :class:`shlex` instance will
24097
 
+   If this attribute is numeric and ``1`` or more, a :class:`shlex` instance will
24098
 
    print verbose progress output on its behavior.  If you need to use this, you can
24099
 
    read the module source code to learn the details.
24100
 
 
24101
 
diff -r 8527427914a2 Doc/library/shutil.rst
24102
 
--- a/Doc/library/shutil.rst
24103
 
+++ b/Doc/library/shutil.rst
24104
 
@@ -1,4 +1,3 @@
24105
 
-
24106
 
 :mod:`shutil` --- High-level file operations
24107
 
 ============================================
24108
 
 
24109
 
@@ -11,20 +10,19 @@
24110
 
    single: file; copying
24111
 
    single: copying files
24112
 
 
24113
 
+**Source code:** :source:`Lib/shutil.py`
24114
 
+
24115
 
+--------------
24116
 
+
24117
 
 The :mod:`shutil` module offers a number of high-level operations on files and
24118
 
 collections of files.  In particular, functions are provided  which support file
24119
 
 copying and removal. For operations on individual files, see also the
24120
 
 :mod:`os` module.
24121
 
 
24122
 
-.. seealso::
24123
 
-
24124
 
-   Latest version of the `shutil module Python source code
24125
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/shutil.py?view=markup>`_
24126
 
-
24127
 
 .. warning::
24128
 
 
24129
 
-   Even the higher-level file copying functions (:func:`copy`, :func:`copy2`)
24130
 
-   can't copy all file metadata.
24131
 
+   Even the higher-level file copying functions (:func:`shutil.copy`,
24132
 
+   :func:`shutil.copy2`) can't copy all file metadata.
24133
 
 
24134
 
    On POSIX platforms, this means that file owner and group are lost as well
24135
 
    as ACLs.  On Mac OS, the resource fork and other metadata are not used.
24136
 
@@ -49,10 +47,10 @@
24137
 
 
24138
 
 .. function:: copyfile(src, dst)
24139
 
 
24140
 
-   Copy the contents (no metadata) of the file named *src* to a file named *dst*.
24141
 
-   *dst* must be the complete target file name; look at :func:`copy` for a copy that
24142
 
-   accepts a target directory path.  If *src* and *dst* are the same files,
24143
 
-   :exc:`Error` is raised.
24144
 
+   Copy the contents (no metadata) of the file named *src* to a file named
24145
 
+   *dst*.  *dst* must be the complete target file name; look at
24146
 
+   :func:`shutil.copy` for a copy that accepts a target directory path.  If
24147
 
+   *src* and *dst* are the same files, :exc:`Error` is raised.
24148
 
    The destination location must be writable; otherwise,  an :exc:`IOError` exception
24149
 
    will be raised. If *dst* already exists, it will be replaced.   Special files
24150
 
    such as character or block devices and pipes cannot be copied with this
24151
 
@@ -82,9 +80,9 @@
24152
 
 
24153
 
 .. function:: copy2(src, dst)
24154
 
 
24155
 
-   Similar to :func:`copy`, but metadata is copied as well -- in fact, this is just
24156
 
-   :func:`copy` followed by :func:`copystat`.  This is similar to the
24157
 
-   Unix command :program:`cp -p`.
24158
 
+   Similar to :func:`shutil.copy`, but metadata is copied as well -- in fact,
24159
 
+   this is just :func:`shutil.copy` followed by :func:`copystat`.  This is
24160
 
+   similar to the Unix command :program:`cp -p`.
24161
 
 
24162
 
 
24163
 
 .. function:: ignore_patterns(\*patterns)
24164
 
@@ -99,14 +97,15 @@
24165
 
 .. function:: copytree(src, dst[, symlinks=False[, ignore=None]])
24166
 
 
24167
 
    Recursively copy an entire directory tree rooted at *src*.  The destination
24168
 
-   directory, named by *dst*, must not already exist; it will be created as well
24169
 
-   as missing parent directories.  Permissions and times of directories are
24170
 
-   copied with :func:`copystat`, individual files are copied using
24171
 
-   :func:`copy2`.
24172
 
+   directory, named by *dst*, must not already exist; it will be created as
24173
 
+   well as missing parent directories.  Permissions and times of directories
24174
 
+   are copied with :func:`copystat`, individual files are copied using
24175
 
+   :func:`shutil.copy2`.
24176
 
 
24177
 
    If *symlinks* is true, symbolic links in the source tree are represented as
24178
 
-   symbolic links in the new tree; if false or omitted, the contents of the
24179
 
-   linked files are copied to the new tree.
24180
 
+   symbolic links in the new tree, but the metadata of the original links is NOT
24181
 
+   copied; if false or omitted, the contents and metadata of the linked files
24182
 
+   are copied to the new tree.
24183
 
 
24184
 
    If *ignore* is given, it must be a callable that will receive as its
24185
 
    arguments the directory being visited by :func:`copytree`, and a list of its
24186
 
@@ -161,22 +160,31 @@
24187
 
 
24188
 
 .. function:: move(src, dst)
24189
 
 
24190
 
-   Recursively move a file or directory to another location.
24191
 
+   Recursively move a file or directory (*src*) to another location (*dst*).
24192
 
 
24193
 
-   If the destination is on the current filesystem, then simply use rename.
24194
 
-   Otherwise, copy src (with :func:`copy2`) to the dst and then remove src.
24195
 
+   If the destination is a directory or a symlink to a directory, then *src* is
24196
 
+   moved inside that directory.
24197
 
+
24198
 
+   The destination directory must not already exist.  If the destination already
24199
 
+   exists but is not a directory, it may be overwritten depending on
24200
 
+   :func:`os.rename` semantics.
24201
 
+
24202
 
+   If the destination is on the current filesystem, then :func:`os.rename` is
24203
 
+   used.  Otherwise, *src* is copied (using :func:`shutil.copy2`) to *dst* and
24204
 
+   then removed.
24205
 
 
24206
 
    .. versionadded:: 2.3
24207
 
 
24208
 
 
24209
 
 .. exception:: Error
24210
 
 
24211
 
-   This exception collects exceptions that raised during a multi-file operation. For
24212
 
-   :func:`copytree`, the exception argument is a list of 3-tuples (*srcname*,
24213
 
-   *dstname*, *exception*).
24214
 
+   This exception collects exceptions that are raised during a multi-file
24215
 
+   operation. For :func:`copytree`, the exception argument is a list of 3-tuples
24216
 
+   (*srcname*, *dstname*, *exception*).
24217
 
 
24218
 
    .. versionadded:: 2.3
24219
 
 
24220
 
+
24221
 
 .. _shutil-example:
24222
 
 
24223
 
 copytree example
24224
 
@@ -270,12 +278,14 @@
24225
 
    *owner* and *group* are used when creating a tar archive. By default,
24226
 
    uses the current owner and group.
24227
 
 
24228
 
+   *logger* is an instance of :class:`logging.Logger`.
24229
 
+
24230
 
    .. versionadded:: 2.7
24231
 
 
24232
 
 
24233
 
 .. function:: get_archive_formats()
24234
 
 
24235
 
-   Returns a list of supported formats for archiving.
24236
 
+   Return a list of supported formats for archiving.
24237
 
    Each element of the returned sequence is a tuple ``(name, description)``
24238
 
 
24239
 
    By default :mod:`shutil` provides these formats:
24240
 
@@ -293,7 +303,7 @@
24241
 
 
24242
 
 .. function:: register_archive_format(name, function, [extra_args, [description]])
24243
 
 
24244
 
-   Registers an archiver for the format *name*. *function* is a callable that
24245
 
+   Register an archiver for the format *name*. *function* is a callable that
24246
 
    will be used to invoke the archiver.
24247
 
 
24248
 
    If given, *extra_args* is a sequence of ``(name, value)`` that will be
24249
 
diff -r 8527427914a2 Doc/library/signal.rst
24250
 
--- a/Doc/library/signal.rst
24251
 
+++ b/Doc/library/signal.rst
24252
 
@@ -69,7 +69,7 @@
24253
 
    All the signal numbers are defined symbolically.  For example, the hangup signal
24254
 
    is defined as :const:`signal.SIGHUP`; the variable names are identical to the
24255
 
    names used in C programs, as found in ``<signal.h>``. The Unix man page for
24256
 
-   ':cfunc:`signal`' lists the existing signals (on some systems this is
24257
 
+   ':c:func:`signal`' lists the existing signals (on some systems this is
24258
 
    :manpage:`signal(2)`, on others the list is in :manpage:`signal(7)`). Note that
24259
 
    not all systems define the same set of signal names; only those names defined by
24260
 
    the system are defined by this module.
24261
 
@@ -216,7 +216,7 @@
24262
 
 
24263
 
    Note that installing a signal handler with :func:`signal` will reset the
24264
 
    restart behaviour to interruptible by implicitly calling
24265
 
-   :cfunc:`siginterrupt` with a true *flag* value for the given signal.
24266
 
+   :c:func:`siginterrupt` with a true *flag* value for the given signal.
24267
 
 
24268
 
    .. versionadded:: 2.6
24269
 
 
24270
 
diff -r 8527427914a2 Doc/library/simplexmlrpcserver.rst
24271
 
--- a/Doc/library/simplexmlrpcserver.rst
24272
 
+++ b/Doc/library/simplexmlrpcserver.rst
24273
 
@@ -14,6 +14,10 @@
24274
 
 
24275
 
 .. versionadded:: 2.2
24276
 
 
24277
 
+**Source code:** :source:`Lib/SimpleXMLRPCServer.py`
24278
 
+
24279
 
+--------------
24280
 
+
24281
 
 The :mod:`SimpleXMLRPCServer` module provides a basic server framework for
24282
 
 XML-RPC servers written in Python.  Servers can either be free standing, using
24283
 
 :class:`SimpleXMLRPCServer`, or embedded in a CGI environment, using
24284
 
diff -r 8527427914a2 Doc/library/site.rst
24285
 
--- a/Doc/library/site.rst
24286
 
+++ b/Doc/library/site.rst
24287
 
@@ -1,17 +1,22 @@
24288
 
-
24289
 
 :mod:`site` --- Site-specific configuration hook
24290
 
 ================================================
24291
 
 
24292
 
 .. module:: site
24293
 
-   :synopsis: A standard way to reference site-specific modules.
24294
 
+   :synopsis: Module responsible for site-specific configuration.
24295
 
 
24296
 
+**Source code:** :source:`Lib/site.py`
24297
 
+
24298
 
+--------------
24299
 
+
24300
 
+.. highlightlang:: none
24301
 
 
24302
 
 **This module is automatically imported during initialization.** The automatic
24303
 
 import can be suppressed using the interpreter's :option:`-S` option.
24304
 
 
24305
 
 .. index:: triple: module; search; path
24306
 
 
24307
 
-Importing this module will append site-specific paths to the module search path.
24308
 
+Importing this module will append site-specific paths to the module search path
24309
 
+and add a few builtins.
24310
 
 
24311
 
 .. index::
24312
 
    pair: site-python; directory
24313
 
@@ -26,11 +31,11 @@
24314
 
 if it refers to an existing directory, and if so, adds it to ``sys.path`` and
24315
 
 also inspects the newly added path for configuration files.
24316
 
 
24317
 
-A path configuration file is a file whose name has the form :file:`package.pth`
24318
 
+A path configuration file is a file whose name has the form :file:`{name}.pth`
24319
 
 and exists in one of the four directories mentioned above; its contents are
24320
 
 additional items (one per line) to be added to ``sys.path``.  Non-existing items
24321
 
-are never added to ``sys.path``, but no check is made that the item refers to a
24322
 
-directory (rather than a file).  No item is added to ``sys.path`` more than
24323
 
+are never added to ``sys.path``, and no check is made that the item refers to a
24324
 
+directory rather than a file.  No item is added to ``sys.path`` more than
24325
 
 once.  Blank lines and lines beginning with ``#`` are skipped.  Lines starting
24326
 
 with ``import`` (followed by space or tab) are executed.
24327
 
 
24328
 
@@ -43,8 +48,7 @@
24329
 
 
24330
 
 For example, suppose ``sys.prefix`` and ``sys.exec_prefix`` are set to
24331
 
 :file:`/usr/local`.  The Python X.Y library is then installed in
24332
 
-:file:`/usr/local/lib/python{X.Y}` (where only the first three characters of
24333
 
-``sys.version`` are used to form the installation path name).  Suppose this has
24334
 
+:file:`/usr/local/lib/python{X.Y}`.  Suppose this has
24335
 
 a subdirectory :file:`/usr/local/lib/python{X.Y}/site-packages` with three
24336
 
 subsubdirectories, :file:`foo`, :file:`bar` and :file:`spam`, and two path
24337
 
 configuration files, :file:`foo.pth` and :file:`bar.pth`.  Assume
24338
 
@@ -77,86 +81,132 @@
24339
 
 
24340
 
 After these path manipulations, an attempt is made to import a module named
24341
 
 :mod:`sitecustomize`, which can perform arbitrary site-specific customizations.
24342
 
-If this import fails with an :exc:`ImportError` exception, it is silently
24343
 
-ignored.
24344
 
+It is typically created by a system administrator in the site-packages
24345
 
+directory.  If this import fails with an :exc:`ImportError` exception, it is
24346
 
+silently ignored.
24347
 
 
24348
 
-.. index:: module: sitecustomize
24349
 
+.. index:: module: usercustomize
24350
 
+
24351
 
+After this, an attempt is made to import a module named :mod:`usercustomize`,
24352
 
+which can perform arbitrary user-specific customizations, if
24353
 
+:data:`ENABLE_USER_SITE` is true.  This file is intended to be created in the
24354
 
+user site-packages directory (see below), which is part of ``sys.path`` unless
24355
 
+disabled by :option:`-s`.  An :exc:`ImportError` will be silently ignored.
24356
 
 
24357
 
 Note that for some non-Unix systems, ``sys.prefix`` and ``sys.exec_prefix`` are
24358
 
 empty, and the path manipulations are skipped; however the import of
24359
 
-:mod:`sitecustomize` is still attempted.
24360
 
+:mod:`sitecustomize` and :mod:`usercustomize` is still attempted.
24361
 
 
24362
 
 
24363
 
 .. data:: PREFIXES
24364
 
 
24365
 
-   A list of prefixes for site package directories
24366
 
+   A list of prefixes for site-packages directories.
24367
 
 
24368
 
    .. versionadded:: 2.6
24369
 
 
24370
 
 
24371
 
 .. data:: ENABLE_USER_SITE
24372
 
 
24373
 
-   Flag showing the status of the user site directory. True means the
24374
 
-   user site directory is enabled and added to sys.path. When the flag
24375
 
-   is None the user site directory is disabled for security reasons.
24376
 
+   Flag showing the status of the user site-packages directory.  ``True`` means
24377
 
+   that it is enabled and was added to ``sys.path``.  ``False`` means that it
24378
 
+   was disabled by user request (with :option:`-s` or
24379
 
+   :envvar:`PYTHONNOUSERSITE`).  ``None`` means it was disabled for security
24380
 
+   reasons (mismatch between user or group id and effective id) or by an
24381
 
+   administrator.
24382
 
 
24383
 
    .. versionadded:: 2.6
24384
 
 
24385
 
 
24386
 
 .. data:: USER_SITE
24387
 
 
24388
 
-   Path to the user site directory for the current Python version or None
24389
 
+   Path to the user site-packages for the running Python.  Can be ``None`` if
24390
 
+   :func:`getusersitepackages` hasn't been called yet.  Default value is
24391
 
+   :file:`~/.local/lib/python{X.Y}/site-packages` for UNIX and non-framework Mac
24392
 
+   OS X builds, :file:`~/Library/Python/{X.Y}/lib/python/site-packages` for Mac
24393
 
+   framework builds, and :file:`{%APPDATA%}\\Python\\Python{XY}\\site-packages`
24394
 
+   on Windows.  This directory is a site directory, which means that
24395
 
+   :file:`.pth` files in it will be processed.
24396
 
 
24397
 
    .. versionadded:: 2.6
24398
 
 
24399
 
 
24400
 
 .. data:: USER_BASE
24401
 
 
24402
 
-   Path to the base directory for user site directories
24403
 
+   Path to the base directory for the user site-packages.  Can be ``None`` if
24404
 
+   :func:`getuserbase` hasn't been called yet.  Default value is
24405
 
+   :file:`~/.local` for UNIX and Mac OS X non-framework builds,
24406
 
+   :file:`~/Library/Python/{X.Y}` for Mac framework builds, and
24407
 
+   :file:`{%APPDATA%}\\Python` for Windows.  This value is used by Distutils to
24408
 
+   compute the installation directories for scripts, data files, Python modules,
24409
 
+   etc. for the :ref:`user installation scheme <inst-alt-install-user>`.  See
24410
 
+   also :envvar:`PYTHONUSERBASE`.
24411
 
 
24412
 
    .. versionadded:: 2.6
24413
 
 
24414
 
 
24415
 
-.. envvar:: PYTHONNOUSERSITE
24416
 
-
24417
 
-   .. versionadded:: 2.6
24418
 
-
24419
 
-
24420
 
-.. envvar:: PYTHONUSERBASE
24421
 
-
24422
 
-   .. versionadded:: 2.6
24423
 
-
24424
 
-
24425
 
 .. function:: addsitedir(sitedir, known_paths=None)
24426
 
 
24427
 
-   Adds a directory to sys.path and processes its pth files.
24428
 
+   Add a directory to sys.path and process its :file:`.pth` files.  Typically
24429
 
+   used in :mod:`sitecustomize` or :mod:`usercustomize` (see above).
24430
 
+
24431
 
 
24432
 
 .. function:: getsitepackages()
24433
 
 
24434
 
-   Returns a list containing all global site-packages directories
24435
 
-   (and possibly site-python).
24436
 
+   Return a list containing all global site-packages directories (and possibly
24437
 
+   site-python).
24438
 
 
24439
 
    .. versionadded:: 2.7
24440
 
 
24441
 
+
24442
 
 .. function:: getuserbase()
24443
 
 
24444
 
-   Returns the "user base" directory path.
24445
 
-
24446
 
-   The "user base" directory can be used to store data. If the global
24447
 
-   variable ``USER_BASE`` is not initialized yet, this function will also set
24448
 
-   it.
24449
 
+   Return the path of the user base directory, :data:`USER_BASE`.  If it is not
24450
 
+   initialized yet, this function will also set it, respecting
24451
 
+   :envvar:`PYTHONUSERBASE`.
24452
 
 
24453
 
    .. versionadded:: 2.7
24454
 
 
24455
 
+
24456
 
 .. function:: getusersitepackages()
24457
 
 
24458
 
-   Returns the user-specific site-packages directory path.
24459
 
-
24460
 
-   If the global variable ``USER_SITE`` is not initialized yet, this
24461
 
-   function will also set it.
24462
 
+   Return the path of the user-specific site-packages directory,
24463
 
+   :data:`USER_SITE`.  If it is not initialized yet, this function will also set
24464
 
+   it, respecting :envvar:`PYTHONNOUSERSITE` and :data:`USER_BASE`.
24465
 
 
24466
 
    .. versionadded:: 2.7
24467
 
 
24468
 
-.. XXX Update documentation
24469
 
-.. XXX document python -m site --user-base --user-site
24470
 
 
24471
 
+The :mod:`site` module also provides a way to get the user directories from the
24472
 
+command line:
24473
 
+
24474
 
+.. code-block:: sh
24475
 
+
24476
 
+   $ python3 -m site --user-site
24477
 
+   /home/user/.local/lib/python3.3/site-packages
24478
 
+
24479
 
+.. program:: site
24480
 
+
24481
 
+If it is called without arguments, it will print the contents of
24482
 
+:data:`sys.path` on the standard output, followed by the value of
24483
 
+:data:`USER_BASE` and whether the directory exists, then the same thing for
24484
 
+:data:`USER_SITE`, and finally the value of :data:`ENABLE_USER_SITE`.
24485
 
+
24486
 
+.. cmdoption:: --user-base
24487
 
+
24488
 
+   Print the path to the user base directory.
24489
 
+
24490
 
+.. cmdoption:: --user-site
24491
 
+
24492
 
+   Print the path to the user site-packages directory.
24493
 
+
24494
 
+If both options are given, user base and user site will be printed (always in
24495
 
+this order), separated by :data:`os.pathsep`.
24496
 
+
24497
 
+If any option is given, the script will exit with one of these values: ``O`` if
24498
 
+the user site-packages directory is enabled, ``1`` if it was disabled by the
24499
 
+user, ``2`` if it is disabled for security reasons or by an administrator, and a
24500
 
+value greater than 2 if there is an error.
24501
 
+
24502
 
+.. seealso::
24503
 
+
24504
 
+   :pep:`370` -- Per user site-packages directory
24505
 
diff -r 8527427914a2 Doc/library/smtpd.rst
24506
 
--- a/Doc/library/smtpd.rst
24507
 
+++ b/Doc/library/smtpd.rst
24508
 
@@ -7,8 +7,9 @@
24509
 
 .. moduleauthor:: Barry Warsaw <barry@zope.com>
24510
 
 .. sectionauthor:: Moshe Zadka <moshez@moshez.org>
24511
 
 
24512
 
+**Source code:** :source:`Lib/smtpd.py`
24513
 
 
24514
 
-
24515
 
+--------------
24516
 
 
24517
 
 This module offers several classes to implement SMTP servers.  One is a generic
24518
 
 do-nothing implementation, which can be overridden, while the other two offer
24519
 
diff -r 8527427914a2 Doc/library/smtplib.rst
24520
 
--- a/Doc/library/smtplib.rst
24521
 
+++ b/Doc/library/smtplib.rst
24522
 
@@ -1,4 +1,3 @@
24523
 
-
24524
 
 :mod:`smtplib` --- SMTP protocol client
24525
 
 =======================================
24526
 
 
24527
 
@@ -11,6 +10,10 @@
24528
 
    pair: SMTP; protocol
24529
 
    single: Simple Mail Transfer Protocol
24530
 
 
24531
 
+**Source code:** :source:`Lib/smtplib.py`
24532
 
+
24533
 
+--------------
24534
 
+
24535
 
 The :mod:`smtplib` module defines an SMTP client session object that can be used
24536
 
 to send mail to any Internet machine with an SMTP or ESMTP listener daemon.  For
24537
 
 details of SMTP and ESMTP operation, consult :rfc:`821` (Simple Mail Transfer
24538
 
diff -r 8527427914a2 Doc/library/sndhdr.rst
24539
 
--- a/Doc/library/sndhdr.rst
24540
 
+++ b/Doc/library/sndhdr.rst
24541
 
@@ -1,4 +1,3 @@
24542
 
-
24543
 
 :mod:`sndhdr` --- Determine type of sound file
24544
 
 ==============================================
24545
 
 
24546
 
@@ -11,6 +10,10 @@
24547
 
    single: A-LAW
24548
 
    single: u-LAW
24549
 
 
24550
 
+**Source code:** :source:`Lib/sndhdr.py`
24551
 
+
24552
 
+--------------
24553
 
+
24554
 
 The :mod:`sndhdr` provides utility functions which attempt to determine the type
24555
 
 of sound data which is in a file.  When these functions are able to determine
24556
 
 what type of sound data is stored in a file, they return a tuple ``(type,
24557
 
diff -r 8527427914a2 Doc/library/socket.rst
24558
 
--- a/Doc/library/socket.rst
24559
 
+++ b/Doc/library/socket.rst
24560
 
@@ -119,7 +119,7 @@
24561
 
 
24562
 
    The accompanying value is a pair ``(h_errno, string)`` representing an error
24563
 
    returned by a library call. *string* represents the description of *h_errno*, as
24564
 
-   returned by the :cfunc:`hstrerror` C function.
24565
 
+   returned by the :c:func:`hstrerror` C function.
24566
 
 
24567
 
 
24568
 
 .. exception:: gaierror
24569
 
@@ -127,7 +127,7 @@
24570
 
    This exception is raised for address-related errors, for :func:`getaddrinfo` and
24571
 
    :func:`getnameinfo`. The accompanying value is a pair ``(error, string)``
24572
 
    representing an error returned by a library call. *string* represents the
24573
 
-   description of *error*, as returned by the :cfunc:`gai_strerror` C function. The
24574
 
+   description of *error*, as returned by the :c:func:`gai_strerror` C function. The
24575
 
    *error* value will match one of the :const:`EAI_\*` constants defined in this
24576
 
    module.
24577
 
 
24578
 
@@ -207,10 +207,17 @@
24579
 
 
24580
 
 .. function:: create_connection(address[, timeout[, source_address]])
24581
 
 
24582
 
-   Convenience function.  Connect to *address* (a 2-tuple ``(host, port)``),
24583
 
-   and return the socket object.  Passing the optional *timeout* parameter will
24584
 
-   set the timeout on the socket instance before attempting to connect.  If no
24585
 
-   *timeout* is supplied, the global default timeout setting returned by
24586
 
+   Connect to a TCP service listening on the Internet *address* (a 2-tuple
24587
 
+   ``(host, port)``), and return the socket object.  This is a higher-level
24588
 
+   function than :meth:`socket.connect`: if *host* is a non-numeric hostname,
24589
 
+   it will try to resolve it for both :data:`AF_INET` and :data:`AF_INET6`,
24590
 
+   and then try to connect to all possible addresses in turn until a
24591
 
+   connection succeeds.  This makes it easy to write clients that are
24592
 
+   compatible to both IPv4 and IPv6.
24593
 
+
24594
 
+   Passing the optional *timeout* parameter will set the timeout on the
24595
 
+   socket instance before attempting to connect.  If no *timeout* is
24596
 
+   supplied, the global default timeout setting returned by
24597
 
    :func:`getdefaulttimeout` is used.
24598
 
 
24599
 
    If supplied, *source_address* must be a 2-tuple ``(host, port)`` for the
24600
 
@@ -423,7 +430,7 @@
24601
 
    Convert an IPv4 address from dotted-quad string format (for example,
24602
 
    '123.45.67.89') to 32-bit packed binary format, as a string four characters in
24603
 
    length.  This is useful when conversing with a program that uses the standard C
24604
 
-   library and needs objects of type :ctype:`struct in_addr`, which is the C type
24605
 
+   library and needs objects of type :c:type:`struct in_addr`, which is the C type
24606
 
    for the 32-bit packed binary this function returns.
24607
 
 
24608
 
    :func:`inet_aton` also accepts strings with less than three dots; see the
24609
 
@@ -431,7 +438,7 @@
24610
 
 
24611
 
    If the IPv4 address string passed to this function is invalid,
24612
 
    :exc:`socket.error` will be raised. Note that exactly what is valid depends on
24613
 
-   the underlying C implementation of :cfunc:`inet_aton`.
24614
 
+   the underlying C implementation of :c:func:`inet_aton`.
24615
 
 
24616
 
    :func:`inet_aton` does not support IPv6, and :func:`inet_pton` should be used
24617
 
    instead for IPv4/v6 dual stack support.
24618
 
@@ -442,7 +449,7 @@
24619
 
    Convert a 32-bit packed IPv4 address (a string four characters in length) to its
24620
 
    standard dotted-quad string representation (for example, '123.45.67.89').  This
24621
 
    is useful when conversing with a program that uses the standard C library and
24622
 
-   needs objects of type :ctype:`struct in_addr`, which is the C type for the
24623
 
+   needs objects of type :c:type:`struct in_addr`, which is the C type for the
24624
 
    32-bit packed binary data this function takes as an argument.
24625
 
 
24626
 
    If the string passed to this function is not exactly 4 bytes in length,
24627
 
@@ -454,14 +461,14 @@
24628
 
 
24629
 
    Convert an IP address from its family-specific string format to a packed, binary
24630
 
    format. :func:`inet_pton` is useful when a library or network protocol calls for
24631
 
-   an object of type :ctype:`struct in_addr` (similar to :func:`inet_aton`) or
24632
 
-   :ctype:`struct in6_addr`.
24633
 
+   an object of type :c:type:`struct in_addr` (similar to :func:`inet_aton`) or
24634
 
+   :c:type:`struct in6_addr`.
24635
 
 
24636
 
    Supported values for *address_family* are currently :const:`AF_INET` and
24637
 
    :const:`AF_INET6`. If the IP address string *ip_string* is invalid,
24638
 
    :exc:`socket.error` will be raised. Note that exactly what is valid depends on
24639
 
    both the value of *address_family* and the underlying implementation of
24640
 
-   :cfunc:`inet_pton`.
24641
 
+   :c:func:`inet_pton`.
24642
 
 
24643
 
    Availability: Unix (maybe not all platforms).
24644
 
 
24645
 
@@ -473,8 +480,8 @@
24646
 
    Convert a packed IP address (a string of some number of characters) to its
24647
 
    standard, family-specific string representation (for example, ``'7.10.0.5'`` or
24648
 
    ``'5aef:2b::8'``) :func:`inet_ntop` is useful when a library or network protocol
24649
 
-   returns an object of type :ctype:`struct in_addr` (similar to :func:`inet_ntoa`)
24650
 
-   or :ctype:`struct in6_addr`.
24651
 
+   returns an object of type :c:type:`struct in_addr` (similar to :func:`inet_ntoa`)
24652
 
+   or :c:type:`struct in6_addr`.
24653
 
 
24654
 
    Supported values for *address_family* are currently :const:`AF_INET` and
24655
 
    :const:`AF_INET6`. If the string *packed_ip* is not the correct length for the
24656
 
@@ -488,7 +495,7 @@
24657
 
 
24658
 
 .. function:: getdefaulttimeout()
24659
 
 
24660
 
-   Return the default timeout in floating seconds for new socket objects. A value
24661
 
+   Return the default timeout in seconds (float) for new socket objects. A value
24662
 
    of ``None`` indicates that new socket objects have no timeout. When the socket
24663
 
    module is first imported, the default is ``None``.
24664
 
 
24665
 
@@ -497,7 +504,7 @@
24666
 
 
24667
 
 .. function:: setdefaulttimeout(timeout)
24668
 
 
24669
 
-   Set the default timeout in floating seconds for new socket objects. A value of
24670
 
+   Set the default timeout in seconds (float) for new socket objects. A value of
24671
 
    ``None`` indicates that new socket objects have no timeout. When the socket
24672
 
    module is first imported, the default is ``None``.
24673
 
 
24674
 
@@ -576,10 +583,10 @@
24675
 
 .. method:: socket.connect_ex(address)
24676
 
 
24677
 
    Like ``connect(address)``, but return an error indicator instead of raising an
24678
 
-   exception for errors returned by the C-level :cfunc:`connect` call (other
24679
 
+   exception for errors returned by the C-level :c:func:`connect` call (other
24680
 
    problems, such as "host not found," can still raise exceptions).  The error
24681
 
    indicator is ``0`` if the operation succeeded, otherwise the value of the
24682
 
-   :cdata:`errno` variable.  This is useful to support, for example, asynchronous
24683
 
+   :c:data:`errno` variable.  This is useful to support, for example, asynchronous
24684
 
    connects.
24685
 
 
24686
 
    .. note::
24687
 
@@ -654,7 +661,7 @@
24688
 
 
24689
 
    Return a :dfn:`file object` associated with the socket.  (File objects are
24690
 
    described in :ref:`bltin-file-objects`.) The file object
24691
 
-   references a :cfunc:`dup`\ ped version of the socket file descriptor, so the
24692
 
+   references a :c:func:`dup`\ ped version of the socket file descriptor, so the
24693
 
    file object and socket object may be closed or garbage-collected independently.
24694
 
    The socket must be in blocking mode (it can not have a timeout). The optional
24695
 
    *mode* and *bufsize* arguments are interpreted the same way as by the built-in
24696
 
@@ -718,7 +725,8 @@
24697
 
    optional *flags* argument has the same meaning as for :meth:`recv` above.
24698
 
    Returns the number of bytes sent. Applications are responsible for checking that
24699
 
    all data has been sent; if only some of the data was transmitted, the
24700
 
-   application needs to attempt delivery of the remaining data.
24701
 
+   application needs to attempt delivery of the remaining data. For further
24702
 
+   information on this concept, consult the :ref:`socket-howto`.
24703
 
 
24704
 
 
24705
 
 .. method:: socket.sendall(string[, flags])
24706
 
@@ -766,7 +774,7 @@
24707
 
 
24708
 
 .. method:: socket.gettimeout()
24709
 
 
24710
 
-   Return the timeout in floating seconds associated with socket operations, or
24711
 
+   Return the timeout in seconds (float) associated with socket operations, or
24712
 
    ``None`` if no timeout is set.  This reflects the last call to
24713
 
    :meth:`setblocking` or :meth:`settimeout`.
24714
 
 
24715
 
@@ -856,8 +864,8 @@
24716
 
 :meth:`~socket.bind`, :meth:`~socket.listen`, :meth:`~socket.accept` (possibly
24717
 
 repeating the :meth:`~socket.accept` to service more than one client), while a
24718
 
 client only needs the sequence :func:`socket`, :meth:`~socket.connect`.  Also
24719
 
-note that the server does not :meth:`~socket.send`/:meth:`~socket.recv` on the
24720
 
-socket it is listening on but on the new socket returned by
24721
 
+note that the server does not :meth:`~socket.sendall`/:meth:`~socket.recv` on
24722
 
+the socket it is listening on but on the new socket returned by
24723
 
 :meth:`~socket.accept`.
24724
 
 
24725
 
 The first two examples support IPv4 only. ::
24726
 
@@ -875,7 +883,7 @@
24727
 
    while 1:
24728
 
        data = conn.recv(1024)
24729
 
        if not data: break
24730
 
-       conn.send(data)
24731
 
+       conn.sendall(data)
24732
 
    conn.close()
24733
 
 
24734
 
 ::
24735
 
@@ -887,7 +895,7 @@
24736
 
    PORT = 50007              # The same port as used by the server
24737
 
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
24738
 
    s.connect((HOST, PORT))
24739
 
-   s.send('Hello, world')
24740
 
+   s.sendall('Hello, world')
24741
 
    data = s.recv(1024)
24742
 
    s.close()
24743
 
    print 'Received', repr(data)
24744
 
@@ -959,7 +967,7 @@
24745
 
    if s is None:
24746
 
        print 'could not open socket'
24747
 
        sys.exit(1)
24748
 
-   s.send('Hello, world')
24749
 
+   s.sendall('Hello, world')
24750
 
    data = s.recv(1024)
24751
 
    s.close()
24752
 
    print 'Received', repr(data)
24753
 
@@ -989,3 +997,22 @@
24754
 
 
24755
 
    # disabled promiscuous mode
24756
 
    s.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)
24757
 
+
24758
 
+
24759
 
+Running an example several times with too small delay between executions, could
24760
 
+lead to this error::
24761
 
+
24762
 
+   socket.error: [Errno 98] Address already in use
24763
 
+
24764
 
+This is because the previous execution has left the socket in a ``TIME_WAIT``
24765
 
+state, and can't be immediately reused.
24766
 
+
24767
 
+There is a :mod:`socket` flag to set, in order to prevent this,
24768
 
+:data:`socket.SO_REUSEADDR`::
24769
 
+
24770
 
+   s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
24771
 
+   s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
24772
 
+   s.bind((HOST, PORT))
24773
 
+
24774
 
+the :data:`SO_REUSEADDR` flag tells the kernel to reuse a local socket in
24775
 
+``TIME_WAIT`` state, without waiting for its natural timeout to expire.
24776
 
diff -r 8527427914a2 Doc/library/socketserver.rst
24777
 
--- a/Doc/library/socketserver.rst
24778
 
+++ b/Doc/library/socketserver.rst
24779
 
@@ -1,4 +1,3 @@
24780
 
-
24781
 
 :mod:`SocketServer` --- A framework for network servers
24782
 
 =======================================================
24783
 
 
24784
 
@@ -11,6 +10,9 @@
24785
 
    Python 3.0.  The :term:`2to3` tool will automatically adapt imports when
24786
 
    converting your sources to 3.0.
24787
 
 
24788
 
+**Source code:** :source:`Lib/SocketServer.py`
24789
 
+
24790
 
+--------------
24791
 
 
24792
 
 The :mod:`SocketServer` module simplifies the task of writing network servers.
24793
 
 
24794
 
@@ -85,7 +87,7 @@
24795
 
    class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass
24796
 
 
24797
 
 The mix-in class must come first, since it overrides a method defined in
24798
 
-:class:`UDPServer`.  Setting the various member variables also changes the
24799
 
+:class:`UDPServer`.  Setting the various attributes also change the
24800
 
 behavior of the underlying server mechanism.
24801
 
 
24802
 
 To implement a service, you must derive a class from :class:`BaseRequestHandler`
24803
 
@@ -156,13 +158,14 @@
24804
 
 
24805
 
 .. method:: BaseServer.serve_forever(poll_interval=0.5)
24806
 
 
24807
 
-   Handle requests until an explicit :meth:`shutdown` request.  Polls for
24808
 
-   shutdown every *poll_interval* seconds.
24809
 
+   Handle requests until an explicit :meth:`shutdown` request.
24810
 
+   Poll for shutdown every *poll_interval* seconds. Ignores :attr:`self.timeout`.
24811
 
+   If you need to do periodic tasks, do them in another thread.
24812
 
 
24813
 
 
24814
 
 .. method:: BaseServer.shutdown()
24815
 
 
24816
 
-   Tells the :meth:`serve_forever` loop to stop and waits until it does.
24817
 
+   Tell the :meth:`serve_forever` loop to stop and wait until it does.
24818
 
 
24819
 
    .. versionadded:: 2.6
24820
 
 
24821
 
@@ -223,6 +226,7 @@
24822
 
    desired.  If :meth:`handle_request` receives no incoming requests within the
24823
 
    timeout period, the :meth:`handle_timeout` method is called.
24824
 
 
24825
 
+
24826
 
 There are various server methods that can be overridden by subclasses of base
24827
 
 server classes like :class:`TCPServer`; these methods aren't useful to external
24828
 
 users of the server object.
24829
 
@@ -353,10 +357,10 @@
24830
 
        def handle(self):
24831
 
            # self.request is the TCP socket connected to the client
24832
 
            self.data = self.request.recv(1024).strip()
24833
 
-           print "%s wrote:" % self.client_address[0]
24834
 
+           print "{} wrote:".format(self.client_address[0])
24835
 
            print self.data
24836
 
            # just send back the same data, but upper-cased
24837
 
-           self.request.send(self.data.upper())
24838
 
+           self.request.sendall(self.data.upper())
24839
 
 
24840
 
    if __name__ == "__main__":
24841
 
        HOST, PORT = "localhost", 9999
24842
 
@@ -377,7 +381,7 @@
24843
 
            # self.rfile is a file-like object created by the handler;
24844
 
            # we can now use e.g. readline() instead of raw recv() calls
24845
 
            self.data = self.rfile.readline().strip()
24846
 
-           print "%s wrote:" % self.client_address[0]
24847
 
+           print "{} wrote:".format(self.client_address[0])
24848
 
            print self.data
24849
 
            # Likewise, self.wfile is a file-like object used to write back
24850
 
            # to the client
24851
 
@@ -386,7 +390,7 @@
24852
 
 The difference is that the ``readline()`` call in the second handler will call
24853
 
 ``recv()`` multiple times until it encounters a newline character, while the
24854
 
 single ``recv()`` call in the first handler will just return what has been sent
24855
 
-from the client in one ``send()`` call.
24856
 
+from the client in one ``sendall()`` call.
24857
 
 
24858
 
 
24859
 
 This is the client side::
24860
 
@@ -400,16 +404,18 @@
24861
 
    # Create a socket (SOCK_STREAM means a TCP socket)
24862
 
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
24863
 
 
24864
 
-   # Connect to server and send data
24865
 
-   sock.connect((HOST, PORT))
24866
 
-   sock.send(data + "\n")
24867
 
+   try:
24868
 
+       # Connect to server and send data
24869
 
+       sock.connect((HOST, PORT))
24870
 
+       sock.sendall(data + "\n")
24871
 
 
24872
 
-   # Receive data from the server and shut down
24873
 
-   received = sock.recv(1024)
24874
 
-   sock.close()
24875
 
+       # Receive data from the server and shut down
24876
 
+       received = sock.recv(1024)
24877
 
+   finally:
24878
 
+       sock.close()
24879
 
 
24880
 
-   print "Sent:     %s" % data
24881
 
-   print "Received: %s" % received
24882
 
+   print "Sent:     {}".format(data)
24883
 
+   print "Received: {}".format(received)
24884
 
 
24885
 
 
24886
 
 The output of the example should look something like this:
24887
 
@@ -450,7 +456,7 @@
24888
 
        def handle(self):
24889
 
            data = self.request[0].strip()
24890
 
            socket = self.request[1]
24891
 
-           print "%s wrote:" % self.client_address[0]
24892
 
+           print "{} wrote:".format(self.client_address[0])
24893
 
            print data
24894
 
            socket.sendto(data.upper(), self.client_address)
24895
 
 
24896
 
@@ -475,8 +481,8 @@
24897
 
    sock.sendto(data + "\n", (HOST, PORT))
24898
 
    received = sock.recv(1024)
24899
 
 
24900
 
-   print "Sent:     %s" % data
24901
 
-   print "Received: %s" % received
24902
 
+   print "Sent:     {}".format(data)
24903
 
+   print "Received: {}".format(received)
24904
 
 
24905
 
 The output of the example should look exactly like for the TCP server example.
24906
 
 
24907
 
@@ -497,9 +503,9 @@
24908
 
 
24909
 
        def handle(self):
24910
 
            data = self.request.recv(1024)
24911
 
-           cur_thread = threading.currentThread()
24912
 
-           response = "%s: %s" % (cur_thread.getName(), data)
24913
 
-           self.request.send(response)
24914
 
+           cur_thread = threading.current_thread()
24915
 
+           response = "{}: {}".format(cur_thread.name, data)
24916
 
+           self.request.sendall(response)
24917
 
 
24918
 
    class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
24919
 
        pass
24920
 
@@ -507,10 +513,12 @@
24921
 
    def client(ip, port, message):
24922
 
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
24923
 
        sock.connect((ip, port))
24924
 
-       sock.send(message)
24925
 
-       response = sock.recv(1024)
24926
 
-       print "Received: %s" % response
24927
 
-       sock.close()
24928
 
+       try:
24929
 
+           sock.sendall(message)
24930
 
+           response = sock.recv(1024)
24931
 
+           print "Received: {}".format(response)
24932
 
+       finally:
24933
 
+           sock.close()
24934
 
 
24935
 
    if __name__ == "__main__":
24936
 
        # Port 0 means to select an arbitrary unused port
24937
 
@@ -523,9 +531,9 @@
24938
 
        # more thread for each request
24939
 
        server_thread = threading.Thread(target=server.serve_forever)
24940
 
        # Exit the server thread when the main thread terminates
24941
 
-       server_thread.setDaemon(True)
24942
 
+       server_thread.daemon = True
24943
 
        server_thread.start()
24944
 
-       print "Server loop running in thread:", server_thread.getName()
24945
 
+       print "Server loop running in thread:", server_thread.name
24946
 
 
24947
 
        client(ip, port, "Hello World 1")
24948
 
        client(ip, port, "Hello World 2")
24949
 
@@ -533,6 +541,7 @@
24950
 
 
24951
 
        server.shutdown()
24952
 
 
24953
 
+
24954
 
 The output of the example should look something like this::
24955
 
 
24956
 
    $ python ThreadedTCPServer.py
24957
 
diff -r 8527427914a2 Doc/library/sqlite3.rst
24958
 
--- a/Doc/library/sqlite3.rst
24959
 
+++ b/Doc/library/sqlite3.rst
24960
 
@@ -22,6 +22,7 @@
24961
 
 represents the database.  Here the data will be stored in the
24962
 
 :file:`/tmp/example` file::
24963
 
 
24964
 
+   import sqlite3
24965
 
    conn = sqlite3.connect('/tmp/example')
24966
 
 
24967
 
 You can also supply the special name ``:memory:`` to create a database in RAM.
24968
 
@@ -58,7 +59,7 @@
24969
 
 
24970
 
    # Never do this -- insecure!
24971
 
    symbol = 'IBM'
24972
 
-   c.execute("... where symbol = '%s'" % symbol)
24973
 
+   c.execute("select * from stocks where symbol = '%s'" % symbol)
24974
 
 
24975
 
    # Do this instead
24976
 
    t = (symbol,)
24977
 
@@ -66,7 +67,7 @@
24978
 
 
24979
 
    # Larger example
24980
 
    for t in [('2006-03-28', 'BUY', 'IBM', 1000, 45.00),
24981
 
-             ('2006-04-05', 'BUY', 'MSOFT', 1000, 72.00),
24982
 
+             ('2006-04-05', 'BUY', 'MSFT', 1000, 72.00),
24983
 
              ('2006-04-06', 'SELL', 'IBM', 500, 53.00),
24984
 
             ]:
24985
 
        c.execute('insert into stocks values (?,?,?,?,?)', t)
24986
 
@@ -86,7 +87,7 @@
24987
 
    (u'2006-01-05', u'BUY', u'RHAT', 100, 35.14)
24988
 
    (u'2006-03-28', u'BUY', u'IBM', 1000, 45.0)
24989
 
    (u'2006-04-06', u'SELL', u'IBM', 500, 53.0)
24990
 
-   (u'2006-04-05', u'BUY', u'MSOFT', 1000, 72.0)
24991
 
+   (u'2006-04-05', u'BUY', u'MSFT', 1000, 72.0)
24992
 
    >>>
24993
 
 
24994
 
 
24995
 
@@ -240,7 +241,7 @@
24996
 
 .. method:: Connection.commit()
24997
 
 
24998
 
    This method commits the current transaction. If you don't call this method,
24999
 
-   anything you did since the last call to ``commit()`` is not visible from from
25000
 
+   anything you did since the last call to ``commit()`` is not visible from
25001
 
    other database connections. If you wonder why you don't see the data you've
25002
 
    written to the database, please check you didn't forget to call this method.
25003
 
 
25004
 
@@ -378,6 +379,8 @@
25005
 
 
25006
 
    .. literalinclude:: ../includes/sqlite3/load_extension.py
25007
 
 
25008
 
+   Loadable extensions are disabled by default. See [#f1]_
25009
 
+
25010
 
 .. method:: Connection.load_extension(path)
25011
 
 
25012
 
    .. versionadded:: 2.7
25013
 
@@ -386,6 +389,8 @@
25014
 
    enable extension loading with :meth:`enable_load_extension` before you can
25015
 
    use this routine.
25016
 
 
25017
 
+   Loadable extensions are disabled by default. See [#f1]_
25018
 
+
25019
 
 .. attribute:: Connection.row_factory
25020
 
 
25021
 
    You can change this attribute to a callable that accepts the cursor and the
25022
 
@@ -600,42 +605,42 @@
25023
 
 
25024
 
 Let's assume we initialize a table as in the example given above::
25025
 
 
25026
 
-    conn = sqlite3.connect(":memory:")
25027
 
-    c = conn.cursor()
25028
 
-    c.execute('''create table stocks
25029
 
-    (date text, trans text, symbol text,
25030
 
-     qty real, price real)''')
25031
 
-    c.execute("""insert into stocks
25032
 
-              values ('2006-01-05','BUY','RHAT',100,35.14)""")
25033
 
-    conn.commit()
25034
 
-    c.close()
25035
 
+   conn = sqlite3.connect(":memory:")
25036
 
+   c = conn.cursor()
25037
 
+   c.execute('''create table stocks
25038
 
+   (date text, trans text, symbol text,
25039
 
+    qty real, price real)''')
25040
 
+   c.execute("""insert into stocks
25041
 
+             values ('2006-01-05','BUY','RHAT',100,35.14)""")
25042
 
+   conn.commit()
25043
 
+   c.close()
25044
 
 
25045
 
 Now we plug :class:`Row` in::
25046
 
 
25047
 
-    >>> conn.row_factory = sqlite3.Row
25048
 
-    >>> c = conn.cursor()
25049
 
-    >>> c.execute('select * from stocks')
25050
 
-    <sqlite3.Cursor object at 0x7f4e7dd8fa80>
25051
 
-    >>> r = c.fetchone()
25052
 
-    >>> type(r)
25053
 
-    <type 'sqlite3.Row'>
25054
 
-    >>> r
25055
 
-    (u'2006-01-05', u'BUY', u'RHAT', 100.0, 35.14)
25056
 
-    >>> len(r)
25057
 
-    5
25058
 
-    >>> r[2]
25059
 
-    u'RHAT'
25060
 
-    >>> r.keys()
25061
 
-    ['date', 'trans', 'symbol', 'qty', 'price']
25062
 
-    >>> r['qty']
25063
 
-    100.0
25064
 
-    >>> for member in r: print member
25065
 
-    ...
25066
 
-    2006-01-05
25067
 
-    BUY
25068
 
-    RHAT
25069
 
-    100.0
25070
 
-    35.14
25071
 
+   >>> conn.row_factory = sqlite3.Row
25072
 
+   >>> c = conn.cursor()
25073
 
+   >>> c.execute('select * from stocks')
25074
 
+   <sqlite3.Cursor object at 0x7f4e7dd8fa80>
25075
 
+   >>> r = c.fetchone()
25076
 
+   >>> type(r)
25077
 
+   <type 'sqlite3.Row'>
25078
 
+   >>> r
25079
 
+   (u'2006-01-05', u'BUY', u'RHAT', 100.0, 35.14)
25080
 
+   >>> len(r)
25081
 
+   5
25082
 
+   >>> r[2]
25083
 
+   u'RHAT'
25084
 
+   >>> r.keys()
25085
 
+   ['date', 'trans', 'symbol', 'qty', 'price']
25086
 
+   >>> r['qty']
25087
 
+   100.0
25088
 
+   >>> for member in r: print member
25089
 
+   ...
25090
 
+   2006-01-05
25091
 
+   BUY
25092
 
+   RHAT
25093
 
+   100.0
25094
 
+   35.14
25095
 
 
25096
 
 
25097
 
 .. _sqlite3-types:
25098
 
@@ -893,3 +898,12 @@
25099
 
 
25100
 
 The only exception is calling the :meth:`~Connection.interrupt` method, which
25101
 
 only makes sense to call from a different thread.
25102
 
+
25103
 
+.. rubric:: Footnotes
25104
 
+
25105
 
+.. [#f1] The sqlite3 module is not built with loadable extension support by
25106
 
+   default, because some platforms (notably Mac OS X) have SQLite libraries
25107
 
+   which are compiled without this feature. To get loadable extension support,
25108
 
+   you must modify setup.py and remove the line that sets
25109
 
+   SQLITE_OMIT_LOAD_EXTENSION.
25110
 
+
25111
 
diff -r 8527427914a2 Doc/library/ssl.rst
25112
 
--- a/Doc/library/ssl.rst
25113
 
+++ b/Doc/library/ssl.rst
25114
 
@@ -5,9 +5,6 @@
25115
 
    :synopsis: TLS/SSL wrapper for socket objects
25116
 
 
25117
 
 .. moduleauthor:: Bill Janssen <bill.janssen@gmail.com>
25118
 
-
25119
 
-.. versionadded:: 2.6
25120
 
-
25121
 
 .. sectionauthor::  Bill Janssen <bill.janssen@gmail.com>
25122
 
 
25123
 
 
25124
 
@@ -15,6 +12,12 @@
25125
 
 
25126
 
 .. index:: TLS, SSL, Transport Layer Security, Secure Sockets Layer
25127
 
 
25128
 
+.. versionadded:: 2.6
25129
 
+
25130
 
+**Source code:** :source:`Lib/ssl.py`
25131
 
+
25132
 
+--------------
25133
 
+
25134
 
 This module provides access to Transport Layer Security (often known as "Secure
25135
 
 Sockets Layer") encryption and peer authentication facilities for network
25136
 
 sockets, both client-side and server-side.  This module uses the OpenSSL
25137
 
@@ -100,9 +103,8 @@
25138
 
    The parameter ``ssl_version`` specifies which version of the SSL protocol to
25139
 
    use.  Typically, the server chooses a particular protocol version, and the
25140
 
    client must adapt to the server's choice.  Most of the versions are not
25141
 
-   interoperable with the other versions.  If not specified, for client-side
25142
 
-   operation, the default SSL version is SSLv3; for server-side operation,
25143
 
-   SSLv23.  These version selections provide the most compatibility with other
25144
 
+   interoperable with the other versions.  If not specified, the default is
25145
 
+   :data:`PROTOCOL_SSLv23`; it provides the most compatibility with other
25146
 
    versions.
25147
 
 
25148
 
    Here's a table showing which versions in a client (down the side) can connect
25149
 
@@ -114,7 +116,7 @@
25150
 
         *client* / **server**    **SSLv2**  **SSLv3**  **SSLv23**  **TLSv1**
25151
 
        ------------------------  ---------  ---------  ----------  ---------
25152
 
         *SSLv2*                    yes        no         yes         no
25153
 
-        *SSLv3*                    yes        yes        yes         no
25154
 
+        *SSLv3*                    no         yes        yes         no
25155
 
         *SSLv23*                   yes        no         yes         no
25156
 
         *TLSv1*                    no         no         yes         yes
25157
 
        ========================  =========  =========  ==========  =========
25158
 
@@ -619,8 +621,8 @@
25159
 
    Class :class:`socket.socket`
25160
 
             Documentation of underlying :mod:`socket` class
25161
 
 
25162
 
-   `Introducing SSL and Certificates using OpenSSL <http://old.pseudonym.org/ssl/wwwj-index.html>`_
25163
 
-       Frederick J. Hirsch
25164
 
+   `TLS (Transport Layer Security) and SSL (Secure Socket Layer) <http://www3.rad.com/networks/applications/secure/tls.htm>`_
25165
 
+      Debby Koren
25166
 
 
25167
 
    `RFC 1422: Privacy Enhancement for Internet Electronic Mail: Part II: Certificate-Based Key Management <http://www.ietf.org/rfc/rfc1422>`_
25168
 
        Steve Kent
25169
 
diff -r 8527427914a2 Doc/library/stat.rst
25170
 
--- a/Doc/library/stat.rst
25171
 
+++ b/Doc/library/stat.rst
25172
 
@@ -1,4 +1,3 @@
25173
 
-
25174
 
 :mod:`stat` --- Interpreting :func:`stat` results
25175
 
 =================================================
25176
 
 
25177
 
@@ -6,11 +5,14 @@
25178
 
    :synopsis: Utilities for interpreting the results of os.stat(), os.lstat() and os.fstat().
25179
 
 .. sectionauthor:: Skip Montanaro <skip@automatrix.com>
25180
 
 
25181
 
+**Source code:** :source:`Lib/stat.py`
25182
 
+
25183
 
+--------------
25184
 
 
25185
 
 The :mod:`stat` module defines constants and functions for interpreting the
25186
 
 results of :func:`os.stat`, :func:`os.fstat` and :func:`os.lstat` (if they
25187
 
-exist).  For complete details about the :cfunc:`stat`, :cfunc:`fstat` and
25188
 
-:cfunc:`lstat` calls, consult the documentation for your system.
25189
 
+exist).  For complete details about the :c:func:`stat`, :c:func:`fstat` and
25190
 
+:c:func:`lstat` calls, consult the documentation for your system.
25191
 
 
25192
 
 The :mod:`stat` module defines the following functions to test for specific file
25193
 
 types:
25194
 
@@ -68,7 +70,7 @@
25195
 
 
25196
 
 Normally, you would use the :func:`os.path.is\*` functions for testing the type
25197
 
 of a file; the functions here are useful when you are doing multiple tests of
25198
 
-the same file and wish to avoid the overhead of the :cfunc:`stat` system call
25199
 
+the same file and wish to avoid the overhead of the :c:func:`stat` system call
25200
 
 for each test.  These are also useful when checking for information about a file
25201
 
 that isn't handled by :mod:`os.path`, like the tests for block and character
25202
 
 devices.
25203
 
@@ -84,7 +86,7 @@
25204
 
 
25205
 
        for f in os.listdir(top):
25206
 
            pathname = os.path.join(top, f)
25207
 
-           mode = os.stat(pathname)[ST_MODE]
25208
 
+           mode = os.stat(pathname).st_mode
25209
 
            if S_ISDIR(mode):
25210
 
                # It's a directory, recurse into it
25211
 
                walktree(pathname, callback)
25212
 
@@ -306,11 +308,19 @@
25213
 
 
25214
 
 .. data:: UF_OPAQUE
25215
 
 
25216
 
-   The file may not be renamed or deleted.
25217
 
+   The directory is opaque when viewed through a union stack.
25218
 
 
25219
 
 .. data:: UF_NOUNLINK
25220
 
 
25221
 
-   The directory is opaque when viewed through a union stack.
25222
 
+   The file may not be renamed or deleted.
25223
 
+
25224
 
+.. data:: UF_COMPRESSED
25225
 
+
25226
 
+   The file is stored compressed (Mac OS X 10.6+).
25227
 
+
25228
 
+.. data:: UF_HIDDEN
25229
 
+
25230
 
+   The file should not be displayed in a GUI (Mac OS X 10.5+).
25231
 
 
25232
 
 .. data:: SF_ARCHIVED
25233
 
 
25234
 
diff -r 8527427914a2 Doc/library/statvfs.rst
25235
 
--- a/Doc/library/statvfs.rst
25236
 
+++ b/Doc/library/statvfs.rst
25237
 
@@ -61,7 +61,7 @@
25238
 
 
25239
 
 .. data:: F_FLAG
25240
 
 
25241
 
-   Flags. System dependent: see :cfunc:`statvfs` man page.
25242
 
+   Flags. System dependent: see :c:func:`statvfs` man page.
25243
 
 
25244
 
 
25245
 
 .. data:: F_NAMEMAX
25246
 
diff -r 8527427914a2 Doc/library/stdtypes.rst
25247
 
--- a/Doc/library/stdtypes.rst
25248
 
+++ b/Doc/library/stdtypes.rst
25249
 
@@ -63,7 +63,7 @@
25250
 
 
25251
 
 * instances of user-defined classes, if the class defines a :meth:`__nonzero__`
25252
 
   or :meth:`__len__` method, when that method returns the integer zero or
25253
 
-  :class:`bool` value ``False``. [#]_
25254
 
+  :class:`bool` value ``False``. [1]_
25255
 
 
25256
 
 .. index:: single: true
25257
 
 
25258
 
@@ -226,11 +226,11 @@
25259
 
 There are four distinct numeric types: :dfn:`plain integers`, :dfn:`long
25260
 
 integers`, :dfn:`floating point numbers`, and :dfn:`complex numbers`. In
25261
 
 addition, Booleans are a subtype of plain integers. Plain integers (also just
25262
 
-called :dfn:`integers`) are implemented using :ctype:`long` in C, which gives
25263
 
+called :dfn:`integers`) are implemented using :c:type:`long` in C, which gives
25264
 
 them at least 32 bits of precision (``sys.maxint`` is always set to the maximum
25265
 
 plain integer value for the current platform, the minimum value is
25266
 
 ``-sys.maxint - 1``).  Long integers have unlimited precision.  Floating point
25267
 
-numbers are usually implemented using :ctype:`double` in C; information about
25268
 
+numbers are usually implemented using :c:type:`double` in C; information about
25269
 
 the precision and internal representation of floating point numbers for the
25270
 
 machine on which your program is running is available in
25271
 
 :data:`sys.float_info`.  Complex numbers have a real and imaginary part, which
25272
 
@@ -277,7 +277,7 @@
25273
 
 operands of different numeric types, the operand with the "narrower" type is
25274
 
 widened to that of the other, where plain integer is narrower than long integer
25275
 
 is narrower than floating point is narrower than complex. Comparisons between
25276
 
-numbers of mixed type use the same rule. [#]_ The constructors :func:`int`,
25277
 
+numbers of mixed type use the same rule. [2]_ The constructors :func:`int`,
25278
 
 :func:`long`, :func:`float`, and :func:`complex` can be used to produce numbers
25279
 
 of a specific type.
25280
 
 
25281
 
@@ -401,12 +401,12 @@
25282
 
 
25283
 
 .. _bitstring-ops:
25284
 
 
25285
 
-Bit-string Operations on Integer Types
25286
 
+Bitwise Operations on Integer Types
25287
 
 --------------------------------------
25288
 
 
25289
 
 .. index::
25290
 
    triple: operations on; integer; types
25291
 
-   pair: bit-string; operations
25292
 
+   pair: bitwise; operations
25293
 
    pair: shifting; operations
25294
 
    pair: masking; operations
25295
 
    operator: ^
25296
 
@@ -414,16 +414,16 @@
25297
 
    operator: <<
25298
 
    operator: >>
25299
 
 
25300
 
-Plain and long integer types support additional operations that make sense only
25301
 
-for bit-strings.  Negative numbers are treated as their 2's complement value
25302
 
-(for long integers, this assumes a sufficiently large number of bits that no
25303
 
-overflow occurs during the operation).
25304
 
+Bitwise operations only make sense for integers.  Negative numbers are treated
25305
 
+as their 2's complement value (this assumes a sufficiently large number of bits
25306
 
+that no overflow occurs during the operation).
25307
 
 
25308
 
 The priorities of the binary bitwise operations are all lower than the numeric
25309
 
 operations and higher than the comparisons; the unary operation ``~`` has the
25310
 
 same priority as the other unary numeric operations (``+`` and ``-``).
25311
 
 
25312
 
-This table lists the bit-string operations sorted in ascending priority:
25313
 
+This table lists the bitwise operations sorted in ascending priority
25314
 
+(operations in the same box have the same priority):
25315
 
 
25316
 
 +------------+--------------------------------+----------+
25317
 
 | Operation  | Result                         | Notes    |
25318
 
@@ -709,7 +709,7 @@
25319
 
 Most sequence types support the following operations.  The ``in`` and ``not in``
25320
 
 operations have the same priorities as the comparison operations.  The ``+`` and
25321
 
 ``*`` operations have the same priority as the corresponding numeric operations.
25322
 
-[#]_ Additional methods are provided for :ref:`typesseq-mutable`.
25323
 
+[3]_ Additional methods are provided for :ref:`typesseq-mutable`.
25324
 
 
25325
 
 This table lists the sequence operations sorted in ascending priority
25326
 
 (operations in the same box have the same priority).  In the table, *s* and *t*
25327
 
@@ -730,7 +730,7 @@
25328
 
 | ``s * n, n * s`` | *n* shallow copies of *s*      | \(2)     |
25329
 
 |                  | concatenated                   |          |
25330
 
 +------------------+--------------------------------+----------+
25331
 
-| ``s[i]``         | *i*'th item of *s*, origin 0   | \(3)     |
25332
 
+| ``s[i]``         | *i*\ th item of *s*, origin 0  | \(3)     |
25333
 
 +------------------+--------------------------------+----------+
25334
 
 | ``s[i:j]``       | slice of *s* from *i* to *j*   | (3)(4)   |
25335
 
 +------------------+--------------------------------+----------+
25336
 
@@ -1007,7 +1007,7 @@
25337
 
 
25338
 
 .. method:: str.islower()
25339
 
 
25340
 
-   Return true if all cased characters in the string are lowercase and there is at
25341
 
+   Return true if all cased characters [4]_ in the string are lowercase and there is at
25342
 
    least one cased character, false otherwise.
25343
 
 
25344
 
    For 8-bit strings, this method is locale-dependent.
25345
 
@@ -1032,7 +1032,7 @@
25346
 
 
25347
 
 .. method:: str.isupper()
25348
 
 
25349
 
-   Return true if all cased characters in the string are uppercase and there is at
25350
 
+   Return true if all cased characters [4]_ in the string are uppercase and there is at
25351
 
    least one cased character, false otherwise.
25352
 
 
25353
 
    For 8-bit strings, this method is locale-dependent.
25354
 
@@ -1049,7 +1049,7 @@
25355
 
 
25356
 
    Return the string left justified in a string of length *width*. Padding is done
25357
 
    using the specified *fillchar* (default is a space).  The original string is
25358
 
-   returned if *width* is less than ``len(s)``.
25359
 
+   returned if *width* is less than or equal to ``len(s)``.
25360
 
 
25361
 
    .. versionchanged:: 2.4
25362
 
       Support for the *fillchar* argument.
25363
 
@@ -1057,7 +1057,8 @@
25364
 
 
25365
 
 .. method:: str.lower()
25366
 
 
25367
 
-   Return a copy of the string converted to lowercase.
25368
 
+   Return a copy of the string with all the cased characters [4]_ converted to
25369
 
+   lowercase.
25370
 
 
25371
 
    For 8-bit strings, this method is locale-dependent.
25372
 
 
25373
 
@@ -1112,7 +1113,7 @@
25374
 
 
25375
 
    Return the string right justified in a string of length *width*. Padding is done
25376
 
    using the specified *fillchar* (default is a space). The original string is
25377
 
-   returned if *width* is less than ``len(s)``.
25378
 
+   returned if *width* is less than or equal to ``len(s)``.
25379
 
 
25380
 
    .. versionchanged:: 2.4
25381
 
       Support for the *fillchar* argument.
25382
 
@@ -1280,7 +1281,10 @@
25383
 
 
25384
 
 .. method:: str.upper()
25385
 
 
25386
 
-   Return a copy of the string converted to uppercase.
25387
 
+   Return a copy of the string with all the cased characters [4]_ converted to
25388
 
+   uppercase.  Note that ``str.upper().isupper()`` might be ``False`` if ``s``
25389
 
+   contains uncased characters or if the Unicode category of the resulting
25390
 
+   character(s) is not "Lu" (Letter, uppercase), but e.g. "Lt" (Letter, titlecase).
25391
 
 
25392
 
    For 8-bit strings, this method is locale-dependent.
25393
 
 
25394
 
@@ -1289,7 +1293,7 @@
25395
 
 
25396
 
    Return the numeric string left filled with zeros in a string of length
25397
 
    *width*.  A sign prefix is handled correctly.  The original string is
25398
 
-   returned if *width* is less than ``len(s)``.
25399
 
+   returned if *width* is less than or equal to ``len(s)``.
25400
 
 
25401
 
 
25402
 
    .. versionadded:: 2.2.2
25403
 
@@ -1307,7 +1311,7 @@
25404
 
 
25405
 
    Return ``True`` if there are only decimal characters in S, ``False``
25406
 
    otherwise. Decimal characters include digit characters, and all characters
25407
 
-   that that can be used to form decimal-radix numbers, e.g. U+0660,
25408
 
+   that can be used to form decimal-radix numbers, e.g. U+0660,
25409
 
    ARABIC-INDIC DIGIT ZERO.
25410
 
 
25411
 
 
25412
 
@@ -1331,12 +1335,12 @@
25413
 
 *interpolation* operator.  Given ``format % values`` (where *format* is a string
25414
 
 or Unicode object), ``%`` conversion specifications in *format* are replaced
25415
 
 with zero or more elements of *values*.  The effect is similar to the using
25416
 
-:cfunc:`sprintf` in the C language.  If *format* is a Unicode object, or if any
25417
 
+:c:func:`sprintf` in the C language.  If *format* is a Unicode object, or if any
25418
 
 of the objects being converted using the ``%s`` conversion are Unicode objects,
25419
 
 the result will also be a Unicode object.
25420
 
 
25421
 
 If *format* requires a single argument, *values* may be a single non-tuple
25422
 
-object. [#]_  Otherwise, *values* must be a tuple with exactly the number of
25423
 
+object. [5]_  Otherwise, *values* must be a tuple with exactly the number of
25424
 
 items specified by the format string, or a single mapping object (for example, a
25425
 
 dictionary).
25426
 
 
25427
 
@@ -2327,7 +2331,7 @@
25428
 
 
25429
 
 .. method:: file.flush()
25430
 
 
25431
 
-   Flush the internal buffer, like ``stdio``'s :cfunc:`fflush`.  This may be a
25432
 
+   Flush the internal buffer, like ``stdio``'s :c:func:`fflush`.  This may be a
25433
 
    no-op on some file-like objects.
25434
 
 
25435
 
    .. note::
25436
 
@@ -2368,12 +2372,12 @@
25437
 
    A file object is its own iterator, for example ``iter(f)`` returns *f* (unless
25438
 
    *f* is closed).  When a file is used as an iterator, typically in a
25439
 
    :keyword:`for` loop (for example, ``for line in f: print line``), the
25440
 
-   :meth:`.next` method is called repeatedly.  This method returns the next input
25441
 
+   :meth:`~file.next` method is called repeatedly.  This method returns the next input
25442
 
    line, or raises :exc:`StopIteration` when EOF is hit when the file is open for
25443
 
    reading (behavior is undefined when the file is open for writing).  In order to
25444
 
    make a :keyword:`for` loop the most efficient way of looping over the lines of a
25445
 
-   file (a very common operation), the :meth:`next` method uses a hidden read-ahead
25446
 
-   buffer.  As a consequence of using a read-ahead buffer, combining :meth:`.next`
25447
 
+   file (a very common operation), the :meth:`~file.next` method uses a hidden read-ahead
25448
 
+   buffer.  As a consequence of using a read-ahead buffer, combining :meth:`~file.next`
25449
 
    with other file methods (like :meth:`readline`) does not work right.  However,
25450
 
    using :meth:`seek` to reposition the file to an absolute position will flush the
25451
 
    read-ahead buffer.
25452
 
@@ -2388,21 +2392,21 @@
25453
 
    all data until EOF is reached.  The bytes are returned as a string object.  An
25454
 
    empty string is returned when EOF is encountered immediately.  (For certain
25455
 
    files, like ttys, it makes sense to continue reading after an EOF is hit.)  Note
25456
 
-   that this method may call the underlying C function :cfunc:`fread` more than
25457
 
+   that this method may call the underlying C function :c:func:`fread` more than
25458
 
    once in an effort to acquire as close to *size* bytes as possible. Also note
25459
 
    that when in non-blocking mode, less data than was requested may be
25460
 
    returned, even if no *size* parameter was given.
25461
 
 
25462
 
    .. note::
25463
 
       This function is simply a wrapper for the underlying
25464
 
-      :cfunc:`fread` C function, and will behave the same in corner cases,
25465
 
+      :c:func:`fread` C function, and will behave the same in corner cases,
25466
 
       such as whether the EOF value is cached.
25467
 
 
25468
 
 
25469
 
 .. method:: file.readline([size])
25470
 
 
25471
 
    Read one entire line from the file.  A trailing newline character is kept in
25472
 
-   the string (but may be absent when a file ends with an incomplete line). [#]_
25473
 
+   the string (but may be absent when a file ends with an incomplete line). [6]_
25474
 
    If the *size* argument is present and non-negative, it is a maximum byte
25475
 
    count (including the trailing newline) and an incomplete line may be
25476
 
    returned. When *size* is not 0, an empty string is returned *only* when EOF
25477
 
@@ -2410,7 +2414,7 @@
25478
 
 
25479
 
    .. note::
25480
 
 
25481
 
-      Unlike ``stdio``'s :cfunc:`fgets`, the returned string contains null characters
25482
 
+      Unlike ``stdio``'s :c:func:`fgets`, the returned string contains null characters
25483
 
       (``'\0'``) if they occurred in the input.
25484
 
 
25485
 
 
25486
 
@@ -2436,7 +2440,7 @@
25487
 
 
25488
 
 .. method:: file.seek(offset[, whence])
25489
 
 
25490
 
-   Set the file's current position, like ``stdio``'s :cfunc:`fseek`. The *whence*
25491
 
+   Set the file's current position, like ``stdio``'s :c:func:`fseek`. The *whence*
25492
 
    argument is optional and defaults to  ``os.SEEK_SET`` or ``0`` (absolute file
25493
 
    positioning); other values are ``os.SEEK_CUR`` or ``1`` (seek relative to the
25494
 
    current position) and ``os.SEEK_END`` or ``2``  (seek relative to the file's
25495
 
@@ -2461,11 +2465,11 @@
25496
 
 
25497
 
 .. method:: file.tell()
25498
 
 
25499
 
-   Return the file's current position, like ``stdio``'s :cfunc:`ftell`.
25500
 
+   Return the file's current position, like ``stdio``'s :c:func:`ftell`.
25501
 
 
25502
 
    .. note::
25503
 
 
25504
 
-      On Windows, :meth:`tell` can return illegal values (after an :cfunc:`fgets`)
25505
 
+      On Windows, :meth:`tell` can return illegal values (after an :c:func:`fgets`)
25506
 
       when reading files with Unix-style line-endings. Use binary mode (``'rb'``) to
25507
 
       circumvent this problem.
25508
 
 
25509
 
@@ -2787,7 +2791,7 @@
25510
 
 foo`` does not require a module object named *foo* to exist, rather it requires
25511
 
 an (external) *definition* for a module named *foo* somewhere.)
25512
 
 
25513
 
-A special member of every module is :attr:`__dict__`. This is the dictionary
25514
 
+A special attribute of every module is :attr:`__dict__`. This is the dictionary
25515
 
 containing the module's symbol table. Modifying this dictionary will actually
25516
 
 change the module's symbol table, but direct assignment to the :attr:`__dict__`
25517
 
 attribute is not possible (you can write ``m.__dict__['a'] = 1``, which defines
25518
 
@@ -2930,7 +2934,18 @@
25519
 
 supports no special operations.  There is exactly one ellipsis object, named
25520
 
 :const:`Ellipsis` (a built-in name).
25521
 
 
25522
 
-It is written as ``Ellipsis``.
25523
 
+It is written as ``Ellipsis``.  When in a subscript, it can also be written as
25524
 
+``...``, for example ``seq[...]``.
25525
 
+
25526
 
+
25527
 
+The NotImplemented Object
25528
 
+-------------------------
25529
 
+
25530
 
+This object is returned from comparisons and binary operations when they are
25531
 
+asked to operate on types they don't support. See :ref:`comparisons` for more
25532
 
+information.
25533
 
+
25534
 
+It is written as ``NotImplemented``.
25535
 
 
25536
 
 
25537
 
 Boolean Values
25538
 
@@ -2940,9 +2955,9 @@
25539
 
 used to represent truth values (although other values can also be considered
25540
 
 false or true).  In numeric contexts (for example when used as the argument to
25541
 
 an arithmetic operator), they behave like the integers 0 and 1, respectively.
25542
 
-The built-in function :func:`bool` can be used to cast any value to a Boolean,
25543
 
-if the value can be interpreted as a truth value (see section Truth Value
25544
 
-Testing above).
25545
 
+The built-in function :func:`bool` can be used to convert any value to a
25546
 
+Boolean, if the value can be interpreted as a truth value (see section
25547
 
+:ref:`truth` above).
25548
 
 
25549
 
 .. index::
25550
 
    single: False
25551
 
@@ -3033,18 +3048,21 @@
25552
 
 
25553
 
 .. rubric:: Footnotes
25554
 
 
25555
 
-.. [#] Additional information on these special methods may be found in the Python
25556
 
+.. [1] Additional information on these special methods may be found in the Python
25557
 
    Reference Manual (:ref:`customization`).
25558
 
 
25559
 
-.. [#] As a consequence, the list ``[1, 2]`` is considered equal to ``[1.0, 2.0]``, and
25560
 
+.. [2] As a consequence, the list ``[1, 2]`` is considered equal to ``[1.0, 2.0]``, and
25561
 
    similarly for tuples.
25562
 
 
25563
 
-.. [#] They must have since the parser can't tell the type of the operands.
25564
 
-
25565
 
-.. [#] To format only a tuple you should therefore provide a singleton tuple whose only
25566
 
+.. [3] They must have since the parser can't tell the type of the operands.
25567
 
+
25568
 
+.. [4] Cased characters are those with general category property being one of
25569
 
+   "Lu" (Letter, uppercase), "Ll" (Letter, lowercase), or "Lt" (Letter, titlecase).
25570
 
+
25571
 
+.. [5] To format only a tuple you should therefore provide a singleton tuple whose only
25572
 
    element is the tuple to be formatted.
25573
 
 
25574
 
-.. [#] The advantage of leaving the newline on is that returning an empty string is
25575
 
+.. [6] The advantage of leaving the newline on is that returning an empty string is
25576
 
    then an unambiguous EOF indication.  It is also possible (in cases where it
25577
 
    might matter, for example, if you want to make an exact copy of a file while
25578
 
    scanning its lines) to tell whether the last line of a file ended in a newline
25579
 
diff -r 8527427914a2 Doc/library/string.rst
25580
 
--- a/Doc/library/string.rst
25581
 
+++ b/Doc/library/string.rst
25582
 
@@ -7,6 +7,10 @@
25583
 
 
25584
 
 .. index:: module: re
25585
 
 
25586
 
+**Source code:** :source:`Lib/string.py`
25587
 
+
25588
 
+--------------
25589
 
+
25590
 
 The :mod:`string` module contains a number of useful constants and
25591
 
 classes, as well as some deprecated legacy functions that are also
25592
 
 available as methods on strings. In addition, Python's built-in string
25593
 
@@ -17,12 +21,6 @@
25594
 
 :ref:`string-formatting` section. Also, see the :mod:`re` module for
25595
 
 string functions based on regular expressions.
25596
 
 
25597
 
-.. seealso::
25598
 
-
25599
 
-   Latest version of the `string module Python source code
25600
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/string.py?view=markup>`_
25601
 
-
25602
 
-
25603
 
 String constants
25604
 
 ----------------
25605
 
 
25606
 
@@ -245,11 +243,13 @@
25607
 
 
25608
 
 See also the :ref:`formatspec` section.
25609
 
 
25610
 
-The *field_name* itself begins with an *arg_name* that is either either a number or a
25611
 
+The *field_name* itself begins with an *arg_name* that is either a number or a
25612
 
 keyword.  If it's a number, it refers to a positional argument, and if it's a keyword,
25613
 
 it refers to a named keyword argument.  If the numerical arg_names in a format string
25614
 
 are 0, 1, 2, ... in sequence, they can all be omitted (not just some)
25615
 
 and the numbers 0, 1, 2, ... will be automatically inserted in that order.
25616
 
+Because *arg_name* is not quote-delimited, it is not possible to specify arbitrary
25617
 
+dictionary keys (e.g., the strings ``'10'`` or ``':-]'``) within a format string.
25618
 
 The *arg_name* can be followed by any number of index or
25619
 
 attribute expressions. An expression of the form ``'.name'`` selects the named
25620
 
 attribute using :func:`getattr`, while an expression of the form ``'[index]'``
25621
 
@@ -602,7 +602,7 @@
25622
 
 
25623
 
    >>> points = 19.5
25624
 
    >>> total = 22
25625
 
-   >>> 'Correct answers: {:.2%}.'.format(points/total)
25626
 
+   >>> 'Correct answers: {:.2%}'.format(points/total)
25627
 
    'Correct answers: 88.64%'
25628
 
 
25629
 
 Using type-specific formatting::
25630
 
@@ -729,9 +729,9 @@
25631
 
 to parse template strings.  To do this, you can override these class attributes:
25632
 
 
25633
 
 * *delimiter* -- This is the literal string describing a placeholder introducing
25634
 
-  delimiter.  The default value ``$``.  Note that this should *not* be a regular
25635
 
-  expression, as the implementation will call :meth:`re.escape` on this string as
25636
 
-  needed.
25637
 
+  delimiter.  The default value is ``$``.  Note that this should *not* be a
25638
 
+  regular expression, as the implementation will call :meth:`re.escape` on this
25639
 
+  string as needed.
25640
 
 
25641
 
 * *idpattern* -- This is the regular expression describing the pattern for
25642
 
   non-braced placeholders (the braces will be added automatically as
25643
 
diff -r 8527427914a2 Doc/library/stringio.rst
25644
 
--- a/Doc/library/stringio.rst
25645
 
+++ b/Doc/library/stringio.rst
25646
 
@@ -82,10 +82,7 @@
25647
 
    those cases.
25648
 
 
25649
 
    Unlike the :mod:`StringIO` module, this module is not able to accept Unicode
25650
 
-   strings that cannot be encoded as plain ASCII strings.  Calling
25651
 
-   :func:`StringIO` with a Unicode string parameter populates the object with
25652
 
-   the buffer representation of the Unicode string instead of encoding the
25653
 
-   string.
25654
 
+   strings that cannot be encoded as plain ASCII strings.
25655
 
 
25656
 
    Another difference from the :mod:`StringIO` module is that calling
25657
 
    :func:`StringIO` with a string parameter creates a read-only object. Unlike an
25658
 
diff -r 8527427914a2 Doc/library/struct.rst
25659
 
--- a/Doc/library/struct.rst
25660
 
+++ b/Doc/library/struct.rst
25661
 
@@ -22,8 +22,8 @@
25662
 
    alignment is taken into account when unpacking.  This behavior is chosen so
25663
 
    that the bytes of a packed struct correspond exactly to the layout in memory
25664
 
    of the corresponding C struct.  To handle platform-independent data formats
25665
 
-   or omit implicit pad bytes, use `standard` size and alignment instead of
25666
 
-   `native` size and alignment: see :ref:`struct-alignment` for details.
25667
 
+   or omit implicit pad bytes, use ``standard`` size and alignment instead of
25668
 
+   ``native`` size and alignment: see :ref:`struct-alignment` for details.
25669
 
 
25670
 
 Functions and Exceptions
25671
 
 ------------------------
25672
 
@@ -162,60 +162,60 @@
25673
 
 ``'='``.  When using native size, the size of the packed value is
25674
 
 platform-dependent.
25675
 
 
25676
 
-+--------+-------------------------+--------------------+----------------+------------+
25677
 
-| Format | C Type                  | Python type        | Standard size  | Notes      |
25678
 
-+========+=========================+====================+================+============+
25679
 
-| ``x``  | pad byte                | no value           |                |            |
25680
 
-+--------+-------------------------+--------------------+----------------+------------+
25681
 
-| ``c``  | :ctype:`char`           | string of length 1 | 1              |            |
25682
 
-+--------+-------------------------+--------------------+----------------+------------+
25683
 
-| ``b``  | :ctype:`signed char`    | integer            | 1              | \(3)       |
25684
 
-+--------+-------------------------+--------------------+----------------+------------+
25685
 
-| ``B``  | :ctype:`unsigned char`  | integer            | 1              | \(3)       |
25686
 
-+--------+-------------------------+--------------------+----------------+------------+
25687
 
-| ``?``  | :ctype:`_Bool`          | bool               | 1              | \(1)       |
25688
 
-+--------+-------------------------+--------------------+----------------+------------+
25689
 
-| ``h``  | :ctype:`short`          | integer            | 2              | \(3)       |
25690
 
-+--------+-------------------------+--------------------+----------------+------------+
25691
 
-| ``H``  | :ctype:`unsigned short` | integer            | 2              | \(3)       |
25692
 
-+--------+-------------------------+--------------------+----------------+------------+
25693
 
-| ``i``  | :ctype:`int`            | integer            | 4              | \(3)       |
25694
 
-+--------+-------------------------+--------------------+----------------+------------+
25695
 
-| ``I``  | :ctype:`unsigned int`   | integer            | 4              | \(3)       |
25696
 
-+--------+-------------------------+--------------------+----------------+------------+
25697
 
-| ``l``  | :ctype:`long`           | integer            | 4              | \(3)       |
25698
 
-+--------+-------------------------+--------------------+----------------+------------+
25699
 
-| ``L``  | :ctype:`unsigned long`  | integer            | 4              | \(3)       |
25700
 
-+--------+-------------------------+--------------------+----------------+------------+
25701
 
-| ``q``  | :ctype:`long long`      | integer            | 8              | \(2), \(3) |
25702
 
-+--------+-------------------------+--------------------+----------------+------------+
25703
 
-| ``Q``  | :ctype:`unsigned long   | integer            | 8              | \(2), \(3) |
25704
 
-|        | long`                   |                    |                |            |
25705
 
-+--------+-------------------------+--------------------+----------------+------------+
25706
 
-| ``f``  | :ctype:`float`          | float              | 4              | \(4)       |
25707
 
-+--------+-------------------------+--------------------+----------------+------------+
25708
 
-| ``d``  | :ctype:`double`         | float              | 8              | \(4)       |
25709
 
-+--------+-------------------------+--------------------+----------------+------------+
25710
 
-| ``s``  | :ctype:`char[]`         | string             |                |            |
25711
 
-+--------+-------------------------+--------------------+----------------+------------+
25712
 
-| ``p``  | :ctype:`char[]`         | string             |                |            |
25713
 
-+--------+-------------------------+--------------------+----------------+------------+
25714
 
-| ``P``  | :ctype:`void \*`        | integer            |                | \(5), \(3) |
25715
 
-+--------+-------------------------+--------------------+----------------+------------+
25716
 
++--------+--------------------------+--------------------+----------------+------------+
25717
 
+| Format | C Type                   | Python type        | Standard size  | Notes      |
25718
 
++========+==========================+====================+================+============+
25719
 
+| ``x``  | pad byte                 | no value           |                |            |
25720
 
++--------+--------------------------+--------------------+----------------+------------+
25721
 
+| ``c``  | :c:type:`char`           | string of length 1 | 1              |            |
25722
 
++--------+--------------------------+--------------------+----------------+------------+
25723
 
+| ``b``  | :c:type:`signed char`    | integer            | 1              | \(3)       |
25724
 
++--------+--------------------------+--------------------+----------------+------------+
25725
 
+| ``B``  | :c:type:`unsigned char`  | integer            | 1              | \(3)       |
25726
 
++--------+--------------------------+--------------------+----------------+------------+
25727
 
+| ``?``  | :c:type:`_Bool`          | bool               | 1              | \(1)       |
25728
 
++--------+--------------------------+--------------------+----------------+------------+
25729
 
+| ``h``  | :c:type:`short`          | integer            | 2              | \(3)       |
25730
 
++--------+--------------------------+--------------------+----------------+------------+
25731
 
+| ``H``  | :c:type:`unsigned short` | integer            | 2              | \(3)       |
25732
 
++--------+--------------------------+--------------------+----------------+------------+
25733
 
+| ``i``  | :c:type:`int`            | integer            | 4              | \(3)       |
25734
 
++--------+--------------------------+--------------------+----------------+------------+
25735
 
+| ``I``  | :c:type:`unsigned int`   | integer            | 4              | \(3)       |
25736
 
++--------+--------------------------+--------------------+----------------+------------+
25737
 
+| ``l``  | :c:type:`long`           | integer            | 4              | \(3)       |
25738
 
++--------+--------------------------+--------------------+----------------+------------+
25739
 
+| ``L``  | :c:type:`unsigned long`  | integer            | 4              | \(3)       |
25740
 
++--------+--------------------------+--------------------+----------------+------------+
25741
 
+| ``q``  | :c:type:`long long`      | integer            | 8              | \(2), \(3) |
25742
 
++--------+--------------------------+--------------------+----------------+------------+
25743
 
+| ``Q``  | :c:type:`unsigned long   | integer            | 8              | \(2), \(3) |
25744
 
+|        | long`                    |                    |                |            |
25745
 
++--------+--------------------------+--------------------+----------------+------------+
25746
 
+| ``f``  | :c:type:`float`          | float              | 4              | \(4)       |
25747
 
++--------+--------------------------+--------------------+----------------+------------+
25748
 
+| ``d``  | :c:type:`double`         | float              | 8              | \(4)       |
25749
 
++--------+--------------------------+--------------------+----------------+------------+
25750
 
+| ``s``  | :c:type:`char[]`         | string             |                |            |
25751
 
++--------+--------------------------+--------------------+----------------+------------+
25752
 
+| ``p``  | :c:type:`char[]`         | string             |                |            |
25753
 
++--------+--------------------------+--------------------+----------------+------------+
25754
 
+| ``P``  | :c:type:`void \*`        | integer            |                | \(5), \(3) |
25755
 
++--------+--------------------------+--------------------+----------------+------------+
25756
 
 
25757
 
 Notes:
25758
 
 
25759
 
 (1)
25760
 
-   The ``'?'`` conversion code corresponds to the :ctype:`_Bool` type defined by
25761
 
-   C99. If this type is not available, it is simulated using a :ctype:`char`. In
25762
 
+   The ``'?'`` conversion code corresponds to the :c:type:`_Bool` type defined by
25763
 
+   C99. If this type is not available, it is simulated using a :c:type:`char`. In
25764
 
    standard mode, it is always represented by one byte.
25765
 
 
25766
 
    .. versionadded:: 2.6
25767
 
 
25768
 
 (2)
25769
 
    The ``'q'`` and ``'Q'`` conversion codes are available in native mode only if
25770
 
-   the platform C compiler supports C :ctype:`long long`, or, on Windows,
25771
 
-   :ctype:`__int64`.  They are always available in standard modes.
25772
 
+   the platform C compiler supports C :c:type:`long long`, or, on Windows,
25773
 
+   :c:type:`__int64`.  They are always available in standard modes.
25774
 
 
25775
 
    .. versionadded:: 2.2
25776
 
 
25777
 
@@ -257,10 +257,11 @@
25778
 
 For the ``'s'`` format character, the count is interpreted as the size of the
25779
 
 string, not a repeat count like for the other format characters; for example,
25780
 
 ``'10s'`` means a single 10-byte string, while ``'10c'`` means 10 characters.
25781
 
-For packing, the string is truncated or padded with null bytes as appropriate to
25782
 
-make it fit. For unpacking, the resulting string always has exactly the
25783
 
-specified number of bytes.  As a special case, ``'0s'`` means a single, empty
25784
 
-string (while ``'0c'`` means 0 characters).
25785
 
+If a count is not given, it defaults to 1.  For packing, the string is
25786
 
+truncated or padded with null bytes as appropriate to make it fit. For
25787
 
+unpacking, the resulting string always has exactly the specified number of
25788
 
+bytes.  As a special case, ``'0s'`` means a single, empty string (while
25789
 
+``'0c'`` means 0 characters).
25790
 
 
25791
 
 The ``'p'`` format character encodes a "Pascal string", meaning a short
25792
 
 variable-length string stored in a *fixed number of bytes*, given by the count.
25793
 
diff -r 8527427914a2 Doc/library/subprocess.rst
25794
 
--- a/Doc/library/subprocess.rst
25795
 
+++ b/Doc/library/subprocess.rst
25796
 
@@ -31,7 +31,215 @@
25797
 
 Using the subprocess Module
25798
 
 ---------------------------
25799
 
 
25800
 
-This module defines one class called :class:`Popen`:
25801
 
+The recommended approach to invoking subprocesses is to use the following
25802
 
+convenience functions for all use cases they can handle. For more advanced
25803
 
+use cases, the underlying :class:`Popen` interface can be used directly.
25804
 
+
25805
 
+
25806
 
+.. function:: call(args, *, stdin=None, stdout=None, stderr=None, shell=False)
25807
 
+
25808
 
+   Run the command described by *args*.  Wait for command to complete, then
25809
 
+   return the :attr:`returncode` attribute.
25810
 
+
25811
 
+   The arguments shown above are merely the most common ones, described below
25812
 
+   in :ref:`frequently-used-arguments` (hence the slightly odd notation in
25813
 
+   the abbreviated signature). The full function signature is the same as
25814
 
+   that of the :class:`Popen` constructor - this functions passes all
25815
 
+   supplied arguments directly through to that interface.
25816
 
+
25817
 
+   Examples::
25818
 
+
25819
 
+      >>> subprocess.call(["ls", "-l"])
25820
 
+      0
25821
 
+
25822
 
+      >>> subprocess.call("exit 1", shell=True)
25823
 
+      1
25824
 
+
25825
 
+   .. warning::
25826
 
+
25827
 
+      Invoking the system shell with ``shell=True`` can be a security hazard
25828
 
+      if combined with untrusted input. See the warning under
25829
 
+      :ref:`frequently-used-arguments` for details.
25830
 
+
25831
 
+   .. note::
25832
 
+
25833
 
+      Do not use ``stdout=PIPE`` or ``stderr=PIPE`` with this function. As
25834
 
+      the pipes are not being read in the current process, the child
25835
 
+      process may block if it generates enough output to a pipe to fill up
25836
 
+      the OS pipe buffer.
25837
 
+
25838
 
+
25839
 
+.. function:: check_call(args, *, stdin=None, stdout=None, stderr=None, shell=False)
25840
 
+
25841
 
+   Run command with arguments.  Wait for command to complete. If the return
25842
 
+   code was zero then return, otherwise raise :exc:`CalledProcessError`. The
25843
 
+   :exc:`CalledProcessError` object will have the return code in the
25844
 
+   :attr:`returncode` attribute.
25845
 
+
25846
 
+   The arguments shown above are merely the most common ones, described below
25847
 
+   in :ref:`frequently-used-arguments` (hence the slightly odd notation in
25848
 
+   the abbreviated signature). The full function signature is the same as
25849
 
+   that of the :class:`Popen` constructor - this functions passes all
25850
 
+   supplied arguments directly through to that interface.
25851
 
+
25852
 
+   Examples::
25853
 
+
25854
 
+      >>> subprocess.check_call(["ls", "-l"])
25855
 
+      0
25856
 
+
25857
 
+      >>> subprocess.check_call("exit 1", shell=True)
25858
 
+      Traceback (most recent call last):
25859
 
+         ...
25860
 
+      subprocess.CalledProcessError: Command 'exit 1' returned non-zero exit status 1
25861
 
+
25862
 
+   .. versionadded:: 2.5
25863
 
+
25864
 
+   .. warning::
25865
 
+
25866
 
+      Invoking the system shell with ``shell=True`` can be a security hazard
25867
 
+      if combined with untrusted input. See the warning under
25868
 
+      :ref:`frequently-used-arguments` for details.
25869
 
+
25870
 
+   .. note::
25871
 
+
25872
 
+      Do not use ``stdout=PIPE`` or ``stderr=PIPE`` with this function. As
25873
 
+      the pipes are not being read in the current process, the child
25874
 
+      process may block if it generates enough output to a pipe to fill up
25875
 
+      the OS pipe buffer.
25876
 
+
25877
 
+
25878
 
+.. function:: check_output(args, *, stdin=None, stderr=None, shell=False, universal_newlines=False)
25879
 
+
25880
 
+   Run command with arguments and return its output as a byte string.
25881
 
+
25882
 
+   If the return code was non-zero it raises a :exc:`CalledProcessError`. The
25883
 
+   :exc:`CalledProcessError` object will have the return code in the
25884
 
+   :attr:`returncode` attribute and any output in the :attr:`output`
25885
 
+   attribute.
25886
 
+
25887
 
+   The arguments shown above are merely the most common ones, described below
25888
 
+   in :ref:`frequently-used-arguments` (hence the slightly odd notation in
25889
 
+   the abbreviated signature). The full function signature is largely the
25890
 
+   same as that of the :class:`Popen` constructor, except that *stdout* is
25891
 
+   not permitted as it is used internally. All other supplied arguments are
25892
 
+   passed directly through to the :class:`Popen` constructor.
25893
 
+
25894
 
+   Examples::
25895
 
+
25896
 
+      >>> subprocess.check_output(["echo", "Hello World!"])
25897
 
+      'Hello World!\n'
25898
 
+
25899
 
+      >>> subprocess.check_output("exit 1", shell=True)
25900
 
+      Traceback (most recent call last):
25901
 
+         ...
25902
 
+      subprocess.CalledProcessError: Command 'exit 1' returned non-zero exit status 1
25903
 
+
25904
 
+   To also capture standard error in the result, use
25905
 
+   ``stderr=subprocess.STDOUT``::
25906
 
+
25907
 
+      >>> subprocess.check_output(
25908
 
+      ...     "ls non_existent_file; exit 0",
25909
 
+      ...     stderr=subprocess.STDOUT,
25910
 
+      ...     shell=True)
25911
 
+      'ls: non_existent_file: No such file or directory\n'
25912
 
+
25913
 
+   .. versionadded:: 2.7
25914
 
+
25915
 
+   .. warning::
25916
 
+
25917
 
+      Invoking the system shell with ``shell=True`` can be a security hazard
25918
 
+      if combined with untrusted input. See the warning under
25919
 
+      :ref:`frequently-used-arguments` for details.
25920
 
+
25921
 
+   .. note::
25922
 
+
25923
 
+      Do not use ``stderr=PIPE`` with this function. As the pipe is not being
25924
 
+      read in the current process, the child process may block if it
25925
 
+      generates enough output to the pipe to fill up the OS pipe buffer.
25926
 
+
25927
 
+
25928
 
+.. data:: PIPE
25929
 
+
25930
 
+   Special value that can be used as the *stdin*, *stdout* or *stderr* argument
25931
 
+   to :class:`Popen` and indicates that a pipe to the standard stream should be
25932
 
+   opened.
25933
 
+
25934
 
+
25935
 
+.. data:: STDOUT
25936
 
+
25937
 
+   Special value that can be used as the *stderr* argument to :class:`Popen` and
25938
 
+   indicates that standard error should go into the same handle as standard
25939
 
+   output.
25940
 
+
25941
 
+
25942
 
+.. _frequently-used-arguments:
25943
 
+
25944
 
+Frequently Used Arguments
25945
 
+^^^^^^^^^^^^^^^^^^^^^^^^^
25946
 
+
25947
 
+To support a wide variety of use cases, the :class:`Popen` constructor (and
25948
 
+the convenience functions) accept a large number of optional arguments. For
25949
 
+most typical use cases, many of these arguments can be safely left at their
25950
 
+default values. The arguments that are most commonly needed are:
25951
 
+
25952
 
+   *args* is required for all calls and should be a string, or a sequence of
25953
 
+   program arguments. Providing a sequence of arguments is generally
25954
 
+   preferred, as it allows the module to take care of any required escaping
25955
 
+   and quoting of arguments (e.g. to permit spaces in file names). If passing
25956
 
+   a single string, either *shell* must be :const:`True` (see below) or else
25957
 
+   the string must simply name the program to be executed without specifying
25958
 
+   any arguments.
25959
 
+
25960
 
+   *stdin*, *stdout* and *stderr* specify the executed program's standard input,
25961
 
+   standard output and standard error file handles, respectively.  Valid values
25962
 
+   are :data:`PIPE`, an existing file descriptor (a positive integer), an
25963
 
+   existing file object, and ``None``.  :data:`PIPE` indicates that a new pipe
25964
 
+   to the child should be created.  With the default settings of ``None``, no
25965
 
+   redirection will occur; the child's file handles will be inherited from the
25966
 
+   parent.  Additionally, *stderr* can be :data:`STDOUT`, which indicates that
25967
 
+   the stderr data from the child process should be captured into the same file
25968
 
+   handle as for stdout.
25969
 
+
25970
 
+   When *stdout* or *stderr* are pipes and *universal_newlines* is
25971
 
+   :const:`True` then all line endings will be converted to ``'\n'`` as
25972
 
+   described for the universal newlines `'U'`` mode argument to :func:`open`.
25973
 
+
25974
 
+   If *shell* is :const:`True`, the specified command will be executed through
25975
 
+   the shell. This can be useful if you are using Python primarily for the
25976
 
+   enhanced control flow it offers over most system shells and still want
25977
 
+   access to other shell features such as filename wildcards, shell pipes and
25978
 
+   environment variable expansion.
25979
 
+
25980
 
+   .. warning::
25981
 
+
25982
 
+      Executing shell commands that incorporate unsanitized input from an
25983
 
+      untrusted source makes a program vulnerable to `shell injection
25984
 
+      <http://en.wikipedia.org/wiki/Shell_injection#Shell_injection>`_,
25985
 
+      a serious security flaw which can result in arbitrary command execution.
25986
 
+      For this reason, the use of *shell=True* is **strongly discouraged** in cases
25987
 
+      where the command string is constructed from external input::
25988
 
+
25989
 
+         >>> from subprocess import call
25990
 
+         >>> filename = input("What file would you like to display?\n")
25991
 
+         What file would you like to display?
25992
 
+         non_existent; rm -rf / #
25993
 
+         >>> call("cat " + filename, shell=True) # Uh-oh. This will end badly...
25994
 
+
25995
 
+      ``shell=False`` disables all shell based features, but does not suffer
25996
 
+      from this vulnerability; see the Note in the :class:`Popen` constructor
25997
 
+      documentation for helpful hints in getting ``shell=False`` to work.
25998
 
+
25999
 
+These options, along with all of the other options, are described in more
26000
 
+detail in the :class:`Popen` constructor documentation.
26001
 
+
26002
 
+
26003
 
+Popen Constructor
26004
 
+^^^^^^^^^^^^^^^^^
26005
 
+
26006
 
+The underlying process creation and management in this module is handled by
26007
 
+the :class:`Popen` class. It offers a lot of flexibility so that developers
26008
 
+are able to handle the less common cases not covered by the convenience
26009
 
+functions.
26010
 
 
26011
 
 
26012
 
 .. class:: Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0)
26013
 
@@ -81,24 +289,6 @@
26014
 
 
26015
 
       Popen(['/bin/sh', '-c', args[0], args[1], ...])
26016
 
 
26017
 
-   .. warning::
26018
 
-
26019
 
-      Executing shell commands that incorporate unsanitized input from an
26020
 
-      untrusted source makes a program vulnerable to `shell injection
26021
 
-      <http://en.wikipedia.org/wiki/Shell_injection#Shell_injection>`_,
26022
 
-      a serious security flaw which can result in arbitrary command execution.
26023
 
-      For this reason, the use of *shell=True* is **strongly discouraged** in cases
26024
 
-      where the command string is constructed from external input::
26025
 
-
26026
 
-         >>> from subprocess import call
26027
 
-         >>> filename = input("What file would you like to display?\n")
26028
 
-         What file would you like to display?
26029
 
-         non_existent; rm -rf / #
26030
 
-         >>> call("cat " + filename, shell=True) # Uh-oh. This will end badly...
26031
 
-
26032
 
-      *shell=False* does not suffer from this vulnerability; the above Note may be
26033
 
-      helpful in getting code using *shell=False* to work.
26034
 
-
26035
 
    On Windows: the :class:`Popen` class uses CreateProcess() to execute the child
26036
 
    child program, which operates on strings.  If *args* is a sequence, it will
26037
 
    be converted to a string in a manner described in
26038
 
@@ -126,14 +316,15 @@
26039
 
    You don't need ``shell=True`` to run a batch file, nor to run a console-based
26040
 
    executable.
26041
 
 
26042
 
-   *stdin*, *stdout* and *stderr* specify the executed programs' standard input,
26043
 
+   *stdin*, *stdout* and *stderr* specify the executed program's standard input,
26044
 
    standard output and standard error file handles, respectively.  Valid values
26045
 
    are :data:`PIPE`, an existing file descriptor (a positive integer), an
26046
 
    existing file object, and ``None``.  :data:`PIPE` indicates that a new pipe
26047
 
-   to the child should be created.  With ``None``, no redirection will occur;
26048
 
-   the child's file handles will be inherited from the parent.  Additionally,
26049
 
-   *stderr* can be :data:`STDOUT`, which indicates that the stderr data from the
26050
 
-   applications should be captured into the same file handle as for stdout.
26051
 
+   to the child should be created.  With the default settings of ``None``, no
26052
 
+   redirection will occur; the child's file handles will be inherited from the
26053
 
+   parent.  Additionally, *stderr* can be :data:`STDOUT`, which indicates that
26054
 
+   the stderr data from the child process should be captured into the same file
26055
 
+   handle as for stdout.
26056
 
 
26057
 
    If *preexec_fn* is set to a callable object, this object will be called in the
26058
 
    child process just before the child is executed. (Unix only)
26059
 
@@ -147,6 +338,12 @@
26060
 
    If *shell* is :const:`True`, the specified command will be executed through the
26061
 
    shell.
26062
 
 
26063
 
+   .. warning::
26064
 
+
26065
 
+      Enabling this option can be a security hazard if combined with untrusted
26066
 
+      input. See the warning under :ref:`frequently-used-arguments`
26067
 
+      for details.
26068
 
+
26069
 
    If *cwd* is not ``None``, the child's current directory will be changed to *cwd*
26070
 
    before it is executed.  Note that this directory is not considered when
26071
 
    searching the executable, so you can't specify the program's path relative to
26072
 
@@ -184,87 +381,6 @@
26073
 
    :data:`CREATE_NEW_PROCESS_GROUP`. (Windows only)
26074
 
 
26075
 
 
26076
 
-.. data:: PIPE
26077
 
-
26078
 
-   Special value that can be used as the *stdin*, *stdout* or *stderr* argument
26079
 
-   to :class:`Popen` and indicates that a pipe to the standard stream should be
26080
 
-   opened.
26081
 
-
26082
 
-
26083
 
-.. data:: STDOUT
26084
 
-
26085
 
-   Special value that can be used as the *stderr* argument to :class:`Popen` and
26086
 
-   indicates that standard error should go into the same handle as standard
26087
 
-   output.
26088
 
-
26089
 
-
26090
 
-Convenience Functions
26091
 
-^^^^^^^^^^^^^^^^^^^^^
26092
 
-
26093
 
-This module also defines the following shortcut functions:
26094
 
-
26095
 
-
26096
 
-.. function:: call(*popenargs, **kwargs)
26097
 
-
26098
 
-   Run command with arguments.  Wait for command to complete, then return the
26099
 
-   :attr:`returncode` attribute.
26100
 
-
26101
 
-   The arguments are the same as for the :class:`Popen` constructor.  Example::
26102
 
-
26103
 
-      >>> retcode = subprocess.call(["ls", "-l"])
26104
 
-
26105
 
-   .. warning::
26106
 
-
26107
 
-      Like :meth:`Popen.wait`, this will deadlock when using
26108
 
-      ``stdout=PIPE`` and/or ``stderr=PIPE`` and the child process
26109
 
-      generates enough output to a pipe such that it blocks waiting
26110
 
-      for the OS pipe buffer to accept more data.
26111
 
-
26112
 
-
26113
 
-.. function:: check_call(*popenargs, **kwargs)
26114
 
-
26115
 
-   Run command with arguments.  Wait for command to complete. If the exit code was
26116
 
-   zero then return, otherwise raise :exc:`CalledProcessError`. The
26117
 
-   :exc:`CalledProcessError` object will have the return code in the
26118
 
-   :attr:`returncode` attribute.
26119
 
-
26120
 
-   The arguments are the same as for the :class:`Popen` constructor.  Example::
26121
 
-
26122
 
-      >>> subprocess.check_call(["ls", "-l"])
26123
 
-      0
26124
 
-
26125
 
-   .. versionadded:: 2.5
26126
 
-
26127
 
-   .. warning::
26128
 
-
26129
 
-      See the warning for :func:`call`.
26130
 
-
26131
 
-
26132
 
-.. function:: check_output(*popenargs, **kwargs)
26133
 
-
26134
 
-   Run command with arguments and return its output as a byte string.
26135
 
-
26136
 
-   If the exit code was non-zero it raises a :exc:`CalledProcessError`.  The
26137
 
-   :exc:`CalledProcessError` object will have the return code in the
26138
 
-   :attr:`returncode`
26139
 
-   attribute and output in the :attr:`output` attribute.
26140
 
-
26141
 
-   The arguments are the same as for the :class:`Popen` constructor.  Example::
26142
 
-
26143
 
-      >>> subprocess.check_output(["ls", "-l", "/dev/null"])
26144
 
-      'crw-rw-rw- 1 root root 1, 3 Oct 18  2007 /dev/null\n'
26145
 
-
26146
 
-   The stdout argument is not allowed as it is used internally.
26147
 
-   To capture standard error in the result, use ``stderr=subprocess.STDOUT``::
26148
 
-
26149
 
-      >>> subprocess.check_output(
26150
 
-      ...     ["/bin/sh", "-c", "ls non_existent_file; exit 0"],
26151
 
-      ...     stderr=subprocess.STDOUT)
26152
 
-      'ls: non_existent_file: No such file or directory\n'
26153
 
-
26154
 
-   .. versionadded:: 2.7
26155
 
-
26156
 
-
26157
 
 Exceptions
26158
 
 ^^^^^^^^^^
26159
 
 
26160
 
@@ -280,16 +396,19 @@
26161
 
 A :exc:`ValueError` will be raised if :class:`Popen` is called with invalid
26162
 
 arguments.
26163
 
 
26164
 
-check_call() will raise :exc:`CalledProcessError`, if the called process returns
26165
 
-a non-zero return code.
26166
 
+:func:`check_call` and :func:`check_output` will raise
26167
 
+:exc:`CalledProcessError` if the called process returns a non-zero return
26168
 
+code.
26169
 
 
26170
 
 
26171
 
 Security
26172
 
 ^^^^^^^^
26173
 
 
26174
 
-Unlike some other popen functions, this implementation will never call /bin/sh
26175
 
-implicitly.  This means that all characters, including shell metacharacters, can
26176
 
-safely be passed to child processes.
26177
 
+Unlike some other popen functions, this implementation will never call a
26178
 
+system shell implicitly.  This means that all characters, including shell
26179
 
+metacharacters, can safely be passed to child processes. Obviously, if the
26180
 
+shell is invoked explicitly, then it is the application's responsibility to
26181
 
+ensure that all whitespace and metacharacters are quoted appropriately.
26182
 
 
26183
 
 
26184
 
 Popen Objects
26185
 
@@ -353,7 +472,7 @@
26186
 
 .. method:: Popen.terminate()
26187
 
 
26188
 
    Stop the child. On Posix OSs the method sends SIGTERM to the
26189
 
-   child. On Windows the Win32 API function :cfunc:`TerminateProcess` is called
26190
 
+   child. On Windows the Win32 API function :c:func:`TerminateProcess` is called
26191
 
    to stop the child.
26192
 
 
26193
 
    .. versionadded:: 2.6
26194
 
@@ -428,38 +547,39 @@
26195
 
 
26196
 
    .. attribute:: dwFlags
26197
 
 
26198
 
-      A bit field that determines whether certain :class:`STARTUPINFO` members
26199
 
-      are used when the process creates a window. ::
26200
 
+      A bit field that determines whether certain :class:`STARTUPINFO`
26201
 
+      attributes are used when the process creates a window. ::
26202
 
 
26203
 
          si = subprocess.STARTUPINFO()
26204
 
          si.dwFlags = subprocess.STARTF_USESTDHANDLES | subprocess.STARTF_USESHOWWINDOW
26205
 
 
26206
 
    .. attribute:: hStdInput
26207
 
 
26208
 
-      If :attr:`dwFlags` specifies :data:`STARTF_USESTDHANDLES`, this member is
26209
 
-      the standard input handle for the process. If :data:`STARTF_USESTDHANDLES`
26210
 
-      is not specified, the default for standard input is the keyboard buffer.
26211
 
+      If :attr:`dwFlags` specifies :data:`STARTF_USESTDHANDLES`, this attribute
26212
 
+      is the standard input handle for the process. If
26213
 
+      :data:`STARTF_USESTDHANDLES` is not specified, the default for standard
26214
 
+      input is the keyboard buffer.
26215
 
 
26216
 
    .. attribute:: hStdOutput
26217
 
 
26218
 
-      If :attr:`dwFlags` specifies :data:`STARTF_USESTDHANDLES`, this member is
26219
 
-      the standard output handle for the process. Otherwise, this member is
26220
 
-      ignored and the default for standard output is the console window's
26221
 
+      If :attr:`dwFlags` specifies :data:`STARTF_USESTDHANDLES`, this attribute
26222
 
+      is the standard output handle for the process. Otherwise, this attribute
26223
 
+      is ignored and the default for standard output is the console window's
26224
 
       buffer.
26225
 
 
26226
 
    .. attribute:: hStdError
26227
 
 
26228
 
-      If :attr:`dwFlags` specifies :data:`STARTF_USESTDHANDLES`, this member is
26229
 
-      the standard error handle for the process. Otherwise, this member is
26230
 
+      If :attr:`dwFlags` specifies :data:`STARTF_USESTDHANDLES`, this attribute
26231
 
+      is the standard error handle for the process. Otherwise, this attribute is
26232
 
       ignored and the default for standard error is the console window's buffer.
26233
 
 
26234
 
    .. attribute:: wShowWindow
26235
 
 
26236
 
-      If :attr:`dwFlags` specifies :data:`STARTF_USESHOWWINDOW`, this member
26237
 
+      If :attr:`dwFlags` specifies :data:`STARTF_USESHOWWINDOW`, this attribute
26238
 
       can be any of the values that can be specified in the ``nCmdShow``
26239
 
       parameter for the
26240
 
       `ShowWindow <http://msdn.microsoft.com/en-us/library/ms633548(v=vs.85).aspx>`__
26241
 
-      function, except for ``SW_SHOWDEFAULT``. Otherwise, this member is
26242
 
+      function, except for ``SW_SHOWDEFAULT``. Otherwise, this attribute is
26243
 
       ignored.
26244
 
 
26245
 
       :data:`SW_HIDE` is provided for this attribute. It is used when
26246
 
@@ -493,12 +613,12 @@
26247
 
 .. data:: STARTF_USESTDHANDLES
26248
 
 
26249
 
    Specifies that the :attr:`STARTUPINFO.hStdInput`,
26250
 
-   :attr:`STARTUPINFO.hStdOutput`, and :attr:`STARTUPINFO.hStdError` members
26251
 
+   :attr:`STARTUPINFO.hStdOutput`, and :attr:`STARTUPINFO.hStdError` attributes
26252
 
    contain additional information.
26253
 
 
26254
 
 .. data:: STARTF_USESHOWWINDOW
26255
 
 
26256
 
-   Specifies that the :attr:`STARTUPINFO.wShowWindow` member contains
26257
 
+   Specifies that the :attr:`STARTUPINFO.wShowWindow` attribute contains
26258
 
    additional information.
26259
 
 
26260
 
 .. data:: CREATE_NEW_CONSOLE
26261
 
@@ -522,15 +642,21 @@
26262
 
 Replacing Older Functions with the subprocess Module
26263
 
 ----------------------------------------------------
26264
 
 
26265
 
-In this section, "a ==> b" means that b can be used as a replacement for a.
26266
 
+In this section, "a becomes b" means that b can be used as a replacement for a.
26267
 
 
26268
 
 .. note::
26269
 
 
26270
 
-   All functions in this section fail (more or less) silently if the executed
26271
 
-   program cannot be found; this module raises an :exc:`OSError` exception.
26272
 
+   All "a" functions in this section fail (more or less) silently if the
26273
 
+   executed program cannot be found; the "b" replacements raise :exc:`OSError`
26274
 
+   instead.
26275
 
 
26276
 
-In the following examples, we assume that the subprocess module is imported with
26277
 
-"from subprocess import \*".
26278
 
+   In addition, the replacements using :func:`check_output` will fail with a
26279
 
+   :exc:`CalledProcessError` if the requested operation produces a non-zero
26280
 
+   return code. The output is still available as the ``output`` attribute of
26281
 
+   the raised exception.
26282
 
+
26283
 
+In the following examples, we assume that the relevant functions have already
26284
 
+been imported from the subprocess module.
26285
 
 
26286
 
 
26287
 
 Replacing /bin/sh shell backquote
26288
 
@@ -539,8 +665,8 @@
26289
 
 ::
26290
 
 
26291
 
    output=`mycmd myarg`
26292
 
-   ==>
26293
 
-   output = Popen(["mycmd", "myarg"], stdout=PIPE).communicate()[0]
26294
 
+   # becomes
26295
 
+   output = check_output(["mycmd", "myarg"])
26296
 
 
26297
 
 
26298
 
 Replacing shell pipeline
26299
 
@@ -549,7 +675,7 @@
26300
 
 ::
26301
 
 
26302
 
    output=`dmesg | grep hda`
26303
 
-   ==>
26304
 
+   # becomes
26305
 
    p1 = Popen(["dmesg"], stdout=PIPE)
26306
 
    p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE)
26307
 
    p1.stdout.close()  # Allow p1 to receive a SIGPIPE if p2 exits.
26308
 
@@ -558,22 +684,27 @@
26309
 
 The p1.stdout.close() call after starting the p2 is important in order for p1
26310
 
 to receive a SIGPIPE if p2 exits before p1.
26311
 
 
26312
 
+Alternatively, for trusted input, the shell's own pipeline support may still
26313
 
+be used directly:
26314
 
+
26315
 
+   output=`dmesg | grep hda`
26316
 
+   # becomes
26317
 
+   output=check_output("dmesg | grep hda", shell=True)
26318
 
+
26319
 
+
26320
 
 Replacing :func:`os.system`
26321
 
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
26322
 
 
26323
 
 ::
26324
 
 
26325
 
    sts = os.system("mycmd" + " myarg")
26326
 
-   ==>
26327
 
-   p = Popen("mycmd" + " myarg", shell=True)
26328
 
-   sts = os.waitpid(p.pid, 0)[1]
26329
 
+   # becomes
26330
 
+   sts = call("mycmd" + " myarg", shell=True)
26331
 
 
26332
 
 Notes:
26333
 
 
26334
 
 * Calling the program through the shell is usually not required.
26335
 
 
26336
 
-* It's easier to look at the :attr:`returncode` attribute than the exit status.
26337
 
-
26338
 
 A more realistic example would look like this::
26339
 
 
26340
 
    try:
26341
 
@@ -718,6 +849,7 @@
26342
 
 * popen2 closes all file descriptors by default, but you have to specify
26343
 
   ``close_fds=True`` with :class:`Popen`.
26344
 
 
26345
 
+
26346
 
 Notes
26347
 
 -----
26348
 
 
26349
 
diff -r 8527427914a2 Doc/library/sunau.rst
26350
 
--- a/Doc/library/sunau.rst
26351
 
+++ b/Doc/library/sunau.rst
26352
 
@@ -1,4 +1,3 @@
26353
 
-
26354
 
 :mod:`sunau` --- Read and write Sun AU files
26355
 
 ============================================
26356
 
 
26357
 
@@ -6,6 +5,9 @@
26358
 
    :synopsis: Provide an interface to the Sun AU sound format.
26359
 
 .. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
26360
 
 
26361
 
+**Source code:** :source:`Lib/sunau.py`
26362
 
+
26363
 
+--------------
26364
 
 
26365
 
 The :mod:`sunau` module provides a convenient interface to the Sun AU sound
26366
 
 format.  Note that this module is interface-compatible with the modules
26367
 
diff -r 8527427914a2 Doc/library/sunaudio.rst
26368
 
--- a/Doc/library/sunaudio.rst
26369
 
+++ b/Doc/library/sunaudio.rst
26370
 
@@ -93,10 +93,10 @@
26371
 
    names and meanings of the attributes are described in ``<sun/audioio.h>`` and in
26372
 
    the :manpage:`audio(7I)` manual page.  Member names are slightly different from
26373
 
    their C counterparts: a status object is only a single structure. Members of the
26374
 
-   :cdata:`play` substructure have ``o_`` prepended to their name and members of
26375
 
-   the :cdata:`record` structure have ``i_``. So, the C member
26376
 
-   :cdata:`play.sample_rate` is accessed as :attr:`o_sample_rate`,
26377
 
-   :cdata:`record.gain` as :attr:`i_gain` and :cdata:`monitor_gain` plainly as
26378
 
+   :c:data:`play` substructure have ``o_`` prepended to their name and members of
26379
 
+   the :c:data:`record` structure have ``i_``. So, the C member
26380
 
+   :c:data:`play.sample_rate` is accessed as :attr:`o_sample_rate`,
26381
 
+   :c:data:`record.gain` as :attr:`i_gain` and :c:data:`monitor_gain` plainly as
26382
 
    :attr:`monitor_gain`.
26383
 
 
26384
 
 
26385
 
diff -r 8527427914a2 Doc/library/symbol.rst
26386
 
--- a/Doc/library/symbol.rst
26387
 
+++ b/Doc/library/symbol.rst
26388
 
@@ -1,4 +1,3 @@
26389
 
-
26390
 
 :mod:`symbol` --- Constants used with Python parse trees
26391
 
 ========================================================
26392
 
 
26393
 
@@ -6,6 +5,9 @@
26394
 
    :synopsis: Constants representing internal nodes of the parse tree.
26395
 
 .. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
26396
 
 
26397
 
+**Source code:** :source:`Lib/symbol.py`
26398
 
+
26399
 
+--------------
26400
 
 
26401
 
 This module provides constants which represent the numeric values of internal
26402
 
 nodes of the parse tree.  Unlike most Python constants, these use lower-case
26403
 
@@ -23,10 +25,3 @@
26404
 
    back to name strings, allowing more human-readable representation of parse trees
26405
 
    to be generated.
26406
 
 
26407
 
-
26408
 
-.. seealso::
26409
 
-
26410
 
-   Module :mod:`parser`
26411
 
-      The second example for the :mod:`parser` module shows how to use the
26412
 
-      :mod:`symbol` module.
26413
 
-
26414
 
diff -r 8527427914a2 Doc/library/sys.rst
26415
 
--- a/Doc/library/sys.rst
26416
 
+++ b/Doc/library/sys.rst
26417
 
@@ -32,20 +32,6 @@
26418
 
    .. versionadded:: 2.0
26419
 
 
26420
 
 
26421
 
-.. data:: subversion
26422
 
-
26423
 
-   A triple (repo, branch, version) representing the Subversion information of the
26424
 
-   Python interpreter. *repo* is the name of the repository, ``'CPython'``.
26425
 
-   *branch* is a string of one of the forms ``'trunk'``, ``'branches/name'`` or
26426
 
-   ``'tags/name'``. *version* is the output of ``svnversion``, if the interpreter
26427
 
-   was built from a Subversion checkout; it contains the revision number (range)
26428
 
-   and possibly a trailing 'M' if there were local modifications. If the tree was
26429
 
-   exported (or svnversion was not available), it is the revision of
26430
 
-   ``Include/patchlevel.h`` if the branch is a tag. Otherwise, it is ``None``.
26431
 
-
26432
 
-   .. versionadded:: 2.5
26433
 
-
26434
 
-
26435
 
 .. data:: builtin_module_names
26436
 
 
26437
 
    A tuple of strings giving the names of all modules that are compiled into this
26438
 
@@ -109,6 +95,17 @@
26439
 
    customized by assigning another one-argument function to ``sys.displayhook``.
26440
 
 
26441
 
 
26442
 
+.. data:: dont_write_bytecode
26443
 
+
26444
 
+   If this is true, Python won't try to write ``.pyc`` or ``.pyo`` files on the
26445
 
+   import of source modules.  This value is initially set to ``True`` or
26446
 
+   ``False`` depending on the :option:`-B` command line option and the
26447
 
+   :envvar:`PYTHONDONTWRITEBYTECODE` environment variable, but you can set it
26448
 
+   yourself to control bytecode file generation.
26449
 
+
26450
 
+   .. versionadded:: 2.6
26451
 
+
26452
 
+
26453
 
 .. function:: excepthook(type, value, traceback)
26454
 
 
26455
 
    This function prints out a given traceback and exception to ``sys.stderr``.
26456
 
@@ -210,16 +207,18 @@
26457
 
    Python files are installed; by default, this is also ``'/usr/local'``.  This can
26458
 
    be set at build time with the ``--exec-prefix`` argument to the
26459
 
    :program:`configure` script.  Specifically, all configuration files (e.g. the
26460
 
-   :file:`pyconfig.h` header file) are installed in the directory ``exec_prefix +
26461
 
-   '/lib/pythonversion/config'``, and shared library modules are installed in
26462
 
-   ``exec_prefix + '/lib/pythonversion/lib-dynload'``, where *version* is equal to
26463
 
-   ``version[:3]``.
26464
 
+   :file:`pyconfig.h` header file) are installed in the directory
26465
 
+   :file:`{exec_prefix}/lib/python{X.Y}/config', and shared library modules are
26466
 
+   installed in :file:`{exec_prefix}/lib/python{X.Y}/lib-dynload`, where *X.Y*
26467
 
+   is the version number of Python, for example ``2.7``.
26468
 
 
26469
 
 
26470
 
 .. data:: executable
26471
 
 
26472
 
-   A string giving the name of the executable binary for the Python interpreter, on
26473
 
-   systems where this makes sense.
26474
 
+   A string giving the absolute path of the executable binary for the Python
26475
 
+   interpreter, on systems where this makes sense. If Python is unable to retrieve
26476
 
+   the real path to its executable, :data:`sys.executable` will be an empty string
26477
 
+   or ``None``.
26478
 
 
26479
 
 
26480
 
 .. function:: exit([arg])
26481
 
@@ -331,8 +330,12 @@
26482
 
    +---------------------+----------------+--------------------------------------------------+
26483
 
    | :const:`radix`      | FLT_RADIX      | radix of exponent representation                 |
26484
 
    +---------------------+----------------+--------------------------------------------------+
26485
 
-   | :const:`rounds`     | FLT_ROUNDS     | constant representing rounding mode              |
26486
 
-   |                     |                | used for arithmetic operations                   |
26487
 
+   | :const:`rounds`     | FLT_ROUNDS     | integer constant representing the rounding mode  |
26488
 
+   |                     |                | used for arithmetic operations.  This reflects   |
26489
 
+   |                     |                | the value of the system FLT_ROUNDS macro at      |
26490
 
+   |                     |                | interpreter startup time.  See section 5.2.4.2.2 |
26491
 
+   |                     |                | of the C99 standard for an explanation of the    |
26492
 
+   |                     |                | possible values and their meanings.              |
26493
 
    +---------------------+----------------+--------------------------------------------------+
26494
 
 
26495
 
    The attribute :attr:`sys.float_info.dig` needs further explanation.  If
26496
 
@@ -387,7 +390,7 @@
26497
 
 
26498
 
 .. function:: getdlopenflags()
26499
 
 
26500
 
-   Return the current value of the flags that are used for :cfunc:`dlopen` calls.
26501
 
+   Return the current value of the flags that are used for :c:func:`dlopen` calls.
26502
 
    The flag constants are defined in the :mod:`dl` and :mod:`DLFCN` modules.
26503
 
    Availability: Unix.
26504
 
 
26505
 
@@ -532,8 +535,8 @@
26506
 
    +---------------------------------------+---------------------------------+
26507
 
 
26508
 
 
26509
 
-   This function wraps the Win32 :cfunc:`GetVersionEx` function; see the
26510
 
-   Microsoft documentation on :cfunc:`OSVERSIONINFOEX` for more information
26511
 
+   This function wraps the Win32 :c:func:`GetVersionEx` function; see the
26512
 
+   Microsoft documentation on :c:func:`OSVERSIONINFOEX` for more information
26513
 
    about these fields.
26514
 
 
26515
 
    Availability: Windows.
26516
 
@@ -652,7 +655,7 @@
26517
 
     imported. The :meth:`find_module` method is called at least with the
26518
 
     absolute name of the module being imported. If the module to be imported is
26519
 
     contained in package then the parent package's :attr:`__path__` attribute
26520
 
-    is passed in as a second argument. The method returns :keyword:`None` if
26521
 
+    is passed in as a second argument. The method returns ``None`` if
26522
 
     the module cannot be found, else returns a :term:`loader`.
26523
 
 
26524
 
     :data:`sys.meta_path` is searched before any implicit default finders or
26525
 
@@ -711,7 +714,7 @@
26526
 
     A dictionary acting as a cache for :term:`finder` objects. The keys are
26527
 
     paths that have been passed to :data:`sys.path_hooks` and the values are
26528
 
     the finders that are found. If a path is a valid file system path but no
26529
 
-    explicit finder is found on :data:`sys.path_hooks` then :keyword:`None` is
26530
 
+    explicit finder is found on :data:`sys.path_hooks` then ``None`` is
26531
 
     stored to represent the implicit default finder should be used. If the path
26532
 
     is not an existing path then :class:`imp.NullImporter` is set.
26533
 
 
26534
 
@@ -723,23 +726,45 @@
26535
 
    This string contains a platform identifier that can be used to append
26536
 
    platform-specific components to :data:`sys.path`, for instance.
26537
 
 
26538
 
-   For Unix systems, this is the lowercased OS name as returned by ``uname -s``
26539
 
-   with the first part of the version as returned by ``uname -r`` appended,
26540
 
-   e.g. ``'sunos5'`` or ``'linux2'``, *at the time when Python was built*.
26541
 
+   For most Unix systems, this is the lowercased OS name as returned by ``uname
26542
 
+   -s`` with the first part of the version as returned by ``uname -r`` appended,
26543
 
+   e.g. ``'sunos5'``, *at the time when Python was built*.  Unless you want to
26544
 
+   test for a specific system version, it is therefore recommended to use the
26545
 
+   following idiom::
26546
 
+
26547
 
+      if sys.platform.startswith('freebsd'):
26548
 
+          # FreeBSD-specific code here...
26549
 
+      elif sys.platform.startswith('linux'):
26550
 
+          # Linux-specific code here...
26551
 
+
26552
 
+   .. versionchanged:: 2.7.3
26553
 
+      Since lots of code check for ``sys.platform == 'linux2'``, and there is
26554
 
+      no essential change between Linux 2.x and 3.x, ``sys.platform`` is always
26555
 
+      set to ``'linux2'``, even on Linux 3.x.  In Python 3.3 and later, the
26556
 
+      value will always be set to ``'linux'``, so it is recommended to always
26557
 
+      use the ``startswith`` idiom presented above.
26558
 
+
26559
 
    For other systems, the values are:
26560
 
 
26561
 
-   ================ ===========================
26562
 
-   System           :data:`platform` value
26563
 
-   ================ ===========================
26564
 
-   Windows          ``'win32'``
26565
 
-   Windows/Cygwin   ``'cygwin'``
26566
 
-   Mac OS X         ``'darwin'``
26567
 
-   OS/2             ``'os2'``
26568
 
-   OS/2 EMX         ``'os2emx'``
26569
 
-   RiscOS           ``'riscos'``
26570
 
-   AtheOS           ``'atheos'``
26571
 
-   ================ ===========================
26572
 
+   ===================== ===========================
26573
 
+   System                :data:`platform` value
26574
 
+   ===================== ===========================
26575
 
+   Linux (2.x *and* 3.x) ``'linux2'``
26576
 
+   Windows               ``'win32'``
26577
 
+   Windows/Cygwin        ``'cygwin'``
26578
 
+   Mac OS X              ``'darwin'``
26579
 
+   OS/2                  ``'os2'``
26580
 
+   OS/2 EMX              ``'os2emx'``
26581
 
+   RiscOS                ``'riscos'``
26582
 
+   AtheOS                ``'atheos'``
26583
 
+   ===================== ===========================
26584
 
 
26585
 
+   .. seealso::
26586
 
+      :attr:`os.name` has a coarser granularity.  :func:`os.uname` gives
26587
 
+      system-dependent version information.
26588
 
+
26589
 
+      The :mod:`platform` module provides detailed checks for the
26590
 
+      system's identity.
26591
 
 
26592
 
 .. data:: prefix
26593
 
 
26594
 
@@ -747,10 +772,10 @@
26595
 
    independent Python files are installed; by default, this is the string
26596
 
    ``'/usr/local'``.  This can be set at build time with the ``--prefix``
26597
 
    argument to the :program:`configure` script.  The main collection of Python
26598
 
-   library modules is installed in the directory ``prefix + '/lib/pythonversion'``
26599
 
+   library modules is installed in the directory :file:`{prefix}/lib/python{X.Y}``
26600
 
    while the platform independent header files (all except :file:`pyconfig.h`) are
26601
 
-   stored in ``prefix + '/include/pythonversion'``, where *version* is equal to
26602
 
-   ``version[:3]``.
26603
 
+   stored in :file:`{prefix}/include/python{X.Y}``, where *X.Y* is the version
26604
 
+   number of Python, for example ``2.7``.
26605
 
 
26606
 
 
26607
 
 .. data:: ps1
26608
 
@@ -778,17 +803,6 @@
26609
 
    .. versionadded:: 2.6
26610
 
 
26611
 
 
26612
 
-.. data:: dont_write_bytecode
26613
 
-
26614
 
-   If this is true, Python won't try to write ``.pyc`` or ``.pyo`` files on the
26615
 
-   import of source modules.  This value is initially set to ``True`` or ``False``
26616
 
-   depending on the ``-B`` command line option and the ``PYTHONDONTWRITEBYTECODE``
26617
 
-   environment variable, but you can set it yourself to control bytecode file
26618
 
-   generation.
26619
 
-
26620
 
-   .. versionadded:: 2.6
26621
 
-
26622
 
-
26623
 
 .. function:: setcheckinterval(interval)
26624
 
 
26625
 
    Set the interpreter's "check interval".  This integer value determines how often
26626
 
@@ -815,7 +829,7 @@
26627
 
 
26628
 
 .. function:: setdlopenflags(n)
26629
 
 
26630
 
-   Set the flags used by the interpreter for :cfunc:`dlopen` calls, such as when
26631
 
+   Set the flags used by the interpreter for :c:func:`dlopen` calls, such as when
26632
 
    the interpreter loads extension modules.  Among other things, this will enable a
26633
 
    lazy resolving of symbols when importing a module, if called as
26634
 
    ``sys.setdlopenflags(0)``.  To share symbols across extension modules, call as
26635
 
@@ -980,6 +994,26 @@
26636
 
    replacing it, and restore the saved object.
26637
 
 
26638
 
 
26639
 
+.. data:: subversion
26640
 
+
26641
 
+   A triple (repo, branch, version) representing the Subversion information of the
26642
 
+   Python interpreter. *repo* is the name of the repository, ``'CPython'``.
26643
 
+   *branch* is a string of one of the forms ``'trunk'``, ``'branches/name'`` or
26644
 
+   ``'tags/name'``. *version* is the output of ``svnversion``, if the interpreter
26645
 
+   was built from a Subversion checkout; it contains the revision number (range)
26646
 
+   and possibly a trailing 'M' if there were local modifications. If the tree was
26647
 
+   exported (or svnversion was not available), it is the revision of
26648
 
+   ``Include/patchlevel.h`` if the branch is a tag. Otherwise, it is ``None``.
26649
 
+
26650
 
+   .. versionadded:: 2.5
26651
 
+
26652
 
+   .. note::
26653
 
+      Python is now `developed <http://docs.python.org/devguide/>`_ using
26654
 
+      Mercurial.  In recent Python 2.7 bugfix releases, :data:`subversion`
26655
 
+      therefore contains placeholder information.  It is removed in Python
26656
 
+      3.3.
26657
 
+
26658
 
+
26659
 
 .. data:: tracebacklimit
26660
 
 
26661
 
    When this variable is set to an integer value, it determines the maximum number
26662
 
diff -r 8527427914a2 Doc/library/sysconfig.rst
26663
 
--- a/Doc/library/sysconfig.rst
26664
 
+++ b/Doc/library/sysconfig.rst
26665
 
@@ -5,10 +5,15 @@
26666
 
    :synopsis: Python's configuration information
26667
 
 .. moduleauthor:: Tarek Ziade <tarek@ziade.org>
26668
 
 .. sectionauthor:: Tarek Ziade <tarek@ziade.org>
26669
 
-.. versionadded:: 2.7
26670
 
 .. index::
26671
 
    single: configuration information
26672
 
 
26673
 
+.. versionadded:: 2.7
26674
 
+
26675
 
+**Source code:** :source:`Lib/sysconfig.py`
26676
 
+
26677
 
+--------------
26678
 
+
26679
 
 The :mod:`sysconfig` module provides access to Python's configuration
26680
 
 information like the list of installation paths and the configuration variables
26681
 
 relevant for the current platform.
26682
 
diff -r 8527427914a2 Doc/library/syslog.rst
26683
 
--- a/Doc/library/syslog.rst
26684
 
+++ b/Doc/library/syslog.rst
26685
 
@@ -30,7 +30,7 @@
26686
 
    ``openlog()`` will be called with no arguments.
26687
 
 
26688
 
 
26689
 
-.. function:: openlog([ident[, logopt[, facility]]])
26690
 
+.. function:: openlog([ident[, logoption[, facility]]])
26691
 
 
26692
 
    Logging options of subsequent :func:`syslog` calls can be set by calling
26693
 
    :func:`openlog`.  :func:`syslog` will call :func:`openlog` with no arguments
26694
 
@@ -38,7 +38,7 @@
26695
 
 
26696
 
    The optional *ident* keyword argument is a string which is prepended to every
26697
 
    message, and defaults to ``sys.argv[0]`` with leading path components
26698
 
-   stripped.  The optional *logopt* keyword argument (default is 0) is a bit
26699
 
+   stripped.  The optional *logoption* keyword argument (default is 0) is a bit
26700
 
    field -- see below for possible values to combine.  The optional *facility*
26701
 
    keyword argument (default is :const:`LOG_USER`) sets the default facility for
26702
 
    messages which do not have a facility explicitly encoded.
26703
 
@@ -98,5 +98,5 @@
26704
 
 logged messages, and write the messages to the destination facility used for
26705
 
 mail logging::
26706
 
 
26707
 
-   syslog.openlog(logopt=syslog.LOG_PID, facility=syslog.LOG_MAIL)
26708
 
+   syslog.openlog(logoption=syslog.LOG_PID, facility=syslog.LOG_MAIL)
26709
 
    syslog.syslog('E-mail processing initiated...')
26710
 
diff -r 8527427914a2 Doc/library/tabnanny.rst
26711
 
--- a/Doc/library/tabnanny.rst
26712
 
+++ b/Doc/library/tabnanny.rst
26713
 
@@ -9,6 +9,10 @@
26714
 
 
26715
 
 .. rudimentary documentation based on module comments
26716
 
 
26717
 
+**Source code:** :source:`Lib/tabnanny.py`
26718
 
+
26719
 
+--------------
26720
 
+
26721
 
 For the time being this module is intended to be called as a script. However it
26722
 
 is possible to import it into an IDE and use the function :func:`check`
26723
 
 described below.
26724
 
diff -r 8527427914a2 Doc/library/tarfile.rst
26725
 
--- a/Doc/library/tarfile.rst
26726
 
+++ b/Doc/library/tarfile.rst
26727
 
@@ -1,5 +1,3 @@
26728
 
-.. _tarfile-mod:
26729
 
-
26730
 
 :mod:`tarfile` --- Read and write tar archive files
26731
 
 ===================================================
26732
 
 
26733
 
@@ -12,6 +10,9 @@
26734
 
 .. moduleauthor:: Lars Gustäbel <lars@gustaebel.de>
26735
 
 .. sectionauthor:: Lars Gustäbel <lars@gustaebel.de>
26736
 
 
26737
 
+**Source code:** :source:`Lib/tarfile.py`
26738
 
+
26739
 
+--------------
26740
 
 
26741
 
 The :mod:`tarfile` module makes it possible to read and write tar
26742
 
 archives, including those using gzip or bz2 compression.
26743
 
diff -r 8527427914a2 Doc/library/telnetlib.rst
26744
 
--- a/Doc/library/telnetlib.rst
26745
 
+++ b/Doc/library/telnetlib.rst
26746
 
@@ -1,4 +1,3 @@
26747
 
-
26748
 
 :mod:`telnetlib` --- Telnet client
26749
 
 ==================================
26750
 
 
26751
 
@@ -9,6 +8,10 @@
26752
 
 
26753
 
 .. index:: single: protocol; Telnet
26754
 
 
26755
 
+**Source code:** :source:`Lib/telnetlib.py`
26756
 
+
26757
 
+--------------
26758
 
+
26759
 
 The :mod:`telnetlib` module provides a :class:`Telnet` class that implements the
26760
 
 Telnet protocol.  See :rfc:`854` for details about the protocol. In addition, it
26761
 
 provides symbolic constants for the protocol characters (see below), and for the
26762
 
diff -r 8527427914a2 Doc/library/tempfile.rst
26763
 
--- a/Doc/library/tempfile.rst
26764
 
+++ b/Doc/library/tempfile.rst
26765
 
@@ -1,4 +1,3 @@
26766
 
-
26767
 
 :mod:`tempfile` --- Generate temporary files and directories
26768
 
 ============================================================
26769
 
 
26770
 
@@ -13,6 +12,10 @@
26771
 
    pair: temporary; file name
26772
 
    pair: temporary; file
26773
 
 
26774
 
+**Source code:** :source:`Lib/tempfile.py`
26775
 
+
26776
 
+--------------
26777
 
+
26778
 
 This module generates temporary files and directories.  It works on all
26779
 
 supported platforms.
26780
 
 
26781
 
@@ -61,7 +64,7 @@
26782
 
    This function operates exactly as :func:`TemporaryFile` does, except that
26783
 
    the file is guaranteed to have a visible name in the file system (on
26784
 
    Unix, the directory entry is not unlinked).  That name can be retrieved
26785
 
-   from the :attr:`name` member of the file object.  Whether the name can be
26786
 
+   from the :attr:`name` attribute of the file object.  Whether the name can be
26787
 
    used to open the file a second time, while the named temporary file is
26788
 
    still open, varies across platforms (it can be so used on Unix; it cannot
26789
 
    on Windows NT or later).  If *delete* is true (the default), the file is
26790
 
diff -r 8527427914a2 Doc/library/textwrap.rst
26791
 
--- a/Doc/library/textwrap.rst
26792
 
+++ b/Doc/library/textwrap.rst
26793
 
@@ -1,4 +1,3 @@
26794
 
-
26795
 
 :mod:`textwrap` --- Text wrapping and filling
26796
 
 =============================================
26797
 
 
26798
 
@@ -7,8 +6,11 @@
26799
 
 .. moduleauthor:: Greg Ward <gward@python.net>
26800
 
 .. sectionauthor:: Greg Ward <gward@python.net>
26801
 
 
26802
 
+.. versionadded:: 2.3
26803
 
 
26804
 
-.. versionadded:: 2.3
26805
 
+**Source code:** :source:`Lib/textwrap.py`
26806
 
+
26807
 
+--------------
26808
 
 
26809
 
 The :mod:`textwrap` module provides two convenience functions, :func:`wrap` and
26810
 
 :func:`fill`, as well as :class:`TextWrapper`, the class that does all the work,
26811
 
@@ -16,11 +18,6 @@
26812
 
 or two  text strings, the convenience functions should be good enough;
26813
 
 otherwise,  you should use an instance of :class:`TextWrapper` for efficiency.
26814
 
 
26815
 
-.. seealso::
26816
 
-
26817
 
-   Latest version of the `textwrap module Python source code
26818
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/textwrap.py?view=markup>`_
26819
 
-
26820
 
 .. function:: wrap(text[, width[, ...]])
26821
 
 
26822
 
    Wraps the single paragraph in *text* (a string) so every line is at most *width*
26823
 
diff -r 8527427914a2 Doc/library/threading.rst
26824
 
--- a/Doc/library/threading.rst
26825
 
+++ b/Doc/library/threading.rst
26826
 
@@ -4,6 +4,9 @@
26827
 
 .. module:: threading
26828
 
    :synopsis: Higher-level threading interface.
26829
 
 
26830
 
+**Source code:** :source:`Lib/threading.py`
26831
 
+
26832
 
+--------------
26833
 
 
26834
 
 This module constructs higher-level threading interfaces on top of the  lower
26835
 
 level :mod:`thread` module.
26836
 
@@ -36,11 +39,6 @@
26837
 
    :mod:`multiprocessing`. However, threading is still an appropriate model
26838
 
    if you want to run multiple I/O-bound tasks simultaneously.
26839
 
 
26840
 
-.. seealso::
26841
 
-
26842
 
-   Latest version of the `threading module Python source code
26843
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/threading.py?view=markup>`_
26844
 
-
26845
 
 
26846
 
 This module defines the following functions and objects:
26847
 
 
26848
 
@@ -575,20 +573,21 @@
26849
 
       interface is then used to restore the recursion level when the lock is
26850
 
       reacquired.
26851
 
 
26852
 
-   .. method:: notify()
26853
 
+   .. method:: notify(n=1)
26854
 
 
26855
 
-      Wake up a thread waiting on this condition, if any.  If the calling thread
26856
 
-      has not acquired the lock when this method is called, a
26857
 
+      By default, wake up one thread waiting on this condition, if any.  If the
26858
 
+      calling thread has not acquired the lock when this method is called, a
26859
 
       :exc:`RuntimeError` is raised.
26860
 
 
26861
 
-      This method wakes up one of the threads waiting for the condition
26862
 
-      variable, if any are waiting; it is a no-op if no threads are waiting.
26863
 
+      This method wakes up at most *n* of the threads waiting for the condition
26864
 
+      variable; it is a no-op if no threads are waiting.
26865
 
 
26866
 
-      The current implementation wakes up exactly one thread, if any are
26867
 
-      waiting.  However, it's not safe to rely on this behavior.  A future,
26868
 
-      optimized implementation may occasionally wake up more than one thread.
26869
 
+      The current implementation wakes up exactly *n* threads, if at least *n*
26870
 
+      threads are waiting.  However, it's not safe to rely on this behavior.
26871
 
+      A future, optimized implementation may occasionally wake up more than
26872
 
+      *n* threads.
26873
 
 
26874
 
-      Note: the awakened thread does not actually return from its :meth:`wait`
26875
 
+      Note: an awakened thread does not actually return from its :meth:`wait`
26876
 
       call until it can reacquire the lock.  Since :meth:`notify` does not
26877
 
       release the lock, its caller should.
26878
 
 
26879
 
diff -r 8527427914a2 Doc/library/time.rst
26880
 
--- a/Doc/library/time.rst
26881
 
+++ b/Doc/library/time.rst
26882
 
@@ -74,8 +74,8 @@
26883
 
 * On the other hand, the precision of :func:`time` and :func:`sleep` is better
26884
 
   than their Unix equivalents: times are expressed as floating point numbers,
26885
 
   :func:`time` returns the most accurate time available (using Unix
26886
 
-  :cfunc:`gettimeofday` where available), and :func:`sleep` will accept a time
26887
 
-  with a nonzero fraction (Unix :cfunc:`select` is used to implement this, where
26888
 
+  :c:func:`gettimeofday` where available), and :func:`sleep` will accept a time
26889
 
+  with a nonzero fraction (Unix :c:func:`select` is used to implement this, where
26890
 
   available).
26891
 
 
26892
 
 * The time value as returned by :func:`gmtime`, :func:`localtime`, and
26893
 
@@ -156,7 +156,7 @@
26894
 
 
26895
 
    On Windows, this function returns wall-clock seconds elapsed since the first
26896
 
    call to this function, as a floating point number, based on the Win32 function
26897
 
-   :cfunc:`QueryPerformanceCounter`. The resolution is typically better than one
26898
 
+   :c:func:`QueryPerformanceCounter`. The resolution is typically better than one
26899
 
    microsecond.
26900
 
 
26901
 
 
26902
 
@@ -560,6 +560,6 @@
26903
 
    preferred  hour/minute offset is not supported by all ANSI C libraries. Also, a
26904
 
    strict reading of the original 1982 :rfc:`822` standard calls for a two-digit
26905
 
    year (%y rather than %Y), but practice moved to 4-digit years long before the
26906
 
-   year 2000.  The 4-digit year has been mandated by :rfc:`2822`, which obsoletes
26907
 
-   :rfc:`822`.
26908
 
+   year 2000.  After that, :rfc:`822` became obsolete and the 4-digit year has
26909
 
+   been first recommended by :rfc:`1123` and then mandated by :rfc:`2822`.
26910
 
 
26911
 
diff -r 8527427914a2 Doc/library/timeit.rst
26912
 
--- a/Doc/library/timeit.rst
26913
 
+++ b/Doc/library/timeit.rst
26914
 
@@ -1,4 +1,3 @@
26915
 
-
26916
 
 :mod:`timeit` --- Measure execution time of small code snippets
26917
 
 ===============================================================
26918
 
 
26919
 
@@ -12,6 +11,10 @@
26920
 
    single: Benchmarking
26921
 
    single: Performance
26922
 
 
26923
 
+**Source code:** :source:`Lib/timeit.py`
26924
 
+
26925
 
+--------------
26926
 
+
26927
 
 This module provides a simple way to time small bits of Python code. It has both
26928
 
 command line as well as callable interfaces.  It avoids a number of common traps
26929
 
 for measuring execution times.  See also Tim Peters' introduction to the
26930
 
@@ -195,13 +198,13 @@
26931
 
 :keyword:`try`/:keyword:`except` to test for missing and present object
26932
 
 attributes. ::
26933
 
 
26934
 
-   % timeit.py 'try:' '  str.__nonzero__' 'except AttributeError:' '  pass'
26935
 
+   $ python -m timeit 'try:' '  str.__nonzero__' 'except AttributeError:' '  pass'
26936
 
    100000 loops, best of 3: 15.7 usec per loop
26937
 
-   % timeit.py 'if hasattr(str, "__nonzero__"): pass'
26938
 
+   $ python -m timeit 'if hasattr(str, "__nonzero__"): pass'
26939
 
    100000 loops, best of 3: 4.26 usec per loop
26940
 
-   % timeit.py 'try:' '  int.__nonzero__' 'except AttributeError:' '  pass'
26941
 
+   $ python -m timeit 'try:' '  int.__nonzero__' 'except AttributeError:' '  pass'
26942
 
    1000000 loops, best of 3: 1.43 usec per loop
26943
 
-   % timeit.py 'if hasattr(int, "__nonzero__"): pass'
26944
 
+   $ python -m timeit 'if hasattr(int, "__nonzero__"): pass'
26945
 
    100000 loops, best of 3: 2.23 usec per loop
26946
 
 
26947
 
 ::
26948
 
@@ -242,12 +245,12 @@
26949
 
 ``setup`` parameter which contains an import statement::
26950
 
 
26951
 
    def test():
26952
 
-       "Stupid test function"
26953
 
+       """Stupid test function"""
26954
 
        L = []
26955
 
        for i in range(100):
26956
 
            L.append(i)
26957
 
 
26958
 
-   if __name__=='__main__':
26959
 
+   if __name__ == '__main__':
26960
 
        from timeit import Timer
26961
 
        t = Timer("test()", "from __main__ import test")
26962
 
        print t.timeit()
26963
 
diff -r 8527427914a2 Doc/library/token.rst
26964
 
--- a/Doc/library/token.rst
26965
 
+++ b/Doc/library/token.rst
26966
 
@@ -1,4 +1,3 @@
26967
 
-
26968
 
 :mod:`token` --- Constants used with Python parse trees
26969
 
 =======================================================
26970
 
 
26971
 
@@ -6,6 +5,9 @@
26972
 
    :synopsis: Constants representing terminal nodes of the parse tree.
26973
 
 .. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
26974
 
 
26975
 
+**Source code:** :source:`Lib/token.py`
26976
 
+
26977
 
+--------------
26978
 
 
26979
 
 This module provides constants which represent the numeric values of leaf nodes
26980
 
 of the parse tree (terminal tokens).  Refer to the file :file:`Grammar/Grammar`
26981
 
diff -r 8527427914a2 Doc/library/tokenize.rst
26982
 
--- a/Doc/library/tokenize.rst
26983
 
+++ b/Doc/library/tokenize.rst
26984
 
@@ -1,4 +1,3 @@
26985
 
-
26986
 
 :mod:`tokenize` --- Tokenizer for Python source
26987
 
 ===============================================
26988
 
 
26989
 
@@ -7,16 +6,20 @@
26990
 
 .. moduleauthor:: Ka Ping Yee
26991
 
 .. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
26992
 
 
26993
 
+**Source code:** :source:`Lib/tokenize.py`
26994
 
+
26995
 
+--------------
26996
 
 
26997
 
 The :mod:`tokenize` module provides a lexical scanner for Python source code,
26998
 
 implemented in Python.  The scanner in this module returns comments as tokens as
26999
 
 well, making it useful for implementing "pretty-printers," including colorizers
27000
 
 for on-screen displays.
27001
 
 
27002
 
-.. seealso::
27003
 
-
27004
 
-   Latest version of the `tokenize module Python source code
27005
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/tokenize.py?view=markup>`_
27006
 
+To simplify token stream handling, all :ref:`operators` and :ref:`delimiters`
27007
 
+tokens are returned using the generic :data:`token.OP` token type.  The exact
27008
 
+type can be determined by checking the token ``string`` field on the
27009
 
+:term:`named tuple` returned from :func:`tokenize.tokenize` for the character
27010
 
+sequence that identifies a specific operator token.
27011
 
 
27012
 
 The primary entry point is a :term:`generator`:
27013
 
 
27014
 
diff -r 8527427914a2 Doc/library/trace.rst
27015
 
--- a/Doc/library/trace.rst
27016
 
+++ b/Doc/library/trace.rst
27017
 
@@ -1,21 +1,18 @@
27018
 
-
27019
 
 :mod:`trace` --- Trace or track Python statement execution
27020
 
 ==========================================================
27021
 
 
27022
 
 .. module:: trace
27023
 
    :synopsis: Trace or track Python statement execution.
27024
 
 
27025
 
+**Source code:** :source:`Lib/trace.py`
27026
 
+
27027
 
+--------------
27028
 
 
27029
 
 The :mod:`trace` module allows you to trace program execution, generate
27030
 
 annotated statement coverage listings, print caller/callee relationships and
27031
 
 list functions executed during a program run.  It can be used in another program
27032
 
 or from the command line.
27033
 
 
27034
 
-.. seealso::
27035
 
-
27036
 
-   Latest version of the `trace module Python source code
27037
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/trace.py?view=markup>`_
27038
 
-
27039
 
 .. _trace-cli:
27040
 
 
27041
 
 Command-Line Usage
27042
 
diff -r 8527427914a2 Doc/library/ttk.rst
27043
 
--- a/Doc/library/ttk.rst
27044
 
+++ b/Doc/library/ttk.rst
27045
 
@@ -1243,7 +1243,7 @@
27046
 
       *layoutspec*, if specified, is expected to be a list or some other
27047
 
       sequence type (excluding strings), where each item should be a tuple and
27048
 
       the first item is the layout name and the second item should have the
27049
 
-      format described described in `Layouts`_.
27050
 
+      format described in `Layouts`_.
27051
 
 
27052
 
       To understand the format, see the following example (it is not
27053
 
       intended to do anything useful)::
27054
 
@@ -1294,7 +1294,7 @@
27055
 
 
27056
 
        * sticky=spec
27057
 
           Specifies how the image is placed within the final parcel. spec
27058
 
-          contains zero or more characters “n”, “s”, “w”, or “e”.
27059
 
+          contains zero or more characters "n", "s", "w", or "e".
27060
 
 
27061
 
        * width=width
27062
 
           Specifies a minimum width for the element. If less than zero, the
27063
 
diff -r 8527427914a2 Doc/library/turtle.rst
27064
 
--- a/Doc/library/turtle.rst
27065
 
+++ b/Doc/library/turtle.rst
27066
 
@@ -18,10 +18,10 @@
27067
 
 part of the original Logo programming language developed by Wally Feurzig and
27068
 
 Seymour Papert in 1966.
27069
 
 
27070
 
-Imagine a robotic turtle starting at (0, 0) in the x-y plane.  Give it the
27071
 
+Imagine a robotic turtle starting at (0, 0) in the x-y plane.  After an ``import turtle``, give it the
27072
 
 command ``turtle.forward(15)``, and it moves (on-screen!) 15 pixels in the
27073
 
 direction it is facing, drawing a line as it moves.  Give it the command
27074
 
-``turtle.left(25)``, and it rotates in-place 25 degrees clockwise.
27075
 
+``turtle.right(25)``, and it rotates in-place 25 degrees clockwise.
27076
 
 
27077
 
 By combining together these and similar commands, intricate shapes and pictures
27078
 
 can easily be drawn.
27079
 
@@ -157,6 +157,7 @@
27080
 
    | :func:`onclick`
27081
 
    | :func:`onrelease`
27082
 
    | :func:`ondrag`
27083
 
+   | :func:`mainloop` | :func:`done`
27084
 
 
27085
 
 Special Turtle methods
27086
 
    | :func:`begin_poly`
27087
 
@@ -1291,6 +1292,15 @@
27088
 
    the screen thereby producing handdrawings (if pen is down).
27089
 
 
27090
 
 
27091
 
+.. function:: mainloop()
27092
 
+              done()
27093
 
+
27094
 
+   Starts event loop - calling Tkinter's mainloop function. Must be the last
27095
 
+   statement in a turtle graphics program.
27096
 
+
27097
 
+      >>> turtle.mainloop()
27098
 
+
27099
 
+
27100
 
 Special Turtle methods
27101
 
 ----------------------
27102
 
 
27103
 
diff -r 8527427914a2 Doc/library/types.rst
27104
 
--- a/Doc/library/types.rst
27105
 
+++ b/Doc/library/types.rst
27106
 
@@ -4,6 +4,9 @@
27107
 
 .. module:: types
27108
 
    :synopsis: Names for built-in types.
27109
 
 
27110
 
+**Source code:** :source:`Lib/types.py`
27111
 
+
27112
 
+--------------
27113
 
 
27114
 
 This module defines names for some object types that are used by the standard
27115
 
 Python interpreter, but not for the types defined by various extension modules.
27116
 
diff -r 8527427914a2 Doc/library/unicodedata.rst
27117
 
--- a/Doc/library/unicodedata.rst
27118
 
+++ b/Doc/library/unicodedata.rst
27119
 
@@ -107,7 +107,7 @@
27120
 
    based on the definition of canonical equivalence and compatibility equivalence.
27121
 
    In Unicode, several characters can be expressed in various way. For example, the
27122
 
    character U+00C7 (LATIN CAPITAL LETTER C WITH CEDILLA) can also be expressed as
27123
 
-   the sequence U+0327 (COMBINING CEDILLA) U+0043 (LATIN CAPITAL LETTER C).
27124
 
+   the sequence U+0043 (LATIN CAPITAL LETTER C) U+0327 (COMBINING CEDILLA).
27125
 
 
27126
 
    For each character, there are two normal forms: normal form C and normal form D.
27127
 
    Normal form D (NFD) is also known as canonical decomposition, and translates
27128
 
diff -r 8527427914a2 Doc/library/unittest.rst
27129
 
--- a/Doc/library/unittest.rst
27130
 
+++ b/Doc/library/unittest.rst
27131
 
@@ -307,7 +307,7 @@
27132
 
 
27133
 
     Test discovery loads tests by importing them. Once test discovery has
27134
 
     found all the test files from the start directory you specify it turns the
27135
 
-    paths into package names to import. For example `foo/bar/baz.py` will be
27136
 
+    paths into package names to import. For example :file:`foo/bar/baz.py` will be
27137
 
     imported as ``foo.bar.baz``.
27138
 
 
27139
 
     If you have a package installed globally and attempt test discovery on
27140
 
@@ -352,7 +352,7 @@
27141
 
            widget = Widget('The widget')
27142
 
            self.assertEqual(widget.size(), (50, 50), 'incorrect default size')
27143
 
 
27144
 
-Note that in order to test something, we use the one of the :meth:`assert\*`
27145
 
+Note that in order to test something, we use one of the :meth:`assert\*`
27146
 
 methods provided by the :class:`TestCase` base class.  If the test fails, an
27147
 
 exception will be raised, and :mod:`unittest` will identify the test case as a
27148
 
 :dfn:`failure`.  Any other exceptions will be treated as :dfn:`errors`. This
27149
 
@@ -840,13 +840,13 @@
27150
 
 
27151
 
       In addition, if *first* and *second* are the exact same type and one of
27152
 
       list, tuple, dict, set, frozenset or unicode or any type that a subclass
27153
 
-      registers with :meth:`addTypeEqualityFunc` the type specific equality
27154
 
+      registers with :meth:`addTypeEqualityFunc` the type-specific equality
27155
 
       function will be called in order to generate a more useful default
27156
 
       error message (see also the :ref:`list of type-specific methods
27157
 
       <type-specific-methods>`).
27158
 
 
27159
 
       .. versionchanged:: 2.7
27160
 
-         Added the automatic calling of type specific equality function.
27161
 
+         Added the automatic calling of type-specific equality function.
27162
 
 
27163
 
 
27164
 
    .. method:: assertNotEqual(first, second, msg=None)
27165
 
@@ -895,6 +895,7 @@
27166
 
 
27167
 
       Test that *obj* is (or is not) an instance of *cls* (which can be a
27168
 
       class or a tuple of classes, as supported by :func:`isinstance`).
27169
 
+      To check for the exact type, use :func:`assertIs(type(obj), cls) <assertIs>`.
27170
 
 
27171
 
       .. versionadded:: 2.7
27172
 
 
27173
 
@@ -905,11 +906,11 @@
27174
 
    +---------------------------------------------------------+--------------------------------------+------------+
27175
 
    | Method                                                  | Checks that                          | New in     |
27176
 
    +=========================================================+======================================+============+
27177
 
-   | :meth:`assertRaises(exc, fun, *args, **kwds)            | ``fun(*args, **kwds)`` raises `exc`  |            |
27178
 
+   | :meth:`assertRaises(exc, fun, *args, **kwds)            | ``fun(*args, **kwds)`` raises *exc*  |            |
27179
 
    | <TestCase.assertRaises>`                                |                                      |            |
27180
 
    +---------------------------------------------------------+--------------------------------------+------------+
27181
 
-   | :meth:`assertRaisesRegexp(exc, re, fun, *args, **kwds)  | ``fun(*args, **kwds)`` raises `exc`  | 2.7        |
27182
 
-   | <TestCase.assertRaisesRegexp>`                          | and the message matches `re`         |            |
27183
 
+   | :meth:`assertRaisesRegexp(exc, re, fun, *args, **kwds)  | ``fun(*args, **kwds)`` raises *exc*  | 2.7        |
27184
 
+   | <TestCase.assertRaisesRegexp>`                          | and the message matches *re*         |            |
27185
 
    +---------------------------------------------------------+--------------------------------------+------------+
27186
 
 
27187
 
    .. method:: assertRaises(exception, callable, *args, **kwds)
27188
 
@@ -995,7 +996,7 @@
27189
 
    | <TestCase.assertItemsEqual>`          | works with unhashable objs     |              |
27190
 
    +---------------------------------------+--------------------------------+--------------+
27191
 
    | :meth:`assertDictContainsSubset(a, b) | all the key/value pairs        | 2.7          |
27192
 
-   | <TestCase.assertDictContainsSubset>`  | in `a` exist in `b`            |              |
27193
 
+   | <TestCase.assertDictContainsSubset>`  | in *a* exist in *b*            |              |
27194
 
    +---------------------------------------+--------------------------------+--------------+
27195
 
 
27196
 
 
27197
 
diff -r 8527427914a2 Doc/library/urllib.rst
27198
 
--- a/Doc/library/urllib.rst
27199
 
+++ b/Doc/library/urllib.rst
27200
 
@@ -23,7 +23,7 @@
27201
 
 instead of filenames.  Some restrictions apply --- it can only open URLs for
27202
 
 reading, and no seek operations are available.
27203
 
 
27204
 
-.. warning:: When opening HTTPS URLs, it is not attempted to validate the
27205
 
+.. warning:: When opening HTTPS URLs, it does not attempt to validate the
27206
 
    server certificate.  Use at your own risk!
27207
 
 
27208
 
 
27209
 
@@ -210,7 +210,7 @@
27210
 
 
27211
 
    Replace special characters in *string* using the ``%xx`` escape. Letters,
27212
 
    digits, and the characters ``'_.-'`` are never quoted. By default, this
27213
 
-   function is intended for quoting the path section of the URL.The optional
27214
 
+   function is intended for quoting the path section of the URL. The optional
27215
 
    *safe* parameter specifies additional characters that should not be quoted
27216
 
    --- its default value is ``'/'``.
27217
 
 
27218
 
@@ -274,10 +274,10 @@
27219
 
 .. function:: getproxies()
27220
 
 
27221
 
    This helper function returns a dictionary of scheme to proxy server URL
27222
 
-   mappings. It scans the environment for variables named ``<scheme>_proxy``
27223
 
-   for all operating systems first, and when it cannot find it, looks for proxy
27224
 
-   information from Mac OSX System Configuration for Mac OS X and Windows
27225
 
-   Systems Registry for Windows.
27226
 
+   mappings. It scans the environment for variables named ``<scheme>_proxy``,
27227
 
+   in case insensitive way, for all operating systems first, and when it cannot
27228
 
+   find it, looks for proxy information from Mac OSX System Configuration for
27229
 
+   Mac OS X and Windows Systems Registry for Windows.
27230
 
 
27231
 
 
27232
 
 URL Opener objects
27233
 
diff -r 8527427914a2 Doc/library/urllib2.rst
27234
 
--- a/Doc/library/urllib2.rst
27235
 
+++ b/Doc/library/urllib2.rst
27236
 
@@ -36,7 +36,7 @@
27237
 
    :mimetype:`application/x-www-form-urlencoded` format.  The
27238
 
    :func:`urllib.urlencode` function takes a mapping or sequence of 2-tuples and
27239
 
    returns a string in this format. urllib2 module sends HTTP/1.1 requests with
27240
 
-   `Connection:close` header included.
27241
 
+   ``Connection:close`` header included.
27242
 
 
27243
 
    The optional *timeout* parameter specifies a timeout in seconds for blocking
27244
 
    operations like the connection attempt (if not specified, the global default
27245
 
@@ -90,7 +90,7 @@
27246
 
    :class:`HTTPSHandler` will also be added.
27247
 
 
27248
 
    Beginning in Python 2.3, a :class:`BaseHandler` subclass may also change its
27249
 
-   :attr:`handler_order` member variable to modify its position in the handlers
27250
 
+   :attr:`handler_order` attribute to modify its position in the handlers
27251
 
    list.
27252
 
 
27253
 
 The following exceptions are raised as appropriate:
27254
 
@@ -297,6 +297,11 @@
27255
 
    A catch-all class to handle unknown URLs.
27256
 
 
27257
 
 
27258
 
+.. class:: HTTPErrorProcessor()
27259
 
+
27260
 
+   Process HTTP error responses.
27261
 
+
27262
 
+
27263
 
 .. _request-objects:
27264
 
 
27265
 
 Request Objects
27266
 
@@ -495,7 +500,7 @@
27267
 
 
27268
 
    Remove any parents.
27269
 
 
27270
 
-The following members and methods should only be used by classes derived from
27271
 
+The following attributes and methods should only be used by classes derived from
27272
 
 :class:`BaseHandler`.
27273
 
 
27274
 
 .. note::
27275
 
@@ -881,7 +886,7 @@
27276
 
 .. versionadded:: 2.4
27277
 
 
27278
 
 
27279
 
-.. method:: HTTPErrorProcessor.unknown_open()
27280
 
+.. method:: HTTPErrorProcessor.http_response()
27281
 
 
27282
 
    Process HTTP error responses.
27283
 
 
27284
 
@@ -893,6 +898,12 @@
27285
 
    :class:`urllib2.HTTPDefaultErrorHandler` will raise an :exc:`HTTPError` if no
27286
 
    other handler handles the error.
27287
 
 
27288
 
+.. method:: HTTPErrorProcessor.https_response()
27289
 
+
27290
 
+   Process HTTPS error responses.
27291
 
+
27292
 
+   The behavior is same as :meth:`http_response`.
27293
 
+
27294
 
 
27295
 
 .. _urllib2-examples:
27296
 
 
27297
 
diff -r 8527427914a2 Doc/library/urlparse.rst
27298
 
--- a/Doc/library/urlparse.rst
27299
 
+++ b/Doc/library/urlparse.rst
27300
 
@@ -17,6 +17,9 @@
27301
 
    The :term:`2to3` tool will automatically adapt imports when converting
27302
 
    your sources to 3.0.
27303
 
 
27304
 
+**Source code:** :source:`Lib/urlparse.py`
27305
 
+
27306
 
+--------------
27307
 
 
27308
 
 This module defines a standard interface to break Uniform Resource Locator (URL)
27309
 
 strings up in components (addressing scheme, network location, path etc.), to
27310
 
@@ -33,11 +36,6 @@
27311
 
 .. versionadded:: 2.5
27312
 
    Support for the ``sftp`` and ``sips`` schemes.
27313
 
 
27314
 
-.. seealso::
27315
 
-
27316
 
-   Latest version of the `urlparse module Python source code
27317
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/urlparse.py?view=markup>`_
27318
 
-
27319
 
 The :mod:`urlparse` module defines the following functions:
27320
 
 
27321
 
 
27322
 
diff -r 8527427914a2 Doc/library/userdict.rst
27323
 
--- a/Doc/library/userdict.rst
27324
 
+++ b/Doc/library/userdict.rst
27325
 
@@ -1,4 +1,3 @@
27326
 
-
27327
 
 :mod:`UserDict` --- Class wrapper for dictionary objects
27328
 
 ========================================================
27329
 
 
27330
 
@@ -6,6 +5,10 @@
27331
 
    :synopsis: Class wrapper for dictionary objects.
27332
 
 
27333
 
 
27334
 
+**Source code:** :source:`Lib/UserDict.py`
27335
 
+
27336
 
+--------------
27337
 
+
27338
 
 The module defines a mixin,  :class:`DictMixin`, defining all dictionary methods
27339
 
 for classes that already have a minimum mapping interface.  This greatly
27340
 
 simplifies writing classes that need to be substitutable for dictionaries (such
27341
 
@@ -19,11 +22,6 @@
27342
 
 sub-classes that obtained new behaviors by overriding existing methods or adding
27343
 
 new ones.
27344
 
 
27345
 
-.. seealso::
27346
 
-
27347
 
-   Latest version of the `UserDict Python source code
27348
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/UserDict.py?view=markup>`_
27349
 
-
27350
 
 The :mod:`UserDict` module defines the :class:`UserDict` class and
27351
 
 :class:`DictMixin`:
27352
 
 
27353
 
@@ -85,9 +83,18 @@
27354
 
 
27355
 
 .. note::
27356
 
 
27357
 
-   This module is available for backward compatibility only.  If you are writing
27358
 
-   code that does not need to work with versions of Python earlier than Python 2.2,
27359
 
-   please consider subclassing directly from the built-in :class:`list` type.
27360
 
+   When Python 2.2 was released, many of the use cases for this class were
27361
 
+   subsumed by the ability to subclass :class:`list` directly.  However, a
27362
 
+   handful of use cases remain.
27363
 
+
27364
 
+   This module provides a list-interface around an underlying data store.  By
27365
 
+   default, that data store is a :class:`list`; however, it can be used to wrap
27366
 
+   a list-like interface around other objects (such as persistent storage).
27367
 
+
27368
 
+   In addition, this class can be mixed-in with built-in classes using multiple
27369
 
+   inheritance.  This can sometimes be useful.  For example, you can inherit
27370
 
+   from :class:`UserList` and :class:`str` at the same time.  That would not be
27371
 
+   possible with both a real :class:`list` and a real :class:`str`.
27372
 
 
27373
 
 This module defines a class that acts as a wrapper around list objects.  It is a
27374
 
 useful base class for your own list-like classes, which can inherit from them
27375
 
diff -r 8527427914a2 Doc/library/uu.rst
27376
 
--- a/Doc/library/uu.rst
27377
 
+++ b/Doc/library/uu.rst
27378
 
@@ -1,4 +1,3 @@
27379
 
-
27380
 
 :mod:`uu` --- Encode and decode uuencode files
27381
 
 ==============================================
27382
 
 
27383
 
@@ -6,6 +5,9 @@
27384
 
    :synopsis: Encode and decode files in uuencode format.
27385
 
 .. moduleauthor:: Lance Ellinghouse
27386
 
 
27387
 
+**Source code:** :source:`Lib/uu.py`
27388
 
+
27389
 
+--------------
27390
 
 
27391
 
 This module encodes and decodes files in uuencode format, allowing arbitrary
27392
 
 binary data to be transferred over ASCII-only connections. Wherever a file
27393
 
@@ -22,11 +24,6 @@
27394
 
 
27395
 
 This code was contributed by Lance Ellinghouse, and modified by Jack Jansen.
27396
 
 
27397
 
-.. seealso::
27398
 
-
27399
 
-   Latest version of the `uu module Python source code
27400
 
-   <http://svn.python.org/view/python/branches/release27-maint/Lib/uu.py?view=markup>`_
27401
 
-
27402
 
 The :mod:`uu` module defines the following functions:
27403
 
 
27404
 
 
27405
 
@@ -62,4 +59,3 @@
27406
 
 
27407
 
    Module :mod:`binascii`
27408
 
       Support module containing ASCII-to-binary and binary-to-ASCII conversions.
27409
 
-
27410
 
diff -r 8527427914a2 Doc/library/uuid.rst
27411
 
--- a/Doc/library/uuid.rst
27412
 
+++ b/Doc/library/uuid.rst
27413
 
@@ -225,34 +225,34 @@
27414
 
 
27415
 
    >>> import uuid
27416
 
 
27417
 
-   # make a UUID based on the host ID and current time
27418
 
+   >>> # make a UUID based on the host ID and current time
27419
 
    >>> uuid.uuid1()
27420
 
    UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')
27421
 
 
27422
 
-   # make a UUID using an MD5 hash of a namespace UUID and a name
27423
 
+   >>> # make a UUID using an MD5 hash of a namespace UUID and a name
27424
 
    >>> uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')
27425
 
    UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')
27426
 
 
27427
 
-   # make a random UUID
27428
 
+   >>> # make a random UUID
27429
 
    >>> uuid.uuid4()
27430
 
    UUID('16fd2706-8baf-433b-82eb-8c7fada847da')
27431
 
 
27432
 
-   # make a UUID using a SHA-1 hash of a namespace UUID and a name
27433
 
+   >>> # make a UUID using a SHA-1 hash of a namespace UUID and a name
27434
 
    >>> uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org')
27435
 
    UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d')
27436
 
 
27437
 
-   # make a UUID from a string of hex digits (braces and hyphens ignored)
27438
 
+   >>> # make a UUID from a string of hex digits (braces and hyphens ignored)
27439
 
    >>> x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}')
27440
 
 
27441
 
-   # convert a UUID to a string of hex digits in standard form
27442
 
+   >>> # convert a UUID to a string of hex digits in standard form
27443
 
    >>> str(x)
27444
 
    '00010203-0405-0607-0809-0a0b0c0d0e0f'
27445
 
 
27446
 
-   # get the raw 16 bytes of the UUID
27447
 
+   >>> # get the raw 16 bytes of the UUID
27448
 
    >>> x.bytes
27449
 
    '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f'
27450
 
 
27451
 
-   # make a UUID from a 16-byte string
27452
 
+   >>> # make a UUID from a 16-byte string
27453
 
    >>> uuid.UUID(bytes=x.bytes)
27454
 
    UUID('00010203-0405-0607-0809-0a0b0c0d0e0f')
27455
 
 
27456
 
diff -r 8527427914a2 Doc/library/warnings.rst
27457
 
--- a/Doc/library/warnings.rst
27458
 
+++ b/Doc/library/warnings.rst
27459
 
@@ -9,13 +9,17 @@
27460
 
 
27461
 
 .. versionadded:: 2.1
27462
 
 
27463
 
+**Source code:** :source:`Lib/warnings.py`
27464
 
+
27465
 
+--------------
27466
 
+
27467
 
 Warning messages are typically issued in situations where it is useful to alert
27468
 
 the user of some condition in a program, where that condition (normally) doesn't
27469
 
 warrant raising an exception and terminating the program.  For example, one
27470
 
 might want to issue a warning when a program uses an obsolete module.
27471
 
 
27472
 
 Python programmers issue warnings by calling the :func:`warn` function defined
27473
 
-in this module.  (C programmers use :cfunc:`PyErr_WarnEx`; see
27474
 
+in this module.  (C programmers use :c:func:`PyErr_WarnEx`; see
27475
 
 :ref:`exceptionhandling` for details).
27476
 
 
27477
 
 Warning messages are normally written to ``sys.stderr``, but their disposition
27478
 
@@ -39,6 +43,10 @@
27479
 
 message by calling :func:`formatwarning`, which is also available for use by
27480
 
 custom implementations.
27481
 
 
27482
 
+.. seealso::
27483
 
+   :func:`logging.captureWarnings` allows you to handle all warnings with
27484
 
+   the standard logging infrastructure.
27485
 
+
27486
 
 
27487
 
 .. _warning-categories:
27488
 
 
27489
 
diff -r 8527427914a2 Doc/library/wave.rst
27490
 
--- a/Doc/library/wave.rst
27491
 
+++ b/Doc/library/wave.rst
27492
 
@@ -6,6 +6,10 @@
27493
 
 .. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
27494
 
 .. Documentations stolen from comments in file.
27495
 
 
27496
 
+**Source code:** :source:`Lib/wave.py`
27497
 
+
27498
 
+--------------
27499
 
+
27500
 
 The :mod:`wave` module provides a convenient interface to the WAV sound format.
27501
 
 It does not support compression/decompression, but it does support mono/stereo.
27502
 
 
27503
 
diff -r 8527427914a2 Doc/library/weakref.rst
27504
 
--- a/Doc/library/weakref.rst
27505
 
+++ b/Doc/library/weakref.rst
27506
 
@@ -11,6 +11,10 @@
27507
 
 
27508
 
 .. versionadded:: 2.1
27509
 
 
27510
 
+**Source code:** :source:`Lib/weakref.py`
27511
 
+
27512
 
+--------------
27513
 
+
27514
 
 The :mod:`weakref` module allows the Python programmer to create :dfn:`weak
27515
 
 references` to objects.
27516
 
 
27517
 
diff -r 8527427914a2 Doc/library/webbrowser.rst
27518
 
--- a/Doc/library/webbrowser.rst
27519
 
+++ b/Doc/library/webbrowser.rst
27520
 
@@ -1,4 +1,3 @@
27521
 
-
27522
 
 :mod:`webbrowser` --- Convenient Web-browser controller
27523
 
 =======================================================
27524
 
 
27525
 
@@ -7,6 +6,9 @@
27526
 
 .. moduleauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
27527
 
 .. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
27528
 
 
27529
 
+**Source code:** :source:`Lib/webbrowser.py`
27530
 
+
27531
 
+--------------
27532
 
 
27533
 
 The :mod:`webbrowser` module provides a high-level interface to allow displaying
27534
 
 Web-based documents to users. Under most circumstances, simply calling the
27535
 
diff -r 8527427914a2 Doc/library/winsound.rst
27536
 
--- a/Doc/library/winsound.rst
27537
 
+++ b/Doc/library/winsound.rst
27538
 
@@ -27,7 +27,7 @@
27539
 
 
27540
 
 .. function:: PlaySound(sound, flags)
27541
 
 
27542
 
-   Call the underlying :cfunc:`PlaySound` function from the Platform API.  The
27543
 
+   Call the underlying :c:func:`PlaySound` function from the Platform API.  The
27544
 
    *sound* parameter may be a filename, audio data as a string, or ``None``.  Its
27545
 
    interpretation depends on the value of *flags*, which can be a bitwise ORed
27546
 
    combination of the constants described below. If the *sound* parameter is
27547
 
@@ -37,7 +37,7 @@
27548
 
 
27549
 
 .. function:: MessageBeep([type=MB_OK])
27550
 
 
27551
 
-   Call the underlying :cfunc:`MessageBeep` function from the Platform API.  This
27552
 
+   Call the underlying :c:func:`MessageBeep` function from the Platform API.  This
27553
 
    plays a sound as specified in the registry.  The *type* argument specifies which
27554
 
    sound to play; possible values are ``-1``, ``MB_ICONASTERISK``,
27555
 
    ``MB_ICONEXCLAMATION``, ``MB_ICONHAND``, ``MB_ICONQUESTION``, and ``MB_OK``, all
27556
 
diff -r 8527427914a2 Doc/library/xdrlib.rst
27557
 
--- a/Doc/library/xdrlib.rst
27558
 
+++ b/Doc/library/xdrlib.rst
27559
 
@@ -1,4 +1,3 @@
27560
 
-
27561
 
 :mod:`xdrlib` --- Encode and decode XDR data
27562
 
 ============================================
27563
 
 
27564
 
@@ -10,6 +9,10 @@
27565
 
    single: XDR
27566
 
    single: External Data Representation
27567
 
 
27568
 
+**Source code:** :source:`Lib/xdrlib.py`
27569
 
+
27570
 
+--------------
27571
 
+
27572
 
 The :mod:`xdrlib` module supports the External Data Representation Standard as
27573
 
 described in :rfc:`1014`, written by Sun Microsystems, Inc. June 1987.  It
27574
 
 supports most of the data types described in the RFC.
27575
 
@@ -257,7 +260,7 @@
27576
 
 
27577
 
 .. exception:: Error
27578
 
 
27579
 
-   The base exception class.  :exc:`Error` has a single public data member
27580
 
+   The base exception class.  :exc:`Error` has a single public attribute
27581
 
    :attr:`msg` containing the description of the error.
27582
 
 
27583
 
 
27584
 
diff -r 8527427914a2 Doc/library/xml.dom.minidom.rst
27585
 
--- a/Doc/library/xml.dom.minidom.rst
27586
 
+++ b/Doc/library/xml.dom.minidom.rst
27587
 
@@ -1,4 +1,3 @@
27588
 
-
27589
 
 :mod:`xml.dom.minidom` --- Lightweight DOM implementation
27590
 
 =========================================================
27591
 
 
27592
 
@@ -11,6 +10,10 @@
27593
 
 
27594
 
 .. versionadded:: 2.0
27595
 
 
27596
 
+**Source code:** :source:`Lib/xml/dom/minidom.py`
27597
 
+
27598
 
+--------------
27599
 
+
27600
 
 :mod:`xml.dom.minidom` is a light-weight implementation of the Document Object
27601
 
 Model interface.  It is intended to be simpler than the full DOM and also
27602
 
 significantly smaller.
27603
 
diff -r 8527427914a2 Doc/library/xml.dom.pulldom.rst
27604
 
--- a/Doc/library/xml.dom.pulldom.rst
27605
 
+++ b/Doc/library/xml.dom.pulldom.rst
27606
 
@@ -1,4 +1,3 @@
27607
 
-
27608
 
 :mod:`xml.dom.pulldom` --- Support for building partial DOM trees
27609
 
 =================================================================
27610
 
 
27611
 
@@ -9,6 +8,10 @@
27612
 
 
27613
 
 .. versionadded:: 2.0
27614
 
 
27615
 
+**Source code:** :source:`Lib/xml/dom/pulldom.py`
27616
 
+
27617
 
+--------------
27618
 
+
27619
 
 :mod:`xml.dom.pulldom` allows building only selected portions of a Document
27620
 
 Object Model representation of a document from SAX events.
27621
 
 
27622
 
diff -r 8527427914a2 Doc/library/xml.etree.elementtree.rst
27623
 
--- a/Doc/library/xml.etree.elementtree.rst
27624
 
+++ b/Doc/library/xml.etree.elementtree.rst
27625
 
@@ -1,4 +1,3 @@
27626
 
-
27627
 
 :mod:`xml.etree.ElementTree` --- The ElementTree XML API
27628
 
 ========================================================
27629
 
 
27630
 
@@ -9,6 +8,10 @@
27631
 
 
27632
 
 .. versionadded:: 2.5
27633
 
 
27634
 
+**Source code:** :source:`Lib/xml/etree/ElementTree.py`
27635
 
+
27636
 
+--------------
27637
 
+
27638
 
 The :class:`Element` type is a flexible container object, designed to store
27639
 
 hierarchical data structures in memory.  The type can be described as a cross
27640
 
 between a list and a dictionary.
27641
 
@@ -333,6 +336,8 @@
27642
 
       elements whose tag equals *tag* are returned from the iterator.  If the
27643
 
       tree structure is modified during iteration, the result is undefined.
27644
 
 
27645
 
+      .. versionadded:: 2.7
27646
 
+
27647
 
 
27648
 
    .. method:: iterfind(match)
27649
 
 
27650
 
diff -r 8527427914a2 Doc/library/xmlrpclib.rst
27651
 
--- a/Doc/library/xmlrpclib.rst
27652
 
+++ b/Doc/library/xmlrpclib.rst
27653
 
@@ -17,6 +17,10 @@
27654
 
 
27655
 
 .. versionadded:: 2.2
27656
 
 
27657
 
+**Source code:** :source:`Lib/xmlrpclib.py`
27658
 
+
27659
 
+--------------
27660
 
+
27661
 
 XML-RPC is a Remote Procedure Call method that uses XML passed via HTTP as a
27662
 
 transport.  With it, a client can call methods with parameters on a remote
27663
 
 server (the server is named by a URI) and get back structured data.  This module
27664
 
@@ -148,7 +152,7 @@
27665
 
 :class:`Fault` or :class:`ProtocolError` object indicating an error.
27666
 
 
27667
 
 Servers that support the XML introspection API support some common methods
27668
 
-grouped under the reserved :attr:`system` member:
27669
 
+grouped under the reserved :attr:`system` attribute:
27670
 
 
27671
 
 
27672
 
 .. method:: ServerProxy.system.listMethods()
27673
 
@@ -341,7 +345,7 @@
27674
 
 -------------
27675
 
 
27676
 
 A :class:`Fault` object encapsulates the content of an XML-RPC fault tag. Fault
27677
 
-objects have the following members:
27678
 
+objects have the following attributes:
27679
 
 
27680
 
 
27681
 
 .. attribute:: Fault.faultCode
27682
 
@@ -390,7 +394,7 @@
27683
 
 
27684
 
 A :class:`ProtocolError` object describes a protocol error in the underlying
27685
 
 transport layer (such as a 404 'not found' error if the server named by the URI
27686
 
-does not exist).  It has the following members:
27687
 
+does not exist).  It has the following attributes:
27688
 
 
27689
 
 
27690
 
 .. attribute:: ProtocolError.url
27691
 
@@ -435,8 +439,8 @@
27692
 
 
27693
 
 .. versionadded:: 2.4
27694
 
 
27695
 
-In http://www.xmlrpc.com/discuss/msgReader%241208, an approach is presented to
27696
 
-encapsulate multiple calls to a remote server into a single request.
27697
 
+The :class:`MultiCall` object provides a way to encapsulate multiple calls to a
27698
 
+remote server into a single request [#]_.
27699
 
 
27700
 
 
27701
 
 .. class:: MultiCall(server)
27702
 
@@ -577,3 +581,10 @@
27703
 
 See :ref:`simplexmlrpcserver-example`.
27704
 
 
27705
 
 
27706
 
+.. rubric:: Footnotes
27707
 
+
27708
 
+.. [#] This approach has been first presented in `a discussion on xmlrpc.com
27709
 
+   <http://web.archive.org/web/20060624230303/http://www.xmlrpc.com/discuss/msgReader$1208?mode=topic>`_.
27710
 
+.. the link now points to webarchive since the one at
27711
 
+.. http://www.xmlrpc.com/discuss/msgReader%241208 is broken (and webadmin
27712
 
+.. doesn't reply)
27713
 
diff -r 8527427914a2 Doc/library/zipfile.rst
27714
 
--- a/Doc/library/zipfile.rst
27715
 
+++ b/Doc/library/zipfile.rst
27716
 
@@ -1,4 +1,3 @@
27717
 
-
27718
 
 :mod:`zipfile` --- Work with ZIP archives
27719
 
 =========================================
27720
 
 
27721
 
@@ -9,6 +8,10 @@
27722
 
 
27723
 
 .. versionadded:: 1.6
27724
 
 
27725
 
+**Source code:** :source:`Lib/zipfile.py`
27726
 
+
27727
 
+--------------
27728
 
+
27729
 
 The ZIP file format is a common archive and compression standard. This module
27730
 
 provides tools to create, read, write, append, and list a ZIP file.  Any
27731
 
 advanced use of this module will require an understanding of the format, as
27732
 
@@ -385,7 +388,7 @@
27733
 
    +-------+--------------------------+
27734
 
    | Index | Value                    |
27735
 
    +=======+==========================+
27736
 
-   | ``0`` | Year                     |
27737
 
+   | ``0`` | Year (>= 1980)           |
27738
 
    +-------+--------------------------+
27739
 
    | ``1`` | Month (one-based)        |
27740
 
    +-------+--------------------------+
27741
 
@@ -398,6 +401,10 @@
27742
 
    | ``5`` | Seconds (zero-based)     |
27743
 
    +-------+--------------------------+
27744
 
 
27745
 
+   .. note::
27746
 
+
27747
 
+      The ZIP file format does not support timestamps before 1980.
27748
 
+
27749
 
 
27750
 
 .. attribute:: ZipInfo.compress_type
27751
 
 
27752
 
diff -r 8527427914a2 Doc/library/zipimport.rst
27753
 
--- a/Doc/library/zipimport.rst
27754
 
+++ b/Doc/library/zipimport.rst
27755
 
@@ -12,11 +12,11 @@
27756
 
 This module adds the ability to import Python modules (:file:`\*.py`,
27757
 
 :file:`\*.py[co]`) and packages from ZIP-format archives. It is usually not
27758
 
 needed to use the :mod:`zipimport` module explicitly; it is automatically used
27759
 
-by the built-in :keyword:`import` mechanism for ``sys.path`` items that are paths
27760
 
+by the built-in :keyword:`import` mechanism for :data:`sys.path` items that are paths
27761
 
 to ZIP archives.
27762
 
 
27763
 
-Typically, ``sys.path`` is a list of directory names as strings.  This module
27764
 
-also allows an item of ``sys.path`` to be a string naming a ZIP file archive.
27765
 
+Typically, :data:`sys.path` is a list of directory names as strings.  This module
27766
 
+also allows an item of :data:`sys.path` to be a string naming a ZIP file archive.
27767
 
 The ZIP archive can contain a subdirectory structure to support package imports,
27768
 
 and a path within the archive can be specified to only import from a
27769
 
 subdirectory.  For example, the path :file:`/tmp/example.zip/lib/` would only
27770
 
diff -r 8527427914a2 Doc/library/zlib.rst
27771
 
--- a/Doc/library/zlib.rst
27772
 
+++ b/Doc/library/zlib.rst
27773
 
@@ -132,7 +132,7 @@
27774
 
    *bufsize* is the initial size of the buffer used to hold decompressed data.  If
27775
 
    more space is required, the buffer size will be increased as needed, so you
27776
 
    don't have to get this value exactly right; tuning it will only save a few calls
27777
 
-   to :cfunc:`malloc`.  The default size is 16384.
27778
 
+   to :c:func:`malloc`.  The default size is 16384.
27779
 
 
27780
 
 
27781
 
 .. function:: decompressobj([wbits])
27782
 
diff -r 8527427914a2 Doc/license.rst
27783
 
--- a/Doc/license.rst
27784
 
+++ b/Doc/license.rst
27785
 
@@ -132,7 +132,7 @@
27786
 
    analyze, test, perform and/or display publicly, prepare derivative works,
27787
 
    distribute, and otherwise use Python |release| alone or in any derivative
27788
 
    version, provided, however, that PSF's License Agreement and PSF's notice of
27789
 
-   copyright, i.e., "Copyright © 2001-2010 Python Software Foundation; All Rights
27790
 
+   copyright, i.e., "Copyright © 2001-2012 Python Software Foundation; All Rights
27791
 
    Reserved" are retained in Python |release| alone or in any derivative version
27792
 
    prepared by Licensee.
27793
 
 
27794
 
@@ -536,36 +536,6 @@
27795
 
    PERFORMANCE OF THIS SOFTWARE.
27796
 
 
27797
 
 
27798
 
-Profiling
27799
 
----------
27800
 
-
27801
 
-The :mod:`profile` and :mod:`pstats` modules contain the following notice::
27802
 
-
27803
 
-   Copyright 1994, by InfoSeek Corporation, all rights reserved.
27804
 
-   Written by James Roskind
27805
 
-
27806
 
-   Permission to use, copy, modify, and distribute this Python software
27807
 
-   and its associated documentation for any purpose (subject to the
27808
 
-   restriction in the following sentence) without fee is hereby granted,
27809
 
-   provided that the above copyright notice appears in all copies, and
27810
 
-   that both that copyright notice and this permission notice appear in
27811
 
-   supporting documentation, and that the name of InfoSeek not be used in
27812
 
-   advertising or publicity pertaining to distribution of the software
27813
 
-   without specific, written prior permission.  This permission is
27814
 
-   explicitly restricted to the copying and modification of the software
27815
 
-   to remain in Python, compiled Python, or other languages (such as C)
27816
 
-   wherein the modified or derived code is exclusively imported into a
27817
 
-   Python module.
27818
 
-
27819
 
-   INFOSEEK CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
27820
 
-   SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
27821
 
-   FITNESS. IN NO EVENT SHALL INFOSEEK CORPORATION BE LIABLE FOR ANY
27822
 
-   SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
27823
 
-   RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
27824
 
-   CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
27825
 
-   CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27826
 
-
27827
 
-
27828
 
 Execution tracing
27829
 
 -----------------
27830
 
 
27831
 
@@ -889,7 +859,7 @@
27832
 
 -----
27833
 
 
27834
 
 The :mod:`pyexpat` extension is built using an included copy of the expat
27835
 
-sources unless the build is configured :option:`--with-system-expat`::
27836
 
+sources unless the build is configured ``--with-system-expat``::
27837
 
 
27838
 
   Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
27839
 
                                  and Clark Cooper
27840
 
@@ -918,7 +888,7 @@
27841
 
 ------
27842
 
 
27843
 
 The :mod:`_ctypes` extension is built using an included copy of the libffi
27844
 
-sources unless the build is configured :option:`--with-system-libffi`::
27845
 
+sources unless the build is configured ``--with-system-libffi``::
27846
 
 
27847
 
    Copyright (c) 1996-2008  Red Hat, Inc and others.
27848
 
 
27849
 
@@ -947,7 +917,7 @@
27850
 
 ----
27851
 
 
27852
 
 The :mod:`zlib` extension is built using an included copy of the zlib
27853
 
-sources unless the zlib version found on the system is too old to be
27854
 
+sources if the zlib version found on the system is too old to be
27855
 
 used for the build::
27856
 
 
27857
 
   Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
27858
 
diff -r 8527427914a2 Doc/reference/compound_stmts.rst
27859
 
--- a/Doc/reference/compound_stmts.rst
27860
 
+++ b/Doc/reference/compound_stmts.rst
27861
 
@@ -470,7 +470,7 @@
27862
 
 
27863
 
 **Default parameter values are evaluated when the function definition is
27864
 
 executed.**  This means that the expression is evaluated once, when the function
27865
 
-is defined, and that that same "pre-computed" value is used for each call.  This
27866
 
+is defined, and that the same "pre-computed" value is used for each call.  This
27867
 
 is especially important to understand when a default parameter is a mutable
27868
 
 object, such as a list or a dictionary: if the function modifies the object
27869
 
 (e.g. by appending an item to a list), the default value is in effect modified.
27870
 
@@ -562,8 +562,9 @@
27871
 
 
27872
 
 .. rubric:: Footnotes
27873
 
 
27874
 
-.. [#] The exception is propagated to the invocation stack only if there is no
27875
 
-   :keyword:`finally` clause that negates the exception.
27876
 
+.. [#] The exception is propagated to the invocation stack unless
27877
 
+   there is a :keyword:`finally` clause which happens to raise another
27878
 
+   exception. That new exception causes the old one to be lost.
27879
 
 
27880
 
 .. [#] Currently, control "flows off the end" except in the case of an exception or the
27881
 
    execution of a :keyword:`return`, :keyword:`continue`, or :keyword:`break`
27882
 
diff -r 8527427914a2 Doc/reference/datamodel.rst
27883
 
--- a/Doc/reference/datamodel.rst
27884
 
+++ b/Doc/reference/datamodel.rst
27885
 
@@ -2308,7 +2308,7 @@
27886
 
 
27887
 
 *
27888
 
 
27889
 
-  In ``x * y``, if one operator is a sequence that implements sequence
27890
 
+  In ``x * y``, if one operand is a sequence that implements sequence
27891
 
   repetition, and the other is an integer (:class:`int` or :class:`long`),
27892
 
   sequence repetition is invoked.
27893
 
 
27894
 
diff -r 8527427914a2 Doc/reference/expressions.rst
27895
 
--- a/Doc/reference/expressions.rst
27896
 
+++ b/Doc/reference/expressions.rst
27897
 
@@ -347,7 +347,7 @@
27898
 
 quotes:
27899
 
 
27900
 
 .. productionlist::
27901
 
-   string_conversion: "'" `expression_list` "'"
27902
 
+   string_conversion: "`" `expression_list` "`"
27903
 
 
27904
 
 A string conversion evaluates the contained expression list and converts the
27905
 
 resulting object into a string according to rules specific to its type.
27906
 
@@ -719,7 +719,7 @@
27907
 
    An implementation may provide built-in functions whose positional parameters
27908
 
    do not have names, even if they are 'named' for the purpose of documentation,
27909
 
    and which therefore cannot be supplied by keyword.  In CPython, this is the
27910
 
-   case for functions implemented in C that use :cfunc:`PyArg_ParseTuple` to
27911
 
+   case for functions implemented in C that use :c:func:`PyArg_ParseTuple` to
27912
 
    parse their arguments.
27913
 
 
27914
 
 If there are more positional arguments than there are formal parameter slots, a
27915
 
@@ -735,12 +735,15 @@
27916
 
 and the argument values as corresponding values), or a (new) empty dictionary if
27917
 
 there were no excess keyword arguments.
27918
 
 
27919
 
+.. index::
27920
 
+   single: *; in function calls
27921
 
+
27922
 
 If the syntax ``*expression`` appears in the function call, ``expression`` must
27923
 
-evaluate to a sequence.  Elements from this sequence are treated as if they were
27924
 
-additional positional arguments; if there are positional arguments *x1*,...,
27925
 
-*xN*, and ``expression`` evaluates to a sequence *y1*, ..., *yM*, this is
27926
 
-equivalent to a call with M+N positional arguments *x1*, ..., *xN*, *y1*, ...,
27927
 
-*yM*.
27928
 
+evaluate to an iterable.  Elements from this iterable are treated as if they
27929
 
+were additional positional arguments; if there are positional arguments
27930
 
+*x1*, ..., *xN*, and ``expression`` evaluates to a sequence *y1*, ..., *yM*, this
27931
 
+is equivalent to a call with M+N positional arguments *x1*, ..., *xN*, *y1*,
27932
 
+..., *yM*.
27933
 
 
27934
 
 A consequence of this is that although the ``*expression`` syntax may appear
27935
 
 *after* some keyword arguments, it is processed *before* the keyword arguments
27936
 
@@ -761,6 +764,9 @@
27937
 
 It is unusual for both keyword arguments and the ``*expression`` syntax to be
27938
 
 used in the same call, so in practice this confusion does not arise.
27939
 
 
27940
 
+.. index::
27941
 
+   single: **; in function calls
27942
 
+
27943
 
 If the syntax ``**expression`` appears in the function call, ``expression`` must
27944
 
 evaluate to a mapping, the contents of which are treated as additional keyword
27945
 
 arguments.  In the case of a keyword appearing in both ``expression`` and as an
27946
 
@@ -1042,9 +1048,9 @@
27947
 
 
27948
 
 .. _comparisons:
27949
 
 .. _is:
27950
 
-.. _isnot:
27951
 
+.. _is not:
27952
 
 .. _in:
27953
 
-.. _notin:
27954
 
+.. _not in:
27955
 
 
27956
 
 Comparisons
27957
 
 ===========
27958
 
diff -r 8527427914a2 Doc/reference/introduction.rst
27959
 
--- a/Doc/reference/introduction.rst
27960
 
+++ b/Doc/reference/introduction.rst
27961
 
@@ -65,7 +65,7 @@
27962
 
    An alternate Python for .NET.  Unlike Python.NET, this is a complete Python
27963
 
    implementation that generates IL, and compiles Python code directly to .NET
27964
 
    assemblies.  It was created by Jim Hugunin, the original creator of Jython.  For
27965
 
-   more information, see `the IronPython website <http://www.ironpython.com/>`_.
27966
 
+   more information, see `the IronPython website <http://www.ironpython.net/>`_.
27967
 
 
27968
 
 PyPy
27969
 
    An implementation of Python written completely in Python. It supports several
27970
 
diff -r 8527427914a2 Doc/reference/lexical_analysis.rst
27971
 
--- a/Doc/reference/lexical_analysis.rst
27972
 
+++ b/Doc/reference/lexical_analysis.rst
27973
 
@@ -357,11 +357,11 @@
27974
 
    assign a different object to it.
27975
 
 
27976
 
 .. versionchanged:: 2.5
27977
 
-   Both :keyword:`as` and :keyword:`with` are only recognized when the
27978
 
-   ``with_statement`` future feature has been enabled. It will always be enabled in
27979
 
-   Python 2.6.  See section :ref:`with` for details.  Note that using :keyword:`as`
27980
 
-   and :keyword:`with` as identifiers will always issue a warning, even when the
27981
 
-   ``with_statement`` future directive is not in effect.
27982
 
+   Using :keyword:`as` and :keyword:`with` as identifiers triggers a warning.  To
27983
 
+   use them as keywords, enable the ``with_statement`` future feature .
27984
 
+
27985
 
+.. versionchanged:: 2.6
27986
 
+    :keyword:`as` and :keyword:`with` are full keywords.
27987
 
 
27988
 
 
27989
 
 .. _id-classes:
27990
 
diff -r 8527427914a2 Doc/reference/simple_stmts.rst
27991
 
--- a/Doc/reference/simple_stmts.rst
27992
 
+++ b/Doc/reference/simple_stmts.rst
27993
 
@@ -352,7 +352,7 @@
27994
 
    del_stmt: "del" `target_list`
27995
 
 
27996
 
 Deletion is recursively defined very similar to the way assignment is defined.
27997
 
-Rather that spelling it out in full details, here are some hints.
27998
 
+Rather than spelling it out in full details, here are some hints.
27999
 
 
28000
 
 Deletion of a target list recursively deletes each target, from left to right.
28001
 
 
28002
 
@@ -706,7 +706,7 @@
28003
 
 second argument to :meth:`find_module` is given as the value of the
28004
 
 :attr:`__path__` attribute from the parent package (everything up to the last
28005
 
 dot in the name of the module being imported). If a finder can find the module
28006
 
-it returns a :term:`loader` (discussed later) or returns :keyword:`None`.
28007
 
+it returns a :term:`loader` (discussed later) or returns ``None``.
28008
 
 
28009
 
 .. index::
28010
 
     single: sys.path_hooks
28011
 
@@ -733,11 +733,11 @@
28012
 
 the list with a single argument of the path, returning a finder or raises
28013
 
 :exc:`ImportError`. If a finder is returned then it is cached in
28014
 
 :data:`sys.path_importer_cache` and then used for that path entry. If no finder
28015
 
-can be found but the path exists then a value of :keyword:`None` is
28016
 
+can be found but the path exists then a value of ``None`` is
28017
 
 stored in :data:`sys.path_importer_cache` to signify that an implicit,
28018
 
 file-based finder that handles modules stored as individual files should be
28019
 
 used for that path. If the path does not exist then a finder which always
28020
 
-returns :keyword:`None` is placed in the cache for the path.
28021
 
+returns `None`` is placed in the cache for the path.
28022
 
 
28023
 
 .. index::
28024
 
     single: loader
28025
 
diff -r 8527427914a2 Doc/tools/sphinxext/indexcontent.html
28026
 
--- a/Doc/tools/sphinxext/indexcontent.html
28027
 
+++ b/Doc/tools/sphinxext/indexcontent.html
28028
 
@@ -24,8 +24,6 @@
28029
 
          <span class="linkdescr">information for installers &amp; sys-admins</span></p>
28030
 
       <p class="biglink"><a class="biglink" href="{{ pathto("distutils/index") }}">Distributing Python Modules</a><br/>
28031
 
          <span class="linkdescr">sharing modules with others</span></p>
28032
 
-      <p class="biglink"><a class="biglink" href="{{ pathto("documenting/index") }}">Documenting Python</a><br/>
28033
 
-         <span class="linkdescr">guide for documentation authors</span></p>
28034
 
       <p class="biglink"><a class="biglink" href="{{ pathto("faq/index") }}">FAQs</a><br/>
28035
 
          <span class="linkdescr">frequently asked questions (with answers!)</span></p>
28036
 
     </td></tr>
28037
 
diff -r 8527427914a2 Doc/tools/sphinxext/layout.html
28038
 
--- a/Doc/tools/sphinxext/layout.html
28039
 
+++ b/Doc/tools/sphinxext/layout.html
28040
 
@@ -6,6 +6,7 @@
28041
 
 {% endblock %}
28042
 
 {% block extrahead %}
28043
 
     <link rel="shortcut icon" type="image/png" href="{{ pathto('_static/py.png', 1) }}" />
28044
 
+    <script type="text/javascript" src="{{ pathto('_static/copybutton.js', 1) }}"></script>
28045
 
 {{ super() }}
28046
 
 {% endblock %}
28047
 
 {% block footer %}
28048
 
diff -r 8527427914a2 Doc/tools/sphinxext/pyspecific.py
28049
 
--- a/Doc/tools/sphinxext/pyspecific.py
28050
 
+++ b/Doc/tools/sphinxext/pyspecific.py
28051
 
@@ -5,13 +5,15 @@
28052
 
 
28053
 
     Sphinx extension with Python doc-specific markup.
28054
 
 
28055
 
-    :copyright: 2008, 2009 by Georg Brandl.
28056
 
+    :copyright: 2008, 2009, 2010 by Georg Brandl.
28057
 
     :license: Python license.
28058
 
 """
28059
 
 
28060
 
 ISSUE_URI = 'http://bugs.python.org/issue%s'
28061
 
+SOURCE_URI = 'http://hg.python.org/cpython/file/2.7/%s'
28062
 
 
28063
 
 from docutils import nodes, utils
28064
 
+from sphinx.util.nodes import split_explicit_title
28065
 
 
28066
 
 # monkey-patch reST parser to disable alphabetic and roman enumerated lists
28067
 
 from docutils.parsers.rst.states import Body
28068
 
@@ -44,6 +46,16 @@
28069
 
     return [refnode], []
28070
 
 
28071
 
 
28072
 
+# Support for linking to Python source files easily
28073
 
+
28074
 
+def source_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
28075
 
+    has_t, title, target = split_explicit_title(text)
28076
 
+    title = utils.unescape(title)
28077
 
+    target = utils.unescape(target)
28078
 
+    refnode = nodes.reference(title, title, refuri=SOURCE_URI % target)
28079
 
+    return [refnode], []
28080
 
+
28081
 
+
28082
 
 # Support for marking up implementation details
28083
 
 
28084
 
 from sphinx.util.compat import Directive
28085
 
@@ -72,26 +84,85 @@
28086
 
         return [pnode]
28087
 
 
28088
 
 
28089
 
+# Support for documenting decorators
28090
 
+
28091
 
+from sphinx import addnodes
28092
 
+from sphinx.domains.python import PyModulelevel, PyClassmember
28093
 
+
28094
 
+class PyDecoratorMixin(object):
28095
 
+    def handle_signature(self, sig, signode):
28096
 
+        ret = super(PyDecoratorMixin, self).handle_signature(sig, signode)
28097
 
+        signode.insert(0, addnodes.desc_addname('@', '@'))
28098
 
+        return ret
28099
 
+
28100
 
+    def needs_arglist(self):
28101
 
+        return False
28102
 
+
28103
 
+class PyDecoratorFunction(PyDecoratorMixin, PyModulelevel):
28104
 
+    def run(self):
28105
 
+        # a decorator function is a function after all
28106
 
+        self.name = 'py:function'
28107
 
+        return PyModulelevel.run(self)
28108
 
+
28109
 
+class PyDecoratorMethod(PyDecoratorMixin, PyClassmember):
28110
 
+    def run(self):
28111
 
+        self.name = 'py:method'
28112
 
+        return PyClassmember.run(self)
28113
 
+
28114
 
+
28115
 
+# Support for documenting version of removal in deprecations
28116
 
+
28117
 
+from sphinx.locale import versionlabels
28118
 
+from sphinx.util.compat import Directive
28119
 
+
28120
 
+versionlabels['deprecated-removed'] = \
28121
 
+    'Deprecated since version %s, will be removed in version %s'
28122
 
+
28123
 
+class DeprecatedRemoved(Directive):
28124
 
+    has_content = True
28125
 
+    required_arguments = 2
28126
 
+    optional_arguments = 1
28127
 
+    final_argument_whitespace = True
28128
 
+    option_spec = {}
28129
 
+
28130
 
+    def run(self):
28131
 
+        node = addnodes.versionmodified()
28132
 
+        node.document = self.state.document
28133
 
+        node['type'] = 'deprecated-removed'
28134
 
+        version = (self.arguments[0], self.arguments[1])
28135
 
+        node['version'] = version
28136
 
+        if len(self.arguments) == 3:
28137
 
+            inodes, messages = self.state.inline_text(self.arguments[2],
28138
 
+                                                      self.lineno+1)
28139
 
+            node.extend(inodes)
28140
 
+            if self.content:
28141
 
+                self.state.nested_parse(self.content, self.content_offset, node)
28142
 
+            ret = [node] + messages
28143
 
+        else:
28144
 
+            ret = [node]
28145
 
+        env = self.state.document.settings.env
28146
 
+        env.note_versionchange('deprecated', version[0], node, self.lineno)
28147
 
+        return ret
28148
 
+
28149
 
+
28150
 
 # Support for building "topic help" for pydoc
28151
 
 
28152
 
 pydoc_topic_labels = [
28153
 
     'assert', 'assignment', 'atom-identifiers', 'atom-literals',
28154
 
     'attribute-access', 'attribute-references', 'augassign', 'binary',
28155
 
     'bitwise', 'bltin-code-objects', 'bltin-ellipsis-object',
28156
 
-    'bltin-file-objects', 'bltin-null-object', 'bltin-type-objects', 'booleans',
28157
 
-    'break', 'callable-types', 'calls', 'class', 'coercion-rules',
28158
 
-    'comparisons', 'compound', 'context-managers', 'continue', 'conversions',
28159
 
-    'customization', 'debugger', 'del', 'dict', 'dynamic-features', 'else',
28160
 
-    'exceptions', 'exec', 'execmodel', 'exprlists', 'floating', 'for',
28161
 
-    'formatstrings', 'function', 'global', 'id-classes', 'identifiers', 'if',
28162
 
-    'imaginary', 'import', 'in', 'integers', 'lambda', 'lists', 'naming',
28163
 
-    'numbers', 'numeric-types', 'objects', 'operator-summary', 'pass', 'power',
28164
 
-    'print', 'raise', 'return', 'sequence-methods', 'sequence-types',
28165
 
-    'shifting', 'slicings', 'specialattrs', 'specialnames',
28166
 
-    'string-conversions', 'string-methods', 'strings', 'subscriptions', 'truth',
28167
 
-    'try', 'types', 'typesfunctions', 'typesmapping', 'typesmethods',
28168
 
-    'typesmodules', 'typesseq', 'typesseq-mutable', 'unary', 'while', 'with',
28169
 
-    'yield'
28170
 
+    'bltin-null-object', 'bltin-type-objects', 'booleans',
28171
 
+    'break', 'callable-types', 'calls', 'class', 'comparisons', 'compound',
28172
 
+    'context-managers', 'continue', 'conversions', 'customization', 'debugger',
28173
 
+    'del', 'dict', 'dynamic-features', 'else', 'exceptions', 'execmodel',
28174
 
+    'exprlists', 'floating', 'for', 'formatstrings', 'function', 'global',
28175
 
+    'id-classes', 'identifiers', 'if', 'imaginary', 'import', 'in', 'integers',
28176
 
+    'lambda', 'lists', 'naming', 'nonlocal', 'numbers', 'numeric-types',
28177
 
+    'objects', 'operator-summary', 'pass', 'power', 'raise', 'return',
28178
 
+    'sequence-types', 'shifting', 'slicings', 'specialattrs', 'specialnames',
28179
 
+    'string-methods', 'strings', 'subscriptions', 'truth', 'try', 'types',
28180
 
+    'typesfunctions', 'typesmapping', 'typesmethods', 'typesmodules',
28181
 
+    'typesseq', 'typesseq-mutable', 'unary', 'while', 'with', 'yield'
28182
 
 ]
28183
 
 
28184
 
 from os import path
28185
 
@@ -121,16 +192,16 @@
28186
 
         for label in self.status_iterator(pydoc_topic_labels,
28187
 
                                           'building topics... ',
28188
 
                                           length=len(pydoc_topic_labels)):
28189
 
-            if label not in self.env.labels:
28190
 
+            if label not in self.env.domaindata['std']['labels']:
28191
 
                 self.warn('label %r not in documentation' % label)
28192
 
                 continue
28193
 
-            docname, labelid, sectname = self.env.labels[label]
28194
 
+            docname, labelid, sectname = self.env.domaindata['std']['labels'][label]
28195
 
             doctree = self.env.get_and_resolve_doctree(docname, self)
28196
 
             document = new_document('<section node>')
28197
 
             document.append(doctree.ids[labelid])
28198
 
             destination = StringOutput(encoding='utf-8')
28199
 
             writer.write(document, destination)
28200
 
-            self.topics[label] = writer.output
28201
 
+            self.topics[label] = str(writer.output)
28202
 
 
28203
 
     def finish(self):
28204
 
         f = open(path.join(self.outdir, 'topics.py'), 'w')
28205
 
@@ -149,9 +220,8 @@
28206
 
 # Support for documenting Opcodes
28207
 
 
28208
 
 import re
28209
 
-from sphinx import addnodes
28210
 
 
28211
 
-opcode_sig_re = re.compile(r'(\w+(?:\+\d)?)\s*\((.*)\)')
28212
 
+opcode_sig_re = re.compile(r'(\w+(?:\+\d)?)(?:\s*\((.*)\))?')
28213
 
 
28214
 
 def parse_opcode_signature(env, sig, signode):
28215
 
     """Transform an opcode signature into RST nodes."""
28216
 
@@ -160,17 +230,48 @@
28217
 
         raise ValueError
28218
 
     opname, arglist = m.groups()
28219
 
     signode += addnodes.desc_name(opname, opname)
28220
 
-    paramlist = addnodes.desc_parameterlist()
28221
 
-    signode += paramlist
28222
 
-    paramlist += addnodes.desc_parameter(arglist, arglist)
28223
 
+    if arglist is not None:
28224
 
+        paramlist = addnodes.desc_parameterlist()
28225
 
+        signode += paramlist
28226
 
+        paramlist += addnodes.desc_parameter(arglist, arglist)
28227
 
     return opname.strip()
28228
 
 
28229
 
 
28230
 
+# Support for documenting pdb commands
28231
 
+
28232
 
+pdbcmd_sig_re = re.compile(r'([a-z()!]+)\s*(.*)')
28233
 
+
28234
 
+# later...
28235
 
+#pdbargs_tokens_re = re.compile(r'''[a-zA-Z]+  |  # identifiers
28236
 
+#                                   [.,:]+     |  # punctuation
28237
 
+#                                   [\[\]()]   |  # parens
28238
 
+#                                   \s+           # whitespace
28239
 
+#                                   ''', re.X)
28240
 
+
28241
 
+def parse_pdb_command(env, sig, signode):
28242
 
+    """Transform a pdb command signature into RST nodes."""
28243
 
+    m = pdbcmd_sig_re.match(sig)
28244
 
+    if m is None:
28245
 
+        raise ValueError
28246
 
+    name, args = m.groups()
28247
 
+    fullname = name.replace('(', '').replace(')', '')
28248
 
+    signode += addnodes.desc_name(name, name)
28249
 
+    if args:
28250
 
+        signode += addnodes.desc_addname(' '+args, ' '+args)
28251
 
+    return fullname
28252
 
+
28253
 
+
28254
 
 def setup(app):
28255
 
     app.add_role('issue', issue_role)
28256
 
+    app.add_role('source', source_role)
28257
 
     app.add_directive('impl-detail', ImplementationDetail)
28258
 
+    app.add_directive('deprecated-removed', DeprecatedRemoved)
28259
 
     app.add_builder(PydocTopicsBuilder)
28260
 
     app.add_builder(suspicious.CheckSuspiciousMarkupBuilder)
28261
 
     app.add_description_unit('opcode', 'opcode', '%s (opcode)',
28262
 
                              parse_opcode_signature)
28263
 
+    app.add_description_unit('pdbcommand', 'pdbcmd', '%s (pdb command)',
28264
 
+                             parse_pdb_command)
28265
 
     app.add_description_unit('2to3fixer', '2to3fixer', '%s (2to3 fixer)')
28266
 
+    app.add_directive_to_domain('py', 'decorator', PyDecoratorFunction)
28267
 
+    app.add_directive_to_domain('py', 'decoratormethod', PyDecoratorMethod)
28268
 
diff -r 8527427914a2 Doc/tools/sphinxext/static/copybutton.js
28269
 
--- /dev/null
28270
 
+++ b/Doc/tools/sphinxext/static/copybutton.js
28271
 
@@ -0,0 +1,56 @@
28272
 
+$(document).ready(function() {
28273
 
+    /* Add a [>>>] button on the top-right corner of code samples to hide
28274
 
+     * the >>> and ... prompts and the output and thus make the code
28275
 
+     * copyable. */
28276
 
+    var div = $('.highlight-python .highlight,' +
28277
 
+                '.highlight-python3 .highlight')
28278
 
+    var pre = div.find('pre');
28279
 
+
28280
 
+    // get the styles from the current theme
28281
 
+    pre.parent().parent().css('position', 'relative');
28282
 
+    var hide_text = 'Hide the prompts and output';
28283
 
+    var show_text = 'Show the prompts and output';
28284
 
+    var border_width = pre.css('border-top-width');
28285
 
+    var border_style = pre.css('border-top-style');
28286
 
+    var border_color = pre.css('border-top-color');
28287
 
+    var button_styles = {
28288
 
+        'cursor':'pointer', 'position': 'absolute', 'top': '0', 'right': '0',
28289
 
+        'border-color': border_color, 'border-style': border_style,
28290
 
+        'border-width': border_width, 'color': border_color, 'text-size': '75%',
28291
 
+        'font-family': 'monospace', 'padding-left': '0.2em', 'padding-right': '0.2em'
28292
 
+    }
28293
 
+
28294
 
+    // create and add the button to all the code blocks that contain >>>
28295
 
+    div.each(function(index) {
28296
 
+        var jthis = $(this);
28297
 
+        if (jthis.find('.gp').length > 0) {
28298
 
+            var button = $('<span class="copybutton">&gt;&gt;&gt;</span>');
28299
 
+            button.css(button_styles)
28300
 
+            button.attr('title', hide_text);
28301
 
+            jthis.prepend(button);
28302
 
+        }
28303
 
+        // tracebacks (.gt) contain bare text elements that need to be
28304
 
+        // wrapped in a span to work with .nextUntil() (see later)
28305
 
+        jthis.find('pre:has(.gt)').contents().filter(function() {
28306
 
+            return ((this.nodeType == 3) && (this.data.trim().length > 0));
28307
 
+        }).wrap('<span>');
28308
 
+    });
28309
 
+
28310
 
+    // define the behavior of the button when it's clicked
28311
 
+    $('.copybutton').toggle(
28312
 
+        function() {
28313
 
+            var button = $(this);
28314
 
+            button.parent().find('.go, .gp, .gt').hide();
28315
 
+            button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'hidden');
28316
 
+            button.css('text-decoration', 'line-through');
28317
 
+            button.attr('title', show_text);
28318
 
+        },
28319
 
+        function() {
28320
 
+            var button = $(this);
28321
 
+            button.parent().find('.go, .gp, .gt').show();
28322
 
+            button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'visible');
28323
 
+            button.css('text-decoration', 'none');
28324
 
+            button.attr('title', hide_text);
28325
 
+        });
28326
 
+});
28327
 
+
28328
 
diff -r 8527427914a2 Doc/tools/sphinxext/susp-ignored.csv
28329
 
--- a/Doc/tools/sphinxext/susp-ignored.csv
28330
 
+++ b/Doc/tools/sphinxext/susp-ignored.csv
28331
 
@@ -5,7 +5,6 @@
28332
 
 c-api/sequence,,:i2,o[i1:i2] = v
28333
 
 c-api/sequence,,:i2,del o[i1:i2]
28334
 
 c-api/unicode,,:end,str[start:end]
28335
 
-distutils/apiref,,:action,http://pypi.python.org/pypi?:action=list_classifiers
28336
 
 distutils/setupscript,,::,
28337
 
 extending/embedding,,:numargs,"if(!PyArg_ParseTuple(args, "":numargs""))"
28338
 
 extending/extending,,:set,"if (PyArg_ParseTuple(args, ""O:set_callback"", &temp)) {"
28339
 
@@ -165,35 +164,6 @@
28340
 
 whatsnew/2.5,,:step,[start:stop:step]
28341
 
 whatsnew/2.5,,:stop,[start:stop:step]
28342
 
 distutils/examples,267,`,This is the description of the ``foobar`` package.
28343
 
-documenting/fromlatex,39,:func,:func:`str(object)`
28344
 
-documenting/fromlatex,39,`,:func:`str(object)`
28345
 
-documenting/fromlatex,39,`,``str(object)``
28346
 
-documenting/fromlatex,55,.. deprecated:,.. deprecated:: 2.5
28347
 
-documenting/fromlatex,66,.. note:,.. note::
28348
 
-documenting/fromlatex,76,:samp,":samp:`open({filename}, {mode})`"
28349
 
-documenting/fromlatex,76,`,":samp:`open({filename}, {mode})`"
28350
 
-documenting/fromlatex,80,`,``'c'``
28351
 
-documenting/fromlatex,80,`,`Title <URL>`_
28352
 
-documenting/fromlatex,80,`,``code``
28353
 
-documenting/fromlatex,80,`,`Title <URL>`_
28354
 
-documenting/fromlatex,99,:file,:file:`C:\\Temp\\my.tmp`
28355
 
-documenting/fromlatex,99,`,:file:`C:\\Temp\\my.tmp`
28356
 
-documenting/fromlatex,99,`,"``open(""C:\Temp\my.tmp"")``"
28357
 
-documenting/fromlatex,129,.. function:,.. function:: do_foo(bar)
28358
 
-documenting/fromlatex,141,.. function:,".. function:: open(filename[, mode[, buffering]])"
28359
 
-documenting/fromlatex,152,.. function:,.. function:: foo_*
28360
 
-documenting/fromlatex,152,:noindex,:noindex:
28361
 
-documenting/fromlatex,162,.. describe:,.. describe:: a == b
28362
 
-documenting/fromlatex,168,.. cmdoption:,.. cmdoption:: -O
28363
 
-documenting/fromlatex,168,.. envvar:,.. envvar:: PYTHONINSPECT
28364
 
-documenting/rest,33,`,``text``
28365
 
-documenting/rest,47,:rolename,:rolename:`content`
28366
 
-documenting/rest,47,`,:rolename:`content`
28367
 
-documenting/rest,103,::,This is a normal text paragraph. The next paragraph is a code sample::
28368
 
-documenting/rest,130,`,`Link text <http://target>`_
28369
 
-documenting/rest,187,.. function:,.. function:: foo(x)
28370
 
-documenting/rest,187,:bar,:bar: no
28371
 
-documenting/rest,208,.. rubric:,.. rubric:: Footnotes
28372
 
 faq/programming,,:reduce,"print (lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y,"
28373
 
 faq/programming,,:reduce,"Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro,"
28374
 
 faq/programming,,:chr,">=4.0) or 1+f(xc,yc,x*x-y*y+xc,2.0*x*y+yc,k-1,f):f(xc,yc,x,y,k,f):chr("
28375
 
@@ -222,81 +192,7 @@
28376
 
 whatsnew/2.7,862,:Cookie,"export PYTHONWARNINGS=all,error:::Cookie:0"
28377
 
 whatsnew/2.7,,::,>>> urlparse.urlparse('http://[1080::8:800:200C:417A]/foo')
28378
 
 whatsnew/2.7,,::,"ParseResult(scheme='http', netloc='[1080::8:800:200C:417A]',"
28379
 
-documenting/markup,33,.. sectionauthor:,.. sectionauthor:: Guido van Rossum <guido@python.org>
28380
 
-documenting/markup,42,:mod,:mod:`parrot` -- Dead parrot access
28381
 
-documenting/markup,42,`,:mod:`parrot` -- Dead parrot access
28382
 
-documenting/markup,42,.. module:,.. module:: parrot
28383
 
-documenting/markup,42,:platform,":platform: Unix, Windows"
28384
 
-documenting/markup,42,:synopsis,:synopsis: Analyze and reanimate dead parrots.
28385
 
-documenting/markup,42,.. moduleauthor:,.. moduleauthor:: Eric Cleese <eric@python.invalid>
28386
 
-documenting/markup,42,.. moduleauthor:,.. moduleauthor:: John Idle <john@python.invalid>
28387
 
-documenting/markup,88,:noindex,:noindex:
28388
 
-documenting/markup,95,.. function:,.. function:: spam(eggs)
28389
 
-documenting/markup,95,:noindex,:noindex:
28390
 
-documenting/markup,101,.. method:,.. method:: FileInput.input(...)
28391
 
-documenting/markup,121,.. cfunction:,".. cfunction:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)"
28392
 
-documenting/markup,131,.. cmember:,.. cmember:: PyObject* PyTypeObject.tp_bases
28393
 
-documenting/markup,150,.. cvar:,.. cvar:: PyObject* PyClass_Type
28394
 
-documenting/markup,179,.. function:,".. function:: Timer.repeat([repeat=3[, number=1000000]])"
28395
 
-documenting/markup,209,.. cmdoption:,.. cmdoption:: -m <module>
28396
 
-documenting/markup,227,.. describe:,.. describe:: opcode
28397
 
-documenting/markup,256,.. highlightlang:,.. highlightlang:: c
28398
 
-documenting/markup,276,.. literalinclude:,.. literalinclude:: example.py
28399
 
-documenting/markup,291,:rolename,:rolename:`content`
28400
 
-documenting/markup,291,`,:rolename:`content`
28401
 
-documenting/markup,296,:role,:role:`title <target>`
28402
 
-documenting/markup,296,`,:role:`title <target>`
28403
 
-documenting/markup,302,:meth,:meth:`~Queue.Queue.get`
28404
 
-documenting/markup,302,`,:meth:`~Queue.Queue.get`
28405
 
-documenting/markup,350,:func,:func:`filter`
28406
 
-documenting/markup,350,`,:func:`filter`
28407
 
-documenting/markup,350,:func,:func:`foo.filter`
28408
 
-documenting/markup,350,`,:func:`foo.filter`
28409
 
-documenting/markup,356,:func,:func:`open`
28410
 
-documenting/markup,356,`,:func:`open`
28411
 
-documenting/markup,356,:func,:func:`.open`
28412
 
-documenting/markup,356,`,:func:`.open`
28413
 
-documenting/markup,435,:file,... is installed in :file:`/usr/lib/python2.{x}/site-packages` ...
28414
 
-documenting/markup,435,`,... is installed in :file:`/usr/lib/python2.{x}/site-packages` ...
28415
 
-documenting/markup,454,:kbd,:kbd:`C-x C-f`
28416
 
-documenting/markup,454,`,:kbd:`C-x C-f`
28417
 
-documenting/markup,454,:kbd,:kbd:`Control-x Control-f`
28418
 
-documenting/markup,454,`,:kbd:`Control-x Control-f`
28419
 
-documenting/markup,468,:mailheader,:mailheader:`Content-Type`
28420
 
-documenting/markup,468,`,:mailheader:`Content-Type`
28421
 
-documenting/markup,477,:manpage,:manpage:`ls(1)`
28422
 
-documenting/markup,477,`,:manpage:`ls(1)`
28423
 
-documenting/markup,493,:menuselection,:menuselection:`Start --> Programs`
28424
 
-documenting/markup,493,`,:menuselection:`Start --> Programs`
28425
 
-documenting/markup,508,`,``code``
28426
 
-documenting/markup,526,:file,:file:
28427
 
-documenting/markup,526,`,``code``
28428
 
-documenting/markup,561,:ref,:ref:`label-name`
28429
 
-documenting/markup,561,`,:ref:`label-name`
28430
 
-documenting/markup,565,:ref,"It refers to the section itself, see :ref:`my-reference-label`."
28431
 
-documenting/markup,565,`,"It refers to the section itself, see :ref:`my-reference-label`."
28432
 
-documenting/markup,574,:ref,:ref:
28433
 
-documenting/markup,595,.. note:,.. note::
28434
 
-documenting/markup,622,.. versionadded:,.. versionadded:: 2.5
28435
 
-documenting/markup,647,::,.. impl-detail::
28436
 
-documenting/markup,647,::,.. impl-detail:: This shortly mentions an implementation detail.
28437
 
-documenting/markup,667,.. seealso:,.. seealso::
28438
 
-documenting/markup,667,:mod,Module :mod:`zipfile`
28439
 
-documenting/markup,667,`,Module :mod:`zipfile`
28440
 
-documenting/markup,667,:mod,Documentation of the :mod:`zipfile` standard module.
28441
 
-documenting/markup,667,`,Documentation of the :mod:`zipfile` standard module.
28442
 
-documenting/markup,667,`,"`GNU tar manual, Basic Tar Format <http://link>`_"
28443
 
-documenting/markup,681,.. centered:,.. centered::
28444
 
-documenting/markup,726,.. toctree:,.. toctree::
28445
 
-documenting/markup,726,:maxdepth,:maxdepth: 2
28446
 
-documenting/markup,742,.. index:,.. index::
28447
 
-documenting/markup,772,.. index:,".. index:: BNF, grammar, syntax, notation"
28448
 
-documenting/markup,803,`,"unaryneg ::= ""-"" `integer`"
28449
 
-documenting/markup,808,.. productionlist:,.. productionlist::
28450
 
-documenting/markup,808,`,"try1_stmt: ""try"" "":"" `suite`"
28451
 
-documenting/markup,808,`,": (""except"" [`expression` ["","" `target`]] "":"" `suite`)+"
28452
 
-documenting/markup,808,`,": [""else"" "":"" `suite`]"
28453
 
-documenting/markup,808,`,": [""finally"" "":"" `suite`]"
28454
 
-documenting/markup,808,`,"try2_stmt: ""try"" "":"" `suite`"
28455
 
-documenting/markup,808,`,": ""finally"" "":"" `suite`"
28456
 
+howto/pyporting,75,::,# make sure to use :: Python *and* :: Python :: 3 so
28457
 
+howto/pyporting,75,::,"'Programming Language :: Python',"
28458
 
+howto/pyporting,75,::,'Programming Language :: Python :: 3'
28459
 
 library/urllib2,67,:close,Connection:close
28460
 
diff -r 8527427914a2 Doc/tutorial/classes.rst
28461
 
--- a/Doc/tutorial/classes.rst
28462
 
+++ b/Doc/tutorial/classes.rst
28463
 
@@ -409,8 +409,8 @@
28464
 
            self.add(x)
28465
 
 
28466
 
 Methods may reference global names in the same way as ordinary functions.  The
28467
 
-global scope associated with a method is the module containing the class
28468
 
-definition.  (The class itself is never used as a global scope.)  While one
28469
 
+global scope associated with a method is the module containing its
28470
 
+definition.  (A class is never used as a global scope.)  While one
28471
 
 rarely encounters a good reason for using global data in a method, there are
28472
 
 many legitimate uses of the global scope: for one thing, functions and modules
28473
 
 imported into the global scope can be used by methods, as well as functions and
28474
 
@@ -553,6 +553,28 @@
28475
 
 without regard to the syntactic position of the identifier, as long as it
28476
 
 occurs within the definition of a class.
28477
 
 
28478
 
+Name mangling is helpful for letting subclasses override methods without
28479
 
+breaking intraclass method calls.  For example::
28480
 
+
28481
 
+   class Mapping:
28482
 
+       def __init__(self, iterable):
28483
 
+           self.items_list = []
28484
 
+           self.__update(iterable)
28485
 
+
28486
 
+       def update(self, iterable):
28487
 
+           for item in iterable:
28488
 
+               self.items_list.append(item)
28489
 
+
28490
 
+       __update = update   # private copy of original update() method
28491
 
+
28492
 
+   class MappingSubclass(Mapping):
28493
 
+
28494
 
+       def update(self, keys, values):
28495
 
+           # provides new signature for update()
28496
 
+           # but does not break __init__()
28497
 
+           for item in zip(keys, values):
28498
 
+               self.items_list.append(item)
28499
 
+
28500
 
 Note that the mangling rules are designed mostly to avoid accidents; it still is
28501
 
 possible to access or modify a variable that is considered private.  This can
28502
 
 even be useful in special circumstances, such as in the debugger.
28503
 
diff -r 8527427914a2 Doc/tutorial/controlflow.rst
28504
 
--- a/Doc/tutorial/controlflow.rst
28505
 
+++ b/Doc/tutorial/controlflow.rst
28506
 
@@ -156,6 +156,9 @@
28507
 
    8 equals 2 * 4
28508
 
    9 equals 3 * 3
28509
 
 
28510
 
+(Yes, this is the correct code.  Look closely: the ``else`` clause belongs to
28511
 
+the :keyword:`for` loop, **not** the :keyword:`if` statement.)
28512
 
+
28513
 
 
28514
 
 .. _tut-pass:
28515
 
 
28516
 
@@ -380,8 +383,8 @@
28517
 
 Keyword Arguments
28518
 
 -----------------
28519
 
 
28520
 
-Functions can also be called using keyword arguments of the form ``keyword =
28521
 
-value``.  For instance, the following function::
28522
 
+Functions can also be called using :term:`keyword arguments <keyword argument>`
28523
 
+of the form ``kwarg=value``.  For instance, the following function::
28524
 
 
28525
 
    def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'):
28526
 
        print "-- This parrot wouldn't", action,
28527
 
@@ -389,26 +392,31 @@
28528
 
        print "-- Lovely plumage, the", type
28529
 
        print "-- It's", state, "!"
28530
 
 
28531
 
-could be called in any of the following ways::
28532
 
+accepts one required argument (``voltage``) and three optional arguments
28533
 
+(``state``, ``action``, and ``type``).  This function can be called in any
28534
 
+of the following ways::
28535
 
 
28536
 
-   parrot(1000)
28537
 
-   parrot(action = 'VOOOOOM', voltage = 1000000)
28538
 
-   parrot('a thousand', state = 'pushing up the daisies')
28539
 
-   parrot('a million', 'bereft of life', 'jump')
28540
 
+   parrot(1000)                                          # 1 positional argument
28541
 
+   parrot(voltage=1000)                                  # 1 keyword argument
28542
 
+   parrot(voltage=1000000, action='VOOOOOM')             # 2 keyword arguments
28543
 
+   parrot(action='VOOOOOM', voltage=1000000)             # 2 keyword arguments
28544
 
+   parrot('a million', 'bereft of life', 'jump')         # 3 positional arguments
28545
 
+   parrot('a thousand', state='pushing up the daisies')  # 1 positional, 1 keyword
28546
 
 
28547
 
-but the following calls would all be invalid::
28548
 
+but all the following calls would be invalid::
28549
 
 
28550
 
    parrot()                     # required argument missing
28551
 
-   parrot(voltage=5.0, 'dead')  # non-keyword argument following keyword
28552
 
-   parrot(110, voltage=220)     # duplicate value for argument
28553
 
-   parrot(actor='John Cleese')  # unknown keyword
28554
 
+   parrot(voltage=5.0, 'dead')  # non-keyword argument after a keyword argument
28555
 
+   parrot(110, voltage=220)     # duplicate value for the same argument
28556
 
+   parrot(actor='John Cleese')  # unknown keyword argument
28557
 
 
28558
 
-In general, an argument list must have any positional arguments followed by any
28559
 
-keyword arguments, where the keywords must be chosen from the formal parameter
28560
 
-names.  It's not important whether a formal parameter has a default value or
28561
 
-not.  No argument may receive a value more than once --- formal parameter names
28562
 
-corresponding to positional arguments cannot be used as keywords in the same
28563
 
-calls. Here's an example that fails due to this restriction::
28564
 
+In a function call, keyword arguments must follow positional arguments.
28565
 
+All the keyword arguments passed must match one of the arguments
28566
 
+accepted by the function (e.g. ``actor`` is not a valid argument for the
28567
 
+``parrot`` function), and their order is not important.  This also includes
28568
 
+non-optional arguments (e.g. ``parrot(voltage=1000)`` is valid too).
28569
 
+No argument may receive a value more than once.
28570
 
+Here's an example that fails due to this restriction::
28571
 
 
28572
 
    >>> def function(a):
28573
 
    ...     pass
28574
 
diff -r 8527427914a2 Doc/tutorial/datastructures.rst
28575
 
--- a/Doc/tutorial/datastructures.rst
28576
 
+++ b/Doc/tutorial/datastructures.rst
28577
 
@@ -170,8 +170,8 @@
28578
 
 ``filter(function, sequence)`` returns a sequence consisting of those items from
28579
 
 the sequence for which ``function(item)`` is true. If *sequence* is a
28580
 
 :class:`string` or :class:`tuple`, the result will be of the same type;
28581
 
-otherwise, it is always a :class:`list`. For example, to compute primes up
28582
 
-to 25::
28583
 
+otherwise, it is always a :class:`list`. For example, to compute a sequence of
28584
 
+numbers not divisible by 2 and 3::
28585
 
 
28586
 
    >>> def f(x): return x % 2 != 0 and x % 3 != 0
28587
 
    ...
28588
 
@@ -235,89 +235,139 @@
28589
 
 List Comprehensions
28590
 
 -------------------
28591
 
 
28592
 
-List comprehensions provide a concise way to create lists without resorting to
28593
 
-use of :func:`map`, :func:`filter` and/or :keyword:`lambda`. The resulting list
28594
 
-definition tends often to be clearer than lists built using those constructs.
28595
 
-Each list comprehension consists of an expression followed by a :keyword:`for`
28596
 
-clause, then zero or more :keyword:`for` or :keyword:`if` clauses.  The result
28597
 
-will be a list resulting from evaluating the expression in the context of the
28598
 
-:keyword:`for` and :keyword:`if` clauses which follow it.  If the expression
28599
 
-would evaluate to a tuple, it must be parenthesized. ::
28600
 
+List comprehensions provide a concise way to create lists.
28601
 
+Common applications are to make new lists where each element is the result of
28602
 
+some operations applied to each member of another sequence or iterable, or to
28603
 
+create a subsequence of those elements that satisfy a certain condition.
28604
 
 
28605
 
+For example, assume we want to create a list of squares, like::
28606
 
+
28607
 
+   >>> squares = []
28608
 
+   >>> for x in range(10):
28609
 
+   ...     squares.append(x**2)
28610
 
+   ...
28611
 
+   >>> squares
28612
 
+   [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
28613
 
+
28614
 
+We can obtain the same result with::
28615
 
+
28616
 
+   squares = [x**2 for x in range(10)]
28617
 
+
28618
 
+This is also equivalent to ``squares = map(lambda x: x**2, range(10))``,
28619
 
+but it's more concise and readable.
28620
 
+
28621
 
+A list comprehension consists of brackets containing an expression followed
28622
 
+by a :keyword:`for` clause, then zero or more :keyword:`for` or :keyword:`if`
28623
 
+clauses.  The result will be a new list resulting from evaluating the expression
28624
 
+in the context of the :keyword:`for` and :keyword:`if` clauses which follow it.
28625
 
+For example, this listcomp combines the elements of two lists if they are not
28626
 
+equal::
28627
 
+
28628
 
+   >>> [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y]
28629
 
+   [(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]
28630
 
+
28631
 
+and it's equivalent to:
28632
 
+
28633
 
+   >>> combs = []
28634
 
+   >>> for x in [1,2,3]:
28635
 
+   ...     for y in [3,1,4]:
28636
 
+   ...         if x != y:
28637
 
+   ...             combs.append((x, y))
28638
 
+   ...
28639
 
+   >>> combs
28640
 
+   [(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]
28641
 
+
28642
 
+Note how the order of the :keyword:`for` and :keyword:`if` statements is the
28643
 
+same in both these snippets.
28644
 
+
28645
 
+If the expression is a tuple (e.g. the ``(x, y)`` in the previous example),
28646
 
+it must be parenthesized. ::
28647
 
+
28648
 
+   >>> vec = [-4, -2, 0, 2, 4]
28649
 
+   >>> # create a new list with the values doubled
28650
 
+   >>> [x*2 for x in vec]
28651
 
+   [-8, -4, 0, 4, 8]
28652
 
+   >>> # filter the list to exclude negative numbers
28653
 
+   >>> [x for x in vec if x >= 0]
28654
 
+   [0, 2, 4]
28655
 
+   >>> # apply a function to all the elements
28656
 
+   >>> [abs(x) for x in vec]
28657
 
+   [4, 2, 0, 2, 4]
28658
 
+   >>> # call a method on each element
28659
 
    >>> freshfruit = ['  banana', '  loganberry ', 'passion fruit  ']
28660
 
    >>> [weapon.strip() for weapon in freshfruit]
28661
 
    ['banana', 'loganberry', 'passion fruit']
28662
 
-   >>> vec = [2, 4, 6]
28663
 
-   >>> [3*x for x in vec]
28664
 
-   [6, 12, 18]
28665
 
-   >>> [3*x for x in vec if x > 3]
28666
 
-   [12, 18]
28667
 
-   >>> [3*x for x in vec if x < 2]
28668
 
-   []
28669
 
-   >>> [[x,x**2] for x in vec]
28670
 
-   [[2, 4], [4, 16], [6, 36]]
28671
 
-   >>> [x, x**2 for x in vec]  # error - parens required for tuples
28672
 
-     File "<stdin>", line 1, in ?
28673
 
-       [x, x**2 for x in vec]
28674
 
+   >>> # create a list of 2-tuples like (number, square)
28675
 
+   >>> [(x, x**2) for x in range(6)]
28676
 
+   [(0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (5, 25)]
28677
 
+   >>> # the tuple must be parenthesized, otherwise an error is raised
28678
 
+   >>> [x, x**2 for x in range(6)]
28679
 
+     File "<stdin>", line 1
28680
 
+       [x, x**2 for x in range(6)]
28681
 
                   ^
28682
 
    SyntaxError: invalid syntax
28683
 
-   >>> [(x, x**2) for x in vec]
28684
 
-   [(2, 4), (4, 16), (6, 36)]
28685
 
-   >>> vec1 = [2, 4, 6]
28686
 
-   >>> vec2 = [4, 3, -9]
28687
 
-   >>> [x*y for x in vec1 for y in vec2]
28688
 
-   [8, 6, -18, 16, 12, -36, 24, 18, -54]
28689
 
-   >>> [x+y for x in vec1 for y in vec2]
28690
 
-   [6, 5, -7, 8, 7, -5, 10, 9, -3]
28691
 
-   >>> [vec1[i]*vec2[i] for i in range(len(vec1))]
28692
 
-   [8, 12, -54]
28693
 
+   >>> # flatten a list using a listcomp with two 'for'
28694
 
+   >>> vec = [[1,2,3], [4,5,6], [7,8,9]]
28695
 
+   >>> [num for elem in vec for num in elem]
28696
 
+   [1, 2, 3, 4, 5, 6, 7, 8, 9]
28697
 
 
28698
 
-List comprehensions are much more flexible than :func:`map` and can be applied
28699
 
-to complex expressions and nested functions::
28700
 
+List comprehensions can contain complex expressions and nested functions::
28701
 
 
28702
 
-   >>> [str(round(355/113.0, i)) for i in range(1,6)]
28703
 
+   >>> from math import pi
28704
 
+   >>> [str(round(pi, i)) for i in range(1, 6)]
28705
 
    ['3.1', '3.14', '3.142', '3.1416', '3.14159']
28706
 
 
28707
 
 
28708
 
 Nested List Comprehensions
28709
 
---------------------------
28710
 
+''''''''''''''''''''''''''
28711
 
 
28712
 
-If you've got the stomach for it, list comprehensions can be nested. They are a
28713
 
-powerful tool but -- like all powerful tools -- they need to be used carefully,
28714
 
-if at all.
28715
 
+The initial expression in a list comprehension can be any arbitrary expression,
28716
 
+including another list comprehension.
28717
 
 
28718
 
-Consider the following example of a 3x3 matrix held as a list containing three
28719
 
-lists, one list per row::
28720
 
+Consider the following example of a 3x4 matrix implemented as a list of
28721
 
+3 lists of length 4::
28722
 
 
28723
 
-    >>> mat = [
28724
 
-    ...        [1, 2, 3],
28725
 
-    ...        [4, 5, 6],
28726
 
-    ...        [7, 8, 9],
28727
 
-    ...       ]
28728
 
+   >>> matrix = [
28729
 
+   ...     [1, 2, 3, 4],
28730
 
+   ...     [5, 6, 7, 8],
28731
 
+   ...     [9, 10, 11, 12],
28732
 
+   ... ]
28733
 
 
28734
 
-Now, if you wanted to swap rows and columns, you could use a list
28735
 
-comprehension::
28736
 
+The following list comprehension will transpose rows and columns::
28737
 
 
28738
 
-    >>> print [[row[i] for row in mat] for i in [0, 1, 2]]
28739
 
-    [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
28740
 
+   >>> [[row[i] for row in matrix] for i in range(4)]
28741
 
+   [[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]
28742
 
 
28743
 
-Special care has to be taken for the *nested* list comprehension:
28744
 
+As we saw in the previous section, the nested listcomp is evaluated in
28745
 
+the context of the :keyword:`for` that follows it, so this example is
28746
 
+equivalent to::
28747
 
 
28748
 
-    To avoid apprehension when nesting list comprehensions, read from right to
28749
 
-    left.
28750
 
+   >>> transposed = []
28751
 
+   >>> for i in range(4):
28752
 
+   ...     transposed.append([row[i] for row in matrix])
28753
 
+   ...
28754
 
+   >>> transposed
28755
 
+   [[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]
28756
 
 
28757
 
-A more verbose version of this snippet shows the flow explicitly::
28758
 
+which, in turn, is the same as::
28759
 
 
28760
 
-    for i in [0, 1, 2]:
28761
 
-        for row in mat:
28762
 
-            print row[i],
28763
 
-        print
28764
 
+   >>> transposed = []
28765
 
+   >>> for i in range(4):
28766
 
+   ...     # the following 3 lines implement the nested listcomp
28767
 
+   ...     transposed_row = []
28768
 
+   ...     for row in matrix:
28769
 
+   ...         transposed_row.append(row[i])
28770
 
+   ...     transposed.append(transposed_row)
28771
 
+   ...
28772
 
+   >>> transposed
28773
 
+   [[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]
28774
 
 
28775
 
-In real world, you should prefer built-in functions to complex flow statements.
28776
 
+
28777
 
+In the real world, you should prefer built-in functions to complex flow statements.
28778
 
 The :func:`zip` function would do a great job for this use case::
28779
 
 
28780
 
-    >>> zip(*mat)
28781
 
-    [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
28782
 
+   >>> zip(*matrix)
28783
 
+   [(1, 5, 9), (2, 6, 10), (3, 7, 11), (4, 8, 12)]
28784
 
 
28785
 
 See :ref:`tut-unpacking-arguments` for details on the asterisk in this line.
28786
 
 
28787
 
diff -r 8527427914a2 Doc/tutorial/inputoutput.rst
28788
 
--- a/Doc/tutorial/inputoutput.rst
28789
 
+++ b/Doc/tutorial/inputoutput.rst
28790
 
@@ -207,7 +207,7 @@
28791
 
 ---------------------
28792
 
 
28793
 
 The ``%`` operator can also be used for string formatting. It interprets the
28794
 
-left argument much like a :cfunc:`sprintf`\ -style format string to be applied
28795
 
+left argument much like a :c:func:`sprintf`\ -style format string to be applied
28796
 
 to the right argument, and returns the string resulting from this formatting
28797
 
 operation. For example::
28798
 
 
28799
 
diff -r 8527427914a2 Doc/tutorial/interactive.rst
28800
 
--- a/Doc/tutorial/interactive.rst
28801
 
+++ b/Doc/tutorial/interactive.rst
28802
 
@@ -156,17 +156,18 @@
28803
 
 quotes, etc., would also be useful.
28804
 
 
28805
 
 One alternative enhanced interactive interpreter that has been around for quite
28806
 
-some time is `IPython`_, which features tab completion, object exploration and
28807
 
+some time is IPython_, which features tab completion, object exploration and
28808
 
 advanced history management.  It can also be thoroughly customized and embedded
28809
 
 into other applications.  Another similar enhanced interactive environment is
28810
 
-`bpython`_.
28811
 
+bpython_.
28812
 
 
28813
 
 
28814
 
 .. rubric:: Footnotes
28815
 
 
28816
 
 .. [#] Python will execute the contents of a file identified by the
28817
 
    :envvar:`PYTHONSTARTUP` environment variable when you start an interactive
28818
 
-   interpreter.
28819
 
+   interpreter.  To customize Python even for non-interactive mode, see
28820
 
+   :ref:`tut-customize`.
28821
 
 
28822
 
 
28823
 
 .. _GNU Readline: http://tiswww.case.edu/php/chet/readline/rltop.html
28824
 
diff -r 8527427914a2 Doc/tutorial/interpreter.rst
28825
 
--- a/Doc/tutorial/interpreter.rst
28826
 
+++ b/Doc/tutorial/interpreter.rst
28827
 
@@ -60,8 +60,7 @@
28828
 
 
28829
 
 When a script file is used, it is sometimes useful to be able to run the script
28830
 
 and enter interactive mode afterwards.  This can be done by passing :option:`-i`
28831
 
-before the script.  (This does not work if the script is read from standard
28832
 
-input, for the same reason as explained in the previous paragraph.)
28833
 
+before the script.
28834
 
 
28835
 
 
28836
 
 .. _tut-argpassing:
28837
 
@@ -166,6 +165,8 @@
28838
 
 suppressed.
28839
 
 
28840
 
 
28841
 
+.. _tut-source-encoding:
28842
 
+
28843
 
 Source Code Encoding
28844
 
 --------------------
28845
 
 
28846
 
@@ -240,7 +241,29 @@
28847
 
        execfile(filename)
28848
 
 
28849
 
 
28850
 
+.. _tut-customize:
28851
 
+
28852
 
+The Customization Modules
28853
 
+-------------------------
28854
 
+
28855
 
+Python provides two hooks to let you customize it: :mod:`sitecustomize` and
28856
 
+:mod:`usercustomize`.  To see how it works, you need first to find the location
28857
 
+of your user site-packages directory.  Start Python and run this code:
28858
 
+
28859
 
+   >>> import site
28860
 
+   >>> site.getusersitepackages()
28861
 
+   '/home/user/.local/lib/python3.2/site-packages'
28862
 
+
28863
 
+Now you can create a file named :file:`usercustomize.py` in that directory and
28864
 
+put anything you want in it.  It will affect every invocation of Python, unless
28865
 
+it is started with the :option:`-s` option to disable the automatic import.
28866
 
+
28867
 
+:mod:`sitecustomize` works in the same way, but is typically created by an
28868
 
+administrator of the computer in the global site-packages directory, and is
28869
 
+imported before :mod:`usercustomize`.  See the documentation of the :mod:`site`
28870
 
+module for more details.
28871
 
+
28872
 
+
28873
 
 .. rubric:: Footnotes
28874
 
 
28875
 
 .. [#] A problem with the GNU Readline package may prevent this.
28876
 
-
28877
 
diff -r 8527427914a2 Doc/tutorial/introduction.rst
28878
 
--- a/Doc/tutorial/introduction.rst
28879
 
+++ b/Doc/tutorial/introduction.rst
28880
 
@@ -240,13 +240,6 @@
28881
 
    This is a rather long string containing\n\
28882
 
    several lines of text much as you would do in C.
28883
 
 
28884
 
-The interpreter prints the result of string operations in the same way as they
28885
 
-are typed for input: inside quotes, and with quotes and other funny characters
28886
 
-escaped by backslashes, to show the precise value.  The string is enclosed in
28887
 
-double quotes if the string contains a single quote and no double quotes, else
28888
 
-it's enclosed in single quotes.  (The :keyword:`print` statement, described
28889
 
-later, can be used to write strings without quotes or escapes.)
28890
 
-
28891
 
 Strings can be concatenated (glued together) with the ``+`` operator, and
28892
 
 repeated with ``*``::
28893
 
 
28894
 
@@ -637,13 +630,13 @@
28895
 
   and ``!=`` (not equal to).
28896
 
 
28897
 
 * The *body* of the loop is *indented*: indentation is Python's way of grouping
28898
 
-  statements.  Python does not (yet!) provide an intelligent input line editing
28899
 
-  facility, so you have to type a tab or space(s) for each indented line.  In
28900
 
-  practice you will prepare more complicated input for Python with a text editor;
28901
 
-  most text editors have an auto-indent facility.  When a compound statement is
28902
 
-  entered interactively, it must be followed by a blank line to indicate
28903
 
-  completion (since the parser cannot guess when you have typed the last line).
28904
 
-  Note that each line within a basic block must be indented by the same amount.
28905
 
+  statements.  At the interactive prompt, you have to type a tab or space(s) for
28906
 
+  each indented line.  In practice you will prepare more complicated input
28907
 
+  for Python with a text editor; all decent text editors have an auto-indent
28908
 
+  facility.  When a compound statement is entered interactively, it must be
28909
 
+  followed by a blank line to indicate completion (since the parser cannot
28910
 
+  guess when you have typed the last line).  Note that each line within a basic
28911
 
+  block must be indented by the same amount.
28912
 
 
28913
 
 * The :keyword:`print` statement writes the value of the expression(s) it is
28914
 
   given.  It differs from just writing the expression you want to write (as we did
28915
 
diff -r 8527427914a2 Doc/tutorial/modules.rst
28916
 
--- a/Doc/tutorial/modules.rst
28917
 
+++ b/Doc/tutorial/modules.rst
28918
 
@@ -155,23 +155,22 @@
28919
 
 
28920
 
 .. index:: triple: module; search; path
28921
 
 
28922
 
-When a module named :mod:`spam` is imported, the interpreter searches for a file
28923
 
-named :file:`spam.py` in the current directory, and then in the list of
28924
 
-directories specified by the environment variable :envvar:`PYTHONPATH`.  This
28925
 
-has the same syntax as the shell variable :envvar:`PATH`, that is, a list of
28926
 
-directory names.  When :envvar:`PYTHONPATH` is not set, or when the file is not
28927
 
-found there, the search continues in an installation-dependent default path; on
28928
 
-Unix, this is usually :file:`.:/usr/local/lib/python`.
28929
 
+When a module named :mod:`spam` is imported, the interpreter first searches for
28930
 
+a built-in module with that name. If not found, it then searches for a file
28931
 
+named :file:`spam.py` in a list of directories given by the variable
28932
 
+:data:`sys.path`.  :data:`sys.path` is initialized from these locations:
28933
 
 
28934
 
-Actually, modules are searched in the list of directories given by the variable
28935
 
-``sys.path`` which is initialized from the directory containing the input script
28936
 
-(or the current directory), :envvar:`PYTHONPATH` and the installation- dependent
28937
 
-default.  This allows Python programs that know what they're doing to modify or
28938
 
-replace the module search path.  Note that because the directory containing the
28939
 
-script being run is on the search path, it is important that the script not have
28940
 
-the same name as a standard module, or Python will attempt to load the script as
28941
 
-a module when that module is imported. This will generally be an error.  See
28942
 
-section :ref:`tut-standardmodules` for more information.
28943
 
+* the directory containing the input script (or the current directory).
28944
 
+* :envvar:`PYTHONPATH` (a list of directory names, with the same syntax as the
28945
 
+  shell variable :envvar:`PATH`).
28946
 
+* the installation-dependent default.
28947
 
+
28948
 
+After initialization, Python programs can modify :data:`sys.path`.  The
28949
 
+directory containing the script being run is placed at the beginning of the
28950
 
+search path, ahead of the standard library path. This means that scripts in that
28951
 
+directory will be loaded instead of modules of the same name in the library
28952
 
+directory. This is an error unless the replacement is intended.  See section
28953
 
+:ref:`tut-standardmodules` for more information.
28954
 
 
28955
 
 
28956
 
 "Compiled" Python files
28957
 
diff -r 8527427914a2 Doc/using/cmdline.rst
28958
 
--- a/Doc/using/cmdline.rst
28959
 
+++ b/Doc/using/cmdline.rst
28960
 
@@ -255,7 +255,8 @@
28961
 
 
28962
 
 .. cmdoption:: -s
28963
 
 
28964
 
-   Don't add user site directory to sys.path
28965
 
+   Don't add the :data:`user site-packages directory <site.USER_SITE>` to
28966
 
+   :data:`sys.path`.
28967
 
 
28968
 
    .. versionadded:: 2.6
28969
 
 
28970
 
@@ -511,7 +512,7 @@
28971
 
 .. envvar:: PYTHONCASEOK
28972
 
 
28973
 
    If this is set, Python ignores case in :keyword:`import` statements.  This
28974
 
-   only works on Windows.
28975
 
+   only works on Windows, OS X, OS/2, and RiscOS.
28976
 
 
28977
 
 
28978
 
 .. envvar:: PYTHONDONTWRITEBYTECODE
28979
 
@@ -532,7 +533,8 @@
28980
 
 
28981
 
 .. envvar:: PYTHONNOUSERSITE
28982
 
 
28983
 
-   If this is set, Python won't add the user site directory to sys.path
28984
 
+   If this is set, Python won't add the :data:`user site-packages directory
28985
 
+   <site.USER_SITE>` to :data:`sys.path`.
28986
 
 
28987
 
    .. versionadded:: 2.6
28988
 
 
28989
 
@@ -543,7 +545,10 @@
28990
 
 
28991
 
 .. envvar:: PYTHONUSERBASE
28992
 
 
28993
 
-   Sets the base directory for the user site directory
28994
 
+   Defines the :data:`user base directory <site.USER_BASE>`, which is used to
28995
 
+   compute the path of the :data:`user site-packages directory <site.USER_SITE>`
28996
 
+   and :ref:`Distutils installation paths <inst-alt-install-user>` for ``python
28997
 
+   setup.py install --user``.
28998
 
 
28999
 
    .. versionadded:: 2.6
29000
 
 
29001
 
@@ -569,7 +574,7 @@
29002
 
 ~~~~~~~~~~~~~~~~~~~~
29003
 
 
29004
 
 Setting these variables only has an effect in a debug build of Python, that is,
29005
 
-if Python was configured with the :option:`--with-pydebug` build option.
29006
 
+if Python was configured with the ``--with-pydebug`` build option.
29007
 
 
29008
 
 .. envvar:: PYTHONTHREADDEBUG
29009
 
 
29010
 
diff -r 8527427914a2 Doc/using/unix.rst
29011
 
--- a/Doc/using/unix.rst
29012
 
+++ b/Doc/using/unix.rst
29013
 
@@ -1,4 +1,4 @@
29014
 
-.. highlightlang:: none
29015
 
+.. highlightlang:: sh
29016
 
 
29017
 
 .. _using-on-unix:
29018
 
 
29019
 
@@ -26,11 +26,11 @@
29020
 
 
29021
 
 .. seealso::
29022
 
 
29023
 
-   http://www.linux.com/articles/60383
29024
 
+   http://www.debian.org/doc/manuals/maint-guide/first.en.html
29025
 
       for Debian users
29026
 
    http://linuxmafia.com/pub/linux/suse-linux-internals/chapter35.html
29027
 
       for OpenSuse users
29028
 
-   http://docs.fedoraproject.org/drafts/rpm-guide-en/ch-creating-rpms.html
29029
 
+   http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch-creating-rpms.html
29030
 
       for Fedora users
29031
 
    http://www.slackbook.org/html/package-management-making-packages.html
29032
 
       for Slackware users
29033
 
@@ -55,8 +55,8 @@
29034
 
 On OpenSolaris
29035
 
 --------------
29036
 
 
29037
 
-To install the newest Python versions on OpenSolaris, install blastwave
29038
 
-(http://www.blastwave.org/howto.html) and type "pkg_get -i python" at the
29039
 
+To install the newest Python versions on OpenSolaris, install `blastwave
29040
 
+<http://www.blastwave.org/howto.html>`_ and type ``pkg_get -i python`` at the
29041
 
 prompt.
29042
 
 
29043
 
 
29044
 
@@ -65,17 +65,18 @@
29045
 
 
29046
 
 If you want to compile CPython yourself, first thing you should do is get the
29047
 
 `source <http://python.org/download/source/>`_. You can download either the
29048
 
-latest release's source or just grab a fresh `checkout
29049
 
-<http://www.python.org/dev/faq/#how-do-i-get-a-checkout-of-the-repository-read-only-and-read-write>`_.
29050
 
+latest release's source or just grab a fresh `clone
29051
 
+<http://docs.python.org/devguide/setup#getting-the-source-code>`_.  (If you want
29052
 
+to contribute patches, you will need a clone.)
29053
 
 
29054
 
-The build process consists the usual ::
29055
 
+The build process consists in the usual ::
29056
 
 
29057
 
    ./configure
29058
 
    make
29059
 
    make install
29060
 
 
29061
 
 invocations. Configuration options and caveats for specific Unix platforms are
29062
 
-extensively documented in the :file:`README` file in the root of the Python
29063
 
+extensively documented in the :source:`README` file in the root of the Python
29064
 
 source tree.
29065
 
 
29066
 
 .. warning::
29067
 
diff -r 8527427914a2 Doc/using/windows.rst
29068
 
--- a/Doc/using/windows.rst
29069
 
+++ b/Doc/using/windows.rst
29070
 
@@ -47,9 +47,9 @@
29071
 
       "7 Minutes to "Hello World!""
29072
 
       by Richard Dooling, 2006
29073
 
 
29074
 
-   `Installing on Windows <http://diveintopython.org/installing_python/windows.html>`_
29075
 
+   `Installing on Windows <http://diveintopython.net/installing_python/windows.html>`_
29076
 
       in "`Dive into Python: Python from novice to pro
29077
 
-      <http://diveintopython.org/index.html>`_"
29078
 
+      <http://diveintopython.net/index.html>`_"
29079
 
       by Mark Pilgrim, 2004,
29080
 
       ISBN 1-59059-356-1
29081
 
 
29082
 
@@ -292,7 +292,7 @@
29083
 
 If you want to compile CPython yourself, first thing you should do is get the
29084
 
 `source <http://python.org/download/source/>`_. You can download either the
29085
 
 latest release's source or just grab a fresh `checkout
29086
 
-<http://www.python.org/dev/faq/#how-do-i-get-a-checkout-of-the-repository-read-only-and-read-write>`_.
29087
 
+<http://docs.python.org/devguide/setup#checking-out-the-code>`_.
29088
 
 
29089
 
 For Microsoft Visual C++, which is the compiler with which official Python
29090
 
 releases are built, the source tree contains solutions/project files.  View the
29091
 
diff -r 8527427914a2 Doc/whatsnew/2.2.rst
29092
 
--- a/Doc/whatsnew/2.2.rst
29093
 
+++ b/Doc/whatsnew/2.2.rst
29094
 
@@ -754,7 +754,7 @@
29095
 
 
29096
 
 * Classes can define methods called :meth:`__truediv__` and :meth:`__floordiv__`
29097
 
   to overload the two division operators.  At the C level, there are also slots in
29098
 
-  the :ctype:`PyNumberMethods` structure so extension types can define the two
29099
 
+  the :c:type:`PyNumberMethods` structure so extension types can define the two
29100
 
   operators.
29101
 
 
29102
 
 * Python 2.2 supports some command-line arguments for testing whether code will
29103
 
@@ -983,7 +983,7 @@
29104
 
   Jun-ichiro "itojun" Hagino.)
29105
 
 
29106
 
 * Two new format characters were added to the :mod:`struct` module for 64-bit
29107
 
-  integers on platforms that support the C :ctype:`long long` type.  ``q`` is for
29108
 
+  integers on platforms that support the C :c:type:`long long` type.  ``q`` is for
29109
 
   a signed 64-bit integer, and ``Q`` is for an unsigned one.  The value is
29110
 
   returned in Python's long integer type.  (Contributed by Tim Peters.)
29111
 
 
29112
 
@@ -1057,16 +1057,16 @@
29113
 
   at much higher speeds than Python-based functions and should reduce the overhead
29114
 
   of profiling and tracing.  This  will be of interest to authors of development
29115
 
   environments for Python.  Two new C functions were added to Python's API,
29116
 
-  :cfunc:`PyEval_SetProfile` and :cfunc:`PyEval_SetTrace`. The existing
29117
 
+  :c:func:`PyEval_SetProfile` and :c:func:`PyEval_SetTrace`. The existing
29118
 
   :func:`sys.setprofile` and :func:`sys.settrace` functions still exist, and have
29119
 
   simply been changed to use the new C-level interface.  (Contributed by Fred L.
29120
 
   Drake, Jr.)
29121
 
 
29122
 
 * Another low-level API, primarily of interest to implementors of Python
29123
 
-  debuggers and development tools, was added. :cfunc:`PyInterpreterState_Head` and
29124
 
-  :cfunc:`PyInterpreterState_Next` let a caller walk through all the existing
29125
 
-  interpreter objects; :cfunc:`PyInterpreterState_ThreadHead` and
29126
 
-  :cfunc:`PyThreadState_Next` allow looping over all the thread states for a given
29127
 
+  debuggers and development tools, was added. :c:func:`PyInterpreterState_Head` and
29128
 
+  :c:func:`PyInterpreterState_Next` let a caller walk through all the existing
29129
 
+  interpreter objects; :c:func:`PyInterpreterState_ThreadHead` and
29130
 
+  :c:func:`PyThreadState_Next` allow looping over all the thread states for a given
29131
 
   interpreter.  (Contributed by David Beazley.)
29132
 
 
29133
 
 * The C-level interface to the garbage collector has been changed to make it
29134
 
@@ -1078,19 +1078,19 @@
29135
 
 
29136
 
   To upgrade an extension module to the new API, perform the following steps:
29137
 
 
29138
 
-* Rename :cfunc:`Py_TPFLAGS_GC` to :cfunc:`PyTPFLAGS_HAVE_GC`.
29139
 
+* Rename :c:func:`Py_TPFLAGS_GC` to :c:func:`PyTPFLAGS_HAVE_GC`.
29140
 
 
29141
 
-* Use :cfunc:`PyObject_GC_New` or :cfunc:`PyObject_GC_NewVar` to allocate
29142
 
-    objects, and :cfunc:`PyObject_GC_Del` to deallocate them.
29143
 
+* Use :c:func:`PyObject_GC_New` or :c:func:`PyObject_GC_NewVar` to allocate
29144
 
+    objects, and :c:func:`PyObject_GC_Del` to deallocate them.
29145
 
 
29146
 
-* Rename :cfunc:`PyObject_GC_Init` to :cfunc:`PyObject_GC_Track` and
29147
 
-    :cfunc:`PyObject_GC_Fini` to :cfunc:`PyObject_GC_UnTrack`.
29148
 
+* Rename :c:func:`PyObject_GC_Init` to :c:func:`PyObject_GC_Track` and
29149
 
+    :c:func:`PyObject_GC_Fini` to :c:func:`PyObject_GC_UnTrack`.
29150
 
 
29151
 
-* Remove :cfunc:`PyGC_HEAD_SIZE` from object size calculations.
29152
 
+* Remove :c:func:`PyGC_HEAD_SIZE` from object size calculations.
29153
 
 
29154
 
-* Remove calls to :cfunc:`PyObject_AS_GC` and :cfunc:`PyObject_FROM_GC`.
29155
 
+* Remove calls to :c:func:`PyObject_AS_GC` and :c:func:`PyObject_FROM_GC`.
29156
 
 
29157
 
-* A new ``et`` format sequence was added to :cfunc:`PyArg_ParseTuple`; ``et``
29158
 
+* A new ``et`` format sequence was added to :c:func:`PyArg_ParseTuple`; ``et``
29159
 
   takes both a parameter and an encoding name, and converts the parameter to the
29160
 
   given encoding if the parameter turns out to be a Unicode string, or leaves it
29161
 
   alone if it's an 8-bit string, assuming it to already be in the desired
29162
 
@@ -1099,10 +1099,10 @@
29163
 
   specified new encoding. (Contributed by M.-A. Lemburg, and used for the MBCS
29164
 
   support on Windows described in the following section.)
29165
 
 
29166
 
-* A different argument parsing function, :cfunc:`PyArg_UnpackTuple`, has been
29167
 
+* A different argument parsing function, :c:func:`PyArg_UnpackTuple`, has been
29168
 
   added that's simpler and presumably faster.  Instead of specifying a format
29169
 
   string, the caller simply gives the minimum and maximum number of arguments
29170
 
-  expected, and a set of pointers to :ctype:`PyObject\*` variables that will be
29171
 
+  expected, and a set of pointers to :c:type:`PyObject\*` variables that will be
29172
 
   filled in with argument values.
29173
 
 
29174
 
 * Two new flags :const:`METH_NOARGS` and :const:`METH_O` are available in method
29175
 
@@ -1111,14 +1111,14 @@
29176
 
   corresponding method that uses :const:`METH_VARARGS`.  Also, the old
29177
 
   :const:`METH_OLDARGS` style of writing C methods is  now officially deprecated.
29178
 
 
29179
 
-* Two new wrapper functions, :cfunc:`PyOS_snprintf` and :cfunc:`PyOS_vsnprintf`
29180
 
+* Two new wrapper functions, :c:func:`PyOS_snprintf` and :c:func:`PyOS_vsnprintf`
29181
 
   were added to provide  cross-platform implementations for the relatively new
29182
 
-  :cfunc:`snprintf` and :cfunc:`vsnprintf` C lib APIs. In contrast to the standard
29183
 
-  :cfunc:`sprintf` and :cfunc:`vsprintf` functions, the Python versions check the
29184
 
+  :c:func:`snprintf` and :c:func:`vsnprintf` C lib APIs. In contrast to the standard
29185
 
+  :c:func:`sprintf` and :c:func:`vsprintf` functions, the Python versions check the
29186
 
   bounds of the buffer used to protect against buffer overruns. (Contributed by
29187
 
   M.-A. Lemburg.)
29188
 
 
29189
 
-* The :cfunc:`_PyTuple_Resize` function has lost an unused parameter, so now it
29190
 
+* The :c:func:`_PyTuple_Resize` function has lost an unused parameter, so now it
29191
 
   takes 2 parameters instead of 3.  The third argument was never used, and can
29192
 
   simply be discarded when porting code from earlier versions to Python 2.2.
29193
 
 
29194
 
@@ -1219,7 +1219,7 @@
29195
 
   operator, but these features were rarely used and therefore buggy.  The
29196
 
   :meth:`tolist` method and the :attr:`start`, :attr:`stop`, and :attr:`step`
29197
 
   attributes are also being deprecated.  At the C level, the fourth argument to
29198
 
-  the :cfunc:`PyRange_New` function, ``repeat``, has also been deprecated.
29199
 
+  the :c:func:`PyRange_New` function, ``repeat``, has also been deprecated.
29200
 
 
29201
 
 * There were a bunch of patches to the dictionary implementation, mostly to fix
29202
 
   potential core dumps if a dictionary contains objects that sneakily changed
29203
 
@@ -1242,8 +1242,8 @@
29204
 
   up to display the output.  This patch makes it possible to import such scripts,
29205
 
   in case they're also usable as modules.  (Implemented by David Bolen.)
29206
 
 
29207
 
-* On platforms where Python uses the C :cfunc:`dlopen` function  to load
29208
 
-  extension modules, it's now possible to set the flags used  by :cfunc:`dlopen`
29209
 
+* On platforms where Python uses the C :c:func:`dlopen` function  to load
29210
 
+  extension modules, it's now possible to set the flags used  by :c:func:`dlopen`
29211
 
   using the :func:`sys.getdlopenflags` and :func:`sys.setdlopenflags` functions.
29212
 
   (Contributed by Bram Stolk.)
29213
 
 
29214
 
diff -r 8527427914a2 Doc/whatsnew/2.3.rst
29215
 
--- a/Doc/whatsnew/2.3.rst
29216
 
+++ b/Doc/whatsnew/2.3.rst
29217
 
@@ -1797,8 +1797,8 @@
29218
 
 
29219
 
 Pymalloc, a specialized object allocator written by Vladimir Marangozov, was a
29220
 
 feature added to Python 2.1.  Pymalloc is intended to be faster than the system
29221
 
-:cfunc:`malloc` and to have less memory overhead for allocation patterns typical
29222
 
-of Python programs. The allocator uses C's :cfunc:`malloc` function to get large
29223
 
+:c:func:`malloc` and to have less memory overhead for allocation patterns typical
29224
 
+of Python programs. The allocator uses C's :c:func:`malloc` function to get large
29225
 
 pools of memory and then fulfills smaller memory requests from these pools.
29226
 
 
29227
 
 In 2.1 and 2.2, pymalloc was an experimental feature and wasn't enabled by
29228
 
@@ -1814,13 +1814,13 @@
29229
 
 
29230
 
 There's one particularly common error that causes problems.  There are a number
29231
 
 of memory allocation functions in Python's C API that have previously just been
29232
 
-aliases for the C library's :cfunc:`malloc` and :cfunc:`free`, meaning that if
29233
 
+aliases for the C library's :c:func:`malloc` and :c:func:`free`, meaning that if
29234
 
 you accidentally called mismatched functions the error wouldn't be noticeable.
29235
 
 When the object allocator is enabled, these functions aren't aliases of
29236
 
-:cfunc:`malloc` and :cfunc:`free` any more, and calling the wrong function to
29237
 
+:c:func:`malloc` and :c:func:`free` any more, and calling the wrong function to
29238
 
 free memory may get you a core dump.  For example, if memory was allocated using
29239
 
-:cfunc:`PyObject_Malloc`, it has to be freed using :cfunc:`PyObject_Free`, not
29240
 
-:cfunc:`free`.  A few modules included with Python fell afoul of this and had to
29241
 
+:c:func:`PyObject_Malloc`, it has to be freed using :c:func:`PyObject_Free`, not
29242
 
+:c:func:`free`.  A few modules included with Python fell afoul of this and had to
29243
 
 be fixed; doubtless there are more third-party modules that will have the same
29244
 
 problem.
29245
 
 
29246
 
@@ -1831,14 +1831,14 @@
29247
 
 specifically for allocating Python objects.
29248
 
 
29249
 
 * To allocate and free an undistinguished chunk of memory use the "raw memory"
29250
 
-  family: :cfunc:`PyMem_Malloc`, :cfunc:`PyMem_Realloc`, and :cfunc:`PyMem_Free`.
29251
 
+  family: :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc`, and :c:func:`PyMem_Free`.
29252
 
 
29253
 
 * The "object memory" family is the interface to the pymalloc facility described
29254
 
   above and is biased towards a large number of "small" allocations:
29255
 
-  :cfunc:`PyObject_Malloc`, :cfunc:`PyObject_Realloc`, and :cfunc:`PyObject_Free`.
29256
 
+  :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc`, and :c:func:`PyObject_Free`.
29257
 
 
29258
 
 * To allocate and free Python objects, use the "object" family
29259
 
-  :cfunc:`PyObject_New`, :cfunc:`PyObject_NewVar`, and :cfunc:`PyObject_Del`.
29260
 
+  :c:func:`PyObject_New`, :c:func:`PyObject_NewVar`, and :c:func:`PyObject_Del`.
29261
 
 
29262
 
 Thanks to lots of work by Tim Peters, pymalloc in 2.3 also provides debugging
29263
 
 features to catch memory overwrites and doubled frees in both extension modules
29264
 
@@ -1877,10 +1877,10 @@
29265
 
   (:file:`libpython2.3.so`) by supplying :option:`--enable-shared` when running
29266
 
   Python's :program:`configure` script.  (Contributed by Ondrej Palkovsky.)
29267
 
 
29268
 
-* The :cmacro:`DL_EXPORT` and :cmacro:`DL_IMPORT` macros are now deprecated.
29269
 
+* The :c:macro:`DL_EXPORT` and :c:macro:`DL_IMPORT` macros are now deprecated.
29270
 
   Initialization functions for Python extension modules should now be declared
29271
 
-  using the new macro :cmacro:`PyMODINIT_FUNC`, while the Python core will
29272
 
-  generally use the :cmacro:`PyAPI_FUNC` and :cmacro:`PyAPI_DATA` macros.
29273
 
+  using the new macro :c:macro:`PyMODINIT_FUNC`, while the Python core will
29274
 
+  generally use the :c:macro:`PyAPI_FUNC` and :c:macro:`PyAPI_DATA` macros.
29275
 
 
29276
 
 * The interpreter can be compiled without any docstrings for the built-in
29277
 
   functions and modules by supplying :option:`--without-doc-strings` to the
29278
 
@@ -1888,19 +1888,19 @@
29279
 
   but will also mean that you can't get help for Python's built-ins.  (Contributed
29280
 
   by Gustavo Niemeyer.)
29281
 
 
29282
 
-* The :cfunc:`PyArg_NoArgs` macro is now deprecated, and code that uses it
29283
 
+* The :c:func:`PyArg_NoArgs` macro is now deprecated, and code that uses it
29284
 
   should be changed.  For Python 2.2 and later, the method definition table can
29285
 
   specify the :const:`METH_NOARGS` flag, signalling that there are no arguments,
29286
 
   and the argument checking can then be removed.  If compatibility with pre-2.2
29287
 
   versions of Python is important, the code could use ``PyArg_ParseTuple(args,
29288
 
   "")`` instead, but this will be slower than using :const:`METH_NOARGS`.
29289
 
 
29290
 
-* :cfunc:`PyArg_ParseTuple` accepts new format characters for various sizes of
29291
 
-  unsigned integers: ``B`` for :ctype:`unsigned char`, ``H`` for :ctype:`unsigned
29292
 
-  short int`,  ``I`` for :ctype:`unsigned int`,  and ``K`` for :ctype:`unsigned
29293
 
+* :c:func:`PyArg_ParseTuple` accepts new format characters for various sizes of
29294
 
+  unsigned integers: ``B`` for :c:type:`unsigned char`, ``H`` for :c:type:`unsigned
29295
 
+  short int`,  ``I`` for :c:type:`unsigned int`,  and ``K`` for :c:type:`unsigned
29296
 
   long long`.
29297
 
 
29298
 
-* A new function, :cfunc:`PyObject_DelItemString(mapping, char \*key)` was added
29299
 
+* A new function, :c:func:`PyObject_DelItemString(mapping, char \*key)` was added
29300
 
   as shorthand for ``PyObject_DelItem(mapping, PyString_New(key))``.
29301
 
 
29302
 
 * File objects now manage their internal string buffer differently, increasing
29303
 
@@ -1910,7 +1910,7 @@
29304
 
 
29305
 
 * It's now possible to define class and static methods for a C extension type by
29306
 
   setting either the :const:`METH_CLASS` or :const:`METH_STATIC` flags in a
29307
 
-  method's :ctype:`PyMethodDef` structure.
29308
 
+  method's :c:type:`PyMethodDef` structure.
29309
 
 
29310
 
 * Python now includes a copy of the Expat XML parser's source code, removing any
29311
 
   dependence on a system version or local installation of Expat.
29312
 
diff -r 8527427914a2 Doc/whatsnew/2.4.rst
29313
 
--- a/Doc/whatsnew/2.4.rst
29314
 
+++ b/Doc/whatsnew/2.4.rst
29315
 
@@ -469,7 +469,7 @@
29316
 
 ==========================
29317
 
 
29318
 
 Python has always supported floating-point (FP) numbers, based on the underlying
29319
 
-C :ctype:`double` type, as a data type.  However, while most programming
29320
 
+C :c:type:`double` type, as a data type.  However, while most programming
29321
 
 languages provide a floating-point type, many people (even programmers) are
29322
 
 unaware that floating-point numbers don't represent certain decimal fractions
29323
 
 accurately.  The new :class:`Decimal` type can represent these fractions
29324
 
@@ -498,7 +498,7 @@
29325
 
 5.
29326
 
 
29327
 
 Modern systems usually provide floating-point support that conforms to a
29328
 
-standard called IEEE 754.  C's :ctype:`double` type is usually implemented as a
29329
 
+standard called IEEE 754.  C's :c:type:`double` type is usually implemented as a
29330
 
 64-bit IEEE 754 number, which uses 52 bits of space for the mantissa.  This
29331
 
 means that numbers can only be specified to 52 bits of precision.  If you're
29332
 
 trying to represent numbers whose expansion repeats endlessly, the expansion is
29333
 
@@ -736,7 +736,7 @@
29334
 
 However, the module was careful to not change the numeric locale because various
29335
 
 functions in Python's implementation required that the numeric locale remain set
29336
 
 to the ``'C'`` locale.  Often this was because the code was using the C
29337
 
-library's :cfunc:`atof` function.
29338
 
+library's :c:func:`atof` function.
29339
 
 
29340
 
 Not setting the numeric locale caused trouble for extensions that used third-
29341
 
 party C libraries, however, because they wouldn't have the correct locale set.
29342
 
@@ -746,11 +746,11 @@
29343
 
 The solution described in the PEP is to add three new functions to the Python
29344
 
 API that perform ASCII-only conversions, ignoring the locale setting:
29345
 
 
29346
 
-* :cfunc:`PyOS_ascii_strtod(str, ptr)`  and :cfunc:`PyOS_ascii_atof(str, ptr)`
29347
 
-  both convert a string to a C :ctype:`double`.
29348
 
+* :c:func:`PyOS_ascii_strtod(str, ptr)`  and :c:func:`PyOS_ascii_atof(str, ptr)`
29349
 
+  both convert a string to a C :c:type:`double`.
29350
 
 
29351
 
-* :cfunc:`PyOS_ascii_formatd(buffer, buf_len, format, d)` converts a
29352
 
-  :ctype:`double` to an ASCII string.
29353
 
+* :c:func:`PyOS_ascii_formatd(buffer, buf_len, format, d)` converts a
29354
 
+  :c:type:`double` to an ASCII string.
29355
 
 
29356
 
 The code for these functions came from the GLib library
29357
 
 (http://library.gnome.org/devel/glib/stable/), whose developers kindly
29358
 
@@ -938,7 +938,7 @@
29359
 
 * The machinery for growing and shrinking lists was optimized for speed and for
29360
 
   space efficiency.  Appending and popping from lists now runs faster due to more
29361
 
   efficient code paths and less frequent use of the underlying system
29362
 
-  :cfunc:`realloc`.  List comprehensions also benefit.   :meth:`list.extend` was
29363
 
+  :c:func:`realloc`.  List comprehensions also benefit.   :meth:`list.extend` was
29364
 
   also optimized and no longer converts its argument into a temporary list before
29365
 
   extending the base list.  (Contributed by Raymond Hettinger.)
29366
 
 
29367
 
@@ -947,7 +947,7 @@
29368
 
   :meth:`__len__` method.  (Contributed by Raymond Hettinger.)
29369
 
 
29370
 
 * The methods :meth:`list.__getitem__`, :meth:`dict.__getitem__`, and
29371
 
-  :meth:`dict.__contains__` are are now implemented as :class:`method_descriptor`
29372
 
+  :meth:`dict.__contains__` are now implemented as :class:`method_descriptor`
29373
 
   objects rather than :class:`wrapper_descriptor` objects.  This form of  access
29374
 
   doubles their performance and makes them more suitable for use as arguments to
29375
 
   functionals: ``map(mydict.__getitem__, keylist)``. (Contributed by Raymond
29376
 
@@ -1445,34 +1445,34 @@
29377
 
 Some of the changes to Python's build process and to the C API are:
29378
 
 
29379
 
 * Three new convenience macros were added for common return values from
29380
 
-  extension functions: :cmacro:`Py_RETURN_NONE`, :cmacro:`Py_RETURN_TRUE`, and
29381
 
-  :cmacro:`Py_RETURN_FALSE`. (Contributed by Brett Cannon.)
29382
 
+  extension functions: :c:macro:`Py_RETURN_NONE`, :c:macro:`Py_RETURN_TRUE`, and
29383
 
+  :c:macro:`Py_RETURN_FALSE`. (Contributed by Brett Cannon.)
29384
 
 
29385
 
-* Another new macro, :cmacro:`Py_CLEAR(obj)`,  decreases the reference count of
29386
 
+* Another new macro, :c:macro:`Py_CLEAR(obj)`,  decreases the reference count of
29387
 
   *obj* and sets *obj* to the null pointer.  (Contributed by Jim Fulton.)
29388
 
 
29389
 
-* A new function, :cfunc:`PyTuple_Pack(N, obj1, obj2, ..., objN)`, constructs
29390
 
+* A new function, :c:func:`PyTuple_Pack(N, obj1, obj2, ..., objN)`, constructs
29391
 
   tuples from a variable length argument list of Python objects.  (Contributed by
29392
 
   Raymond Hettinger.)
29393
 
 
29394
 
-* A new function, :cfunc:`PyDict_Contains(d, k)`, implements fast dictionary
29395
 
+* A new function, :c:func:`PyDict_Contains(d, k)`, implements fast dictionary
29396
 
   lookups without masking exceptions raised during the look-up process.
29397
 
   (Contributed by Raymond Hettinger.)
29398
 
 
29399
 
-* The :cmacro:`Py_IS_NAN(X)` macro returns 1 if  its float or double argument
29400
 
+* The :c:macro:`Py_IS_NAN(X)` macro returns 1 if  its float or double argument
29401
 
   *X* is a NaN.   (Contributed by Tim Peters.)
29402
 
 
29403
 
 * C code can avoid unnecessary locking by using the new
29404
 
-  :cfunc:`PyEval_ThreadsInitialized` function to tell  if any thread operations
29405
 
+  :c:func:`PyEval_ThreadsInitialized` function to tell  if any thread operations
29406
 
   have been performed.  If this function  returns false, no lock operations are
29407
 
   needed. (Contributed by Nick Coghlan.)
29408
 
 
29409
 
-* A new function, :cfunc:`PyArg_VaParseTupleAndKeywords`, is the same as
29410
 
-  :cfunc:`PyArg_ParseTupleAndKeywords` but takes a  :ctype:`va_list` instead of a
29411
 
+* A new function, :c:func:`PyArg_VaParseTupleAndKeywords`, is the same as
29412
 
+  :c:func:`PyArg_ParseTupleAndKeywords` but takes a  :c:type:`va_list` instead of a
29413
 
   number of arguments. (Contributed by Greg Chapman.)
29414
 
 
29415
 
 * A new method flag, :const:`METH_COEXISTS`, allows a function defined in slots
29416
 
-  to co-exist with a :ctype:`PyCFunction` having the same name.  This can halve
29417
 
+  to co-exist with a :c:type:`PyCFunction` having the same name.  This can halve
29418
 
   the access time for a method such as :meth:`set.__contains__`.  (Contributed by
29419
 
   Raymond Hettinger.)
29420
 
 
29421
 
@@ -1486,8 +1486,8 @@
29422
 
   though that processor architecture doesn't call that register "the TSC
29423
 
   register".  (Contributed by Jeremy Hylton.)
29424
 
 
29425
 
-* The :ctype:`tracebackobject` type has been renamed to
29426
 
-  :ctype:`PyTracebackObject`.
29427
 
+* The :c:type:`tracebackobject` type has been renamed to
29428
 
+  :c:type:`PyTracebackObject`.
29429
 
 
29430
 
 .. ======================================================================
29431
 
 
29432
 
diff -r 8527427914a2 Doc/whatsnew/2.5.rst
29433
 
--- a/Doc/whatsnew/2.5.rst
29434
 
+++ b/Doc/whatsnew/2.5.rst
29435
 
@@ -870,31 +870,31 @@
29436
 
 PEP 353: Using ssize_t as the index type
29437
 
 ========================================
29438
 
 
29439
 
-A wide-ranging change to Python's C API, using a new  :ctype:`Py_ssize_t` type
29440
 
-definition instead of :ctype:`int`,  will permit the interpreter to handle more
29441
 
+A wide-ranging change to Python's C API, using a new  :c:type:`Py_ssize_t` type
29442
 
+definition instead of :c:type:`int`,  will permit the interpreter to handle more
29443
 
 data on 64-bit platforms. This change doesn't affect Python's capacity on 32-bit
29444
 
 platforms.
29445
 
 
29446
 
-Various pieces of the Python interpreter used C's :ctype:`int` type to store
29447
 
+Various pieces of the Python interpreter used C's :c:type:`int` type to store
29448
 
 sizes or counts; for example, the number of items in a list or tuple were stored
29449
 
-in an :ctype:`int`.  The C compilers for most 64-bit platforms still define
29450
 
-:ctype:`int` as a 32-bit type, so that meant that lists could only hold up to
29451
 
+in an :c:type:`int`.  The C compilers for most 64-bit platforms still define
29452
 
+:c:type:`int` as a 32-bit type, so that meant that lists could only hold up to
29453
 
 ``2**31 - 1`` = 2147483647 items. (There are actually a few different
29454
 
 programming models that 64-bit C compilers can use -- see
29455
 
 http://www.unix.org/version2/whatsnew/lp64_wp.html for a discussion -- but the
29456
 
-most commonly available model leaves :ctype:`int` as 32 bits.)
29457
 
+most commonly available model leaves :c:type:`int` as 32 bits.)
29458
 
 
29459
 
 A limit of 2147483647 items doesn't really matter on a 32-bit platform because
29460
 
 you'll run out of memory before hitting the length limit. Each list item
29461
 
 requires space for a pointer, which is 4 bytes, plus space for a
29462
 
-:ctype:`PyObject` representing the item.  2147483647\*4 is already more bytes
29463
 
+:c:type:`PyObject` representing the item.  2147483647\*4 is already more bytes
29464
 
 than a 32-bit address space can contain.
29465
 
 
29466
 
 It's possible to address that much memory on a 64-bit platform, however.  The
29467
 
 pointers for a list that size would only require 16 GiB of space, so it's not
29468
 
 unreasonable that Python programmers might construct lists that large.
29469
 
 Therefore, the Python interpreter had to be changed to use some type other than
29470
 
-:ctype:`int`, and this will be a 64-bit type on 64-bit platforms.  The change
29471
 
+:c:type:`int`, and this will be a 64-bit type on 64-bit platforms.  The change
29472
 
 will cause incompatibilities on 64-bit machines, so it was deemed worth making
29473
 
 the transition now, while the number of 64-bit users is still relatively small.
29474
 
 (In 5 or 10 years, we may *all* be on 64-bit machines, and the transition would
29475
 
@@ -902,15 +902,15 @@
29476
 
 
29477
 
 This change most strongly affects authors of C extension modules.   Python
29478
 
 strings and container types such as lists and tuples  now use
29479
 
-:ctype:`Py_ssize_t` to store their size.   Functions such as
29480
 
-:cfunc:`PyList_Size`  now return :ctype:`Py_ssize_t`.  Code in extension modules
29481
 
-may therefore need to have some variables changed to :ctype:`Py_ssize_t`.
29482
 
-
29483
 
-The :cfunc:`PyArg_ParseTuple` and :cfunc:`Py_BuildValue` functions have a new
29484
 
-conversion code, ``n``, for :ctype:`Py_ssize_t`.   :cfunc:`PyArg_ParseTuple`'s
29485
 
-``s#`` and ``t#`` still output :ctype:`int` by default, but you can define the
29486
 
-macro  :cmacro:`PY_SSIZE_T_CLEAN` before including :file:`Python.h`  to make
29487
 
-them return :ctype:`Py_ssize_t`.
29488
 
+:c:type:`Py_ssize_t` to store their size.   Functions such as
29489
 
+:c:func:`PyList_Size`  now return :c:type:`Py_ssize_t`.  Code in extension modules
29490
 
+may therefore need to have some variables changed to :c:type:`Py_ssize_t`.
29491
 
+
29492
 
+The :c:func:`PyArg_ParseTuple` and :c:func:`Py_BuildValue` functions have a new
29493
 
+conversion code, ``n``, for :c:type:`Py_ssize_t`.   :c:func:`PyArg_ParseTuple`'s
29494
 
+``s#`` and ``t#`` still output :c:type:`int` by default, but you can define the
29495
 
+macro  :c:macro:`PY_SSIZE_T_CLEAN` before including :file:`Python.h`  to make
29496
 
+them return :c:type:`Py_ssize_t`.
29497
 
 
29498
 
 :pep:`353` has a section on conversion guidelines that  extension authors should
29499
 
 read to learn about supporting 64-bit platforms.
29500
 
@@ -954,8 +954,8 @@
29501
 
 :exc:`TypeError` if this requirement isn't met.
29502
 
 
29503
 
 A corresponding :attr:`nb_index` slot was added to the C-level
29504
 
-:ctype:`PyNumberMethods` structure to let C extensions implement this protocol.
29505
 
-:cfunc:`PyNumber_Index(obj)` can be used in extension code to call the
29506
 
+:c:type:`PyNumberMethods` structure to let C extensions implement this protocol.
29507
 
+:c:func:`PyNumber_Index(obj)` can be used in extension code to call the
29508
 
 :meth:`__index__` function and retrieve its result.
29509
 
 
29510
 
 
29511
 
@@ -1179,7 +1179,7 @@
29512
 
   (Contributed by Bob Ippolito at the NeedForSpeed sprint.)
29513
 
 
29514
 
 * The :mod:`re` module got a 1 or 2% speedup by switching to  Python's allocator
29515
 
-  functions instead of the system's  :cfunc:`malloc` and :cfunc:`free`.
29516
 
+  functions instead of the system's  :c:func:`malloc` and :c:func:`free`.
29517
 
   (Contributed by Jack Diederich at the NeedForSpeed sprint.)
29518
 
 
29519
 
 * The code generator's peephole optimizer now performs simple constant folding
29520
 
@@ -1203,7 +1203,7 @@
29521
 
   Sean Reifschneider at the NeedForSpeed sprint.)
29522
 
 
29523
 
 * Importing now caches the paths tried, recording whether  they exist or not so
29524
 
-  that the interpreter makes fewer  :cfunc:`open` and :cfunc:`stat` calls on
29525
 
+  that the interpreter makes fewer  :c:func:`open` and :c:func:`stat` calls on
29526
 
   startup. (Contributed by Martin von Löwis and Georg Brandl.)
29527
 
 
29528
 
   .. Patch 921466
29529
 
@@ -1459,7 +1459,7 @@
29530
 
 
29531
 
   On FreeBSD, the :func:`os.stat` function now returns  times with nanosecond
29532
 
   resolution, and the returned object now has :attr:`st_gen` and
29533
 
-  :attr:`st_birthtime`. The :attr:`st_flags` member is also available, if the
29534
 
+  :attr:`st_birthtime`. The :attr:`st_flags` attribute is also available, if the
29535
 
   platform supports it. (Contributed by Antti Louko and  Diego Pettenò.)
29536
 
 
29537
 
   .. (Patch 1180695, 1212117)
29538
 
@@ -1568,7 +1568,7 @@
29539
 
   reporting ``('CPython', 'trunk', '45313:45315')``.
29540
 
 
29541
 
   This information is also available to C extensions via the
29542
 
-  :cfunc:`Py_GetBuildInfo` function that returns a  string of build information
29543
 
+  :c:func:`Py_GetBuildInfo` function that returns a  string of build information
29544
 
   like this: ``"trunk:45355:45356M, Apr 13 2006, 07:42:19"``.   (Contributed by
29545
 
   Barry Warsaw.)
29546
 
 
29547
 
@@ -1690,7 +1690,7 @@
29548
 
    result = libc.printf("Line of output\n")
29549
 
 
29550
 
 Type constructors for the various C types are provided: :func:`c_int`,
29551
 
-:func:`c_float`, :func:`c_double`, :func:`c_char_p` (equivalent to :ctype:`char
29552
 
+:func:`c_float`, :func:`c_double`, :func:`c_char_p` (equivalent to :c:type:`char
29553
 
 \*`), and so forth.  Unlike Python's types, the C versions are all mutable; you
29554
 
 can assign to their :attr:`value` attribute to change the wrapped value.  Python
29555
 
 integers and strings will be automatically converted to the corresponding C
29556
 
@@ -1720,7 +1720,7 @@
29557
 
 ``ctypes.pythonapi`` object.  This object does *not*  release the global
29558
 
 interpreter lock before calling a function, because the lock must be held when
29559
 
 calling into the interpreter's code.   There's a :class:`py_object()` type
29560
 
-constructor that will create a  :ctype:`PyObject \*` pointer.  A simple usage::
29561
 
+constructor that will create a  :c:type:`PyObject \*` pointer.  A simple usage::
29562
 
 
29563
 
    import ctypes
29564
 
 
29565
 
@@ -2087,8 +2087,8 @@
29566
 
   http://scan.coverity.com for the statistics.
29567
 
 
29568
 
 * The largest change to the C API came from :pep:`353`, which modifies the
29569
 
-  interpreter to use a :ctype:`Py_ssize_t` type definition instead of
29570
 
-  :ctype:`int`.  See the earlier section :ref:`pep-353` for a discussion of this
29571
 
+  interpreter to use a :c:type:`Py_ssize_t` type definition instead of
29572
 
+  :c:type:`int`.  See the earlier section :ref:`pep-353` for a discussion of this
29573
 
   change.
29574
 
 
29575
 
 * The design of the bytecode compiler has changed a great deal,  no longer
29576
 
@@ -2113,10 +2113,10 @@
29577
 
   discusses the design.  To start learning about the code, read the definition of
29578
 
   the various AST nodes in :file:`Parser/Python.asdl`.  A Python script reads this
29579
 
   file and generates a set of C structure definitions in
29580
 
-  :file:`Include/Python-ast.h`.  The :cfunc:`PyParser_ASTFromString` and
29581
 
-  :cfunc:`PyParser_ASTFromFile`, defined in :file:`Include/pythonrun.h`, take
29582
 
+  :file:`Include/Python-ast.h`.  The :c:func:`PyParser_ASTFromString` and
29583
 
+  :c:func:`PyParser_ASTFromFile`, defined in :file:`Include/pythonrun.h`, take
29584
 
   Python source as input and return the root of an AST representing the contents.
29585
 
-  This AST can then be turned into a code object by :cfunc:`PyAST_Compile`.  For
29586
 
+  This AST can then be turned into a code object by :c:func:`PyAST_Compile`.  For
29587
 
   more information, read the source code, and then ask questions on python-dev.
29588
 
 
29589
 
   The AST code was developed under Jeremy Hylton's management, and implemented by
29590
 
@@ -2138,55 +2138,55 @@
29591
 
 
29592
 
   Note that this change means extension modules must be more careful when
29593
 
   allocating memory.  Python's API has many different functions for allocating
29594
 
-  memory that are grouped into families.  For example, :cfunc:`PyMem_Malloc`,
29595
 
-  :cfunc:`PyMem_Realloc`, and :cfunc:`PyMem_Free` are one family that allocates
29596
 
-  raw memory, while :cfunc:`PyObject_Malloc`, :cfunc:`PyObject_Realloc`, and
29597
 
-  :cfunc:`PyObject_Free` are another family that's supposed to be used for
29598
 
+  memory that are grouped into families.  For example, :c:func:`PyMem_Malloc`,
29599
 
+  :c:func:`PyMem_Realloc`, and :c:func:`PyMem_Free` are one family that allocates
29600
 
+  raw memory, while :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc`, and
29601
 
+  :c:func:`PyObject_Free` are another family that's supposed to be used for
29602
 
   creating Python objects.
29603
 
 
29604
 
   Previously these different families all reduced to the platform's
29605
 
-  :cfunc:`malloc` and :cfunc:`free` functions.  This meant  it didn't matter if
29606
 
-  you got things wrong and allocated memory with the :cfunc:`PyMem` function but
29607
 
-  freed it with the :cfunc:`PyObject` function.  With 2.5's changes to obmalloc,
29608
 
+  :c:func:`malloc` and :c:func:`free` functions.  This meant  it didn't matter if
29609
 
+  you got things wrong and allocated memory with the :c:func:`PyMem` function but
29610
 
+  freed it with the :c:func:`PyObject` function.  With 2.5's changes to obmalloc,
29611
 
   these families now do different things and mismatches will probably result in a
29612
 
   segfault.  You should carefully test your C extension modules with Python 2.5.
29613
 
 
29614
 
-* The built-in set types now have an official C API.  Call :cfunc:`PySet_New`
29615
 
-  and :cfunc:`PyFrozenSet_New` to create a new set, :cfunc:`PySet_Add` and
29616
 
-  :cfunc:`PySet_Discard` to add and remove elements, and :cfunc:`PySet_Contains`
29617
 
-  and :cfunc:`PySet_Size` to examine the set's state. (Contributed by Raymond
29618
 
+* The built-in set types now have an official C API.  Call :c:func:`PySet_New`
29619
 
+  and :c:func:`PyFrozenSet_New` to create a new set, :c:func:`PySet_Add` and
29620
 
+  :c:func:`PySet_Discard` to add and remove elements, and :c:func:`PySet_Contains`
29621
 
+  and :c:func:`PySet_Size` to examine the set's state. (Contributed by Raymond
29622
 
   Hettinger.)
29623
 
 
29624
 
 * C code can now obtain information about the exact revision of the Python
29625
 
-  interpreter by calling the  :cfunc:`Py_GetBuildInfo` function that returns a
29626
 
+  interpreter by calling the  :c:func:`Py_GetBuildInfo` function that returns a
29627
 
   string of build information like this: ``"trunk:45355:45356M, Apr 13 2006,
29628
 
   07:42:19"``.   (Contributed by Barry Warsaw.)
29629
 
 
29630
 
 * Two new macros can be used to indicate C functions that are local to the
29631
 
   current file so that a faster calling convention can be used.
29632
 
-  :cfunc:`Py_LOCAL(type)` declares the function as returning a value of the
29633
 
+  :c:func:`Py_LOCAL(type)` declares the function as returning a value of the
29634
 
   specified *type* and uses a fast-calling qualifier.
29635
 
-  :cfunc:`Py_LOCAL_INLINE(type)` does the same thing and also requests the
29636
 
-  function be inlined.  If :cfunc:`PY_LOCAL_AGGRESSIVE` is defined before
29637
 
+  :c:func:`Py_LOCAL_INLINE(type)` does the same thing and also requests the
29638
 
+  function be inlined.  If :c:func:`PY_LOCAL_AGGRESSIVE` is defined before
29639
 
   :file:`python.h` is included, a set of more aggressive optimizations are enabled
29640
 
   for the module; you should benchmark the results to find out if these
29641
 
   optimizations actually make the code faster.  (Contributed by Fredrik Lundh at
29642
 
   the NeedForSpeed sprint.)
29643
 
 
29644
 
-* :cfunc:`PyErr_NewException(name, base, dict)` can now accept a tuple of base
29645
 
+* :c:func:`PyErr_NewException(name, base, dict)` can now accept a tuple of base
29646
 
   classes as its *base* argument.  (Contributed by Georg Brandl.)
29647
 
 
29648
 
-* The :cfunc:`PyErr_Warn` function for issuing warnings is now deprecated in
29649
 
-  favour of :cfunc:`PyErr_WarnEx(category, message, stacklevel)` which lets you
29650
 
+* The :c:func:`PyErr_Warn` function for issuing warnings is now deprecated in
29651
 
+  favour of :c:func:`PyErr_WarnEx(category, message, stacklevel)` which lets you
29652
 
   specify the number of stack frames separating this function and the caller.  A
29653
 
-  *stacklevel* of 1 is the function calling :cfunc:`PyErr_WarnEx`, 2 is the
29654
 
+  *stacklevel* of 1 is the function calling :c:func:`PyErr_WarnEx`, 2 is the
29655
 
   function above that, and so forth.  (Added by Neal Norwitz.)
29656
 
 
29657
 
 * The CPython interpreter is still written in C, but  the code can now be
29658
 
   compiled with a C++ compiler without errors.   (Implemented by Anthony Baxter,
29659
 
   Martin von Löwis, Skip Montanaro.)
29660
 
 
29661
 
-* The :cfunc:`PyRange_New` function was removed.  It was never documented, never
29662
 
+* The :c:func:`PyRange_New` function was removed.  It was never documented, never
29663
 
   used in the core code, and had dangerously lax error checking.  In the unlikely
29664
 
   case that your extensions were using it, you can replace it by something like
29665
 
   the following::
29666
 
@@ -2203,7 +2203,7 @@
29667
 
 ---------------------
29668
 
 
29669
 
 * MacOS X (10.3 and higher): dynamic loading of modules now uses the
29670
 
-  :cfunc:`dlopen` function instead of MacOS-specific functions.
29671
 
+  :c:func:`dlopen` function instead of MacOS-specific functions.
29672
 
 
29673
 
 * MacOS X: an :option:`--enable-universalsdk` switch was added to the
29674
 
   :program:`configure` script that compiles the interpreter as a universal binary
29675
 
@@ -2259,15 +2259,15 @@
29676
 
   Setting  :attr:`rpc_paths` to ``None`` or an empty tuple disables  this path
29677
 
   checking.
29678
 
 
29679
 
-* C API: Many functions now use :ctype:`Py_ssize_t`  instead of :ctype:`int` to
29680
 
+* C API: Many functions now use :c:type:`Py_ssize_t`  instead of :c:type:`int` to
29681
 
   allow processing more data on 64-bit machines.  Extension code may need to make
29682
 
   the same change to avoid warnings and to support 64-bit machines.  See the
29683
 
   earlier section :ref:`pep-353` for a discussion of this change.
29684
 
 
29685
 
 * C API:  The obmalloc changes mean that  you must be careful to not mix usage
29686
 
-  of the :cfunc:`PyMem_\*` and :cfunc:`PyObject_\*` families of functions. Memory
29687
 
-  allocated with  one family's :cfunc:`\*_Malloc` must be  freed with the
29688
 
-  corresponding family's :cfunc:`\*_Free` function.
29689
 
+  of the :c:func:`PyMem_\*` and :c:func:`PyObject_\*` families of functions. Memory
29690
 
+  allocated with  one family's :c:func:`\*_Malloc` must be  freed with the
29691
 
+  corresponding family's :c:func:`\*_Free` function.
29692
 
 
29693
 
 .. ======================================================================
29694
 
 
29695
 
diff -r 8527427914a2 Doc/whatsnew/2.6.rst
29696
 
--- a/Doc/whatsnew/2.6.rst
29697
 
+++ b/Doc/whatsnew/2.6.rst
29698
 
@@ -121,7 +121,7 @@
29699
 
 with this switch to see how much work will be necessary to port
29700
 
 code to 3.0.  The value of this switch is available
29701
 
 to Python code as the boolean variable :data:`sys.py3kwarning`,
29702
 
-and to C extension code as :cdata:`Py_Py3kWarningFlag`.
29703
 
+and to C extension code as :c:data:`Py_Py3kWarningFlag`.
29704
 
 
29705
 
 .. seealso::
29706
 
 
29707
 
@@ -232,7 +232,7 @@
29708
 
 
29709
 
 .. seealso::
29710
 
 
29711
 
-   :ref:`documenting-index`
29712
 
+   `Documenting Python <http://docs.python.org/devguide/documenting.html>`__
29713
 
        Describes how to write for Python's documentation.
29714
 
 
29715
 
    `Sphinx <http://sphinx.pocoo.org/>`__
29716
 
@@ -611,8 +611,8 @@
29717
 
         result = queue.get()
29718
 
         print 'Factorial', N, '=', result
29719
 
 
29720
 
-A :class:`Queue` is used to communicate the input parameter *N* and
29721
 
-the result.  The :class:`Queue` object is stored in a global variable.
29722
 
+A :class:`Queue` is used to communicate the result of the factorial.
29723
 
+The :class:`Queue` object is stored in a global variable.
29724
 
 The child process will use the value of the variable when the child
29725
 
 was created; because it's a :class:`Queue`, parent and child can use
29726
 
 the object to communicate.  (If the parent were to change the value of
29727
 
@@ -975,10 +975,10 @@
29728
 
     print len(s)               # 12 Unicode characters
29729
 
 
29730
 
 At the C level, Python 3.0 will rename the existing 8-bit
29731
 
-string type, called :ctype:`PyStringObject` in Python 2.x,
29732
 
-to :ctype:`PyBytesObject`.  Python 2.6 uses ``#define``
29733
 
-to support using the names :cfunc:`PyBytesObject`,
29734
 
-:cfunc:`PyBytes_Check`, :cfunc:`PyBytes_FromStringAndSize`,
29735
 
+string type, called :c:type:`PyStringObject` in Python 2.x,
29736
 
+to :c:type:`PyBytesObject`.  Python 2.6 uses ``#define``
29737
 
+to support using the names :c:func:`PyBytesObject`,
29738
 
+:c:func:`PyBytes_Check`, :c:func:`PyBytes_FromStringAndSize`,
29739
 
 and all the other functions and macros used with strings.
29740
 
 
29741
 
 Instances of the :class:`bytes` type are immutable just
29742
 
@@ -1010,8 +1010,8 @@
29743
 
     bytearray(b'ABCde')
29744
 
 
29745
 
 There's also a corresponding C API, with
29746
 
-:cfunc:`PyByteArray_FromObject`,
29747
 
-:cfunc:`PyByteArray_FromStringAndSize`,
29748
 
+:c:func:`PyByteArray_FromObject`,
29749
 
+:c:func:`PyByteArray_FromStringAndSize`,
29750
 
 and various other functions.
29751
 
 
29752
 
 .. seealso::
29753
 
@@ -1130,7 +1130,7 @@
29754
 
 
29755
 
 .. XXX PyObject_GetBuffer not documented in c-api
29756
 
 
29757
 
-The *flags* argument to :cfunc:`PyObject_GetBuffer` specifies
29758
 
+The *flags* argument to :c:func:`PyObject_GetBuffer` specifies
29759
 
 constraints upon the memory returned.  Some examples are:
29760
 
 
29761
 
  * :const:`PyBUF_WRITABLE` indicates that the memory must be writable.
29762
 
@@ -1141,7 +1141,7 @@
29763
 
    requests a C-contiguous (last dimension varies the fastest) or
29764
 
    Fortran-contiguous (first dimension varies the fastest) array layout.
29765
 
 
29766
 
-Two new argument codes for :cfunc:`PyArg_ParseTuple`,
29767
 
+Two new argument codes for :c:func:`PyArg_ParseTuple`,
29768
 
 ``s*`` and ``z*``, return locked buffer objects for a parameter.
29769
 
 
29770
 
 .. seealso::
29771
 
@@ -1635,7 +1635,7 @@
29772
 
   :meth:`__hash__` method inherited from a parent class, so
29773
 
   assigning ``None`` was implemented as an override.  At the
29774
 
   C level, extensions can set ``tp_hash`` to
29775
 
-  :cfunc:`PyObject_HashNotImplemented`.
29776
 
+  :c:func:`PyObject_HashNotImplemented`.
29777
 
   (Fixed by Nick Coghlan and Amaury Forgeot d'Arc; :issue:`2235`.)
29778
 
 
29779
 
 * The :exc:`GeneratorExit` exception now subclasses
29780
 
@@ -1705,7 +1705,7 @@
29781
 
   By default, this change is only applied to types that are included with
29782
 
   the Python core.  Extension modules may not necessarily be compatible with
29783
 
   this cache,
29784
 
-  so they must explicitly add :cmacro:`Py_TPFLAGS_HAVE_VERSION_TAG`
29785
 
+  so they must explicitly add :c:macro:`Py_TPFLAGS_HAVE_VERSION_TAG`
29786
 
   to the module's ``tp_flags`` field to enable the method cache.
29787
 
   (To be compatible with the method cache, the extension module's code
29788
 
   must not directly access and modify the ``tp_dict`` member of
29789
 
@@ -2284,7 +2284,7 @@
29790
 
   (Contributed by Raymond Hettinger; :issue:`1861`.)
29791
 
 
29792
 
 * The :mod:`select` module now has wrapper functions
29793
 
-  for the Linux :cfunc:`epoll` and BSD :cfunc:`kqueue` system calls.
29794
 
+  for the Linux :c:func:`epoll` and BSD :c:func:`kqueue` system calls.
29795
 
   :meth:`modify` method was added to the existing :class:`poll`
29796
 
   objects; ``pollobj.modify(fd, eventmask)`` takes a file descriptor
29797
 
   or file object and an event mask, modifying the recorded event mask
29798
 
@@ -2317,13 +2317,13 @@
29799
 
   Calling ``signal.set_wakeup_fd(fd)`` sets a file descriptor
29800
 
   to be used; when a signal is received, a byte is written to that
29801
 
   file descriptor.  There's also a C-level function,
29802
 
-  :cfunc:`PySignal_SetWakeupFd`, for setting the descriptor.
29803
 
+  :c:func:`PySignal_SetWakeupFd`, for setting the descriptor.
29804
 
 
29805
 
   Event loops will use this by opening a pipe to create two descriptors,
29806
 
   one for reading and one for writing.  The writable descriptor
29807
 
   will be passed to :func:`set_wakeup_fd`, and the readable descriptor
29808
 
   will be added to the list of descriptors monitored by the event loop via
29809
 
-  :cfunc:`select` or :cfunc:`poll`.
29810
 
+  :c:func:`select` or :c:func:`poll`.
29811
 
   On receiving a signal, a byte will be written and the main event loop
29812
 
   will be woken up, avoiding the need to poll.
29813
 
 
29814
 
@@ -2384,7 +2384,7 @@
29815
 
   has been updated from version 2.3.2 in Python 2.5 to
29816
 
   version 2.4.1.
29817
 
 
29818
 
-* The :mod:`struct` module now supports the C99 :ctype:`_Bool` type,
29819
 
+* The :mod:`struct` module now supports the C99 :c:type:`_Bool` type,
29820
 
   using the format character ``'?'``.
29821
 
   (Contributed by David Remahl.)
29822
 
 
29823
 
@@ -2392,7 +2392,7 @@
29824
 
   now have :meth:`terminate`, :meth:`kill`, and :meth:`send_signal` methods.
29825
 
   On Windows, :meth:`send_signal` only supports the :const:`SIGTERM`
29826
 
   signal, and all these methods are aliases for the Win32 API function
29827
 
-  :cfunc:`TerminateProcess`.
29828
 
+  :c:func:`TerminateProcess`.
29829
 
   (Contributed by Christian Heimes.)
29830
 
 
29831
 
 * A new variable in the :mod:`sys` module, :attr:`float_info`, is an
29832
 
@@ -2977,7 +2977,7 @@
29833
 
 
29834
 
 * Python now must be compiled with C89 compilers (after 19
29835
 
   years!).  This means that the Python source tree has dropped its
29836
 
-  own implementations of :cfunc:`memmove` and :cfunc:`strerror`, which
29837
 
+  own implementations of :c:func:`memmove` and :c:func:`strerror`, which
29838
 
   are in the C89 standard library.
29839
 
 
29840
 
 * Python 2.6 can be built with Microsoft Visual Studio 2008 (version
29841
 
@@ -2999,7 +2999,7 @@
29842
 
 
29843
 
 * The new buffer interface, previously described in
29844
 
   `the PEP 3118 section <#pep-3118-revised-buffer-protocol>`__,
29845
 
-  adds :cfunc:`PyObject_GetBuffer` and :cfunc:`PyBuffer_Release`,
29846
 
+  adds :c:func:`PyObject_GetBuffer` and :c:func:`PyBuffer_Release`,
29847
 
   as well as a few other functions.
29848
 
 
29849
 
 * Python's use of the C stdio library is now thread-safe, or at least
29850
 
@@ -3007,27 +3007,27 @@
29851
 
   bug occurred if one thread closed a file object while another thread
29852
 
   was reading from or writing to the object.  In 2.6 file objects
29853
 
   have a reference count, manipulated by the
29854
 
-  :cfunc:`PyFile_IncUseCount` and :cfunc:`PyFile_DecUseCount`
29855
 
+  :c:func:`PyFile_IncUseCount` and :c:func:`PyFile_DecUseCount`
29856
 
   functions.  File objects can't be closed unless the reference count
29857
 
-  is zero.  :cfunc:`PyFile_IncUseCount` should be called while the GIL
29858
 
+  is zero.  :c:func:`PyFile_IncUseCount` should be called while the GIL
29859
 
   is still held, before carrying out an I/O operation using the
29860
 
-  ``FILE *`` pointer, and :cfunc:`PyFile_DecUseCount` should be called
29861
 
+  ``FILE *`` pointer, and :c:func:`PyFile_DecUseCount` should be called
29862
 
   immediately after the GIL is re-acquired.
29863
 
   (Contributed by Antoine Pitrou and Gregory P. Smith.)
29864
 
 
29865
 
 * Importing modules simultaneously in two different threads no longer
29866
 
   deadlocks; it will now raise an :exc:`ImportError`.  A new API
29867
 
-  function, :cfunc:`PyImport_ImportModuleNoBlock`, will look for a
29868
 
+  function, :c:func:`PyImport_ImportModuleNoBlock`, will look for a
29869
 
   module in ``sys.modules`` first, then try to import it after
29870
 
   acquiring an import lock.  If the import lock is held by another
29871
 
   thread, an :exc:`ImportError` is raised.
29872
 
   (Contributed by Christian Heimes.)
29873
 
 
29874
 
 * Several functions return information about the platform's
29875
 
-  floating-point support.  :cfunc:`PyFloat_GetMax` returns
29876
 
+  floating-point support.  :c:func:`PyFloat_GetMax` returns
29877
 
   the maximum representable floating point value,
29878
 
-  and :cfunc:`PyFloat_GetMin` returns the minimum
29879
 
-  positive value.  :cfunc:`PyFloat_GetInfo` returns an object
29880
 
+  and :c:func:`PyFloat_GetMin` returns the minimum
29881
 
+  positive value.  :c:func:`PyFloat_GetInfo` returns an object
29882
 
   containing more information from the :file:`float.h` file, such as
29883
 
   ``"mant_dig"`` (number of digits in the mantissa), ``"epsilon"``
29884
 
   (smallest difference between 1.0 and the next largest value
29885
 
@@ -3035,7 +3035,7 @@
29886
 
   (Contributed by Christian Heimes; :issue:`1534`.)
29887
 
 
29888
 
 * C functions and methods that use
29889
 
-  :cfunc:`PyComplex_AsCComplex` will now accept arguments that
29890
 
+  :c:func:`PyComplex_AsCComplex` will now accept arguments that
29891
 
   have a :meth:`__complex__` method.  In particular, the functions in the
29892
 
   :mod:`cmath` module will now accept objects with this method.
29893
 
   This is a backport of a Python 3.0 change.
29894
 
@@ -3049,15 +3049,15 @@
29895
 
 * Many C extensions define their own little macro for adding
29896
 
   integers and strings to the module's dictionary in the
29897
 
   ``init*`` function.  Python 2.6 finally defines standard macros
29898
 
-  for adding values to a module, :cmacro:`PyModule_AddStringMacro`
29899
 
-  and :cmacro:`PyModule_AddIntMacro()`.  (Contributed by
29900
 
+  for adding values to a module, :c:macro:`PyModule_AddStringMacro`
29901
 
+  and :c:macro:`PyModule_AddIntMacro()`.  (Contributed by
29902
 
   Christian Heimes.)
29903
 
 
29904
 
 * Some macros were renamed in both 3.0 and 2.6 to make it clearer that
29905
 
   they are macros,
29906
 
-  not functions.  :cmacro:`Py_Size()` became :cmacro:`Py_SIZE()`,
29907
 
-  :cmacro:`Py_Type()` became :cmacro:`Py_TYPE()`, and
29908
 
-  :cmacro:`Py_Refcnt()` became :cmacro:`Py_REFCNT()`.
29909
 
+  not functions.  :c:macro:`Py_Size()` became :c:macro:`Py_SIZE()`,
29910
 
+  :c:macro:`Py_Type()` became :c:macro:`Py_TYPE()`, and
29911
 
+  :c:macro:`Py_Refcnt()` became :c:macro:`Py_REFCNT()`.
29912
 
   The mixed-case macros are still available
29913
 
   in Python 2.6 for backward compatibility.
29914
 
   (:issue:`1629`)
29915
 
@@ -3115,7 +3115,7 @@
29916
 
 
29917
 
 * The :mod:`socket` module's socket objects now have an
29918
 
   :meth:`ioctl` method that provides a limited interface to the
29919
 
-  :cfunc:`WSAIoctl` system interface.
29920
 
+  :c:func:`WSAIoctl` system interface.
29921
 
 
29922
 
 * The :mod:`_winreg` module now has a function,
29923
 
   :func:`ExpandEnvironmentStrings`,
29924
 
@@ -3261,13 +3261,13 @@
29925
 
   the implementation now explicitly checks for this case and raises
29926
 
   an :exc:`ImportError`.
29927
 
 
29928
 
-* C API: the :cfunc:`PyImport_Import` and :cfunc:`PyImport_ImportModule`
29929
 
+* C API: the :c:func:`PyImport_Import` and :c:func:`PyImport_ImportModule`
29930
 
   functions now default to absolute imports, not relative imports.
29931
 
   This will affect C extensions that import other modules.
29932
 
 
29933
 
 * C API: extension data types that shouldn't be hashable
29934
 
   should define their ``tp_hash`` slot to
29935
 
-  :cfunc:`PyObject_HashNotImplemented`.
29936
 
+  :c:func:`PyObject_HashNotImplemented`.
29937
 
 
29938
 
 * The :mod:`socket` module exception :exc:`socket.error` now inherits
29939
 
   from :exc:`IOError`.  Previously it wasn't a subclass of
29940
 
diff -r 8527427914a2 Doc/whatsnew/2.7.rst
29941
 
--- a/Doc/whatsnew/2.7.rst
29942
 
+++ b/Doc/whatsnew/2.7.rst
29943
 
@@ -147,8 +147,8 @@
29944
 
   ``float(repr(x))`` recovers ``x``.
29945
 
 * Float-to-string and string-to-float conversions are correctly rounded.
29946
 
   The :func:`round` function is also now correctly rounded.
29947
 
-* The :ctype:`PyCapsule` type, used to provide a C API for extension modules.
29948
 
-* The :cfunc:`PyLong_AsLongAndOverflow` C API function.
29949
 
+* The :c:type:`PyCapsule` type, used to provide a C API for extension modules.
29950
 
+* The :c:func:`PyLong_AsLongAndOverflow` C API function.
29951
 
 
29952
 
 Other new Python3-mode warnings include:
29953
 
 
29954
 
@@ -311,7 +311,7 @@
29955
 
 This means Python now supports three different modules for parsing
29956
 
 command-line arguments: :mod:`getopt`, :mod:`optparse`, and
29957
 
 :mod:`argparse`.  The :mod:`getopt` module closely resembles the C
29958
 
-library's :cfunc:`getopt` function, so it remains useful if you're writing a
29959
 
+library's :c:func:`getopt` function, so it remains useful if you're writing a
29960
 
 Python prototype that will eventually be rewritten in C.
29961
 
 :mod:`optparse` becomes redundant, but there are no plans to remove it
29962
 
 because there are many scripts still using it, and there's no
29963
 
@@ -783,8 +783,8 @@
29964
 
 
29965
 
   (Contributed by Fredrik Johansson and Victor Stinner; :issue:`3439`.)
29966
 
 
29967
 
-* The :keyword:`import` statement will no longer try a relative import
29968
 
-  if an absolute import (e.g. ``from .os import sep``) fails.  This
29969
 
+* The :keyword:`import` statement will no longer try an absolute import
29970
 
+  if a relative import (e.g. ``from .os import sep``) fails.  This
29971
 
   fixes a bug, but could possibly break certain :keyword:`import`
29972
 
   statements that were only working by accident.  (Fixed by Meador Inge;
29973
 
   :issue:`7902`.)
29974
 
@@ -1478,7 +1478,7 @@
29975
 
 * The :mod:`ssl` module's :class:`~ssl.SSLSocket` objects now support the
29976
 
   buffer API, which fixed a test suite failure (fix by Antoine Pitrou;
29977
 
   :issue:`7133`) and automatically set
29978
 
-  OpenSSL's :cmacro:`SSL_MODE_AUTO_RETRY`, which will prevent an error
29979
 
+  OpenSSL's :c:macro:`SSL_MODE_AUTO_RETRY`, which will prevent an error
29980
 
   code being returned from :meth:`recv` operations that trigger an SSL
29981
 
   renegotiation (fix by Antoine Pitrou; :issue:`8222`).
29982
 
 
29983
 
@@ -1946,7 +1946,7 @@
29984
 
 version 1.3.  Some of the new features are:
29985
 
 
29986
 
 * The various parsing functions now take a *parser* keyword argument
29987
 
-  giving an :class:`XMLParser` instance that will
29988
 
+  giving an :class:`~xml.etree.ElementTree.XMLParser` instance that will
29989
 
   be used.  This makes it possible to override the file's internal encoding::
29990
 
 
29991
 
     p = ET.XMLParser(encoding='utf-8')
29992
 
@@ -1958,8 +1958,8 @@
29993
 
 
29994
 
 * ElementTree's code for converting trees to a string has been
29995
 
   significantly reworked, making it roughly twice as fast in many
29996
 
-  cases.  The :class:`ElementTree` :meth:`write` and :class:`Element`
29997
 
-  :meth:`write` methods now have a *method* parameter that can be
29998
 
+  cases.  The :meth:`ElementTree.write() <xml.etree.ElementTree.ElementTree.write>`
29999
 
+  and :meth:`Element.write` methods now have a *method* parameter that can be
30000
 
   "xml" (the default), "html", or "text".  HTML mode will output empty
30001
 
   elements as ``<empty></empty>`` instead of ``<empty/>``, and text
30002
 
   mode will skip over elements and only output the text chunks.  If
30003
 
@@ -1972,11 +1972,12 @@
30004
 
   declarations are now output on the root element, not scattered throughout
30005
 
   the resulting XML.  You can set the default namespace for a tree
30006
 
   by setting the :attr:`default_namespace` attribute and can
30007
 
-  register new prefixes with :meth:`register_namespace`.  In XML mode,
30008
 
+  register new prefixes with :meth:`~xml.etree.ElementTree.register_namespace`.  In XML mode,
30009
 
   you can use the true/false *xml_declaration* parameter to suppress the
30010
 
   XML declaration.
30011
 
 
30012
 
-* New :class:`Element` method: :meth:`extend` appends the items from a
30013
 
+* New :class:`~xml.etree.ElementTree.Element` method:
30014
 
+  :meth:`~xml.etree.ElementTree.Element.extend` appends the items from a
30015
 
   sequence to the element's children.  Elements themselves behave like
30016
 
   sequences, so it's easy to move children from one element to
30017
 
   another::
30018
 
@@ -1992,13 +1993,15 @@
30019
 
     # Outputs <root><item>1</item>...</root>
30020
 
     print ET.tostring(new)
30021
 
 
30022
 
-* New :class:`Element` method: :meth:`iter` yields the children of the
30023
 
+* New :class:`Element` method:
30024
 
+  :meth:`~xml.etree.ElementTree.Element.iter` yields the children of the
30025
 
   element as a generator.  It's also possible to write ``for child in
30026
 
   elem:`` to loop over an element's children.  The existing method
30027
 
   :meth:`getiterator` is now deprecated, as is :meth:`getchildren`
30028
 
   which constructs and returns a list of children.
30029
 
 
30030
 
-* New :class:`Element` method: :meth:`itertext` yields all chunks of
30031
 
+* New :class:`Element` method:
30032
 
+  :meth:`~xml.etree.ElementTree.Element.itertext` yields all chunks of
30033
 
   text that are descendants of the element.  For example::
30034
 
 
30035
 
     t = ET.XML("""<list>
30036
 
@@ -2047,49 +2050,49 @@
30037
 
   debugged doesn't hold the GIL; the macro now acquires it before printing.
30038
 
   (Contributed by Victor Stinner; :issue:`3632`.)
30039
 
 
30040
 
-* :cfunc:`Py_AddPendingCall` is now thread-safe, letting any
30041
 
+* :c:func:`Py_AddPendingCall` is now thread-safe, letting any
30042
 
   worker thread submit notifications to the main Python thread.  This
30043
 
   is particularly useful for asynchronous IO operations.
30044
 
   (Contributed by Kristján Valur Jónsson; :issue:`4293`.)
30045
 
 
30046
 
-* New function: :cfunc:`PyCode_NewEmpty` creates an empty code object;
30047
 
+* New function: :c:func:`PyCode_NewEmpty` creates an empty code object;
30048
 
   only the filename, function name, and first line number are required.
30049
 
   This is useful for extension modules that are attempting to
30050
 
   construct a more useful traceback stack.  Previously such
30051
 
-  extensions needed to call :cfunc:`PyCode_New`, which had many
30052
 
+  extensions needed to call :c:func:`PyCode_New`, which had many
30053
 
   more arguments.  (Added by Jeffrey Yasskin.)
30054
 
 
30055
 
-* New function: :cfunc:`PyErr_NewExceptionWithDoc` creates a new
30056
 
-  exception class, just as the existing :cfunc:`PyErr_NewException` does,
30057
 
+* New function: :c:func:`PyErr_NewExceptionWithDoc` creates a new
30058
 
+  exception class, just as the existing :c:func:`PyErr_NewException` does,
30059
 
   but takes an extra ``char *`` argument containing the docstring for the
30060
 
   new exception class.  (Added by 'lekma' on the Python bug tracker;
30061
 
   :issue:`7033`.)
30062
 
 
30063
 
-* New function: :cfunc:`PyFrame_GetLineNumber` takes a frame object
30064
 
+* New function: :c:func:`PyFrame_GetLineNumber` takes a frame object
30065
 
   and returns the line number that the frame is currently executing.
30066
 
   Previously code would need to get the index of the bytecode
30067
 
   instruction currently executing, and then look up the line number
30068
 
   corresponding to that address.  (Added by Jeffrey Yasskin.)
30069
 
 
30070
 
-* New functions: :cfunc:`PyLong_AsLongAndOverflow` and
30071
 
-  :cfunc:`PyLong_AsLongLongAndOverflow`  approximates a Python long
30072
 
-  integer as a C :ctype:`long` or :ctype:`long long`.
30073
 
+* New functions: :c:func:`PyLong_AsLongAndOverflow` and
30074
 
+  :c:func:`PyLong_AsLongLongAndOverflow`  approximates a Python long
30075
 
+  integer as a C :c:type:`long` or :c:type:`long long`.
30076
 
   If the number is too large to fit into
30077
 
   the output type, an *overflow* flag is set and returned to the caller.
30078
 
   (Contributed by Case Van Horsen; :issue:`7528` and :issue:`7767`.)
30079
 
 
30080
 
 * New function: stemming from the rewrite of string-to-float conversion,
30081
 
-  a new :cfunc:`PyOS_string_to_double` function was added.  The old
30082
 
-  :cfunc:`PyOS_ascii_strtod` and :cfunc:`PyOS_ascii_atof` functions
30083
 
+  a new :c:func:`PyOS_string_to_double` function was added.  The old
30084
 
+  :c:func:`PyOS_ascii_strtod` and :c:func:`PyOS_ascii_atof` functions
30085
 
   are now deprecated.
30086
 
 
30087
 
-* New function: :cfunc:`PySys_SetArgvEx` sets the value of
30088
 
+* New function: :c:func:`PySys_SetArgvEx` sets the value of
30089
 
   ``sys.argv`` and can optionally update ``sys.path`` to include the
30090
 
   directory containing the script named by ``sys.argv[0]`` depending
30091
 
   on the value of an *updatepath* parameter.
30092
 
 
30093
 
   This function was added to close a security hole for applications
30094
 
-  that embed Python.  The old function, :cfunc:`PySys_SetArgv`, would
30095
 
+  that embed Python.  The old function, :c:func:`PySys_SetArgv`, would
30096
 
   always update ``sys.path``, and sometimes it would add the current
30097
 
   directory.  This meant that, if you ran an application embedding
30098
 
   Python in a directory controlled by someone else, attackers could
30099
 
@@ -2097,8 +2100,8 @@
30100
 
   :file:`os.py`) that your application would then import and run.
30101
 
 
30102
 
   If you maintain a C/C++ application that embeds Python, check
30103
 
-  whether you're calling :cfunc:`PySys_SetArgv` and carefully consider
30104
 
-  whether the application should be using :cfunc:`PySys_SetArgvEx`
30105
 
+  whether you're calling :c:func:`PySys_SetArgv` and carefully consider
30106
 
+  whether the application should be using :c:func:`PySys_SetArgvEx`
30107
 
   with *updatepath* set to false.
30108
 
 
30109
 
   Security issue reported as `CVE-2008-5983
30110
 
@@ -2106,14 +2109,14 @@
30111
 
   discussed in :issue:`5753`, and fixed by Antoine Pitrou.
30112
 
 
30113
 
 * New macros: the Python header files now define the following macros:
30114
 
-  :cmacro:`Py_ISALNUM`,
30115
 
-  :cmacro:`Py_ISALPHA`,
30116
 
-  :cmacro:`Py_ISDIGIT`,
30117
 
-  :cmacro:`Py_ISLOWER`,
30118
 
-  :cmacro:`Py_ISSPACE`,
30119
 
-  :cmacro:`Py_ISUPPER`,
30120
 
-  :cmacro:`Py_ISXDIGIT`,
30121
 
-  :cmacro:`Py_TOLOWER`, and :cmacro:`Py_TOUPPER`.
30122
 
+  :c:macro:`Py_ISALNUM`,
30123
 
+  :c:macro:`Py_ISALPHA`,
30124
 
+  :c:macro:`Py_ISDIGIT`,
30125
 
+  :c:macro:`Py_ISLOWER`,
30126
 
+  :c:macro:`Py_ISSPACE`,
30127
 
+  :c:macro:`Py_ISUPPER`,
30128
 
+  :c:macro:`Py_ISXDIGIT`,
30129
 
+  :c:macro:`Py_TOLOWER`, and :c:macro:`Py_TOUPPER`.
30130
 
   All of these functions are analogous to the C
30131
 
   standard macros for classifying characters, but ignore the current
30132
 
   locale setting, because in
30133
 
@@ -2123,15 +2126,15 @@
30134
 
 
30135
 
   .. XXX these macros don't seem to be described in the c-api docs.
30136
 
 
30137
 
-* Removed function: :cmacro:`PyEval_CallObject` is now only available
30138
 
+* Removed function: :c:macro:`PyEval_CallObject` is now only available
30139
 
   as a macro.  A function version was being kept around to preserve
30140
 
   ABI linking compatibility, but that was in 1997; it can certainly be
30141
 
   deleted by now.  (Removed by Antoine Pitrou; :issue:`8276`.)
30142
 
 
30143
 
-* New format codes: the :cfunc:`PyFormat_FromString`,
30144
 
-  :cfunc:`PyFormat_FromStringV`, and :cfunc:`PyErr_Format` functions now
30145
 
+* New format codes: the :c:func:`PyFormat_FromString`,
30146
 
+  :c:func:`PyFormat_FromStringV`, and :c:func:`PyErr_Format` functions now
30147
 
   accept ``%lld`` and ``%llu`` format codes for displaying
30148
 
-  C's :ctype:`long long` types.
30149
 
+  C's :c:type:`long long` types.
30150
 
   (Contributed by Mark Dickinson; :issue:`7228`.)
30151
 
 
30152
 
 * The complicated interaction between threads and process forking has
30153
 
@@ -2147,17 +2150,17 @@
30154
 
   Python 2.7 acquires the import lock before performing an
30155
 
   :func:`os.fork`, and will also clean up any locks created using the
30156
 
   :mod:`threading` module.  C extension modules that have internal
30157
 
-  locks, or that call :cfunc:`fork()` themselves, will not benefit
30158
 
+  locks, or that call :c:func:`fork()` themselves, will not benefit
30159
 
   from this clean-up.
30160
 
 
30161
 
   (Fixed by Thomas Wouters; :issue:`1590864`.)
30162
 
 
30163
 
-* The :cfunc:`Py_Finalize` function now calls the internal
30164
 
+* The :c:func:`Py_Finalize` function now calls the internal
30165
 
   :func:`threading._shutdown` function; this prevents some exceptions from
30166
 
   being raised when an interpreter shuts down.
30167
 
   (Patch by Adam Olsen; :issue:`1722344`.)
30168
 
 
30169
 
-* When using the :ctype:`PyMemberDef` structure to define attributes
30170
 
+* When using the :c:type:`PyMemberDef` structure to define attributes
30171
 
   of a type, Python will no longer let you try to delete or set a
30172
 
   :const:`T_STRING_INPLACE` attribute.
30173
 
 
30174
 
@@ -2184,7 +2187,7 @@
30175
 
   :issue:`6491`.)
30176
 
 
30177
 
 * The :program:`configure` script now checks for floating-point rounding bugs
30178
 
-  on certain 32-bit Intel chips and defines a :cmacro:`X87_DOUBLE_ROUNDING`
30179
 
+  on certain 32-bit Intel chips and defines a :c:macro:`X87_DOUBLE_ROUNDING`
30180
 
   preprocessor definition.  No code currently uses this definition,
30181
 
   but it's available if anyone wishes to use it.
30182
 
   (Added by Mark Dickinson; :issue:`2937`.)
30183
 
@@ -2205,7 +2208,7 @@
30184
 
 Capsules
30185
 
 -------------------
30186
 
 
30187
 
-Python 3.1 adds a new C datatype, :ctype:`PyCapsule`, for providing a
30188
 
+Python 3.1 adds a new C datatype, :c:type:`PyCapsule`, for providing a
30189
 
 C API to an extension module.  A capsule is essentially the holder of
30190
 
 a C ``void *`` pointer, and is made available as a module attribute; for
30191
 
 example, the :mod:`socket` module's API is exposed as ``socket.CAPI``,
30192
 
@@ -2215,10 +2218,10 @@
30193
 
 to an array of pointers to the module's various API functions.
30194
 
 
30195
 
 There is an existing data type already used for this,
30196
 
-:ctype:`PyCObject`, but it doesn't provide type safety.  Evil code
30197
 
+:c:type:`PyCObject`, but it doesn't provide type safety.  Evil code
30198
 
 written in pure Python could cause a segmentation fault by taking a
30199
 
-:ctype:`PyCObject` from module A and somehow substituting it for the
30200
 
-:ctype:`PyCObject` in module B.   Capsules know their own name,
30201
 
+:c:type:`PyCObject` from module A and somehow substituting it for the
30202
 
+:c:type:`PyCObject` in module B.   Capsules know their own name,
30203
 
 and getting the pointer requires providing the name::
30204
 
 
30205
 
    void *vtable;
30206
 
@@ -2231,15 +2234,15 @@
30207
 
    vtable = PyCapsule_GetPointer(capsule, "mymodule.CAPI");
30208
 
 
30209
 
 You are assured that ``vtable`` points to whatever you're expecting.
30210
 
-If a different capsule was passed in, :cfunc:`PyCapsule_IsValid` would
30211
 
+If a different capsule was passed in, :c:func:`PyCapsule_IsValid` would
30212
 
 detect the mismatched name and return false.  Refer to
30213
 
 :ref:`using-capsules` for more information on using these objects.
30214
 
 
30215
 
 Python 2.7 now uses capsules internally to provide various
30216
 
-extension-module APIs, but the :cfunc:`PyCObject_AsVoidPtr` was
30217
 
+extension-module APIs, but the :c:func:`PyCObject_AsVoidPtr` was
30218
 
 modified to handle capsules, preserving compile-time compatibility
30219
 
-with the :ctype:`CObject` interface.  Use of
30220
 
-:cfunc:`PyCObject_AsVoidPtr` will signal a
30221
 
+with the :c:type:`CObject` interface.  Use of
30222
 
+:c:func:`PyCObject_AsVoidPtr` will signal a
30223
 
 :exc:`PendingDeprecationWarning`, which is silent by default.
30224
 
 
30225
 
 Implemented in Python 3.1 and backported to 2.7 by Larry Hastings;
30226
 
@@ -2266,7 +2269,7 @@
30227
 
   were also tested and documented.
30228
 
   (Implemented by Brian Curtin: :issue:`7347`.)
30229
 
 
30230
 
-* The new :cfunc:`_beginthreadex` API is used to start threads, and
30231
 
+* The new :c:func:`_beginthreadex` API is used to start threads, and
30232
 
   the native thread-local storage functions are now used.
30233
 
   (Contributed by Kristján Valur Jónsson; :issue:`3582`.)
30234
 
 
30235
 
@@ -2274,7 +2277,7 @@
30236
 
   can be the constants :const:`CTRL_C_EVENT`,
30237
 
   :const:`CTRL_BREAK_EVENT`, or any integer.  The first two constants
30238
 
   will send Control-C and Control-Break keystroke events to
30239
 
-  subprocesses; any other value will use the :cfunc:`TerminateProcess`
30240
 
+  subprocesses; any other value will use the :c:func:`TerminateProcess`
30241
 
   API.  (Contributed by Miki Tebeka; :issue:`1220212`.)
30242
 
 
30243
 
 * The :func:`os.listdir` function now correctly fails
30244
 
@@ -2447,17 +2450,17 @@
30245
 
   family of functions will now raise a :exc:`TypeError` exception
30246
 
   instead of triggering a :exc:`DeprecationWarning` (:issue:`5080`).
30247
 
 
30248
 
-* Use the new :cfunc:`PyOS_string_to_double` function instead of the old
30249
 
-  :cfunc:`PyOS_ascii_strtod` and :cfunc:`PyOS_ascii_atof` functions,
30250
 
+* Use the new :c:func:`PyOS_string_to_double` function instead of the old
30251
 
+  :c:func:`PyOS_ascii_strtod` and :c:func:`PyOS_ascii_atof` functions,
30252
 
   which are now deprecated.
30253
 
 
30254
 
 For applications that embed Python:
30255
 
 
30256
 
-* The :cfunc:`PySys_SetArgvEx` function was added, letting
30257
 
+* The :c:func:`PySys_SetArgvEx` function was added, letting
30258
 
   applications close a security hole when the existing
30259
 
-  :cfunc:`PySys_SetArgv` function was used.  Check whether you're
30260
 
-  calling :cfunc:`PySys_SetArgv` and carefully consider whether the
30261
 
-  application should be using :cfunc:`PySys_SetArgvEx` with
30262
 
+  :c:func:`PySys_SetArgv` function was used.  Check whether you're
30263
 
+  calling :c:func:`PySys_SetArgv` and carefully consider whether the
30264
 
+  application should be using :c:func:`PySys_SetArgvEx` with
30265
 
   *updatepath* set to false.
30266
 
 
30267
 
 .. ======================================================================
30268
 
diff -r 8527427914a2 Include/fileobject.h
30269
 
--- a/Include/fileobject.h
30270
 
+++ b/Include/fileobject.h
30271
 
@@ -84,6 +84,13 @@
30272
 
 #define _PyVerify_fd(A) (1) /* dummy */
30273
 
 #endif
30274
 
 
30275
 
+/* A routine to check if a file descriptor can be select()-ed. */
30276
 
+#ifdef HAVE_SELECT
30277
 
+ #define _PyIsSelectable_fd(FD) (((FD) >= 0) && ((FD) < FD_SETSIZE))
30278
 
+#else
30279
 
+ #define _PyIsSelectable_fd(FD) (1)
30280
 
+#endif /* HAVE_SELECT */
30281
 
+
30282
 
 #ifdef __cplusplus
30283
 
 }
30284
 
 #endif
30285
 
diff -r 8527427914a2 Include/patchlevel.h
30286
 
--- a/Include/patchlevel.h
30287
 
+++ b/Include/patchlevel.h
30288
 
@@ -27,7 +27,7 @@
30289
 
 #define PY_RELEASE_SERIAL      0
30290
 
 
30291
 
 /* Version as a string */
30292
 
-#define PY_VERSION             "2.7.2"
30293
 
+#define PY_VERSION             "2.7.2+"
30294
 
 /*--end constants--*/
30295
 
 
30296
 
 /* Subversion Revision number of this file (not of the repository). Empty
30297
 
diff -r 8527427914a2 Include/pyctype.h
30298
 
--- a/Include/pyctype.h
30299
 
+++ b/Include/pyctype.h
30300
 
@@ -9,7 +9,7 @@
30301
 
 #define PY_CTF_SPACE  0x08
30302
 
 #define PY_CTF_XDIGIT 0x10
30303
 
 
30304
 
-extern const unsigned int _Py_ctype_table[256];
30305
 
+PyAPI_DATA(const unsigned int) _Py_ctype_table[256];
30306
 
 
30307
 
 /* Unlike their C counterparts, the following macros are not meant to
30308
 
  * handle an int with any of the values [EOF, 0-UCHAR_MAX]. The argument
30309
 
@@ -22,8 +22,8 @@
30310
 
 #define Py_ISALNUM(c)  (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALNUM)
30311
 
 #define Py_ISSPACE(c)  (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_SPACE)
30312
 
 
30313
 
-extern const unsigned char _Py_ctype_tolower[256];
30314
 
-extern const unsigned char _Py_ctype_toupper[256];
30315
 
+PyAPI_DATA(const unsigned char) _Py_ctype_tolower[256];
30316
 
+PyAPI_DATA(const unsigned char) _Py_ctype_toupper[256];
30317
 
 
30318
 
 #define Py_TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)])
30319
 
 #define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)])
30320
 
diff -r 8527427914a2 Include/pystate.h
30321
 
--- a/Include/pystate.h
30322
 
+++ b/Include/pystate.h
30323
 
@@ -111,7 +111,6 @@
30324
 
 PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *);
30325
 
 #ifdef WITH_THREAD
30326
 
 PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
30327
 
-PyAPI_FUNC(void) _PyGILState_Reinit(void);
30328
 
 #endif
30329
 
 
30330
 
 PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void);
30331
 
@@ -169,7 +168,7 @@
30332
 
 
30333
 
 /* Helper/diagnostic function - get the current thread state for
30334
 
    this thread.  May return NULL if no GILState API has been used
30335
 
-   on the current thread.  Note the main thread always has such a
30336
 
+   on the current thread.  Note that the main thread always has such a
30337
 
    thread-state, even if no auto-thread-state call has been made
30338
 
    on the main thread.
30339
 
 */
30340
 
diff -r 8527427914a2 LICENSE
30341
 
--- a/LICENSE
30342
 
+++ b/LICENSE
30343
 
@@ -98,9 +98,9 @@
30344
 
 analyze, test, perform and/or display publicly, prepare derivative works,
30345
 
 distribute, and otherwise use Python alone or in any derivative version,
30346
 
 provided, however, that PSF's License Agreement and PSF's notice of copyright,
30347
 
-i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
30348
 
-Python Software Foundation; All Rights Reserved" are retained in Python alone or
30349
 
-in any derivative version prepared by Licensee.
30350
 
+i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
30351
 
+2011, 2012 Python Software Foundation; All Rights Reserved" are retained in Python
30352
 
+alone or in any derivative version prepared by Licensee.
30353
 
 
30354
 
 3. In the event Licensee prepares a derivative work that is based on
30355
 
 or incorporates Python or any part thereof, and wants to make
30356
 
diff -r 8527427914a2 Lib/BaseHTTPServer.py
30357
 
--- a/Lib/BaseHTTPServer.py
30358
 
+++ b/Lib/BaseHTTPServer.py
30359
 
@@ -244,14 +244,11 @@
30360
 
         self.request_version = version = self.default_request_version
30361
 
         self.close_connection = 1
30362
 
         requestline = self.raw_requestline
30363
 
-        if requestline[-2:] == '\r\n':
30364
 
-            requestline = requestline[:-2]
30365
 
-        elif requestline[-1:] == '\n':
30366
 
-            requestline = requestline[:-1]
30367
 
+        requestline = requestline.rstrip('\r\n')
30368
 
         self.requestline = requestline
30369
 
         words = requestline.split()
30370
 
         if len(words) == 3:
30371
 
-            [command, path, version] = words
30372
 
+            command, path, version = words
30373
 
             if version[:5] != 'HTTP/':
30374
 
                 self.send_error(400, "Bad request version (%r)" % version)
30375
 
                 return False
30376
 
@@ -277,7 +274,7 @@
30377
 
                           "Invalid HTTP Version (%s)" % base_version_number)
30378
 
                 return False
30379
 
         elif len(words) == 2:
30380
 
-            [command, path] = words
30381
 
+            command, path = words
30382
 
             self.close_connection = 1
30383
 
             if command != 'GET':
30384
 
                 self.send_error(400,
30385
 
diff -r 8527427914a2 Lib/ConfigParser.py
30386
 
--- a/Lib/ConfigParser.py
30387
 
+++ b/Lib/ConfigParser.py
30388
 
@@ -142,6 +142,7 @@
30389
 
     def __init__(self, section):
30390
 
         Error.__init__(self, 'No section: %r' % (section,))
30391
 
         self.section = section
30392
 
+        self.args = (section, )
30393
 
 
30394
 
 class DuplicateSectionError(Error):
30395
 
     """Raised when a section is multiply-created."""
30396
 
@@ -149,6 +150,7 @@
30397
 
     def __init__(self, section):
30398
 
         Error.__init__(self, "Section %r already exists" % section)
30399
 
         self.section = section
30400
 
+        self.args = (section, )
30401
 
 
30402
 
 class NoOptionError(Error):
30403
 
     """A requested option was not found."""
30404
 
@@ -158,6 +160,7 @@
30405
 
                        (option, section))
30406
 
         self.option = option
30407
 
         self.section = section
30408
 
+        self.args = (option, section)
30409
 
 
30410
 
 class InterpolationError(Error):
30411
 
     """Base class for interpolation-related exceptions."""
30412
 
@@ -166,6 +169,7 @@
30413
 
         Error.__init__(self, msg)
30414
 
         self.option = option
30415
 
         self.section = section
30416
 
+        self.args = (option, section, msg)
30417
 
 
30418
 
 class InterpolationMissingOptionError(InterpolationError):
30419
 
     """A string substitution required a setting which was not available."""
30420
 
@@ -179,6 +183,7 @@
30421
 
                % (section, option, reference, rawval))
30422
 
         InterpolationError.__init__(self, option, section, msg)
30423
 
         self.reference = reference
30424
 
+        self.args = (option, section, rawval, reference)
30425
 
 
30426
 
 class InterpolationSyntaxError(InterpolationError):
30427
 
     """Raised when the source text into which substitutions are made
30428
 
@@ -194,6 +199,7 @@
30429
 
                "\trawval : %s\n"
30430
 
                % (section, option, rawval))
30431
 
         InterpolationError.__init__(self, option, section, msg)
30432
 
+        self.args = (option, section, rawval)
30433
 
 
30434
 
 class ParsingError(Error):
30435
 
     """Raised when a configuration file does not follow legal syntax."""
30436
 
@@ -202,6 +208,7 @@
30437
 
         Error.__init__(self, 'File contains parsing errors: %s' % filename)
30438
 
         self.filename = filename
30439
 
         self.errors = []
30440
 
+        self.args = (filename, )
30441
 
 
30442
 
     def append(self, lineno, line):
30443
 
         self.errors.append((lineno, line))
30444
 
@@ -218,6 +225,7 @@
30445
 
         self.filename = filename
30446
 
         self.lineno = lineno
30447
 
         self.line = line
30448
 
+        self.args = (filename, lineno, line)
30449
 
 
30450
 
 
30451
 
 class RawConfigParser:
30452
 
@@ -570,7 +578,7 @@
30453
 
     def keys(self):
30454
 
         result = []
30455
 
         seen = set()
30456
 
-        for mapping in self_maps:
30457
 
+        for mapping in self._maps:
30458
 
             for key in mapping:
30459
 
                 if key not in seen:
30460
 
                     result.append(key)
30461
 
diff -r 8527427914a2 Lib/HTMLParser.py
30462
 
--- a/Lib/HTMLParser.py
30463
 
+++ b/Lib/HTMLParser.py
30464
 
@@ -14,7 +14,6 @@
30465
 
 # Regular expressions used for parsing
30466
 
 
30467
 
 interesting_normal = re.compile('[&<]')
30468
 
-interesting_cdata = re.compile(r'<(/|\Z)')
30469
 
 incomplete = re.compile('&[a-zA-Z#]')
30470
 
 
30471
 
 entityref = re.compile('&([a-zA-Z][-.a-zA-Z0-9]*)[^a-zA-Z0-9]')
30472
 
@@ -24,25 +23,31 @@
30473
 
 piclose = re.compile('>')
30474
 
 commentclose = re.compile(r'--\s*>')
30475
 
 tagfind = re.compile('[a-zA-Z][-.a-zA-Z0-9:_]*')
30476
 
+# see http://www.w3.org/TR/html5/tokenization.html#tag-open-state
30477
 
+# and http://www.w3.org/TR/html5/tokenization.html#tag-name-state
30478
 
+tagfind_tolerant = re.compile('[a-zA-Z][^\t\n\r\f />\x00]*')
30479
 
+
30480
 
 attrfind = re.compile(
30481
 
-    r'\s*([a-zA-Z_][-.:a-zA-Z_0-9]*)(\s*=\s*'
30482
 
-    r'(\'[^\']*\'|"[^"]*"|[^\s"\'=<>`]*))?')
30483
 
+    r'\s*((?<=[\'"\s])[^\s/>][^\s/=>]*)(\s*=+\s*'
30484
 
+    r'(\'[^\']*\'|"[^"]*"|(?![\'"])[^>\s]*))?')
30485
 
 
30486
 
 locatestarttagend = re.compile(r"""
30487
 
   <[a-zA-Z][-.a-zA-Z0-9:_]*          # tag name
30488
 
   (?:\s+                             # whitespace before attribute name
30489
 
-    (?:[a-zA-Z_][-.:a-zA-Z0-9_]*     # attribute name
30490
 
-      (?:\s*=\s*                     # value indicator
30491
 
+    (?:(?<=['"\s])[^\s/>][^\s/=>]*   # attribute name
30492
 
+      (?:\s*=+\s*                    # value indicator
30493
 
         (?:'[^']*'                   # LITA-enclosed value
30494
 
-          |\"[^\"]*\"                # LIT-enclosed value
30495
 
-          |[^'\">\s]+                # bare value
30496
 
+          |"[^"]*"                   # LIT-enclosed value
30497
 
+          |(?!['"])[^>\s]*           # bare value
30498
 
          )
30499
 
-       )?
30500
 
-     )
30501
 
-   )*
30502
 
+       )?\s*
30503
 
+     )*
30504
 
+   )?
30505
 
   \s*                                # trailing whitespace
30506
 
 """, re.VERBOSE)
30507
 
 endendtag = re.compile('>')
30508
 
+# the HTML 5 spec, section 8.1.2.2, doesn't allow spaces between
30509
 
+# </ and the tag name, so maybe this should be fixed
30510
 
 endtagfind = re.compile('</\s*([a-zA-Z][-.a-zA-Z0-9:_]*)\s*>')
30511
 
 
30512
 
 
30513
 
@@ -96,6 +101,7 @@
30514
 
         self.rawdata = ''
30515
 
         self.lasttag = '???'
30516
 
         self.interesting = interesting_normal
30517
 
+        self.cdata_elem = None
30518
 
         markupbase.ParserBase.reset(self)
30519
 
 
30520
 
     def feed(self, data):
30521
 
@@ -120,11 +126,13 @@
30522
 
         """Return full source of start tag: '<...>'."""
30523
 
         return self.__starttag_text
30524
 
 
30525
 
-    def set_cdata_mode(self):
30526
 
-        self.interesting = interesting_cdata
30527
 
+    def set_cdata_mode(self, elem):
30528
 
+        self.cdata_elem = elem.lower()
30529
 
+        self.interesting = re.compile(r'</\s*%s\s*>' % self.cdata_elem, re.I)
30530
 
 
30531
 
     def clear_cdata_mode(self):
30532
 
         self.interesting = interesting_normal
30533
 
+        self.cdata_elem = None
30534
 
 
30535
 
     # Internal -- handle data as far as reasonable.  May leave state
30536
 
     # and data to be processed by a subsequent call.  If 'end' is
30537
 
@@ -138,6 +146,8 @@
30538
 
             if match:
30539
 
                 j = match.start()
30540
 
             else:
30541
 
+                if self.cdata_elem:
30542
 
+                    break
30543
 
                 j = n
30544
 
             if i < j: self.handle_data(rawdata[i:j])
30545
 
             i = self.updatepos(i, j)
30546
 
@@ -153,16 +163,23 @@
30547
 
                 elif startswith("<?", i):
30548
 
                     k = self.parse_pi(i)
30549
 
                 elif startswith("<!", i):
30550
 
-                    k = self.parse_declaration(i)
30551
 
+                    k = self.parse_html_declaration(i)
30552
 
                 elif (i + 1) < n:
30553
 
                     self.handle_data("<")
30554
 
                     k = i + 1
30555
 
                 else:
30556
 
                     break
30557
 
                 if k < 0:
30558
 
-                    if end:
30559
 
-                        self.error("EOF in middle of construct")
30560
 
-                    break
30561
 
+                    if not end:
30562
 
+                        break
30563
 
+                    k = rawdata.find('>', i + 1)
30564
 
+                    if k < 0:
30565
 
+                        k = rawdata.find('<', i + 1)
30566
 
+                        if k < 0:
30567
 
+                            k = i + 1
30568
 
+                    else:
30569
 
+                        k += 1
30570
 
+                    self.handle_data(rawdata[i:k])
30571
 
                 i = self.updatepos(i, k)
30572
 
             elif startswith("&#", i):
30573
 
                 match = charref.match(rawdata, i)
30574
 
@@ -206,11 +223,46 @@
30575
 
             else:
30576
 
                 assert 0, "interesting.search() lied"
30577
 
         # end while
30578
 
-        if end and i < n:
30579
 
+        if end and i < n and not self.cdata_elem:
30580
 
             self.handle_data(rawdata[i:n])
30581
 
             i = self.updatepos(i, n)
30582
 
         self.rawdata = rawdata[i:]
30583
 
 
30584
 
+    # Internal -- parse html declarations, return length or -1 if not terminated
30585
 
+    # See w3.org/TR/html5/tokenization.html#markup-declaration-open-state
30586
 
+    # See also parse_declaration in _markupbase
30587
 
+    def parse_html_declaration(self, i):
30588
 
+        rawdata = self.rawdata
30589
 
+        if rawdata[i:i+2] != '<!':
30590
 
+            self.error('unexpected call to parse_html_declaration()')
30591
 
+        if rawdata[i:i+4] == '<!--':
30592
 
+            # this case is actually already handled in goahead()
30593
 
+            return self.parse_comment(i)
30594
 
+        elif rawdata[i:i+3] == '<![':
30595
 
+            return self.parse_marked_section(i)
30596
 
+        elif rawdata[i:i+9].lower() == '<!doctype':
30597
 
+            # find the closing >
30598
 
+            gtpos = rawdata.find('>', i+9)
30599
 
+            if gtpos == -1:
30600
 
+                return -1
30601
 
+            self.handle_decl(rawdata[i+2:gtpos])
30602
 
+            return gtpos+1
30603
 
+        else:
30604
 
+            return self.parse_bogus_comment(i)
30605
 
+
30606
 
+    # Internal -- parse bogus comment, return length or -1 if not terminated
30607
 
+    # see http://www.w3.org/TR/html5/tokenization.html#bogus-comment-state
30608
 
+    def parse_bogus_comment(self, i, report=1):
30609
 
+        rawdata = self.rawdata
30610
 
+        if rawdata[i:i+2] not in ('<!', '</'):
30611
 
+            self.error('unexpected call to parse_comment()')
30612
 
+        pos = rawdata.find('>', i+2)
30613
 
+        if pos == -1:
30614
 
+            return -1
30615
 
+        if report:
30616
 
+            self.handle_comment(rawdata[i+2:pos])
30617
 
+        return pos + 1
30618
 
+
30619
 
     # Internal -- parse processing instr, return end or -1 if not terminated
30620
 
     def parse_pi(self, i):
30621
 
         rawdata = self.rawdata
30622
 
@@ -249,6 +301,7 @@
30623
 
             elif attrvalue[:1] == '\'' == attrvalue[-1:] or \
30624
 
                  attrvalue[:1] == '"' == attrvalue[-1:]:
30625
 
                 attrvalue = attrvalue[1:-1]
30626
 
+            if attrvalue:
30627
 
                 attrvalue = self.unescape(attrvalue)
30628
 
             attrs.append((attrname.lower(), attrvalue))
30629
 
             k = m.end()
30630
 
@@ -262,15 +315,15 @@
30631
 
                          - self.__starttag_text.rfind("\n")
30632
 
             else:
30633
 
                 offset = offset + len(self.__starttag_text)
30634
 
-            self.error("junk characters in start tag: %r"
30635
 
-                       % (rawdata[k:endpos][:20],))
30636
 
+            self.handle_data(rawdata[i:endpos])
30637
 
+            return endpos
30638
 
         if end.endswith('/>'):
30639
 
             # XHTML-style empty tag: <span attr="value" />
30640
 
             self.handle_startendtag(tag, attrs)
30641
 
         else:
30642
 
             self.handle_starttag(tag, attrs)
30643
 
             if tag in self.CDATA_CONTENT_ELEMENTS:
30644
 
-                self.set_cdata_mode()
30645
 
+                self.set_cdata_mode(tag)
30646
 
         return endpos
30647
 
 
30648
 
     # Internal -- check to see if we have a complete starttag; return end
30649
 
@@ -300,8 +353,10 @@
30650
 
                 # end of input in or before attribute value, or we have the
30651
 
                 # '/' from a '/>' ending
30652
 
                 return -1
30653
 
-            self.updatepos(i, j)
30654
 
-            self.error("malformed start tag")
30655
 
+            if j > i:
30656
 
+                return j
30657
 
+            else:
30658
 
+                return i + 1
30659
 
         raise AssertionError("we should not get here!")
30660
 
 
30661
 
     # Internal -- parse endtag, return end or -1 if incomplete
30662
 
@@ -311,14 +366,38 @@
30663
 
         match = endendtag.search(rawdata, i+1) # >
30664
 
         if not match:
30665
 
             return -1
30666
 
-        j = match.end()
30667
 
+        gtpos = match.end()
30668
 
         match = endtagfind.match(rawdata, i) # </ + tag + >
30669
 
         if not match:
30670
 
-            self.error("bad end tag: %r" % (rawdata[i:j],))
30671
 
-        tag = match.group(1)
30672
 
-        self.handle_endtag(tag.lower())
30673
 
+            if self.cdata_elem is not None:
30674
 
+                self.handle_data(rawdata[i:gtpos])
30675
 
+                return gtpos
30676
 
+            # find the name: w3.org/TR/html5/tokenization.html#tag-name-state
30677
 
+            namematch = tagfind_tolerant.match(rawdata, i+2)
30678
 
+            if not namematch:
30679
 
+                # w3.org/TR/html5/tokenization.html#end-tag-open-state
30680
 
+                if rawdata[i:i+3] == '</>':
30681
 
+                    return i+3
30682
 
+                else:
30683
 
+                    return self.parse_bogus_comment(i)
30684
 
+            tagname = namematch.group().lower()
30685
 
+            # consume and ignore other stuff between the name and the >
30686
 
+            # Note: this is not 100% correct, since we might have things like
30687
 
+            # </tag attr=">">, but looking for > after tha name should cover
30688
 
+            # most of the cases and is much simpler
30689
 
+            gtpos = rawdata.find('>', namematch.end())
30690
 
+            self.handle_endtag(tagname)
30691
 
+            return gtpos+1
30692
 
+
30693
 
+        elem = match.group(1).lower() # script or style
30694
 
+        if self.cdata_elem is not None:
30695
 
+            if elem != self.cdata_elem:
30696
 
+                self.handle_data(rawdata[i:gtpos])
30697
 
+                return gtpos
30698
 
+
30699
 
+        self.handle_endtag(elem)
30700
 
         self.clear_cdata_mode()
30701
 
-        return j
30702
 
+        return gtpos
30703
 
 
30704
 
     # Overridable -- finish processing of start+end tag: <tag.../>
30705
 
     def handle_startendtag(self, tag, attrs):
30706
 
@@ -358,7 +437,7 @@
30707
 
         pass
30708
 
 
30709
 
     def unknown_decl(self, data):
30710
 
-        self.error("unknown declaration: %r" % (data,))
30711
 
+        pass
30712
 
 
30713
 
     # Internal -- helper to remove special character quoting
30714
 
     entitydefs = None
30715
 
diff -r 8527427914a2 Lib/SocketServer.py
30716
 
--- a/Lib/SocketServer.py
30717
 
+++ b/Lib/SocketServer.py
30718
 
@@ -82,7 +82,7 @@
30719
 
 data is stored externally (e.g. in the file system), a synchronous
30720
 
 class will essentially render the service "deaf" while one request is
30721
 
 being handled -- which may be for a very long time if a client is slow
30722
 
-to reqd all the data it has requested.  Here a threading or forking
30723
 
+to read all the data it has requested.  Here a threading or forking
30724
 
 server is appropriate.
30725
 
 
30726
 
 In some cases, it may be appropriate to process part of a request
30727
 
@@ -589,8 +589,7 @@
30728
 
         """Start a new thread to process the request."""
30729
 
         t = threading.Thread(target = self.process_request_thread,
30730
 
                              args = (request, client_address))
30731
 
-        if self.daemon_threads:
30732
 
-            t.setDaemon (1)
30733
 
+        t.daemon = self.daemon_threads
30734
 
         t.start()
30735
 
 
30736
 
 
30737
 
diff -r 8527427914a2 Lib/_pyio.py
30738
 
--- a/Lib/_pyio.py
30739
 
+++ b/Lib/_pyio.py
30740
 
@@ -8,6 +8,7 @@
30741
 
 import abc
30742
 
 import codecs
30743
 
 import warnings
30744
 
+import errno
30745
 
 # Import thread instead of threading to reduce startup cost
30746
 
 try:
30747
 
     from thread import allocate_lock as Lock
30748
 
@@ -720,8 +721,11 @@
30749
 
 
30750
 
     def close(self):
30751
 
         if self.raw is not None and not self.closed:
30752
 
-            self.flush()
30753
 
-            self.raw.close()
30754
 
+            try:
30755
 
+                # may raise BlockingIOError or BrokenPipeError etc
30756
 
+                self.flush()
30757
 
+            finally:
30758
 
+                self.raw.close()
30759
 
 
30760
 
     def detach(self):
30761
 
         if self.raw is None:
30762
 
@@ -1074,13 +1078,9 @@
30763
 
             # XXX we can implement some more tricks to try and avoid
30764
 
             # partial writes
30765
 
             if len(self._write_buf) > self.buffer_size:
30766
 
-                # We're full, so let's pre-flush the buffer
30767
 
-                try:
30768
 
-                    self._flush_unlocked()
30769
 
-                except BlockingIOError as e:
30770
 
-                    # We can't accept anything else.
30771
 
-                    # XXX Why not just let the exception pass through?
30772
 
-                    raise BlockingIOError(e.errno, e.strerror, 0)
30773
 
+                # We're full, so let's pre-flush the buffer.  (This may
30774
 
+                # raise BlockingIOError with characters_written == 0.)
30775
 
+                self._flush_unlocked()
30776
 
             before = len(self._write_buf)
30777
 
             self._write_buf.extend(b)
30778
 
             written = len(self._write_buf) - before
30779
 
@@ -1111,24 +1111,23 @@
30780
 
     def _flush_unlocked(self):
30781
 
         if self.closed:
30782
 
             raise ValueError("flush of closed file")
30783
 
-        written = 0
30784
 
-        try:
30785
 
-            while self._write_buf:
30786
 
-                try:
30787
 
-                    n = self.raw.write(self._write_buf)
30788
 
-                except IOError as e:
30789
 
-                    if e.errno != EINTR:
30790
 
-                        raise
30791
 
-                    continue
30792
 
-                if n > len(self._write_buf) or n < 0:
30793
 
-                    raise IOError("write() returned incorrect number of bytes")
30794
 
-                del self._write_buf[:n]
30795
 
-                written += n
30796
 
-        except BlockingIOError as e:
30797
 
-            n = e.characters_written
30798
 
+        while self._write_buf:
30799
 
+            try:
30800
 
+                n = self.raw.write(self._write_buf)
30801
 
+            except BlockingIOError:
30802
 
+                raise RuntimeError("self.raw should implement RawIOBase: it "
30803
 
+                                   "should not raise BlockingIOError")
30804
 
+            except IOError as e:
30805
 
+                if e.errno != EINTR:
30806
 
+                    raise
30807
 
+                continue
30808
 
+            if n is None:
30809
 
+                raise BlockingIOError(
30810
 
+                    errno.EAGAIN,
30811
 
+                    "write could not complete without blocking", 0)
30812
 
+            if n > len(self._write_buf) or n < 0:
30813
 
+                raise IOError("write() returned incorrect number of bytes")
30814
 
             del self._write_buf[:n]
30815
 
-            written += n
30816
 
-            raise BlockingIOError(e.errno, e.strerror, written)
30817
 
 
30818
 
     def tell(self):
30819
 
         return _BufferedIOMixin.tell(self) + len(self._write_buf)
30820
 
diff -r 8527427914a2 Lib/aifc.py
30821
 
--- a/Lib/aifc.py
30822
 
+++ b/Lib/aifc.py
30823
 
@@ -162,6 +162,12 @@
30824
 
     except struct.error:
30825
 
         raise EOFError
30826
 
 
30827
 
+def _read_ushort(file):
30828
 
+    try:
30829
 
+        return struct.unpack('>H', file.read(2))[0]
30830
 
+    except struct.error:
30831
 
+        raise EOFError
30832
 
+
30833
 
 def _read_string(file):
30834
 
     length = ord(file.read(1))
30835
 
     if length == 0:
30836
 
@@ -194,13 +200,19 @@
30837
 
 def _write_short(f, x):
30838
 
     f.write(struct.pack('>h', x))
30839
 
 
30840
 
+def _write_ushort(f, x):
30841
 
+    f.write(struct.pack('>H', x))
30842
 
+
30843
 
 def _write_long(f, x):
30844
 
+    f.write(struct.pack('>l', x))
30845
 
+
30846
 
+def _write_ulong(f, x):
30847
 
     f.write(struct.pack('>L', x))
30848
 
 
30849
 
 def _write_string(f, s):
30850
 
     if len(s) > 255:
30851
 
         raise ValueError("string exceeds maximum pstring length")
30852
 
-    f.write(chr(len(s)))
30853
 
+    f.write(struct.pack('B', len(s)))
30854
 
     f.write(s)
30855
 
     if len(s) & 1 == 0:
30856
 
         f.write(chr(0))
30857
 
@@ -218,7 +230,7 @@
30858
 
         lomant = 0
30859
 
     else:
30860
 
         fmant, expon = math.frexp(x)
30861
 
-        if expon > 16384 or fmant >= 1:     # Infinity or NaN
30862
 
+        if expon > 16384 or fmant >= 1 or fmant != fmant: # Infinity or NaN
30863
 
             expon = sign|0x7FFF
30864
 
             himant = 0
30865
 
             lomant = 0
30866
 
@@ -234,9 +246,9 @@
30867
 
             fmant = math.ldexp(fmant - fsmant, 32)
30868
 
             fsmant = math.floor(fmant)
30869
 
             lomant = long(fsmant)
30870
 
-    _write_short(f, expon)
30871
 
-    _write_long(f, himant)
30872
 
-    _write_long(f, lomant)
30873
 
+    _write_ushort(f, expon)
30874
 
+    _write_ulong(f, himant)
30875
 
+    _write_ulong(f, lomant)
30876
 
 
30877
 
 from chunk import Chunk
30878
 
 
30879
 
@@ -840,15 +852,15 @@
30880
 
         if self._aifc:
30881
 
             self._file.write('AIFC')
30882
 
             self._file.write('FVER')
30883
 
-            _write_long(self._file, 4)
30884
 
-            _write_long(self._file, self._version)
30885
 
+            _write_ulong(self._file, 4)
30886
 
+            _write_ulong(self._file, self._version)
30887
 
         else:
30888
 
             self._file.write('AIFF')
30889
 
         self._file.write('COMM')
30890
 
-        _write_long(self._file, commlength)
30891
 
+        _write_ulong(self._file, commlength)
30892
 
         _write_short(self._file, self._nchannels)
30893
 
         self._nframes_pos = self._file.tell()
30894
 
-        _write_long(self._file, self._nframes)
30895
 
+        _write_ulong(self._file, self._nframes)
30896
 
         _write_short(self._file, self._sampwidth * 8)
30897
 
         _write_float(self._file, self._framerate)
30898
 
         if self._aifc:
30899
 
@@ -856,9 +868,9 @@
30900
 
             _write_string(self._file, self._compname)
30901
 
         self._file.write('SSND')
30902
 
         self._ssnd_length_pos = self._file.tell()
30903
 
-        _write_long(self._file, self._datalength + 8)
30904
 
-        _write_long(self._file, 0)
30905
 
-        _write_long(self._file, 0)
30906
 
+        _write_ulong(self._file, self._datalength + 8)
30907
 
+        _write_ulong(self._file, 0)
30908
 
+        _write_ulong(self._file, 0)
30909
 
 
30910
 
     def _write_form_length(self, datalength):
30911
 
         if self._aifc:
30912
 
@@ -869,8 +881,8 @@
30913
 
         else:
30914
 
             commlength = 18
30915
 
             verslength = 0
30916
 
-        _write_long(self._file, 4 + verslength + self._marklength + \
30917
 
-                    8 + commlength + 16 + datalength)
30918
 
+        _write_ulong(self._file, 4 + verslength + self._marklength + \
30919
 
+                     8 + commlength + 16 + datalength)
30920
 
         return commlength
30921
 
 
30922
 
     def _patchheader(self):
30923
 
@@ -888,9 +900,9 @@
30924
 
         self._file.seek(self._form_length_pos, 0)
30925
 
         dummy = self._write_form_length(datalength)
30926
 
         self._file.seek(self._nframes_pos, 0)
30927
 
-        _write_long(self._file, self._nframeswritten)
30928
 
+        _write_ulong(self._file, self._nframeswritten)
30929
 
         self._file.seek(self._ssnd_length_pos, 0)
30930
 
-        _write_long(self._file, datalength + 8)
30931
 
+        _write_ulong(self._file, datalength + 8)
30932
 
         self._file.seek(curpos, 0)
30933
 
         self._nframes = self._nframeswritten
30934
 
         self._datalength = datalength
30935
 
@@ -905,13 +917,13 @@
30936
 
             length = length + len(name) + 1 + 6
30937
 
             if len(name) & 1 == 0:
30938
 
                 length = length + 1
30939
 
-        _write_long(self._file, length)
30940
 
+        _write_ulong(self._file, length)
30941
 
         self._marklength = length + 8
30942
 
         _write_short(self._file, len(self._markers))
30943
 
         for marker in self._markers:
30944
 
             id, pos, name = marker
30945
 
             _write_short(self._file, id)
30946
 
-            _write_long(self._file, pos)
30947
 
+            _write_ulong(self._file, pos)
30948
 
             _write_string(self._file, name)
30949
 
 
30950
 
 def open(f, mode=None):
30951
 
diff -r 8527427914a2 Lib/asyncore.py
30952
 
--- a/Lib/asyncore.py
30953
 
+++ b/Lib/asyncore.py
30954
 
@@ -132,7 +132,8 @@
30955
 
             is_w = obj.writable()
30956
 
             if is_r:
30957
 
                 r.append(fd)
30958
 
-            if is_w:
30959
 
+            # accepting sockets should not be writable
30960
 
+            if is_w and not obj.accepting:
30961
 
                 w.append(fd)
30962
 
             if is_r or is_w:
30963
 
                 e.append(fd)
30964
 
@@ -179,7 +180,8 @@
30965
 
             flags = 0
30966
 
             if obj.readable():
30967
 
                 flags |= select.POLLIN | select.POLLPRI
30968
 
-            if obj.writable():
30969
 
+            # accepting sockets should not be writable
30970
 
+            if obj.writable() and not obj.accepting:
30971
 
                 flags |= select.POLLOUT
30972
 
             if flags:
30973
 
                 # Only check for exceptions if object was either readable
30974
 
diff -r 8527427914a2 Lib/cgi.py
30975
 
--- a/Lib/cgi.py
30976
 
+++ b/Lib/cgi.py
30977
 
@@ -293,7 +293,7 @@
30978
 
     while s[:1] == ';':
30979
 
         s = s[1:]
30980
 
         end = s.find(';')
30981
 
-        while end > 0 and s.count('"', 0, end) % 2:
30982
 
+        while end > 0 and (s.count('"', 0, end) - s.count('\\"', 0, end)) % 2:
30983
 
             end = s.find(';', end + 1)
30984
 
         if end < 0:
30985
 
             end = len(s)
30986
 
diff -r 8527427914a2 Lib/cmd.py
30987
 
--- a/Lib/cmd.py
30988
 
+++ b/Lib/cmd.py
30989
 
@@ -209,6 +209,8 @@
30990
 
         if cmd is None:
30991
 
             return self.default(line)
30992
 
         self.lastcmd = line
30993
 
+        if line == 'EOF' :
30994
 
+            self.lastcmd = ''
30995
 
         if cmd == '':
30996
 
             return self.default(line)
30997
 
         else:
30998
 
diff -r 8527427914a2 Lib/collections.py
30999
 
--- a/Lib/collections.py
31000
 
+++ b/Lib/collections.py
31001
 
@@ -312,6 +312,7 @@
31002
 
         def _asdict(self):
31003
 
             'Return a new OrderedDict which maps field names to their values'
31004
 
             return OrderedDict(zip(self._fields, self)) \n
31005
 
+        __dict__ = property(_asdict) \n
31006
 
         def _replace(_self, **kwds):
31007
 
             'Return a new %(typename)s object replacing specified fields with new values'
31008
 
             result = _self._make(map(kwds.pop, %(field_names)r, _self))
31009
 
diff -r 8527427914a2 Lib/compileall.py
31010
 
--- a/Lib/compileall.py
31011
 
+++ b/Lib/compileall.py
31012
 
@@ -1,4 +1,4 @@
31013
 
-"""Module/script to "compile" all .py files to .pyc (or .pyo) file.
31014
 
+"""Module/script to byte-compile all .py files to .pyc (or .pyo) files.
31015
 
 
31016
 
 When called as a script with arguments, this compiles the directories
31017
 
 given as arguments recursively; the -l option prevents it from
31018
 
@@ -26,8 +26,8 @@
31019
 
 
31020
 
     dir:       the directory to byte-compile
31021
 
     maxlevels: maximum recursion level (default 10)
31022
 
-    ddir:      if given, purported directory name (this is the
31023
 
-               directory name that will show up in error messages)
31024
 
+    ddir:      the directory that will be prepended to the path to the
31025
 
+               file as it is compiled into each byte-code file.
31026
 
     force:     if 1, force compilation, even if timestamps are up-to-date
31027
 
     quiet:     if 1, be quiet during compilation
31028
 
     """
31029
 
@@ -64,8 +64,8 @@
31030
 
     Arguments (only fullname is required):
31031
 
 
31032
 
     fullname:  the file to byte-compile
31033
 
-    ddir:      if given, purported directory name (this is the
31034
 
-               directory name that will show up in error messages)
31035
 
+    ddir:      if given, the directory name compiled in to the
31036
 
+               byte-code file.
31037
 
     force:     if 1, force compilation, even if timestamps are up-to-date
31038
 
     quiet:     if 1, be quiet during compilation
31039
 
     """
31040
 
@@ -157,14 +157,27 @@
31041
 
         print msg
31042
 
         print "usage: python compileall.py [-l] [-f] [-q] [-d destdir] " \
31043
 
               "[-x regexp] [-i list] [directory|file ...]"
31044
 
-        print "-l: don't recurse down"
31045
 
+        print
31046
 
+        print "arguments: zero or more file and directory names to compile; " \
31047
 
+              "if no arguments given, "
31048
 
+        print "           defaults to the equivalent of -l sys.path"
31049
 
+        print
31050
 
+        print "options:"
31051
 
+        print "-l: don't recurse into subdirectories"
31052
 
         print "-f: force rebuild even if timestamps are up-to-date"
31053
 
-        print "-q: quiet operation"
31054
 
-        print "-d destdir: purported directory name for error messages"
31055
 
-        print "   if no directory arguments, -l sys.path is assumed"
31056
 
-        print "-x regexp: skip files matching the regular expression regexp"
31057
 
-        print "   the regexp is searched for in the full path of the file"
31058
 
-        print "-i list: expand list with its content (file and directory names)"
31059
 
+        print "-q: output only error messages"
31060
 
+        print "-d destdir: directory to prepend to file paths for use in " \
31061
 
+              "compile-time tracebacks and in"
31062
 
+        print "            runtime tracebacks in cases where the source " \
31063
 
+              "file is unavailable"
31064
 
+        print "-x regexp: skip files matching the regular expression regexp; " \
31065
 
+              "the regexp is searched for"
31066
 
+        print "           in the full path of each file considered for " \
31067
 
+              "compilation"
31068
 
+        print "-i file: add all the files and directories listed in file to " \
31069
 
+              "the list considered for"
31070
 
+        print '         compilation; if "-", names are read from stdin'
31071
 
+
31072
 
         sys.exit(2)
31073
 
     maxlevels = 10
31074
 
     ddir = None
31075
 
@@ -205,7 +218,7 @@
31076
 
         else:
31077
 
             success = compile_path()
31078
 
     except KeyboardInterrupt:
31079
 
-        print "\n[interrupt]"
31080
 
+        print "\n[interrupted]"
31081
 
         success = 0
31082
 
     return success
31083
 
 
31084
 
diff -r 8527427914a2 Lib/cookielib.py
31085
 
--- a/Lib/cookielib.py
31086
 
+++ b/Lib/cookielib.py
31087
 
@@ -1014,7 +1014,7 @@
31088
 
                     (not erhn.startswith(".") and
31089
 
                      not ("."+erhn).endswith(domain))):
31090
 
                     _debug("   effective request-host %s (even with added "
31091
 
-                           "initial dot) does not end end with %s",
31092
 
+                           "initial dot) does not end with %s",
31093
 
                            erhn, domain)
31094
 
                     return False
31095
 
             if (cookie.version > 0 or
31096
 
diff -r 8527427914a2 Lib/ctypes/__init__.py
31097
 
--- a/Lib/ctypes/__init__.py
31098
 
+++ b/Lib/ctypes/__init__.py
31099
 
@@ -262,6 +262,22 @@
31100
 
 
31101
 
 from _ctypes import POINTER, pointer, _pointer_type_cache
31102
 
 
31103
 
+def _reset_cache():
31104
 
+    _pointer_type_cache.clear()
31105
 
+    _c_functype_cache.clear()
31106
 
+    if _os.name in ("nt", "ce"):
31107
 
+        _win_functype_cache.clear()
31108
 
+    # _SimpleCData.c_wchar_p_from_param
31109
 
+    POINTER(c_wchar).from_param = c_wchar_p.from_param
31110
 
+    # _SimpleCData.c_char_p_from_param
31111
 
+    POINTER(c_char).from_param = c_char_p.from_param
31112
 
+    _pointer_type_cache[None] = c_void_p
31113
 
+    # XXX for whatever reasons, creating the first instance of a callback
31114
 
+    # function is needed for the unittests on Win64 to succeed.  This MAY
31115
 
+    # be a compiler bug, since the problem occurs only when _ctypes is
31116
 
+    # compiled with the MS SDK compiler.  Or an uninitialized variable?
31117
 
+    CFUNCTYPE(c_int)(lambda: None)
31118
 
+
31119
 
 try:
31120
 
     from _ctypes import set_conversion_mode
31121
 
 except ImportError:
31122
 
@@ -278,8 +294,6 @@
31123
 
     class c_wchar(_SimpleCData):
31124
 
         _type_ = "u"
31125
 
 
31126
 
-    POINTER(c_wchar).from_param = c_wchar_p.from_param #_SimpleCData.c_wchar_p_from_param
31127
 
-
31128
 
     def create_unicode_buffer(init, size=None):
31129
 
         """create_unicode_buffer(aString) -> character array
31130
 
         create_unicode_buffer(anInteger) -> character array
31131
 
@@ -298,8 +312,6 @@
31132
 
             return buf
31133
 
         raise TypeError(init)
31134
 
 
31135
 
-POINTER(c_char).from_param = c_char_p.from_param #_SimpleCData.c_char_p_from_param
31136
 
-
31137
 
 # XXX Deprecated
31138
 
 def SetPointerType(pointer, cls):
31139
 
     if _pointer_type_cache.get(cls, None) is not None:
31140
 
@@ -458,8 +470,6 @@
31141
 
             descr = FormatError(code).strip()
31142
 
         return WindowsError(code, descr)
31143
 
 
31144
 
-_pointer_type_cache[None] = c_void_p
31145
 
-
31146
 
 if sizeof(c_uint) == sizeof(c_void_p):
31147
 
     c_size_t = c_uint
31148
 
     c_ssize_t = c_int
31149
 
@@ -542,8 +552,4 @@
31150
 
     elif sizeof(kind) == 8: c_uint64 = kind
31151
 
 del(kind)
31152
 
 
31153
 
-# XXX for whatever reasons, creating the first instance of a callback
31154
 
-# function is needed for the unittests on Win64 to succeed.  This MAY
31155
 
-# be a compiler bug, since the problem occurs only when _ctypes is
31156
 
-# compiled with the MS SDK compiler.  Or an uninitialized variable?
31157
 
-CFUNCTYPE(c_int)(lambda: None)
31158
 
+_reset_cache()
31159
 
diff -r 8527427914a2 Lib/ctypes/_endian.py
31160
 
--- a/Lib/ctypes/_endian.py
31161
 
+++ b/Lib/ctypes/_endian.py
31162
 
@@ -4,20 +4,24 @@
31163
 
 import sys
31164
 
 from ctypes import *
31165
 
 
31166
 
-_array_type = type(c_int * 3)
31167
 
+_array_type = type(Array)
31168
 
 
31169
 
 def _other_endian(typ):
31170
 
     """Return the type with the 'other' byte order.  Simple types like
31171
 
     c_int and so on already have __ctype_be__ and __ctype_le__
31172
 
     attributes which contain the types, for more complicated types
31173
 
-    only arrays are supported.
31174
 
+    arrays and structures are supported.
31175
 
     """
31176
 
-    try:
31177
 
+    # check _OTHER_ENDIAN attribute (present if typ is primitive type)
31178
 
+    if hasattr(typ, _OTHER_ENDIAN):
31179
 
         return getattr(typ, _OTHER_ENDIAN)
31180
 
-    except AttributeError:
31181
 
-        if type(typ) == _array_type:
31182
 
-            return _other_endian(typ._type_) * typ._length_
31183
 
-        raise TypeError("This type does not support other endian: %s" % typ)
31184
 
+    # if typ is array
31185
 
+    if isinstance(typ, _array_type):
31186
 
+        return _other_endian(typ._type_) * typ._length_
31187
 
+    # if typ is structure
31188
 
+    if issubclass(typ, Structure):
31189
 
+        return typ
31190
 
+    raise TypeError("This type does not support other endian: %s" % typ)
31191
 
 
31192
 
 class _swapped_meta(type(Structure)):
31193
 
     def __setattr__(self, attrname, value):
31194
 
diff -r 8527427914a2 Lib/ctypes/test/test_as_parameter.py
31195
 
--- a/Lib/ctypes/test/test_as_parameter.py
31196
 
+++ b/Lib/ctypes/test/test_as_parameter.py
31197
 
@@ -74,6 +74,7 @@
31198
 
     def test_callbacks(self):
31199
 
         f = dll._testfunc_callback_i_if
31200
 
         f.restype = c_int
31201
 
+        f.argtypes = None
31202
 
 
31203
 
         MyCallback = CFUNCTYPE(c_int, c_int)
31204
 
 
31205
 
diff -r 8527427914a2 Lib/ctypes/test/test_buffers.py
31206
 
--- a/Lib/ctypes/test/test_buffers.py
31207
 
+++ b/Lib/ctypes/test/test_buffers.py
31208
 
@@ -20,6 +20,10 @@
31209
 
         self.assertEqual(b[::2], "ac")
31210
 
         self.assertEqual(b[::5], "a")
31211
 
 
31212
 
+    def test_buffer_interface(self):
31213
 
+        self.assertEqual(len(bytearray(create_string_buffer(0))), 0)
31214
 
+        self.assertEqual(len(bytearray(create_string_buffer(1))), 1)
31215
 
+
31216
 
     def test_string_conversion(self):
31217
 
         b = create_string_buffer(u"abc")
31218
 
         self.assertEqual(len(b), 4) # trailing nul char
31219
 
diff -r 8527427914a2 Lib/ctypes/test/test_byteswap.py
31220
 
--- a/Lib/ctypes/test/test_byteswap.py
31221
 
+++ b/Lib/ctypes/test/test_byteswap.py
31222
 
@@ -1,4 +1,4 @@
31223
 
-import sys, unittest, struct, math
31224
 
+import sys, unittest, struct, math, ctypes
31225
 
 from binascii import hexlify
31226
 
 
31227
 
 from ctypes import *
31228
 
@@ -185,18 +185,32 @@
31229
 
             self.assertRaises(TypeError, setattr, T, "_fields_", [("x", typ)])
31230
 
 
31231
 
     def test_struct_struct(self):
31232
 
-        # Nested structures with different byte order not (yet) supported
31233
 
-        if sys.byteorder == "little":
31234
 
-            base = BigEndianStructure
31235
 
-        else:
31236
 
-            base = LittleEndianStructure
31237
 
+        # nested structures with different byteorders
31238
 
 
31239
 
-        class T(Structure):
31240
 
-            _fields_ = [("a", c_int),
31241
 
-                        ("b", c_int)]
31242
 
-        class S(base):
31243
 
-            pass
31244
 
-        self.assertRaises(TypeError, setattr, S, "_fields_", [("s", T)])
31245
 
+        # create nested structures with given byteorders and set memory to data
31246
 
+
31247
 
+        for nested, data in (
31248
 
+            (BigEndianStructure, b'\0\0\0\1\0\0\0\2'),
31249
 
+            (LittleEndianStructure, b'\1\0\0\0\2\0\0\0'),
31250
 
+        ):
31251
 
+            for parent in (
31252
 
+                BigEndianStructure,
31253
 
+                LittleEndianStructure,
31254
 
+                Structure,
31255
 
+            ):
31256
 
+                class NestedStructure(nested):
31257
 
+                    _fields_ = [("x", c_uint32),
31258
 
+                                ("y", c_uint32)]
31259
 
+
31260
 
+                class TestStructure(parent):
31261
 
+                    _fields_ = [("point", NestedStructure)]
31262
 
+
31263
 
+                self.assertEqual(len(data), sizeof(TestStructure))
31264
 
+                ptr = POINTER(TestStructure)
31265
 
+                s = cast(data, ptr)[0]
31266
 
+                del ctypes._pointer_type_cache[TestStructure]
31267
 
+                self.assertEqual(s.point.x, 1)
31268
 
+                self.assertEqual(s.point.y, 2)
31269
 
 
31270
 
     def test_struct_fields_2(self):
31271
 
         # standard packing in struct uses no alignment.
31272
 
diff -r 8527427914a2 Lib/ctypes/test/test_callbacks.py
31273
 
--- a/Lib/ctypes/test/test_callbacks.py
31274
 
+++ b/Lib/ctypes/test/test_callbacks.py
31275
 
@@ -140,6 +140,14 @@
31276
 
                 if isinstance(x, X)]
31277
 
         self.assertEqual(len(live), 0)
31278
 
 
31279
 
+    def test_issue12483(self):
31280
 
+        import gc
31281
 
+        class Nasty:
31282
 
+            def __del__(self):
31283
 
+                gc.collect()
31284
 
+        CFUNCTYPE(None)(lambda x=Nasty(): None)
31285
 
+
31286
 
+
31287
 
 try:
31288
 
     WINFUNCTYPE
31289
 
 except NameError:
31290
 
diff -r 8527427914a2 Lib/ctypes/test/test_functions.py
31291
 
--- a/Lib/ctypes/test/test_functions.py
31292
 
+++ b/Lib/ctypes/test/test_functions.py
31293
 
@@ -250,6 +250,7 @@
31294
 
     def test_callbacks(self):
31295
 
         f = dll._testfunc_callback_i_if
31296
 
         f.restype = c_int
31297
 
+        f.argtypes = None
31298
 
 
31299
 
         MyCallback = CFUNCTYPE(c_int, c_int)
31300
 
 
31301
 
diff -r 8527427914a2 Lib/ctypes/test/test_structures.py
31302
 
--- a/Lib/ctypes/test/test_structures.py
31303
 
+++ b/Lib/ctypes/test/test_structures.py
31304
 
@@ -239,6 +239,14 @@
31305
 
             pass
31306
 
         self.assertRaises(TypeError, setattr, POINT, "_fields_", [("x", 1), ("y", 2)])
31307
 
 
31308
 
+    def test_invalid_name(self):
31309
 
+        # field name must be string
31310
 
+        def declare_with_name(name):
31311
 
+            class S(Structure):
31312
 
+                _fields_ = [(name, c_int)]
31313
 
+
31314
 
+        self.assertRaises(TypeError, declare_with_name, u"x\xe9")
31315
 
+
31316
 
     def test_intarray_fields(self):
31317
 
         class SomeInts(Structure):
31318
 
             _fields_ = [("a", c_int * 4)]
31319
 
@@ -324,6 +332,18 @@
31320
 
         else:
31321
 
             self.assertEqual(msg, "(Phone) exceptions.TypeError: too many initializers")
31322
 
 
31323
 
+    def test_huge_field_name(self):
31324
 
+        # issue12881: segfault with large structure field names
31325
 
+        def create_class(length):
31326
 
+            class S(Structure):
31327
 
+                _fields_ = [('x' * length, c_int)]
31328
 
+
31329
 
+        for length in [10 ** i for i in range(0, 8)]:
31330
 
+            try:
31331
 
+                create_class(length)
31332
 
+            except MemoryError:
31333
 
+                # MemoryErrors are OK, we just don't want to segfault
31334
 
+                pass
31335
 
 
31336
 
     def get_except(self, func, *args):
31337
 
         try:
31338
 
diff -r 8527427914a2 Lib/ctypes/util.py
31339
 
--- a/Lib/ctypes/util.py
31340
 
+++ b/Lib/ctypes/util.py
31341
 
@@ -182,28 +182,6 @@
31342
 
 
31343
 
     else:
31344
 
 
31345
 
-        def _findLib_ldconfig(name):
31346
 
-            # XXX assuming GLIBC's ldconfig (with option -p)
31347
 
-            expr = r'/[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)
31348
 
-            f = os.popen('LC_ALL=C LANG=C /sbin/ldconfig -p 2>/dev/null')
31349
 
-            try:
31350
 
-                data = f.read()
31351
 
-            finally:
31352
 
-                f.close()
31353
 
-            res = re.search(expr, data)
31354
 
-            if not res:
31355
 
-                # Hm, this works only for libs needed by the python executable.
31356
 
-                cmd = 'ldd %s 2>/dev/null' % sys.executable
31357
 
-                f = os.popen(cmd)
31358
 
-                try:
31359
 
-                    data = f.read()
31360
 
-                finally:
31361
 
-                    f.close()
31362
 
-                res = re.search(expr, data)
31363
 
-                if not res:
31364
 
-                    return None
31365
 
-            return res.group(0)
31366
 
-
31367
 
         def _findSoname_ldconfig(name):
31368
 
             import struct
31369
 
             if struct.calcsize('l') == 4:
31370
 
@@ -220,8 +198,7 @@
31371
 
             abi_type = mach_map.get(machine, 'libc6')
31372
 
 
31373
 
             # XXX assuming GLIBC's ldconfig (with option -p)
31374
 
-            expr = r'(\S+)\s+\((%s(?:, OS ABI:[^\)]*)?)\)[^/]*(/[^\(\)\s]*lib%s\.[^\(\)\s]*)' \
31375
 
-                   % (abi_type, re.escape(name))
31376
 
+            expr = r'\s+(lib%s\.[^\s]+)\s+\(%s' % (re.escape(name), abi_type)
31377
 
             f = os.popen('/sbin/ldconfig -p 2>/dev/null')
31378
 
             try:
31379
 
                 data = f.read()
31380
 
diff -r 8527427914a2 Lib/decimal.py
31381
 
--- a/Lib/decimal.py
31382
 
+++ b/Lib/decimal.py
31383
 
@@ -21,7 +21,7 @@
31384
 
 This is a Py2.3 implementation of decimal floating point arithmetic based on
31385
 
 the General Decimal Arithmetic Specification:
31386
 
 
31387
 
-    www2.hursley.ibm.com/decimal/decarith.html
31388
 
+    http://speleotrove.com/decimal/decarith.html
31389
 
 
31390
 
 and IEEE standard 854-1987:
31391
 
 
31392
 
@@ -1942,9 +1942,9 @@
31393
 
         nonzero.  For efficiency, other._exp should not be too large,
31394
 
         so that 10**abs(other._exp) is a feasible calculation."""
31395
 
 
31396
 
-        # In the comments below, we write x for the value of self and
31397
 
-        # y for the value of other.  Write x = xc*10**xe and y =
31398
 
-        # yc*10**ye.
31399
 
+        # In the comments below, we write x for the value of self and y for the
31400
 
+        # value of other.  Write x = xc*10**xe and abs(y) = yc*10**ye, with xc
31401
 
+        # and yc positive integers not divisible by 10.
31402
 
 
31403
 
         # The main purpose of this method is to identify the *failure*
31404
 
         # of x**y to be exactly representable with as little effort as
31405
 
@@ -1952,13 +1952,12 @@
31406
 
         # eliminate the possibility of x**y being exact.  Only if all
31407
 
         # these tests are passed do we go on to actually compute x**y.
31408
 
 
31409
 
-        # Here's the main idea.  First normalize both x and y.  We
31410
 
-        # express y as a rational m/n, with m and n relatively prime
31411
 
-        # and n>0.  Then for x**y to be exactly representable (at
31412
 
-        # *any* precision), xc must be the nth power of a positive
31413
 
-        # integer and xe must be divisible by n.  If m is negative
31414
 
-        # then additionally xc must be a power of either 2 or 5, hence
31415
 
-        # a power of 2**n or 5**n.
31416
 
+        # Here's the main idea.  Express y as a rational number m/n, with m and
31417
 
+        # n relatively prime and n>0.  Then for x**y to be exactly
31418
 
+        # representable (at *any* precision), xc must be the nth power of a
31419
 
+        # positive integer and xe must be divisible by n.  If y is negative
31420
 
+        # then additionally xc must be a power of either 2 or 5, hence a power
31421
 
+        # of 2**n or 5**n.
31422
 
         #
31423
 
         # There's a limit to how small |y| can be: if y=m/n as above
31424
 
         # then:
31425
 
@@ -2030,21 +2029,43 @@
31426
 
                     return None
31427
 
                 # now xc is a power of 2; e is its exponent
31428
 
                 e = _nbits(xc)-1
31429
 
-                # find e*y and xe*y; both must be integers
31430
 
-                if ye >= 0:
31431
 
-                    y_as_int = yc*10**ye
31432
 
-                    e = e*y_as_int
31433
 
-                    xe = xe*y_as_int
31434
 
-                else:
31435
 
-                    ten_pow = 10**-ye
31436
 
-                    e, remainder = divmod(e*yc, ten_pow)
31437
 
-                    if remainder:
31438
 
-                        return None
31439
 
-                    xe, remainder = divmod(xe*yc, ten_pow)
31440
 
-                    if remainder:
31441
 
-                        return None
31442
 
-
31443
 
-                if e*65 >= p*93: # 93/65 > log(10)/log(5)
31444
 
+
31445
 
+                # We now have:
31446
 
+                #
31447
 
+                #   x = 2**e * 10**xe, e > 0, and y < 0.
31448
 
+                #
31449
 
+                # The exact result is:
31450
 
+                #
31451
 
+                #   x**y = 5**(-e*y) * 10**(e*y + xe*y)
31452
 
+                #
31453
 
+                # provided that both e*y and xe*y are integers.  Note that if
31454
 
+                # 5**(-e*y) >= 10**p, then the result can't be expressed
31455
 
+                # exactly with p digits of precision.
31456
 
+                #
31457
 
+                # Using the above, we can guard against large values of ye.
31458
 
+                # 93/65 is an upper bound for log(10)/log(5), so if
31459
 
+                #
31460
 
+                #   ye >= len(str(93*p//65))
31461
 
+                #
31462
 
+                # then
31463
 
+                #
31464
 
+                #   -e*y >= -y >= 10**ye > 93*p/65 > p*log(10)/log(5),
31465
 
+                #
31466
 
+                # so 5**(-e*y) >= 10**p, and the coefficient of the result
31467
 
+                # can't be expressed in p digits.
31468
 
+
31469
 
+                # emax >= largest e such that 5**e < 10**p.
31470
 
+                emax = p*93//65
31471
 
+                if ye >= len(str(emax)):
31472
 
+                    return None
31473
 
+
31474
 
+                # Find -e*y and -xe*y; both must be integers
31475
 
+                e = _decimal_lshift_exact(e * yc, ye)
31476
 
+                xe = _decimal_lshift_exact(xe * yc, ye)
31477
 
+                if e is None or xe is None:
31478
 
+                    return None
31479
 
+
31480
 
+                if e > emax:
31481
 
                     return None
31482
 
                 xc = 5**e
31483
 
 
31484
 
@@ -2058,19 +2079,20 @@
31485
 
                 while xc % 5 == 0:
31486
 
                     xc //= 5
31487
 
                     e -= 1
31488
 
-                if ye >= 0:
31489
 
-                    y_as_integer = yc*10**ye
31490
 
-                    e = e*y_as_integer
31491
 
-                    xe = xe*y_as_integer
31492
 
-                else:
31493
 
-                    ten_pow = 10**-ye
31494
 
-                    e, remainder = divmod(e*yc, ten_pow)
31495
 
-                    if remainder:
31496
 
-                        return None
31497
 
-                    xe, remainder = divmod(xe*yc, ten_pow)
31498
 
-                    if remainder:
31499
 
-                        return None
31500
 
-                if e*3 >= p*10: # 10/3 > log(10)/log(2)
31501
 
+
31502
 
+                # Guard against large values of ye, using the same logic as in
31503
 
+                # the 'xc is a power of 2' branch.  10/3 is an upper bound for
31504
 
+                # log(10)/log(2).
31505
 
+                emax = p*10//3
31506
 
+                if ye >= len(str(emax)):
31507
 
+                    return None
31508
 
+
31509
 
+                e = _decimal_lshift_exact(e * yc, ye)
31510
 
+                xe = _decimal_lshift_exact(xe * yc, ye)
31511
 
+                if e is None or xe is None:
31512
 
+                    return None
31513
 
+
31514
 
+                if e > emax:
31515
 
                     return None
31516
 
                 xc = 2**e
31517
 
             else:
31518
 
@@ -5463,6 +5485,27 @@
31519
 
     hex_n = "%x" % n
31520
 
     return 4*len(hex_n) - correction[hex_n[0]]
31521
 
 
31522
 
+def _decimal_lshift_exact(n, e):
31523
 
+    """ Given integers n and e, return n * 10**e if it's an integer, else None.
31524
 
+
31525
 
+    The computation is designed to avoid computing large powers of 10
31526
 
+    unnecessarily.
31527
 
+
31528
 
+    >>> _decimal_lshift_exact(3, 4)
31529
 
+    30000
31530
 
+    >>> _decimal_lshift_exact(300, -999999999)  # returns None
31531
 
+
31532
 
+    """
31533
 
+    if n == 0:
31534
 
+        return 0
31535
 
+    elif e >= 0:
31536
 
+        return n * 10**e
31537
 
+    else:
31538
 
+        # val_n = largest power of 10 dividing n.
31539
 
+        str_n = str(abs(n))
31540
 
+        val_n = len(str_n) - len(str_n.rstrip('0'))
31541
 
+        return None if val_n < -e else n // 10**-e
31542
 
+
31543
 
 def _sqrt_nearest(n, a):
31544
 
     """Closest integer to the square root of the positive integer n.  a is
31545
 
     an initial approximation to the square root.  Any positive integer
31546
 
diff -r 8527427914a2 Lib/distutils/ccompiler.py
31547
 
--- a/Lib/distutils/ccompiler.py
31548
 
+++ b/Lib/distutils/ccompiler.py
31549
 
@@ -18,58 +18,6 @@
31550
 
 from distutils.util import split_quoted, execute
31551
 
 from distutils import log
31552
 
 
31553
 
-_sysconfig = __import__('sysconfig')
31554
 
-
31555
 
-def customize_compiler(compiler):
31556
 
-    """Do any platform-specific customization of a CCompiler instance.
31557
 
-
31558
 
-    Mainly needed on Unix, so we can plug in the information that
31559
 
-    varies across Unices and is stored in Python's Makefile.
31560
 
-    """
31561
 
-    if compiler.compiler_type == "unix":
31562
 
-        (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
31563
 
-            _sysconfig.get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
31564
 
-                                       'CCSHARED', 'LDSHARED', 'SO', 'AR',
31565
 
-                                       'ARFLAGS')
31566
 
-
31567
 
-        if 'CC' in os.environ:
31568
 
-            cc = os.environ['CC']
31569
 
-        if 'CXX' in os.environ:
31570
 
-            cxx = os.environ['CXX']
31571
 
-        if 'LDSHARED' in os.environ:
31572
 
-            ldshared = os.environ['LDSHARED']
31573
 
-        if 'CPP' in os.environ:
31574
 
-            cpp = os.environ['CPP']
31575
 
-        else:
31576
 
-            cpp = cc + " -E"           # not always
31577
 
-        if 'LDFLAGS' in os.environ:
31578
 
-            ldshared = ldshared + ' ' + os.environ['LDFLAGS']
31579
 
-        if 'CFLAGS' in os.environ:
31580
 
-            cflags = opt + ' ' + os.environ['CFLAGS']
31581
 
-            ldshared = ldshared + ' ' + os.environ['CFLAGS']
31582
 
-        if 'CPPFLAGS' in os.environ:
31583
 
-            cpp = cpp + ' ' + os.environ['CPPFLAGS']
31584
 
-            cflags = cflags + ' ' + os.environ['CPPFLAGS']
31585
 
-            ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
31586
 
-        if 'AR' in os.environ:
31587
 
-            ar = os.environ['AR']
31588
 
-        if 'ARFLAGS' in os.environ:
31589
 
-            archiver = ar + ' ' + os.environ['ARFLAGS']
31590
 
-        else:
31591
 
-            archiver = ar + ' ' + ar_flags
31592
 
-
31593
 
-        cc_cmd = cc + ' ' + cflags
31594
 
-        compiler.set_executables(
31595
 
-            preprocessor=cpp,
31596
 
-            compiler=cc_cmd,
31597
 
-            compiler_so=cc_cmd + ' ' + ccshared,
31598
 
-            compiler_cxx=cxx,
31599
 
-            linker_so=ldshared,
31600
 
-            linker_exe=cc,
31601
 
-            archiver=archiver)
31602
 
-
31603
 
-        compiler.shared_lib_extension = so_ext
31604
 
-
31605
 
 class CCompiler:
31606
 
     """Abstract base class to define the interface that must be implemented
31607
 
     by real compiler classes.  Also has some utility methods used by
31608
 
diff -r 8527427914a2 Lib/distutils/command/bdist_dumb.py
31609
 
--- a/Lib/distutils/command/bdist_dumb.py
31610
 
+++ b/Lib/distutils/command/bdist_dumb.py
31611
 
@@ -58,7 +58,7 @@
31612
 
         self.format = None
31613
 
         self.keep_temp = 0
31614
 
         self.dist_dir = None
31615
 
-        self.skip_build = 0
31616
 
+        self.skip_build = None
31617
 
         self.relative = 0
31618
 
         self.owner = None
31619
 
         self.group = None
31620
 
@@ -78,7 +78,8 @@
31621
 
 
31622
 
         self.set_undefined_options('bdist',
31623
 
                                    ('dist_dir', 'dist_dir'),
31624
 
-                                   ('plat_name', 'plat_name'))
31625
 
+                                   ('plat_name', 'plat_name'),
31626
 
+                                   ('skip_build', 'skip_build'))
31627
 
 
31628
 
     def run(self):
31629
 
         if not self.skip_build:
31630
 
diff -r 8527427914a2 Lib/distutils/command/bdist_msi.py
31631
 
--- a/Lib/distutils/command/bdist_msi.py
31632
 
+++ b/Lib/distutils/command/bdist_msi.py
31633
 
@@ -131,18 +131,22 @@
31634
 
         self.no_target_optimize = 0
31635
 
         self.target_version = None
31636
 
         self.dist_dir = None
31637
 
-        self.skip_build = 0
31638
 
+        self.skip_build = None
31639
 
         self.install_script = None
31640
 
         self.pre_install_script = None
31641
 
         self.versions = None
31642
 
 
31643
 
     def finalize_options (self):
31644
 
+        self.set_undefined_options('bdist', ('skip_build', 'skip_build'))
31645
 
+
31646
 
         if self.bdist_dir is None:
31647
 
             bdist_base = self.get_finalized_command('bdist').bdist_base
31648
 
             self.bdist_dir = os.path.join(bdist_base, 'msi')
31649
 
+
31650
 
         short_version = get_python_version()
31651
 
         if (not self.target_version) and self.distribution.has_ext_modules():
31652
 
             self.target_version = short_version
31653
 
+
31654
 
         if self.target_version:
31655
 
             self.versions = [self.target_version]
31656
 
             if not self.skip_build and self.distribution.has_ext_modules()\
31657
 
diff -r 8527427914a2 Lib/distutils/command/bdist_wininst.py
31658
 
--- a/Lib/distutils/command/bdist_wininst.py
31659
 
+++ b/Lib/distutils/command/bdist_wininst.py
31660
 
@@ -71,7 +71,7 @@
31661
 
         self.dist_dir = None
31662
 
         self.bitmap = None
31663
 
         self.title = None
31664
 
-        self.skip_build = 0
31665
 
+        self.skip_build = None
31666
 
         self.install_script = None
31667
 
         self.pre_install_script = None
31668
 
         self.user_access_control = None
31669
 
@@ -80,6 +80,8 @@
31670
 
 
31671
 
 
31672
 
     def finalize_options (self):
31673
 
+        self.set_undefined_options('bdist', ('skip_build', 'skip_build'))
31674
 
+
31675
 
         if self.bdist_dir is None:
31676
 
             if self.skip_build and self.plat_name:
31677
 
                 # If build is skipped and plat_name is overridden, bdist will
31678
 
@@ -89,8 +91,10 @@
31679
 
                 # next the command will be initialized using that name
31680
 
             bdist_base = self.get_finalized_command('bdist').bdist_base
31681
 
             self.bdist_dir = os.path.join(bdist_base, 'wininst')
31682
 
+
31683
 
         if not self.target_version:
31684
 
             self.target_version = ""
31685
 
+
31686
 
         if not self.skip_build and self.distribution.has_ext_modules():
31687
 
             short_version = get_python_version()
31688
 
             if self.target_version and self.target_version != short_version:
31689
 
diff -r 8527427914a2 Lib/distutils/command/build_clib.py
31690
 
--- a/Lib/distutils/command/build_clib.py
31691
 
+++ b/Lib/distutils/command/build_clib.py
31692
 
@@ -19,7 +19,7 @@
31693
 
 import os
31694
 
 from distutils.core import Command
31695
 
 from distutils.errors import DistutilsSetupError
31696
 
-from distutils.ccompiler import customize_compiler
31697
 
+from distutils.sysconfig import customize_compiler
31698
 
 from distutils import log
31699
 
 
31700
 
 def show_compilers():
31701
 
diff -r 8527427914a2 Lib/distutils/command/build_ext.py
31702
 
--- a/Lib/distutils/command/build_ext.py
31703
 
+++ b/Lib/distutils/command/build_ext.py
31704
 
@@ -160,8 +160,7 @@
31705
 
         if plat_py_include != py_include:
31706
 
             self.include_dirs.append(plat_py_include)
31707
 
 
31708
 
-        if isinstance(self.libraries, str):
31709
 
-            self.libraries = [self.libraries]
31710
 
+        self.ensure_string_list('libraries')
31711
 
 
31712
 
         # Life is easier if we're not forever checking for None, so
31713
 
         # simplify these options to empty lists if unset
31714
 
diff -r 8527427914a2 Lib/distutils/command/check.py
31715
 
--- a/Lib/distutils/command/check.py
31716
 
+++ b/Lib/distutils/command/check.py
31717
 
@@ -5,6 +5,7 @@
31718
 
 __revision__ = "$Id$"
31719
 
 
31720
 
 from distutils.core import Command
31721
 
+from distutils.dist import PKG_INFO_ENCODING
31722
 
 from distutils.errors import DistutilsSetupError
31723
 
 
31724
 
 try:
31725
 
@@ -108,6 +109,8 @@
31726
 
     def check_restructuredtext(self):
31727
 
         """Checks if the long string fields are reST-compliant."""
31728
 
         data = self.distribution.get_long_description()
31729
 
+        if not isinstance(data, unicode):
31730
 
+            data = data.decode(PKG_INFO_ENCODING)
31731
 
         for warning in self._check_rst_data(data):
31732
 
             line = warning[-1].get('line')
31733
 
             if line is None:
31734
 
diff -r 8527427914a2 Lib/distutils/command/config.py
31735
 
--- a/Lib/distutils/command/config.py
31736
 
+++ b/Lib/distutils/command/config.py
31737
 
@@ -16,7 +16,7 @@
31738
 
 
31739
 
 from distutils.core import Command
31740
 
 from distutils.errors import DistutilsExecError
31741
 
-from distutils.ccompiler import customize_compiler
31742
 
+from distutils.sysconfig import customize_compiler
31743
 
 from distutils import log
31744
 
 
31745
 
 LANG_EXT = {'c': '.c', 'c++': '.cxx'}
31746
 
diff -r 8527427914a2 Lib/distutils/command/register.py
31747
 
--- a/Lib/distutils/command/register.py
31748
 
+++ b/Lib/distutils/command/register.py
31749
 
@@ -10,7 +10,6 @@
31750
 
 import urllib2
31751
 
 import getpass
31752
 
 import urlparse
31753
 
-import StringIO
31754
 
 from warnings import warn
31755
 
 
31756
 
 from distutils.core import PyPIRCCommand
31757
 
@@ -260,21 +259,30 @@
31758
 
         boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
31759
 
         sep_boundary = '\n--' + boundary
31760
 
         end_boundary = sep_boundary + '--'
31761
 
-        body = StringIO.StringIO()
31762
 
+        chunks = []
31763
 
         for key, value in data.items():
31764
 
             # handle multiple entries for the same name
31765
 
             if type(value) not in (type([]), type( () )):
31766
 
                 value = [value]
31767
 
             for value in value:
31768
 
-                body.write(sep_boundary)
31769
 
-                body.write('\nContent-Disposition: form-data; name="%s"'%key)
31770
 
-                body.write("\n\n")
31771
 
-                body.write(value)
31772
 
+                chunks.append(sep_boundary)
31773
 
+                chunks.append('\nContent-Disposition: form-data; name="%s"'%key)
31774
 
+                chunks.append("\n\n")
31775
 
+                chunks.append(value)
31776
 
                 if value and value[-1] == '\r':
31777
 
-                    body.write('\n')  # write an extra newline (lurve Macs)
31778
 
-        body.write(end_boundary)
31779
 
-        body.write("\n")
31780
 
-        body = body.getvalue()
31781
 
+                    chunks.append('\n')  # write an extra newline (lurve Macs)
31782
 
+        chunks.append(end_boundary)
31783
 
+        chunks.append("\n")
31784
 
+
31785
 
+        # chunks may be bytes (str) or unicode objects that we need to encode
31786
 
+        body = []
31787
 
+        for chunk in chunks:
31788
 
+            if isinstance(chunk, unicode):
31789
 
+                body.append(chunk.encode('utf-8'))
31790
 
+            else:
31791
 
+                body.append(chunk)
31792
 
+
31793
 
+        body = ''.join(body)
31794
 
 
31795
 
         # build the Request
31796
 
         headers = {
31797
 
diff -r 8527427914a2 Lib/distutils/command/sdist.py
31798
 
--- a/Lib/distutils/command/sdist.py
31799
 
+++ b/Lib/distutils/command/sdist.py
31800
 
@@ -182,14 +182,20 @@
31801
 
         reading the manifest, or just using the default file set -- it all
31802
 
         depends on the user's options.
31803
 
         """
31804
 
-        # new behavior:
31805
 
+        # new behavior when using a template:
31806
 
         # the file list is recalculated everytime because
31807
 
         # even if MANIFEST.in or setup.py are not changed
31808
 
         # the user might have added some files in the tree that
31809
 
         # need to be included.
31810
 
         #
31811
 
-        #  This makes --force the default and only behavior.
31812
 
+        #  This makes --force the default and only behavior with templates.
31813
 
         template_exists = os.path.isfile(self.template)
31814
 
+        if not template_exists and self._manifest_is_not_generated():
31815
 
+            self.read_manifest()
31816
 
+            self.filelist.sort()
31817
 
+            self.filelist.remove_duplicates()
31818
 
+            return
31819
 
+
31820
 
         if not template_exists:
31821
 
             self.warn(("manifest template '%s' does not exist " +
31822
 
                         "(using default file list)") %
31823
 
@@ -314,7 +320,10 @@
31824
 
 
31825
 
                 try:
31826
 
                     self.filelist.process_template_line(line)
31827
 
-                except DistutilsTemplateError, msg:
31828
 
+                # the call above can raise a DistutilsTemplateError for
31829
 
+                # malformed lines, or a ValueError from the lower-level
31830
 
+                # convert_path function
31831
 
+                except (DistutilsTemplateError, ValueError) as msg:
31832
 
                     self.warn("%s, line %d: %s" % (template.filename,
31833
 
                                                    template.current_line,
31834
 
                                                    msg))
31835
 
@@ -352,23 +361,28 @@
31836
 
         by 'add_defaults()' and 'read_template()') to the manifest file
31837
 
         named by 'self.manifest'.
31838
 
         """
31839
 
-        if os.path.isfile(self.manifest):
31840
 
-            fp = open(self.manifest)
31841
 
-            try:
31842
 
-                first_line = fp.readline()
31843
 
-            finally:
31844
 
-                fp.close()
31845
 
-
31846
 
-            if first_line != '# file GENERATED by distutils, do NOT edit\n':
31847
 
-                log.info("not writing to manually maintained "
31848
 
-                         "manifest file '%s'" % self.manifest)
31849
 
-                return
31850
 
+        if self._manifest_is_not_generated():
31851
 
+            log.info("not writing to manually maintained "
31852
 
+                     "manifest file '%s'" % self.manifest)
31853
 
+            return
31854
 
 
31855
 
         content = self.filelist.files[:]
31856
 
         content.insert(0, '# file GENERATED by distutils, do NOT edit')
31857
 
         self.execute(file_util.write_file, (self.manifest, content),
31858
 
                      "writing manifest file '%s'" % self.manifest)
31859
 
 
31860
 
+    def _manifest_is_not_generated(self):
31861
 
+        # check for special comment used in 2.7.1 and higher
31862
 
+        if not os.path.isfile(self.manifest):
31863
 
+            return False
31864
 
+
31865
 
+        fp = open(self.manifest, 'rU')
31866
 
+        try:
31867
 
+            first_line = fp.readline()
31868
 
+        finally:
31869
 
+            fp.close()
31870
 
+        return first_line != '# file GENERATED by distutils, do NOT edit\n'
31871
 
+
31872
 
     def read_manifest(self):
31873
 
         """Read the manifest file (named by 'self.manifest') and use it to
31874
 
         fill in 'self.filelist', the list of files to include in the source
31875
 
@@ -376,12 +390,11 @@
31876
 
         """
31877
 
         log.info("reading manifest file '%s'", self.manifest)
31878
 
         manifest = open(self.manifest)
31879
 
-        while 1:
31880
 
-            line = manifest.readline()
31881
 
-            if line == '':              # end of file
31882
 
-                break
31883
 
-            if line[-1] == '\n':
31884
 
-                line = line[0:-1]
31885
 
+        for line in manifest:
31886
 
+            # ignore comments and blank lines
31887
 
+            line = line.strip()
31888
 
+            if line.startswith('#') or not line:
31889
 
+                continue
31890
 
             self.filelist.append(line)
31891
 
         manifest.close()
31892
 
 
31893
 
diff -r 8527427914a2 Lib/distutils/dep_util.py
31894
 
--- a/Lib/distutils/dep_util.py
31895
 
+++ b/Lib/distutils/dep_util.py
31896
 
@@ -7,6 +7,7 @@
31897
 
 __revision__ = "$Id$"
31898
 
 
31899
 
 import os
31900
 
+from stat import ST_MTIME
31901
 
 from distutils.errors import DistutilsFileError
31902
 
 
31903
 
 def newer(source, target):
31904
 
@@ -27,7 +28,7 @@
31905
 
     if not os.path.exists(target):
31906
 
         return True
31907
 
 
31908
 
-    return os.stat(source).st_mtime > os.stat(target).st_mtime
31909
 
+    return os.stat(source)[ST_MTIME] > os.stat(target)[ST_MTIME]
31910
 
 
31911
 
 def newer_pairwise(sources, targets):
31912
 
     """Walk two filename lists in parallel, testing if each source is newer
31913
 
@@ -71,7 +72,7 @@
31914
 
     # is more recent than 'target', then 'target' is out-of-date and
31915
 
     # we can immediately return true.  If we fall through to the end
31916
 
     # of the loop, then 'target' is up-to-date and we return false.
31917
 
-    target_mtime = os.stat(target).st_mtime
31918
 
+    target_mtime = os.stat(target)[ST_MTIME]
31919
 
 
31920
 
     for source in sources:
31921
 
         if not os.path.exists(source):
31922
 
@@ -82,7 +83,7 @@
31923
 
             elif missing == 'newer':    # missing source means target is
31924
 
                 return True             #  out-of-date
31925
 
 
31926
 
-        if os.stat(source).st_mtime > target_mtime:
31927
 
+        if os.stat(source)[ST_MTIME] > target_mtime:
31928
 
             return True
31929
 
 
31930
 
     return False
31931
 
diff -r 8527427914a2 Lib/distutils/dist.py
31932
 
--- a/Lib/distutils/dist.py
31933
 
+++ b/Lib/distutils/dist.py
31934
 
@@ -1111,7 +1111,8 @@
31935
 
         """Write the PKG-INFO format data to a file object.
31936
 
         """
31937
 
         version = '1.0'
31938
 
-        if self.provides or self.requires or self.obsoletes:
31939
 
+        if (self.provides or self.requires or self.obsoletes or
31940
 
+            self.classifiers or self.download_url):
31941
 
             version = '1.1'
31942
 
 
31943
 
         self._write_field(file, 'Metadata-Version', version)
31944
 
diff -r 8527427914a2 Lib/distutils/filelist.py
31945
 
--- a/Lib/distutils/filelist.py
31946
 
+++ b/Lib/distutils/filelist.py
31947
 
@@ -328,7 +328,8 @@
31948
 
         # ditch end of pattern character
31949
 
         empty_pattern = glob_to_re('')
31950
 
         prefix_re = glob_to_re(prefix)[:-len(empty_pattern)]
31951
 
-        pattern_re = "^" + os.path.join(prefix_re, ".*" + pattern_re)
31952
 
+        # paths should always use / in manifest templates
31953
 
+        pattern_re = "^%s/.*%s" % (prefix_re, pattern_re)
31954
 
     else:                               # no prefix -- respect anchor flag
31955
 
         if anchor:
31956
 
             pattern_re = "^" + pattern_re
31957
 
diff -r 8527427914a2 Lib/distutils/msvc9compiler.py
31958
 
--- a/Lib/distutils/msvc9compiler.py
31959
 
+++ b/Lib/distutils/msvc9compiler.py
31960
 
@@ -640,15 +640,7 @@
31961
 
                     self.library_filename(dll_name))
31962
 
                 ld_args.append ('/IMPLIB:' + implib_file)
31963
 
 
31964
 
-            # Embedded manifests are recommended - see MSDN article titled
31965
 
-            # "How to: Embed a Manifest Inside a C/C++ Application"
31966
 
-            # (currently at http://msdn2.microsoft.com/en-us/library/ms235591(VS.80).aspx)
31967
 
-            # Ask the linker to generate the manifest in the temp dir, so
31968
 
-            # we can embed it later.
31969
 
-            temp_manifest = os.path.join(
31970
 
-                    build_temp,
31971
 
-                    os.path.basename(output_filename) + ".manifest")
31972
 
-            ld_args.append('/MANIFESTFILE:' + temp_manifest)
31973
 
+            self.manifest_setup_ldargs(output_filename, build_temp, ld_args)
31974
 
 
31975
 
             if extra_preargs:
31976
 
                 ld_args[:0] = extra_preargs
31977
 
@@ -666,20 +658,54 @@
31978
 
             # will still consider the DLL up-to-date, but it will not have a
31979
 
             # manifest.  Maybe we should link to a temp file?  OTOH, that
31980
 
             # implies a build environment error that shouldn't go undetected.
31981
 
-            if target_desc == CCompiler.EXECUTABLE:
31982
 
-                mfid = 1
31983
 
-            else:
31984
 
-                mfid = 2
31985
 
-                self._remove_visual_c_ref(temp_manifest)
31986
 
-            out_arg = '-outputresource:%s;%s' % (output_filename, mfid)
31987
 
-            try:
31988
 
-                self.spawn(['mt.exe', '-nologo', '-manifest',
31989
 
-                            temp_manifest, out_arg])
31990
 
-            except DistutilsExecError, msg:
31991
 
-                raise LinkError(msg)
31992
 
+            mfinfo = self.manifest_get_embed_info(target_desc, ld_args)
31993
 
+            if mfinfo is not None:
31994
 
+                mffilename, mfid = mfinfo
31995
 
+                out_arg = '-outputresource:%s;%s' % (output_filename, mfid)
31996
 
+                try:
31997
 
+                    self.spawn(['mt.exe', '-nologo', '-manifest',
31998
 
+                                mffilename, out_arg])
31999
 
+                except DistutilsExecError, msg:
32000
 
+                    raise LinkError(msg)
32001
 
         else:
32002
 
             log.debug("skipping %s (up-to-date)", output_filename)
32003
 
 
32004
 
+    def manifest_setup_ldargs(self, output_filename, build_temp, ld_args):
32005
 
+        # If we need a manifest at all, an embedded manifest is recommended.
32006
 
+        # See MSDN article titled
32007
 
+        # "How to: Embed a Manifest Inside a C/C++ Application"
32008
 
+        # (currently at http://msdn2.microsoft.com/en-us/library/ms235591(VS.80).aspx)
32009
 
+        # Ask the linker to generate the manifest in the temp dir, so
32010
 
+        # we can check it, and possibly embed it, later.
32011
 
+        temp_manifest = os.path.join(
32012
 
+                build_temp,
32013
 
+                os.path.basename(output_filename) + ".manifest")
32014
 
+        ld_args.append('/MANIFESTFILE:' + temp_manifest)
32015
 
+
32016
 
+    def manifest_get_embed_info(self, target_desc, ld_args):
32017
 
+        # If a manifest should be embedded, return a tuple of
32018
 
+        # (manifest_filename, resource_id).  Returns None if no manifest
32019
 
+        # should be embedded.  See http://bugs.python.org/issue7833 for why
32020
 
+        # we want to avoid any manifest for extension modules if we can)
32021
 
+        for arg in ld_args:
32022
 
+            if arg.startswith("/MANIFESTFILE:"):
32023
 
+                temp_manifest = arg.split(":", 1)[1]
32024
 
+                break
32025
 
+        else:
32026
 
+            # no /MANIFESTFILE so nothing to do.
32027
 
+            return None
32028
 
+        if target_desc == CCompiler.EXECUTABLE:
32029
 
+            # by default, executables always get the manifest with the
32030
 
+            # CRT referenced.
32031
 
+            mfid = 1
32032
 
+        else:
32033
 
+            # Extension modules try and avoid any manifest if possible.
32034
 
+            mfid = 2
32035
 
+            temp_manifest = self._remove_visual_c_ref(temp_manifest)
32036
 
+        if temp_manifest is None:
32037
 
+            return None
32038
 
+        return temp_manifest, mfid
32039
 
+
32040
 
     def _remove_visual_c_ref(self, manifest_file):
32041
 
         try:
32042
 
             # Remove references to the Visual C runtime, so they will
32043
 
@@ -688,6 +714,8 @@
32044
 
             # runtimes are not in WinSxS folder, but in Python's own
32045
 
             # folder), the runtimes do not need to be in every folder
32046
 
             # with .pyd's.
32047
 
+            # Returns either the filename of the modified manifest or
32048
 
+            # None if no manifest should be embedded.
32049
 
             manifest_f = open(manifest_file)
32050
 
             try:
32051
 
                 manifest_buf = manifest_f.read()
32052
 
@@ -700,9 +728,18 @@
32053
 
             manifest_buf = re.sub(pattern, "", manifest_buf)
32054
 
             pattern = "<dependentAssembly>\s*</dependentAssembly>"
32055
 
             manifest_buf = re.sub(pattern, "", manifest_buf)
32056
 
+            # Now see if any other assemblies are referenced - if not, we
32057
 
+            # don't want a manifest embedded.
32058
 
+            pattern = re.compile(
32059
 
+                r"""<assemblyIdentity.*?name=(?:"|')(.+?)(?:"|')"""
32060
 
+                r""".*?(?:/>|</assemblyIdentity>)""", re.DOTALL)
32061
 
+            if re.search(pattern, manifest_buf) is None:
32062
 
+                return None
32063
 
+
32064
 
             manifest_f = open(manifest_file, 'w')
32065
 
             try:
32066
 
                 manifest_f.write(manifest_buf)
32067
 
+                return manifest_file
32068
 
             finally:
32069
 
                 manifest_f.close()
32070
 
         except IOError:
32071
 
diff -r 8527427914a2 Lib/distutils/spawn.py
32072
 
--- a/Lib/distutils/spawn.py
32073
 
+++ b/Lib/distutils/spawn.py
32074
 
@@ -96,17 +96,43 @@
32075
 
             raise DistutilsExecError, \
32076
 
                   "command '%s' failed with exit status %d" % (cmd[0], rc)
32077
 
 
32078
 
+if sys.platform == 'darwin':
32079
 
+    from distutils import sysconfig
32080
 
+    _cfg_target = None
32081
 
+    _cfg_target_split = None
32082
 
 
32083
 
 def _spawn_posix(cmd, search_path=1, verbose=0, dry_run=0):
32084
 
     log.info(' '.join(cmd))
32085
 
     if dry_run:
32086
 
         return
32087
 
     exec_fn = search_path and os.execvp or os.execv
32088
 
+    exec_args = [cmd[0], cmd]
32089
 
+    if sys.platform == 'darwin':
32090
 
+        global _cfg_target, _cfg_target_split
32091
 
+        if _cfg_target is None:
32092
 
+            _cfg_target = sysconfig.get_config_var(
32093
 
+                                  'MACOSX_DEPLOYMENT_TARGET') or ''
32094
 
+            if _cfg_target:
32095
 
+                _cfg_target_split = [int(x) for x in _cfg_target.split('.')]
32096
 
+        if _cfg_target:
32097
 
+            # ensure that the deployment target of build process is not less
32098
 
+            # than that used when the interpreter was built. This ensures
32099
 
+            # extension modules are built with correct compatibility values
32100
 
+            cur_target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', _cfg_target)
32101
 
+            if _cfg_target_split > [int(x) for x in cur_target.split('.')]:
32102
 
+                my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: '
32103
 
+                          'now "%s" but "%s" during configure'
32104
 
+                                % (cur_target, _cfg_target))
32105
 
+                raise DistutilsPlatformError(my_msg)
32106
 
+            env = dict(os.environ,
32107
 
+                       MACOSX_DEPLOYMENT_TARGET=cur_target)
32108
 
+            exec_fn = search_path and os.execvpe or os.execve
32109
 
+            exec_args.append(env)
32110
 
     pid = os.fork()
32111
 
 
32112
 
     if pid == 0:  # in the child
32113
 
         try:
32114
 
-            exec_fn(cmd[0], cmd)
32115
 
+            exec_fn(*exec_args)
32116
 
         except OSError, e:
32117
 
             sys.stderr.write("unable to execute %s: %s\n" %
32118
 
                              (cmd[0], e.strerror))
32119
 
diff -r 8527427914a2 Lib/distutils/sysconfig.py
32120
 
--- a/Lib/distutils/sysconfig.py
32121
 
+++ b/Lib/distutils/sysconfig.py
32122
 
@@ -141,6 +141,7 @@
32123
 
             "I don't know where Python installs its library "
32124
 
             "on platform '%s'" % os.name)
32125
 
 
32126
 
+_USE_CLANG = None
32127
 
 
32128
 
 def customize_compiler(compiler):
32129
 
     """Do any platform-specific customization of a CCompiler instance.
32130
 
@@ -149,12 +150,43 @@
32131
 
     varies across Unices and is stored in Python's Makefile.
32132
 
     """
32133
 
     if compiler.compiler_type == "unix":
32134
 
-        (cc, cxx, opt, cflags, ccshared, ldshared, so_ext) = \
32135
 
+        (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
32136
 
             get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
32137
 
-                            'CCSHARED', 'LDSHARED', 'SO')
32138
 
+                            'CCSHARED', 'LDSHARED', 'SO', 'AR',
32139
 
+                            'ARFLAGS')
32140
 
 
32141
 
+        newcc = None
32142
 
         if 'CC' in os.environ:
32143
 
-            cc = os.environ['CC']
32144
 
+            newcc = os.environ['CC']
32145
 
+        elif sys.platform == 'darwin' and cc == 'gcc-4.2':
32146
 
+            # Issue #13590:
32147
 
+            #       Since Apple removed gcc-4.2 in Xcode 4.2, we can no
32148
 
+            #       longer assume it is available for extension module builds.
32149
 
+            #       If Python was built with gcc-4.2, check first to see if
32150
 
+            #       it is available on this system; if not, try to use clang
32151
 
+            #       instead unless the caller explicitly set CC.
32152
 
+            global _USE_CLANG
32153
 
+            if _USE_CLANG is None:
32154
 
+                from distutils import log
32155
 
+                from subprocess import Popen, PIPE
32156
 
+                p = Popen("! type gcc-4.2 && type clang && exit 2",
32157
 
+                                shell=True, stdout=PIPE, stderr=PIPE)
32158
 
+                p.wait()
32159
 
+                if p.returncode == 2:
32160
 
+                    _USE_CLANG = True
32161
 
+                    log.warn("gcc-4.2 not found, using clang instead")
32162
 
+                else:
32163
 
+                    _USE_CLANG = False
32164
 
+            if _USE_CLANG:
32165
 
+                newcc = 'clang'
32166
 
+        if newcc:
32167
 
+            # On OS X, if CC is overridden, use that as the default
32168
 
+            #       command for LDSHARED as well
32169
 
+            if (sys.platform == 'darwin'
32170
 
+                    and 'LDSHARED' not in os.environ
32171
 
+                    and ldshared.startswith(cc)):
32172
 
+                ldshared = newcc + ldshared[len(cc):]
32173
 
+            cc = newcc
32174
 
         if 'CXX' in os.environ:
32175
 
             cxx = os.environ['CXX']
32176
 
         if 'LDSHARED' in os.environ:
32177
 
@@ -172,6 +204,12 @@
32178
 
             cpp = cpp + ' ' + os.environ['CPPFLAGS']
32179
 
             cflags = cflags + ' ' + os.environ['CPPFLAGS']
32180
 
             ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
32181
 
+        if 'AR' in os.environ:
32182
 
+            ar = os.environ['AR']
32183
 
+        if 'ARFLAGS' in os.environ:
32184
 
+            archiver = ar + ' ' + os.environ['ARFLAGS']
32185
 
+        else:
32186
 
+            archiver = ar + ' ' + ar_flags
32187
 
 
32188
 
         cc_cmd = cc + ' ' + cflags
32189
 
         compiler.set_executables(
32190
 
@@ -180,7 +218,8 @@
32191
 
             compiler_so=cc_cmd + ' ' + ccshared,
32192
 
             compiler_cxx=cxx,
32193
 
             linker_so=ldshared,
32194
 
-            linker_exe=cc)
32195
 
+            linker_exe=cc,
32196
 
+            archiver=archiver)
32197
 
 
32198
 
         compiler.shared_lib_extension = so_ext
32199
 
 
32200
 
@@ -380,21 +419,6 @@
32201
 
 
32202
 
         raise DistutilsPlatformError(my_msg)
32203
 
 
32204
 
-    # On MacOSX we need to check the setting of the environment variable
32205
 
-    # MACOSX_DEPLOYMENT_TARGET: configure bases some choices on it so
32206
 
-    # it needs to be compatible.
32207
 
-    # If it isn't set we set it to the configure-time value
32208
 
-    if sys.platform == 'darwin' and 'MACOSX_DEPLOYMENT_TARGET' in g:
32209
 
-        cfg_target = g['MACOSX_DEPLOYMENT_TARGET']
32210
 
-        cur_target = os.getenv('MACOSX_DEPLOYMENT_TARGET', '')
32211
 
-        if cur_target == '':
32212
 
-            cur_target = cfg_target
32213
 
-            os.environ['MACOSX_DEPLOYMENT_TARGET'] = cfg_target
32214
 
-        elif map(int, cfg_target.split('.')) > map(int, cur_target.split('.')):
32215
 
-            my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configure'
32216
 
-                % (cur_target, cfg_target))
32217
 
-            raise DistutilsPlatformError(my_msg)
32218
 
-
32219
 
     # On AIX, there are wrong paths to the linker scripts in the Makefile
32220
 
     # -- these paths are relative to the Python source, but when installed
32221
 
     # the scripts are in another directory.
32222
 
diff -r 8527427914a2 Lib/distutils/tests/support.py
32223
 
--- a/Lib/distutils/tests/support.py
32224
 
+++ b/Lib/distutils/tests/support.py
32225
 
@@ -1,7 +1,10 @@
32226
 
 """Support code for distutils test cases."""
32227
 
 import os
32228
 
+import sys
32229
 
 import shutil
32230
 
 import tempfile
32231
 
+import unittest
32232
 
+import sysconfig
32233
 
 from copy import deepcopy
32234
 
 import warnings
32235
 
 
32236
 
@@ -9,6 +12,7 @@
32237
 
 from distutils.log import DEBUG, INFO, WARN, ERROR, FATAL
32238
 
 from distutils.core import Distribution
32239
 
 
32240
 
+
32241
 
 def capture_warnings(func):
32242
 
     def _capture_warnings(*args, **kw):
32243
 
         with warnings.catch_warnings():
32244
 
@@ -16,6 +20,7 @@
32245
 
             return func(*args, **kw)
32246
 
     return _capture_warnings
32247
 
 
32248
 
+
32249
 
 class LoggingSilencer(object):
32250
 
 
32251
 
     def setUp(self):
32252
 
@@ -49,6 +54,7 @@
32253
 
     def clear_logs(self):
32254
 
         self.logs = []
32255
 
 
32256
 
+
32257
 
 class TempdirManager(object):
32258
 
     """Mix-in class that handles temporary directories for test cases.
32259
 
 
32260
 
@@ -57,9 +63,13 @@
32261
 
 
32262
 
     def setUp(self):
32263
 
         super(TempdirManager, self).setUp()
32264
 
+        self.old_cwd = os.getcwd()
32265
 
         self.tempdirs = []
32266
 
 
32267
 
     def tearDown(self):
32268
 
+        # Restore working dir, for Solaris and derivatives, where rmdir()
32269
 
+        # on the current directory fails.
32270
 
+        os.chdir(self.old_cwd)
32271
 
         super(TempdirManager, self).tearDown()
32272
 
         while self.tempdirs:
32273
 
             d = self.tempdirs.pop()
32274
 
@@ -105,6 +115,7 @@
32275
 
 
32276
 
         return pkg_dir, dist
32277
 
 
32278
 
+
32279
 
 class DummyCommand:
32280
 
     """Class to store options for retrieval via set_undefined_options()."""
32281
 
 
32282
 
@@ -115,6 +126,7 @@
32283
 
     def ensure_finalized(self):
32284
 
         pass
32285
 
 
32286
 
+
32287
 
 class EnvironGuard(object):
32288
 
 
32289
 
     def setUp(self):
32290
 
@@ -131,3 +143,79 @@
32291
 
                 del os.environ[key]
32292
 
 
32293
 
         super(EnvironGuard, self).tearDown()
32294
 
+
32295
 
+
32296
 
+def copy_xxmodule_c(directory):
32297
 
+    """Helper for tests that need the xxmodule.c source file.
32298
 
+
32299
 
+    Example use:
32300
 
+
32301
 
+        def test_compile(self):
32302
 
+            copy_xxmodule_c(self.tmpdir)
32303
 
+            self.assertIn('xxmodule.c', os.listdir(self.tmpdir))
32304
 
+
32305
 
+    If the source file can be found, it will be copied to *directory*.  If not,
32306
 
+    the test will be skipped.  Errors during copy are not caught.
32307
 
+    """
32308
 
+    filename = _get_xxmodule_path()
32309
 
+    if filename is None:
32310
 
+        raise unittest.SkipTest('cannot find xxmodule.c (test must run in '
32311
 
+                                'the python build dir)')
32312
 
+    shutil.copy(filename, directory)
32313
 
+
32314
 
+
32315
 
+def _get_xxmodule_path():
32316
 
+    # FIXME when run from regrtest, srcdir seems to be '.', which does not help
32317
 
+    # us find the xxmodule.c file
32318
 
+    srcdir = sysconfig.get_config_var('srcdir')
32319
 
+    candidates = [
32320
 
+        # use installed copy if available
32321
 
+        os.path.join(os.path.dirname(__file__), 'xxmodule.c'),
32322
 
+        # otherwise try using copy from build directory
32323
 
+        os.path.join(srcdir, 'Modules', 'xxmodule.c'),
32324
 
+        # srcdir mysteriously can be $srcdir/Lib/distutils/tests when
32325
 
+        # this file is run from its parent directory, so walk up the
32326
 
+        # tree to find the real srcdir
32327
 
+        os.path.join(srcdir, '..', '..', '..', 'Modules', 'xxmodule.c'),
32328
 
+    ]
32329
 
+    for path in candidates:
32330
 
+        if os.path.exists(path):
32331
 
+            return path
32332
 
+
32333
 
+
32334
 
+def fixup_build_ext(cmd):
32335
 
+    """Function needed to make build_ext tests pass.
32336
 
+
32337
 
+    When Python was build with --enable-shared on Unix, -L. is not good
32338
 
+    enough to find the libpython<blah>.so.  This is because regrtest runs
32339
 
+    it under a tempdir, not in the top level where the .so lives.  By the
32340
 
+    time we've gotten here, Python's already been chdir'd to the tempdir.
32341
 
+
32342
 
+    When Python was built with in debug mode on Windows, build_ext commands
32343
 
+    need their debug attribute set, and it is not done automatically for
32344
 
+    some reason.
32345
 
+
32346
 
+    This function handles both of these things.  Example use:
32347
 
+
32348
 
+        cmd = build_ext(dist)
32349
 
+        support.fixup_build_ext(cmd)
32350
 
+        cmd.ensure_finalized()
32351
 
+
32352
 
+    Unlike most other Unix platforms, Mac OS X embeds absolute paths
32353
 
+    to shared libraries into executables, so the fixup is not needed there.
32354
 
+    """
32355
 
+    if os.name == 'nt':
32356
 
+        cmd.debug = sys.executable.endswith('_d.exe')
32357
 
+    elif sysconfig.get_config_var('Py_ENABLE_SHARED'):
32358
 
+        # To further add to the shared builds fun on Unix, we can't just add
32359
 
+        # library_dirs to the Extension() instance because that doesn't get
32360
 
+        # plumbed through to the final compiler command.
32361
 
+        runshared = sysconfig.get_config_var('RUNSHARED')
32362
 
+        if runshared is None:
32363
 
+            cmd.library_dirs = ['.']
32364
 
+        else:
32365
 
+            if sys.platform == 'darwin':
32366
 
+                cmd.library_dirs = []
32367
 
+            else:
32368
 
+                name, equals, value = runshared.partition('=')
32369
 
+                cmd.library_dirs = value.split(os.pathsep)
32370
 
diff -r 8527427914a2 Lib/distutils/tests/test_archive_util.py
32371
 
--- a/Lib/distutils/tests/test_archive_util.py
32372
 
+++ b/Lib/distutils/tests/test_archive_util.py
32373
 
@@ -1,8 +1,10 @@
32374
 
+# -*- coding: utf-8 -*-
32375
 
 """Tests for distutils.archive_util."""
32376
 
 __revision__ = "$Id$"
32377
 
 
32378
 
 import unittest
32379
 
 import os
32380
 
+import sys
32381
 
 import tarfile
32382
 
 from os.path import splitdrive
32383
 
 import warnings
32384
 
@@ -33,6 +35,18 @@
32385
 
 except ImportError:
32386
 
     zlib = None
32387
 
 
32388
 
+def can_fs_encode(filename):
32389
 
+    """
32390
 
+    Return True if the filename can be saved in the file system.
32391
 
+    """
32392
 
+    if os.path.supports_unicode_filenames:
32393
 
+        return True
32394
 
+    try:
32395
 
+        filename.encode(sys.getfilesystemencoding())
32396
 
+    except UnicodeEncodeError:
32397
 
+        return False
32398
 
+    return True
32399
 
+
32400
 
 
32401
 
 class ArchiveUtilTestCase(support.TempdirManager,
32402
 
                           support.LoggingSilencer,
32403
 
@@ -40,6 +54,9 @@
32404
 
 
32405
 
     @unittest.skipUnless(zlib, "requires zlib")
32406
 
     def test_make_tarball(self):
32407
 
+        self._make_tarball('archive')
32408
 
+
32409
 
+    def _make_tarball(self, target_name):
32410
 
         # creating something to tar
32411
 
         tmpdir = self.mkdtemp()
32412
 
         self.write_file([tmpdir, 'file1'], 'xxx')
32413
 
@@ -51,7 +68,7 @@
32414
 
         unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0],
32415
 
                             "source and target should be on same drive")
32416
 
 
32417
 
-        base_name = os.path.join(tmpdir2, 'archive')
32418
 
+        base_name = os.path.join(tmpdir2, target_name)
32419
 
 
32420
 
         # working with relative paths to avoid tar warnings
32421
 
         old_dir = os.getcwd()
32422
 
@@ -66,7 +83,7 @@
32423
 
         self.assertTrue(os.path.exists(tarball))
32424
 
 
32425
 
         # trying an uncompressed one
32426
 
-        base_name = os.path.join(tmpdir2, 'archive')
32427
 
+        base_name = os.path.join(tmpdir2, target_name)
32428
 
         old_dir = os.getcwd()
32429
 
         os.chdir(tmpdir)
32430
 
         try:
32431
 
@@ -277,6 +294,33 @@
32432
 
         finally:
32433
 
             del ARCHIVE_FORMATS['xxx']
32434
 
 
32435
 
+    @unittest.skipUnless(zlib, "requires zlib")
32436
 
+    def test_make_tarball_unicode(self):
32437
 
+        """
32438
 
+        Mirror test_make_tarball, except filename is unicode.
32439
 
+        """
32440
 
+        self._make_tarball(u'archive')
32441
 
+
32442
 
+    @unittest.skipUnless(zlib, "requires zlib")
32443
 
+    @unittest.skipUnless(can_fs_encode(u'årchiv'),
32444
 
+        'File system cannot handle this filename')
32445
 
+    def test_make_tarball_unicode_latin1(self):
32446
 
+        """
32447
 
+        Mirror test_make_tarball, except filename is unicode and contains
32448
 
+        latin characters.
32449
 
+        """
32450
 
+        self._make_tarball(u'årchiv') # note this isn't a real word
32451
 
+
32452
 
+    @unittest.skipUnless(zlib, "requires zlib")
32453
 
+    @unittest.skipUnless(can_fs_encode(u'のアーカイブ'),
32454
 
+        'File system cannot handle this filename')
32455
 
+    def test_make_tarball_unicode_extended(self):
32456
 
+        """
32457
 
+        Mirror test_make_tarball, except filename is unicode and contains
32458
 
+        characters outside the latin charset.
32459
 
+        """
32460
 
+        self._make_tarball(u'のアーカイブ') # japanese for archive
32461
 
+
32462
 
 def test_suite():
32463
 
     return unittest.makeSuite(ArchiveUtilTestCase)
32464
 
 
32465
 
diff -r 8527427914a2 Lib/distutils/tests/test_bdist.py
32466
 
--- a/Lib/distutils/tests/test_bdist.py
32467
 
+++ b/Lib/distutils/tests/test_bdist.py
32468
 
@@ -1,42 +1,49 @@
32469
 
 """Tests for distutils.command.bdist."""
32470
 
+import os
32471
 
 import unittest
32472
 
-import sys
32473
 
-import os
32474
 
-import tempfile
32475
 
-import shutil
32476
 
 
32477
 
 from test.test_support import run_unittest
32478
 
 
32479
 
-from distutils.core import Distribution
32480
 
 from distutils.command.bdist import bdist
32481
 
 from distutils.tests import support
32482
 
-from distutils.spawn import find_executable
32483
 
-from distutils import spawn
32484
 
-from distutils.errors import DistutilsExecError
32485
 
+
32486
 
 
32487
 
 class BuildTestCase(support.TempdirManager,
32488
 
                     unittest.TestCase):
32489
 
 
32490
 
     def test_formats(self):
32491
 
-
32492
 
         # let's create a command and make sure
32493
 
-        # we can fix the format
32494
 
-        pkg_pth, dist = self.create_dist()
32495
 
+        # we can set the format
32496
 
+        dist = self.create_dist()[1]
32497
 
         cmd = bdist(dist)
32498
 
         cmd.formats = ['msi']
32499
 
         cmd.ensure_finalized()
32500
 
         self.assertEqual(cmd.formats, ['msi'])
32501
 
 
32502
 
-        # what format bdist offers ?
32503
 
-        # XXX an explicit list in bdist is
32504
 
-        # not the best way to  bdist_* commands
32505
 
-        # we should add a registry
32506
 
-        formats = ['rpm', 'zip', 'gztar', 'bztar', 'ztar',
32507
 
-                   'tar', 'wininst', 'msi']
32508
 
-        formats.sort()
32509
 
-        founded = cmd.format_command.keys()
32510
 
-        founded.sort()
32511
 
-        self.assertEqual(founded, formats)
32512
 
+        # what formats does bdist offer?
32513
 
+        formats = ['bztar', 'gztar', 'msi', 'rpm', 'tar',
32514
 
+                   'wininst', 'zip', 'ztar']
32515
 
+        found = sorted(cmd.format_command)
32516
 
+        self.assertEqual(found, formats)
32517
 
+
32518
 
+    def test_skip_build(self):
32519
 
+        # bug #10946: bdist --skip-build should trickle down to subcommands
32520
 
+        dist = self.create_dist()[1]
32521
 
+        cmd = bdist(dist)
32522
 
+        cmd.skip_build = 1
32523
 
+        cmd.ensure_finalized()
32524
 
+        dist.command_obj['bdist'] = cmd
32525
 
+
32526
 
+        names = ['bdist_dumb', 'bdist_wininst']
32527
 
+        # bdist_rpm does not support --skip-build
32528
 
+        if os.name == 'nt':
32529
 
+            names.append('bdist_msi')
32530
 
+
32531
 
+        for name in names:
32532
 
+            subcmd = cmd.get_finalized_command(name)
32533
 
+            self.assertTrue(subcmd.skip_build,
32534
 
+                            '%s should take --skip-build from bdist' % name)
32535
 
+
32536
 
 
32537
 
 def test_suite():
32538
 
     return unittest.makeSuite(BuildTestCase)
32539
 
diff -r 8527427914a2 Lib/distutils/tests/test_build_clib.py
32540
 
--- a/Lib/distutils/tests/test_build_clib.py
32541
 
+++ b/Lib/distutils/tests/test_build_clib.py
32542
 
@@ -122,7 +122,8 @@
32543
 
         # before we run the command, we want to make sure
32544
 
         # all commands are present on the system
32545
 
         # by creating a compiler and checking its executables
32546
 
-        from distutils.ccompiler import new_compiler, customize_compiler
32547
 
+        from distutils.ccompiler import new_compiler
32548
 
+        from distutils.sysconfig import customize_compiler
32549
 
 
32550
 
         compiler = new_compiler()
32551
 
         customize_compiler(compiler)
32552
 
diff -r 8527427914a2 Lib/distutils/tests/test_build_ext.py
32553
 
--- a/Lib/distutils/tests/test_build_ext.py
32554
 
+++ b/Lib/distutils/tests/test_build_ext.py
32555
 
@@ -1,7 +1,5 @@
32556
 
 import sys
32557
 
 import os
32558
 
-import tempfile
32559
 
-import shutil
32560
 
 from StringIO import StringIO
32561
 
 import textwrap
32562
 
 
32563
 
@@ -9,7 +7,8 @@
32564
 
 from distutils.command.build_ext import build_ext
32565
 
 from distutils import sysconfig
32566
 
 from distutils.tests import support
32567
 
-from distutils.errors import DistutilsSetupError, CompileError
32568
 
+from distutils.errors import (DistutilsSetupError, CompileError,
32569
 
+                              DistutilsPlatformError)
32570
 
 
32571
 
 import unittest
32572
 
 from test import test_support
32573
 
@@ -18,71 +17,40 @@
32574
 
 # Don't load the xx module more than once.
32575
 
 ALREADY_TESTED = False
32576
 
 
32577
 
-def _get_source_filename():
32578
 
-    srcdir = sysconfig.get_config_var('srcdir')
32579
 
-    if srcdir is None:
32580
 
-        return os.path.join(sysconfig.project_base, 'Modules', 'xxmodule.c')
32581
 
-    return os.path.join(srcdir, 'Modules', 'xxmodule.c')
32582
 
-
32583
 
-_XX_MODULE_PATH = _get_source_filename()
32584
 
 
32585
 
 class BuildExtTestCase(support.TempdirManager,
32586
 
                        support.LoggingSilencer,
32587
 
                        unittest.TestCase):
32588
 
     def setUp(self):
32589
 
-        # Create a simple test environment
32590
 
-        # Note that we're making changes to sys.path
32591
 
         super(BuildExtTestCase, self).setUp()
32592
 
-        self.tmp_dir = tempfile.mkdtemp(prefix="pythontest_")
32593
 
-        if os.path.exists(_XX_MODULE_PATH):
32594
 
-            self.sys_path = sys.path[:]
32595
 
-            sys.path.append(self.tmp_dir)
32596
 
-            shutil.copy(_XX_MODULE_PATH, self.tmp_dir)
32597
 
+        self.tmp_dir = self.mkdtemp()
32598
 
+        self.xx_created = False
32599
 
+        sys.path.append(self.tmp_dir)
32600
 
+        self.addCleanup(sys.path.remove, self.tmp_dir)
32601
 
+        if sys.version > "2.6":
32602
 
+            import site
32603
 
+            self.old_user_base = site.USER_BASE
32604
 
+            site.USER_BASE = self.mkdtemp()
32605
 
+            from distutils.command import build_ext
32606
 
+            build_ext.USER_BASE = site.USER_BASE
32607
 
 
32608
 
     def tearDown(self):
32609
 
-        # Get everything back to normal
32610
 
-        if os.path.exists(_XX_MODULE_PATH):
32611
 
+        if self.xx_created:
32612
 
             test_support.unload('xx')
32613
 
-            sys.path[:] = self.sys_path
32614
 
             # XXX on Windows the test leaves a directory
32615
 
             # with xx module in TEMP
32616
 
-        shutil.rmtree(self.tmp_dir, os.name == 'nt' or
32617
 
-                                    sys.platform == 'cygwin')
32618
 
         super(BuildExtTestCase, self).tearDown()
32619
 
 
32620
 
-    def _fixup_command(self, cmd):
32621
 
-        # When Python was build with --enable-shared, -L. is not good enough
32622
 
-        # to find the libpython<blah>.so.  This is because regrtest runs it
32623
 
-        # under a tempdir, not in the top level where the .so lives.  By the
32624
 
-        # time we've gotten here, Python's already been chdir'd to the
32625
 
-        # tempdir.
32626
 
-        #
32627
 
-        # To further add to the fun, we can't just add library_dirs to the
32628
 
-        # Extension() instance because that doesn't get plumbed through to the
32629
 
-        # final compiler command.
32630
 
-        if (sysconfig.get_config_var('Py_ENABLE_SHARED') and
32631
 
-            not sys.platform.startswith('win')):
32632
 
-            runshared = sysconfig.get_config_var('RUNSHARED')
32633
 
-            if runshared is None:
32634
 
-                cmd.library_dirs = ['.']
32635
 
-            else:
32636
 
-                name, equals, value = runshared.partition('=')
32637
 
-                cmd.library_dirs = value.split(os.pathsep)
32638
 
-
32639
 
-    @unittest.skipIf(not os.path.exists(_XX_MODULE_PATH),
32640
 
-                     'xxmodule.c not found')
32641
 
     def test_build_ext(self):
32642
 
         global ALREADY_TESTED
32643
 
+        support.copy_xxmodule_c(self.tmp_dir)
32644
 
+        self.xx_created = True
32645
 
         xx_c = os.path.join(self.tmp_dir, 'xxmodule.c')
32646
 
         xx_ext = Extension('xx', [xx_c])
32647
 
         dist = Distribution({'name': 'xx', 'ext_modules': [xx_ext]})
32648
 
         dist.package_dir = self.tmp_dir
32649
 
         cmd = build_ext(dist)
32650
 
-        self._fixup_command(cmd)
32651
 
-        if os.name == "nt":
32652
 
-            # On Windows, we must build a debug version iff running
32653
 
-            # a debug build of Python
32654
 
-            cmd.debug = sys.executable.endswith("_d.exe")
32655
 
+        support.fixup_build_ext(cmd)
32656
 
         cmd.build_lib = self.tmp_dir
32657
 
         cmd.build_temp = self.tmp_dir
32658
 
 
32659
 
@@ -135,6 +103,36 @@
32660
 
         # make sure we get some library dirs under solaris
32661
 
         self.assertTrue(len(cmd.library_dirs) > 0)
32662
 
 
32663
 
+    def test_user_site(self):
32664
 
+        # site.USER_SITE was introduced in 2.6
32665
 
+        if sys.version < '2.6':
32666
 
+            return
32667
 
+
32668
 
+        import site
32669
 
+        dist = Distribution({'name': 'xx'})
32670
 
+        cmd = build_ext(dist)
32671
 
+
32672
 
+        # making sure the user option is there
32673
 
+        options = [name for name, short, label in
32674
 
+                   cmd.user_options]
32675
 
+        self.assertIn('user', options)
32676
 
+
32677
 
+        # setting a value
32678
 
+        cmd.user = 1
32679
 
+
32680
 
+        # setting user based lib and include
32681
 
+        lib = os.path.join(site.USER_BASE, 'lib')
32682
 
+        incl = os.path.join(site.USER_BASE, 'include')
32683
 
+        os.mkdir(lib)
32684
 
+        os.mkdir(incl)
32685
 
+
32686
 
+        cmd.ensure_finalized()
32687
 
+
32688
 
+        # see if include_dirs and library_dirs were set
32689
 
+        self.assertIn(lib, cmd.library_dirs)
32690
 
+        self.assertIn(lib, cmd.rpath)
32691
 
+        self.assertIn(incl, cmd.include_dirs)
32692
 
+
32693
 
     def test_finalize_options(self):
32694
 
         # Make sure Python's include directories (for Python.h, pyconfig.h,
32695
 
         # etc.) are in the include search path.
32696
 
@@ -143,7 +141,6 @@
32697
 
         cmd = build_ext(dist)
32698
 
         cmd.finalize_options()
32699
 
 
32700
 
-        from distutils import sysconfig
32701
 
         py_include = sysconfig.get_python_inc()
32702
 
         self.assertTrue(py_include in cmd.include_dirs)
32703
 
 
32704
 
@@ -153,21 +150,22 @@
32705
 
         # make sure cmd.libraries is turned into a list
32706
 
         # if it's a string
32707
 
         cmd = build_ext(dist)
32708
 
-        cmd.libraries = 'my_lib'
32709
 
+        cmd.libraries = 'my_lib, other_lib lastlib'
32710
 
         cmd.finalize_options()
32711
 
-        self.assertEqual(cmd.libraries, ['my_lib'])
32712
 
+        self.assertEqual(cmd.libraries, ['my_lib', 'other_lib', 'lastlib'])
32713
 
 
32714
 
         # make sure cmd.library_dirs is turned into a list
32715
 
         # if it's a string
32716
 
         cmd = build_ext(dist)
32717
 
-        cmd.library_dirs = 'my_lib_dir'
32718
 
+        cmd.library_dirs = 'my_lib_dir%sother_lib_dir' % os.pathsep
32719
 
         cmd.finalize_options()
32720
 
-        self.assertTrue('my_lib_dir' in cmd.library_dirs)
32721
 
+        self.assertIn('my_lib_dir', cmd.library_dirs)
32722
 
+        self.assertIn('other_lib_dir', cmd.library_dirs)
32723
 
 
32724
 
         # make sure rpath is turned into a list
32725
 
-        # if it's a list of os.pathsep's paths
32726
 
+        # if it's a string
32727
 
         cmd = build_ext(dist)
32728
 
-        cmd.rpath = os.pathsep.join(['one', 'two'])
32729
 
+        cmd.rpath = 'one%stwo' % os.pathsep
32730
 
         cmd.finalize_options()
32731
 
         self.assertEqual(cmd.rpath, ['one', 'two'])
32732
 
 
32733
 
@@ -271,13 +269,10 @@
32734
 
         dist = Distribution({'name': 'xx',
32735
 
                              'ext_modules': [ext]})
32736
 
         cmd = build_ext(dist)
32737
 
-        self._fixup_command(cmd)
32738
 
+        support.fixup_build_ext(cmd)
32739
 
         cmd.ensure_finalized()
32740
 
         self.assertEqual(len(cmd.get_outputs()), 1)
32741
 
 
32742
 
-        if os.name == "nt":
32743
 
-            cmd.debug = sys.executable.endswith("_d.exe")
32744
 
-
32745
 
         cmd.build_lib = os.path.join(self.tmp_dir, 'build')
32746
 
         cmd.build_temp = os.path.join(self.tmp_dir, 'tempt')
32747
 
 
32748
 
@@ -432,18 +427,43 @@
32749
 
         self.assertEqual(ext_path, wanted)
32750
 
 
32751
 
     @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for MacOSX')
32752
 
-    def test_deployment_target(self):
32753
 
-        self._try_compile_deployment_target()
32754
 
+    def test_deployment_target_default(self):
32755
 
+        # Issue 9516: Test that, in the absence of the environment variable,
32756
 
+        # an extension module is compiled with the same deployment target as
32757
 
+        #  the interpreter.
32758
 
+        self._try_compile_deployment_target('==', None)
32759
 
 
32760
 
+    @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for MacOSX')
32761
 
+    def test_deployment_target_too_low(self):
32762
 
+        # Issue 9516: Test that an extension module is not allowed to be
32763
 
+        # compiled with a deployment target less than that of the interpreter.
32764
 
+        self.assertRaises(DistutilsPlatformError,
32765
 
+            self._try_compile_deployment_target, '>', '10.1')
32766
 
+
32767
 
+    @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for MacOSX')
32768
 
+    def test_deployment_target_higher_ok(self):
32769
 
+        # Issue 9516: Test that an extension module can be compiled with a
32770
 
+        # deployment target higher than that of the interpreter: the ext
32771
 
+        # module may depend on some newer OS feature.
32772
 
+        deptarget = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
32773
 
+        if deptarget:
32774
 
+            # increment the minor version number (i.e. 10.6 -> 10.7)
32775
 
+            deptarget = [int(x) for x in deptarget.split('.')]
32776
 
+            deptarget[-1] += 1
32777
 
+            deptarget = '.'.join(str(i) for i in deptarget)
32778
 
+            self._try_compile_deployment_target('<', deptarget)
32779
 
+
32780
 
+    def _try_compile_deployment_target(self, operator, target):
32781
 
         orig_environ = os.environ
32782
 
         os.environ = orig_environ.copy()
32783
 
         self.addCleanup(setattr, os, 'environ', orig_environ)
32784
 
 
32785
 
-        os.environ['MACOSX_DEPLOYMENT_TARGET']='10.1'
32786
 
-        self._try_compile_deployment_target()
32787
 
+        if target is None:
32788
 
+            if os.environ.get('MACOSX_DEPLOYMENT_TARGET'):
32789
 
+                del os.environ['MACOSX_DEPLOYMENT_TARGET']
32790
 
+        else:
32791
 
+            os.environ['MACOSX_DEPLOYMENT_TARGET'] = target
32792
 
 
32793
 
-
32794
 
-    def _try_compile_deployment_target(self):
32795
 
         deptarget_c = os.path.join(self.tmp_dir, 'deptargetmodule.c')
32796
 
 
32797
 
         with open(deptarget_c, 'w') as fp:
32798
 
@@ -452,16 +472,17 @@
32799
 
 
32800
 
                 int dummy;
32801
 
 
32802
 
-                #if TARGET != MAC_OS_X_VERSION_MIN_REQUIRED
32803
 
+                #if TARGET %s MAC_OS_X_VERSION_MIN_REQUIRED
32804
 
+                #else
32805
 
                 #error "Unexpected target"
32806
 
-               #endif
32807
 
+                #endif
32808
 
 
32809
 
-            '''))
32810
 
+            ''' % operator))
32811
 
 
32812
 
+        # get the deployment target that the interpreter was built with
32813
 
         target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
32814
 
         target = tuple(map(int, target.split('.')))
32815
 
         target = '%02d%01d0' % target
32816
 
-
32817
 
         deptarget_ext = Extension(
32818
 
             'deptarget',
32819
 
             [deptarget_c],
32820
 
@@ -477,10 +498,8 @@
32821
 
         cmd.build_temp = self.tmp_dir
32822
 
 
32823
 
         try:
32824
 
-            old_stdout = sys.stdout
32825
 
             cmd.ensure_finalized()
32826
 
             cmd.run()
32827
 
-
32828
 
         except CompileError:
32829
 
             self.fail("Wrong deployment target during compilation")
32830
 
 
32831
 
diff -r 8527427914a2 Lib/distutils/tests/test_ccompiler.py
32832
 
--- a/Lib/distutils/tests/test_ccompiler.py
32833
 
+++ b/Lib/distutils/tests/test_ccompiler.py
32834
 
@@ -4,7 +4,8 @@
32835
 
 from test.test_support import captured_stdout
32836
 
 
32837
 
 from distutils.ccompiler import (gen_lib_options, CCompiler,
32838
 
-                                 get_default_compiler, customize_compiler)
32839
 
+                                 get_default_compiler)
32840
 
+from distutils.sysconfig import customize_compiler
32841
 
 from distutils import debug
32842
 
 from distutils.tests import support
32843
 
 
32844
 
diff -r 8527427914a2 Lib/distutils/tests/test_check.py
32845
 
--- a/Lib/distutils/tests/test_check.py
32846
 
+++ b/Lib/distutils/tests/test_check.py
32847
 
@@ -1,3 +1,4 @@
32848
 
+# -*- encoding: utf8 -*-
32849
 
 """Tests for distutils.command.check."""
32850
 
 import unittest
32851
 
 from test.test_support import run_unittest
32852
 
@@ -46,6 +47,15 @@
32853
 
         cmd = self._run(metadata, strict=1)
32854
 
         self.assertEqual(cmd._warnings, 0)
32855
 
 
32856
 
+        # now a test with Unicode entries
32857
 
+        metadata = {'url': u'xxx', 'author': u'\u00c9ric',
32858
 
+                    'author_email': u'xxx', u'name': 'xxx',
32859
 
+                    'version': u'xxx',
32860
 
+                    'description': u'Something about esszet \u00df',
32861
 
+                    'long_description': u'More things about esszet \u00df'}
32862
 
+        cmd = self._run(metadata)
32863
 
+        self.assertEqual(cmd._warnings, 0)
32864
 
+
32865
 
     def test_check_document(self):
32866
 
         if not HAS_DOCUTILS: # won't test without docutils
32867
 
             return
32868
 
@@ -80,8 +90,8 @@
32869
 
         self.assertRaises(DistutilsSetupError, self._run, metadata,
32870
 
                           **{'strict': 1, 'restructuredtext': 1})
32871
 
 
32872
 
-        # and non-broken rest
32873
 
-        metadata['long_description'] = 'title\n=====\n\ntest'
32874
 
+        # and non-broken rest, including a non-ASCII character to test #12114
32875
 
+        metadata['long_description'] = u'title\n=====\n\ntest \u00df'
32876
 
         cmd = self._run(metadata, strict=1, restructuredtext=1)
32877
 
         self.assertEqual(cmd._warnings, 0)
32878
 
 
32879
 
diff -r 8527427914a2 Lib/distutils/tests/test_config_cmd.py
32880
 
--- a/Lib/distutils/tests/test_config_cmd.py
32881
 
+++ b/Lib/distutils/tests/test_config_cmd.py
32882
 
@@ -44,10 +44,10 @@
32883
 
         cmd = config(dist)
32884
 
 
32885
 
         # simple pattern searches
32886
 
-        match = cmd.search_cpp(pattern='xxx', body='// xxx')
32887
 
+        match = cmd.search_cpp(pattern='xxx', body='/* xxx */')
32888
 
         self.assertEqual(match, 0)
32889
 
 
32890
 
-        match = cmd.search_cpp(pattern='_configtest', body='// xxx')
32891
 
+        match = cmd.search_cpp(pattern='_configtest', body='/* xxx */')
32892
 
         self.assertEqual(match, 1)
32893
 
 
32894
 
     def test_finalize_options(self):
32895
 
diff -r 8527427914a2 Lib/distutils/tests/test_dist.py
32896
 
--- a/Lib/distutils/tests/test_dist.py
32897
 
+++ b/Lib/distutils/tests/test_dist.py
32898
 
@@ -8,12 +8,13 @@
32899
 
 import warnings
32900
 
 import textwrap
32901
 
 
32902
 
-from distutils.dist import Distribution, fix_help_options, DistributionMetadata
32903
 
+from distutils.dist import Distribution, fix_help_options
32904
 
 from distutils.cmd import Command
32905
 
 import distutils.dist
32906
 
 from test.test_support import TESTFN, captured_stdout, run_unittest
32907
 
 from distutils.tests import support
32908
 
 
32909
 
+
32910
 
 class test_dist(Command):
32911
 
     """Sample distutils extension command."""
32912
 
 
32913
 
@@ -61,7 +62,7 @@
32914
 
 
32915
 
     def test_debug_mode(self):
32916
 
         with open(TESTFN, "w") as f:
32917
 
-            f.write("[global]")
32918
 
+            f.write("[global]\n")
32919
 
             f.write("command_packages = foo.bar, splat")
32920
 
 
32921
 
         files = [TESTFN]
32922
 
@@ -97,7 +98,7 @@
32923
 
         self.assertEqual(d.get_command_packages(),
32924
 
                          ["distutils.command", "foo.bar", "distutils.tests"])
32925
 
         cmd = d.get_command_obj("test_dist")
32926
 
-        self.assertTrue(isinstance(cmd, test_dist))
32927
 
+        self.assertIsInstance(cmd, test_dist)
32928
 
         self.assertEqual(cmd.sample_option, "sometext")
32929
 
 
32930
 
     def test_command_packages_configfile(self):
32931
 
@@ -105,8 +106,8 @@
32932
 
         self.addCleanup(os.unlink, TESTFN)
32933
 
         f = open(TESTFN, "w")
32934
 
         try:
32935
 
-            print >>f, "[global]"
32936
 
-            print >>f, "command_packages = foo.bar, splat"
32937
 
+            print >> f, "[global]"
32938
 
+            print >> f, "command_packages = foo.bar, splat"
32939
 
         finally:
32940
 
             f.close()
32941
 
 
32942
 
@@ -138,7 +139,6 @@
32943
 
                             'description': u'Café torréfié',
32944
 
                             'long_description': u'Héhéhé'})
32945
 
 
32946
 
-
32947
 
         # let's make sure the file can be written
32948
 
         # with Unicode fields. they are encoded with
32949
 
         # PKG_INFO_ENCODING
32950
 
@@ -152,33 +152,28 @@
32951
 
                             'long_description': 'Hehehe'})
32952
 
 
32953
 
         my_file2 = os.path.join(tmp_dir, 'f2')
32954
 
-        dist.metadata.write_pkg_file(open(my_file, 'w'))
32955
 
+        dist.metadata.write_pkg_file(open(my_file2, 'w'))
32956
 
 
32957
 
     def test_empty_options(self):
32958
 
         # an empty options dictionary should not stay in the
32959
 
         # list of attributes
32960
 
-        klass = Distribution
32961
 
 
32962
 
         # catching warnings
32963
 
         warns = []
32964
 
+
32965
 
         def _warn(msg):
32966
 
             warns.append(msg)
32967
 
 
32968
 
-        old_warn = warnings.warn
32969
 
+        self.addCleanup(setattr, warnings, 'warn', warnings.warn)
32970
 
         warnings.warn = _warn
32971
 
-        try:
32972
 
-            dist = klass(attrs={'author': 'xxx',
32973
 
-                                'name': 'xxx',
32974
 
-                                'version': 'xxx',
32975
 
-                                'url': 'xxxx',
32976
 
-                                'options': {}})
32977
 
-        finally:
32978
 
-            warnings.warn = old_warn
32979
 
+        dist = Distribution(attrs={'author': 'xxx', 'name': 'xxx',
32980
 
+                                   'version': 'xxx', 'url': 'xxxx',
32981
 
+                                   'options': {}})
32982
 
 
32983
 
         self.assertEqual(len(warns), 0)
32984
 
+        self.assertNotIn('options', dir(dist))
32985
 
 
32986
 
     def test_finalize_options(self):
32987
 
-
32988
 
         attrs = {'keywords': 'one,two',
32989
 
                  'platforms': 'one,two'}
32990
 
 
32991
 
@@ -201,7 +196,6 @@
32992
 
         cmds = dist.get_command_packages()
32993
 
         self.assertEqual(cmds, ['distutils.command', 'one', 'two'])
32994
 
 
32995
 
-
32996
 
     def test_announce(self):
32997
 
         # make sure the level is known
32998
 
         dist = Distribution()
32999
 
@@ -251,15 +245,44 @@
33000
 
         sys.argv[:] = self.argv[1]
33001
 
         super(MetadataTestCase, self).tearDown()
33002
 
 
33003
 
+    def test_classifier(self):
33004
 
+        attrs = {'name': 'Boa', 'version': '3.0',
33005
 
+                 'classifiers': ['Programming Language :: Python :: 3']}
33006
 
+        dist = Distribution(attrs)
33007
 
+        meta = self.format_metadata(dist)
33008
 
+        self.assertIn('Metadata-Version: 1.1', meta)
33009
 
+
33010
 
+    def test_download_url(self):
33011
 
+        attrs = {'name': 'Boa', 'version': '3.0',
33012
 
+                 'download_url': 'http://example.org/boa'}
33013
 
+        dist = Distribution(attrs)
33014
 
+        meta = self.format_metadata(dist)
33015
 
+        self.assertIn('Metadata-Version: 1.1', meta)
33016
 
+
33017
 
+    def test_long_description(self):
33018
 
+        long_desc = textwrap.dedent("""\
33019
 
+        example::
33020
 
+              We start here
33021
 
+            and continue here
33022
 
+          and end here.""")
33023
 
+        attrs = {"name": "package",
33024
 
+                 "version": "1.0",
33025
 
+                 "long_description": long_desc}
33026
 
+
33027
 
+        dist = Distribution(attrs)
33028
 
+        meta = self.format_metadata(dist)
33029
 
+        meta = meta.replace('\n' + 8 * ' ', '\n')
33030
 
+        self.assertIn(long_desc, meta)
33031
 
+
33032
 
     def test_simple_metadata(self):
33033
 
         attrs = {"name": "package",
33034
 
                  "version": "1.0"}
33035
 
         dist = Distribution(attrs)
33036
 
         meta = self.format_metadata(dist)
33037
 
-        self.assertTrue("Metadata-Version: 1.0" in meta)
33038
 
-        self.assertTrue("provides:" not in meta.lower())
33039
 
-        self.assertTrue("requires:" not in meta.lower())
33040
 
-        self.assertTrue("obsoletes:" not in meta.lower())
33041
 
+        self.assertIn("Metadata-Version: 1.0", meta)
33042
 
+        self.assertNotIn("provides:", meta.lower())
33043
 
+        self.assertNotIn("requires:", meta.lower())
33044
 
+        self.assertNotIn("obsoletes:", meta.lower())
33045
 
 
33046
 
     def test_provides(self):
33047
 
         attrs = {"name": "package",
33048
 
@@ -271,9 +294,9 @@
33049
 
         self.assertEqual(dist.get_provides(),
33050
 
                          ["package", "package.sub"])
33051
 
         meta = self.format_metadata(dist)
33052
 
-        self.assertTrue("Metadata-Version: 1.1" in meta)
33053
 
-        self.assertTrue("requires:" not in meta.lower())
33054
 
-        self.assertTrue("obsoletes:" not in meta.lower())
33055
 
+        self.assertIn("Metadata-Version: 1.1", meta)
33056
 
+        self.assertNotIn("requires:", meta.lower())
33057
 
+        self.assertNotIn("obsoletes:", meta.lower())
33058
 
 
33059
 
     def test_provides_illegal(self):
33060
 
         self.assertRaises(ValueError, Distribution,
33061
 
@@ -291,11 +314,11 @@
33062
 
         self.assertEqual(dist.get_requires(),
33063
 
                          ["other", "another (==1.0)"])
33064
 
         meta = self.format_metadata(dist)
33065
 
-        self.assertTrue("Metadata-Version: 1.1" in meta)
33066
 
-        self.assertTrue("provides:" not in meta.lower())
33067
 
-        self.assertTrue("Requires: other" in meta)
33068
 
-        self.assertTrue("Requires: another (==1.0)" in meta)
33069
 
-        self.assertTrue("obsoletes:" not in meta.lower())
33070
 
+        self.assertIn("Metadata-Version: 1.1", meta)
33071
 
+        self.assertNotIn("provides:", meta.lower())
33072
 
+        self.assertIn("Requires: other", meta)
33073
 
+        self.assertIn("Requires: another (==1.0)", meta)
33074
 
+        self.assertNotIn("obsoletes:", meta.lower())
33075
 
 
33076
 
     def test_requires_illegal(self):
33077
 
         self.assertRaises(ValueError, Distribution,
33078
 
@@ -313,11 +336,11 @@
33079
 
         self.assertEqual(dist.get_obsoletes(),
33080
 
                          ["other", "another (<1.0)"])
33081
 
         meta = self.format_metadata(dist)
33082
 
-        self.assertTrue("Metadata-Version: 1.1" in meta)
33083
 
-        self.assertTrue("provides:" not in meta.lower())
33084
 
-        self.assertTrue("requires:" not in meta.lower())
33085
 
-        self.assertTrue("Obsoletes: other" in meta)
33086
 
-        self.assertTrue("Obsoletes: another (<1.0)" in meta)
33087
 
+        self.assertIn("Metadata-Version: 1.1", meta)
33088
 
+        self.assertNotIn("provides:", meta.lower())
33089
 
+        self.assertNotIn("requires:", meta.lower())
33090
 
+        self.assertIn("Obsoletes: other", meta)
33091
 
+        self.assertIn("Obsoletes: another (<1.0)", meta)
33092
 
 
33093
 
     def test_obsoletes_illegal(self):
33094
 
         self.assertRaises(ValueError, Distribution,
33095
 
@@ -353,14 +376,14 @@
33096
 
             if sys.platform in ('linux', 'darwin'):
33097
 
                 os.environ['HOME'] = temp_dir
33098
 
                 files = dist.find_config_files()
33099
 
-                self.assertTrue(user_filename in files)
33100
 
+                self.assertIn(user_filename, files)
33101
 
 
33102
 
             # win32-style
33103
 
             if sys.platform == 'win32':
33104
 
                 # home drive should be found
33105
 
                 os.environ['HOME'] = temp_dir
33106
 
                 files = dist.find_config_files()
33107
 
-                self.assertTrue(user_filename in files,
33108
 
+                self.assertIn(user_filename, files,
33109
 
                              '%r not found in %r' % (user_filename, files))
33110
 
         finally:
33111
 
             os.remove(user_filename)
33112
 
@@ -382,22 +405,7 @@
33113
 
 
33114
 
         output = [line for line in s.getvalue().split('\n')
33115
 
                   if line.strip() != '']
33116
 
-        self.assertTrue(len(output) > 0)
33117
 
-
33118
 
-    def test_long_description(self):
33119
 
-        long_desc = textwrap.dedent("""\
33120
 
-        example::
33121
 
-              We start here
33122
 
-            and continue here
33123
 
-          and end here.""")
33124
 
-        attrs = {"name": "package",
33125
 
-                 "version": "1.0",
33126
 
-                 "long_description": long_desc}
33127
 
-
33128
 
-        dist = distutils.dist.Distribution(attrs)
33129
 
-        meta = self.format_metadata(dist)
33130
 
-        meta = meta.replace('\n' + 8 * ' ', '\n')
33131
 
-        self.assertTrue(long_desc in meta)
33132
 
+        self.assertTrue(output)
33133
 
 
33134
 
     def test_read_metadata(self):
33135
 
         attrs = {"name": "package",
33136
 
@@ -426,6 +434,7 @@
33137
 
         self.assertEqual(metadata.obsoletes, None)
33138
 
         self.assertEqual(metadata.requires, ['foo'])
33139
 
 
33140
 
+
33141
 
 def test_suite():
33142
 
     suite = unittest.TestSuite()
33143
 
     suite.addTest(unittest.makeSuite(DistributionTestCase))
33144
 
diff -r 8527427914a2 Lib/distutils/tests/test_filelist.py
33145
 
--- a/Lib/distutils/tests/test_filelist.py
33146
 
+++ b/Lib/distutils/tests/test_filelist.py
33147
 
@@ -1,10 +1,13 @@
33148
 
 """Tests for distutils.filelist."""
33149
 
-from os.path import join
33150
 
+import re
33151
 
 import unittest
33152
 
+from distutils import debug
33153
 
+from distutils.log import WARN
33154
 
+from distutils.errors import DistutilsTemplateError
33155
 
+from distutils.filelist import glob_to_re, translate_pattern, FileList
33156
 
+
33157
 
 from test.test_support import captured_stdout, run_unittest
33158
 
-
33159
 
-from distutils.filelist import glob_to_re, FileList
33160
 
-from distutils import debug
33161
 
+from distutils.tests import support
33162
 
 
33163
 
 MANIFEST_IN = """\
33164
 
 include ok
33165
 
@@ -20,7 +23,17 @@
33166
 
 prune dir3
33167
 
 """
33168
 
 
33169
 
-class FileListTestCase(unittest.TestCase):
33170
 
+
33171
 
+class FileListTestCase(support.LoggingSilencer,
33172
 
+                       unittest.TestCase):
33173
 
+
33174
 
+    def assertNoWarnings(self):
33175
 
+        self.assertEqual(self.get_logs(WARN), [])
33176
 
+        self.clear_logs()
33177
 
+
33178
 
+    def assertWarnings(self):
33179
 
+        self.assertGreater(len(self.get_logs(WARN)), 0)
33180
 
+        self.clear_logs()
33181
 
 
33182
 
     def test_glob_to_re(self):
33183
 
         # simple cases
33184
 
@@ -40,15 +53,15 @@
33185
 
 
33186
 
         # simulated file list
33187
 
         file_list.allfiles = ['foo.tmp', 'ok', 'xo', 'four.txt',
33188
 
-                              join('global', 'one.txt'),
33189
 
-                              join('global', 'two.txt'),
33190
 
-                              join('global', 'files.x'),
33191
 
-                              join('global', 'here.tmp'),
33192
 
-                              join('f', 'o', 'f.oo'),
33193
 
-                              join('dir', 'graft-one'),
33194
 
-                              join('dir', 'dir2', 'graft2'),
33195
 
-                              join('dir3', 'ok'),
33196
 
-                              join('dir3', 'sub', 'ok.txt')
33197
 
+                              'global/one.txt',
33198
 
+                              'global/two.txt',
33199
 
+                              'global/files.x',
33200
 
+                              'global/here.tmp',
33201
 
+                              'f/o/f.oo',
33202
 
+                              'dir/graft-one',
33203
 
+                              'dir/dir2/graft2',
33204
 
+                              'dir3/ok',
33205
 
+                              'dir3/sub/ok.txt',
33206
 
                               ]
33207
 
 
33208
 
         for line in MANIFEST_IN.split('\n'):
33209
 
@@ -56,9 +69,8 @@
33210
 
                 continue
33211
 
             file_list.process_template_line(line)
33212
 
 
33213
 
-        wanted = ['ok', 'four.txt', join('global', 'one.txt'),
33214
 
-                  join('global', 'two.txt'), join('f', 'o', 'f.oo'),
33215
 
-                  join('dir', 'graft-one'), join('dir', 'dir2', 'graft2')]
33216
 
+        wanted = ['ok', 'four.txt', 'global/one.txt', 'global/two.txt',
33217
 
+                  'f/o/f.oo', 'dir/graft-one', 'dir/dir2/graft2']
33218
 
 
33219
 
         self.assertEqual(file_list.files, wanted)
33220
 
 
33221
 
@@ -66,18 +78,191 @@
33222
 
         file_list = FileList()
33223
 
         with captured_stdout() as stdout:
33224
 
             file_list.debug_print('xxx')
33225
 
-        stdout.seek(0)
33226
 
-        self.assertEqual(stdout.read(), '')
33227
 
+        self.assertEqual(stdout.getvalue(), '')
33228
 
 
33229
 
         debug.DEBUG = True
33230
 
         try:
33231
 
             with captured_stdout() as stdout:
33232
 
                 file_list.debug_print('xxx')
33233
 
-            stdout.seek(0)
33234
 
-            self.assertEqual(stdout.read(), 'xxx\n')
33235
 
+            self.assertEqual(stdout.getvalue(), 'xxx\n')
33236
 
         finally:
33237
 
             debug.DEBUG = False
33238
 
 
33239
 
+    def test_set_allfiles(self):
33240
 
+        file_list = FileList()
33241
 
+        files = ['a', 'b', 'c']
33242
 
+        file_list.set_allfiles(files)
33243
 
+        self.assertEqual(file_list.allfiles, files)
33244
 
+
33245
 
+    def test_remove_duplicates(self):
33246
 
+        file_list = FileList()
33247
 
+        file_list.files = ['a', 'b', 'a', 'g', 'c', 'g']
33248
 
+        # files must be sorted beforehand (sdist does it)
33249
 
+        file_list.sort()
33250
 
+        file_list.remove_duplicates()
33251
 
+        self.assertEqual(file_list.files, ['a', 'b', 'c', 'g'])
33252
 
+
33253
 
+    def test_translate_pattern(self):
33254
 
+        # not regex
33255
 
+        self.assertTrue(hasattr(
33256
 
+            translate_pattern('a', anchor=True, is_regex=False),
33257
 
+            'search'))
33258
 
+
33259
 
+        # is a regex
33260
 
+        regex = re.compile('a')
33261
 
+        self.assertEqual(
33262
 
+            translate_pattern(regex, anchor=True, is_regex=True),
33263
 
+            regex)
33264
 
+
33265
 
+        # plain string flagged as regex
33266
 
+        self.assertTrue(hasattr(
33267
 
+            translate_pattern('a', anchor=True, is_regex=True),
33268
 
+            'search'))
33269
 
+
33270
 
+        # glob support
33271
 
+        self.assertTrue(translate_pattern(
33272
 
+            '*.py', anchor=True, is_regex=False).search('filelist.py'))
33273
 
+
33274
 
+    def test_exclude_pattern(self):
33275
 
+        # return False if no match
33276
 
+        file_list = FileList()
33277
 
+        self.assertFalse(file_list.exclude_pattern('*.py'))
33278
 
+
33279
 
+        # return True if files match
33280
 
+        file_list = FileList()
33281
 
+        file_list.files = ['a.py', 'b.py']
33282
 
+        self.assertTrue(file_list.exclude_pattern('*.py'))
33283
 
+
33284
 
+        # test excludes
33285
 
+        file_list = FileList()
33286
 
+        file_list.files = ['a.py', 'a.txt']
33287
 
+        file_list.exclude_pattern('*.py')
33288
 
+        self.assertEqual(file_list.files, ['a.txt'])
33289
 
+
33290
 
+    def test_include_pattern(self):
33291
 
+        # return False if no match
33292
 
+        file_list = FileList()
33293
 
+        file_list.set_allfiles([])
33294
 
+        self.assertFalse(file_list.include_pattern('*.py'))
33295
 
+
33296
 
+        # return True if files match
33297
 
+        file_list = FileList()
33298
 
+        file_list.set_allfiles(['a.py', 'b.txt'])
33299
 
+        self.assertTrue(file_list.include_pattern('*.py'))
33300
 
+
33301
 
+        # test * matches all files
33302
 
+        file_list = FileList()
33303
 
+        self.assertIsNone(file_list.allfiles)
33304
 
+        file_list.set_allfiles(['a.py', 'b.txt'])
33305
 
+        file_list.include_pattern('*')
33306
 
+        self.assertEqual(file_list.allfiles, ['a.py', 'b.txt'])
33307
 
+
33308
 
+    def test_process_template(self):
33309
 
+        # invalid lines
33310
 
+        file_list = FileList()
33311
 
+        for action in ('include', 'exclude', 'global-include',
33312
 
+                       'global-exclude', 'recursive-include',
33313
 
+                       'recursive-exclude', 'graft', 'prune', 'blarg'):
33314
 
+            self.assertRaises(DistutilsTemplateError,
33315
 
+                              file_list.process_template_line, action)
33316
 
+
33317
 
+        # include
33318
 
+        file_list = FileList()
33319
 
+        file_list.set_allfiles(['a.py', 'b.txt', 'd/c.py'])
33320
 
+
33321
 
+        file_list.process_template_line('include *.py')
33322
 
+        self.assertEqual(file_list.files, ['a.py'])
33323
 
+        self.assertNoWarnings()
33324
 
+
33325
 
+        file_list.process_template_line('include *.rb')
33326
 
+        self.assertEqual(file_list.files, ['a.py'])
33327
 
+        self.assertWarnings()
33328
 
+
33329
 
+        # exclude
33330
 
+        file_list = FileList()
33331
 
+        file_list.files = ['a.py', 'b.txt', 'd/c.py']
33332
 
+
33333
 
+        file_list.process_template_line('exclude *.py')
33334
 
+        self.assertEqual(file_list.files, ['b.txt', 'd/c.py'])
33335
 
+        self.assertNoWarnings()
33336
 
+
33337
 
+        file_list.process_template_line('exclude *.rb')
33338
 
+        self.assertEqual(file_list.files, ['b.txt', 'd/c.py'])
33339
 
+        self.assertWarnings()
33340
 
+
33341
 
+        # global-include
33342
 
+        file_list = FileList()
33343
 
+        file_list.set_allfiles(['a.py', 'b.txt', 'd/c.py'])
33344
 
+
33345
 
+        file_list.process_template_line('global-include *.py')
33346
 
+        self.assertEqual(file_list.files, ['a.py', 'd/c.py'])
33347
 
+        self.assertNoWarnings()
33348
 
+
33349
 
+        file_list.process_template_line('global-include *.rb')
33350
 
+        self.assertEqual(file_list.files, ['a.py', 'd/c.py'])
33351
 
+        self.assertWarnings()
33352
 
+
33353
 
+        # global-exclude
33354
 
+        file_list = FileList()
33355
 
+        file_list.files = ['a.py', 'b.txt', 'd/c.py']
33356
 
+
33357
 
+        file_list.process_template_line('global-exclude *.py')
33358
 
+        self.assertEqual(file_list.files, ['b.txt'])
33359
 
+        self.assertNoWarnings()
33360
 
+
33361
 
+        file_list.process_template_line('global-exclude *.rb')
33362
 
+        self.assertEqual(file_list.files, ['b.txt'])
33363
 
+        self.assertWarnings()
33364
 
+
33365
 
+        # recursive-include
33366
 
+        file_list = FileList()
33367
 
+        file_list.set_allfiles(['a.py', 'd/b.py', 'd/c.txt', 'd/d/e.py'])
33368
 
+
33369
 
+        file_list.process_template_line('recursive-include d *.py')
33370
 
+        self.assertEqual(file_list.files, ['d/b.py', 'd/d/e.py'])
33371
 
+        self.assertNoWarnings()
33372
 
+
33373
 
+        file_list.process_template_line('recursive-include e *.py')
33374
 
+        self.assertEqual(file_list.files, ['d/b.py', 'd/d/e.py'])
33375
 
+        self.assertWarnings()
33376
 
+
33377
 
+        # recursive-exclude
33378
 
+        file_list = FileList()
33379
 
+        file_list.files = ['a.py', 'd/b.py', 'd/c.txt', 'd/d/e.py']
33380
 
+
33381
 
+        file_list.process_template_line('recursive-exclude d *.py')
33382
 
+        self.assertEqual(file_list.files, ['a.py', 'd/c.txt'])
33383
 
+        self.assertNoWarnings()
33384
 
+
33385
 
+        file_list.process_template_line('recursive-exclude e *.py')
33386
 
+        self.assertEqual(file_list.files, ['a.py', 'd/c.txt'])
33387
 
+        self.assertWarnings()
33388
 
+
33389
 
+        # graft
33390
 
+        file_list = FileList()
33391
 
+        file_list.set_allfiles(['a.py', 'd/b.py', 'd/d/e.py', 'f/f.py'])
33392
 
+
33393
 
+        file_list.process_template_line('graft d')
33394
 
+        self.assertEqual(file_list.files, ['d/b.py', 'd/d/e.py'])
33395
 
+        self.assertNoWarnings()
33396
 
+
33397
 
+        file_list.process_template_line('graft e')
33398
 
+        self.assertEqual(file_list.files, ['d/b.py', 'd/d/e.py'])
33399
 
+        self.assertWarnings()
33400
 
+
33401
 
+        # prune
33402
 
+        file_list = FileList()
33403
 
+        file_list.files = ['a.py', 'd/b.py', 'd/d/e.py', 'f/f.py']
33404
 
+
33405
 
+        file_list.process_template_line('prune d')
33406
 
+        self.assertEqual(file_list.files, ['a.py', 'f/f.py'])
33407
 
+        self.assertNoWarnings()
33408
 
+
33409
 
+        file_list.process_template_line('prune e')
33410
 
+        self.assertEqual(file_list.files, ['a.py', 'f/f.py'])
33411
 
+        self.assertWarnings()
33412
 
+
33413
 
+
33414
 
 def test_suite():
33415
 
     return unittest.makeSuite(FileListTestCase)
33416
 
 
33417
 
diff -r 8527427914a2 Lib/distutils/tests/test_install.py
33418
 
--- a/Lib/distutils/tests/test_install.py
33419
 
+++ b/Lib/distutils/tests/test_install.py
33420
 
@@ -1,17 +1,33 @@
33421
 
 """Tests for distutils.command.install."""
33422
 
 
33423
 
 import os
33424
 
+import sys
33425
 
 import unittest
33426
 
+import site
33427
 
 
33428
 
-from test.test_support import run_unittest
33429
 
+from test.test_support import captured_stdout, run_unittest
33430
 
 
33431
 
+from distutils import sysconfig
33432
 
 from distutils.command.install import install
33433
 
+from distutils.command import install as install_module
33434
 
+from distutils.command.build_ext import build_ext
33435
 
+from distutils.command.install import INSTALL_SCHEMES
33436
 
 from distutils.core import Distribution
33437
 
+from distutils.errors import DistutilsOptionError
33438
 
+from distutils.extension import Extension
33439
 
 
33440
 
 from distutils.tests import support
33441
 
 
33442
 
 
33443
 
-class InstallTestCase(support.TempdirManager, unittest.TestCase):
33444
 
+def _make_ext_name(modname):
33445
 
+    if os.name == 'nt' and sys.executable.endswith('_d.exe'):
33446
 
+        modname += '_d'
33447
 
+    return modname + sysconfig.get_config_var('SO')
33448
 
+
33449
 
+
33450
 
+class InstallTestCase(support.TempdirManager,
33451
 
+                      support.LoggingSilencer,
33452
 
+                      unittest.TestCase):
33453
 
 
33454
 
     def test_home_installation_scheme(self):
33455
 
         # This ensure two things:
33456
 
@@ -49,6 +65,181 @@
33457
 
         check_path(cmd.install_scripts, os.path.join(destination, "bin"))
33458
 
         check_path(cmd.install_data, destination)
33459
 
 
33460
 
+    def test_user_site(self):
33461
 
+        # site.USER_SITE was introduced in 2.6
33462
 
+        if sys.version < '2.6':
33463
 
+            return
33464
 
+
33465
 
+        # preparing the environment for the test
33466
 
+        self.old_user_base = site.USER_BASE
33467
 
+        self.old_user_site = site.USER_SITE
33468
 
+        self.tmpdir = self.mkdtemp()
33469
 
+        self.user_base = os.path.join(self.tmpdir, 'B')
33470
 
+        self.user_site = os.path.join(self.tmpdir, 'S')
33471
 
+        site.USER_BASE = self.user_base
33472
 
+        site.USER_SITE = self.user_site
33473
 
+        install_module.USER_BASE = self.user_base
33474
 
+        install_module.USER_SITE = self.user_site
33475
 
+
33476
 
+        def _expanduser(path):
33477
 
+            return self.tmpdir
33478
 
+        self.old_expand = os.path.expanduser
33479
 
+        os.path.expanduser = _expanduser
33480
 
+
33481
 
+        try:
33482
 
+            # this is the actual test
33483
 
+            self._test_user_site()
33484
 
+        finally:
33485
 
+            site.USER_BASE = self.old_user_base
33486
 
+            site.USER_SITE = self.old_user_site
33487
 
+            install_module.USER_BASE = self.old_user_base
33488
 
+            install_module.USER_SITE = self.old_user_site
33489
 
+            os.path.expanduser = self.old_expand
33490
 
+
33491
 
+    def _test_user_site(self):
33492
 
+        for key in ('nt_user', 'unix_user', 'os2_home'):
33493
 
+            self.assertTrue(key in INSTALL_SCHEMES)
33494
 
+
33495
 
+        dist = Distribution({'name': 'xx'})
33496
 
+        cmd = install(dist)
33497
 
+
33498
 
+        # making sure the user option is there
33499
 
+        options = [name for name, short, lable in
33500
 
+                   cmd.user_options]
33501
 
+        self.assertTrue('user' in options)
33502
 
+
33503
 
+        # setting a value
33504
 
+        cmd.user = 1
33505
 
+
33506
 
+        # user base and site shouldn't be created yet
33507
 
+        self.assertTrue(not os.path.exists(self.user_base))
33508
 
+        self.assertTrue(not os.path.exists(self.user_site))
33509
 
+
33510
 
+        # let's run finalize
33511
 
+        cmd.ensure_finalized()
33512
 
+
33513
 
+        # now they should
33514
 
+        self.assertTrue(os.path.exists(self.user_base))
33515
 
+        self.assertTrue(os.path.exists(self.user_site))
33516
 
+
33517
 
+        self.assertTrue('userbase' in cmd.config_vars)
33518
 
+        self.assertTrue('usersite' in cmd.config_vars)
33519
 
+
33520
 
+    def test_handle_extra_path(self):
33521
 
+        dist = Distribution({'name': 'xx', 'extra_path': 'path,dirs'})
33522
 
+        cmd = install(dist)
33523
 
+
33524
 
+        # two elements
33525
 
+        cmd.handle_extra_path()
33526
 
+        self.assertEqual(cmd.extra_path, ['path', 'dirs'])
33527
 
+        self.assertEqual(cmd.extra_dirs, 'dirs')
33528
 
+        self.assertEqual(cmd.path_file, 'path')
33529
 
+
33530
 
+        # one element
33531
 
+        cmd.extra_path = ['path']
33532
 
+        cmd.handle_extra_path()
33533
 
+        self.assertEqual(cmd.extra_path, ['path'])
33534
 
+        self.assertEqual(cmd.extra_dirs, 'path')
33535
 
+        self.assertEqual(cmd.path_file, 'path')
33536
 
+
33537
 
+        # none
33538
 
+        dist.extra_path = cmd.extra_path = None
33539
 
+        cmd.handle_extra_path()
33540
 
+        self.assertEqual(cmd.extra_path, None)
33541
 
+        self.assertEqual(cmd.extra_dirs, '')
33542
 
+        self.assertEqual(cmd.path_file, None)
33543
 
+
33544
 
+        # three elements (no way !)
33545
 
+        cmd.extra_path = 'path,dirs,again'
33546
 
+        self.assertRaises(DistutilsOptionError, cmd.handle_extra_path)
33547
 
+
33548
 
+    def test_finalize_options(self):
33549
 
+        dist = Distribution({'name': 'xx'})
33550
 
+        cmd = install(dist)
33551
 
+
33552
 
+        # must supply either prefix/exec-prefix/home or
33553
 
+        # install-base/install-platbase -- not both
33554
 
+        cmd.prefix = 'prefix'
33555
 
+        cmd.install_base = 'base'
33556
 
+        self.assertRaises(DistutilsOptionError, cmd.finalize_options)
33557
 
+
33558
 
+        # must supply either home or prefix/exec-prefix -- not both
33559
 
+        cmd.install_base = None
33560
 
+        cmd.home = 'home'
33561
 
+        self.assertRaises(DistutilsOptionError, cmd.finalize_options)
33562
 
+
33563
 
+        # can't combine user with with prefix/exec_prefix/home or
33564
 
+        # install_(plat)base
33565
 
+        cmd.prefix = None
33566
 
+        cmd.user = 'user'
33567
 
+        self.assertRaises(DistutilsOptionError, cmd.finalize_options)
33568
 
+
33569
 
+    def test_record(self):
33570
 
+        install_dir = self.mkdtemp()
33571
 
+        project_dir, dist = self.create_dist(scripts=['hello'])
33572
 
+        self.addCleanup(os.chdir, os.getcwd())
33573
 
+        os.chdir(project_dir)
33574
 
+        self.write_file('hello', "print('o hai')")
33575
 
+
33576
 
+        cmd = install(dist)
33577
 
+        dist.command_obj['install'] = cmd
33578
 
+        cmd.root = install_dir
33579
 
+        cmd.record = os.path.join(project_dir, 'RECORD')
33580
 
+        cmd.ensure_finalized()
33581
 
+        cmd.run()
33582
 
+
33583
 
+        f = open(cmd.record)
33584
 
+        try:
33585
 
+            content = f.read()
33586
 
+        finally:
33587
 
+            f.close()
33588
 
+
33589
 
+        found = [os.path.basename(line) for line in content.splitlines()]
33590
 
+        expected = ['hello',
33591
 
+                    'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]]
33592
 
+        self.assertEqual(found, expected)
33593
 
+
33594
 
+    def test_record_extensions(self):
33595
 
+        install_dir = self.mkdtemp()
33596
 
+        project_dir, dist = self.create_dist(ext_modules=[
33597
 
+            Extension('xx', ['xxmodule.c'])])
33598
 
+        self.addCleanup(os.chdir, os.getcwd())
33599
 
+        os.chdir(project_dir)
33600
 
+        support.copy_xxmodule_c(project_dir)
33601
 
+
33602
 
+        buildextcmd = build_ext(dist)
33603
 
+        support.fixup_build_ext(buildextcmd)
33604
 
+        buildextcmd.ensure_finalized()
33605
 
+
33606
 
+        cmd = install(dist)
33607
 
+        dist.command_obj['install'] = cmd
33608
 
+        dist.command_obj['build_ext'] = buildextcmd
33609
 
+        cmd.root = install_dir
33610
 
+        cmd.record = os.path.join(project_dir, 'RECORD')
33611
 
+        cmd.ensure_finalized()
33612
 
+        cmd.run()
33613
 
+
33614
 
+        f = open(cmd.record)
33615
 
+        try:
33616
 
+            content = f.read()
33617
 
+        finally:
33618
 
+            f.close()
33619
 
+
33620
 
+        found = [os.path.basename(line) for line in content.splitlines()]
33621
 
+        expected = [_make_ext_name('xx'),
33622
 
+                    'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]]
33623
 
+        self.assertEqual(found, expected)
33624
 
+
33625
 
+    def test_debug_mode(self):
33626
 
+        # this covers the code called when DEBUG is set
33627
 
+        old_logs_len = len(self.logs)
33628
 
+        install_module.DEBUG = True
33629
 
+        try:
33630
 
+            with captured_stdout():
33631
 
+                self.test_record()
33632
 
+        finally:
33633
 
+            install_module.DEBUG = False
33634
 
+        self.assertTrue(len(self.logs) > old_logs_len)
33635
 
 
33636
 
 def test_suite():
33637
 
     return unittest.makeSuite(InstallTestCase)
33638
 
diff -r 8527427914a2 Lib/distutils/tests/test_msvc9compiler.py
33639
 
--- a/Lib/distutils/tests/test_msvc9compiler.py
33640
 
+++ b/Lib/distutils/tests/test_msvc9compiler.py
33641
 
@@ -7,7 +7,36 @@
33642
 
 from distutils.tests import support
33643
 
 from test.test_support import run_unittest
33644
 
 
33645
 
-_MANIFEST = """\
33646
 
+# A manifest with the only assembly reference being the msvcrt assembly, so
33647
 
+# should have the assembly completely stripped.  Note that although the
33648
 
+# assembly has a <security> reference the assembly is removed - that is
33649
 
+# currently a "feature", not a bug :)
33650
 
+_MANIFEST_WITH_ONLY_MSVC_REFERENCE = """\
33651
 
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
33652
 
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
33653
 
+          manifestVersion="1.0">
33654
 
+  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
33655
 
+    <security>
33656
 
+      <requestedPrivileges>
33657
 
+        <requestedExecutionLevel level="asInvoker" uiAccess="false">
33658
 
+        </requestedExecutionLevel>
33659
 
+      </requestedPrivileges>
33660
 
+    </security>
33661
 
+  </trustInfo>
33662
 
+  <dependency>
33663
 
+    <dependentAssembly>
33664
 
+      <assemblyIdentity type="win32" name="Microsoft.VC90.CRT"
33665
 
+         version="9.0.21022.8" processorArchitecture="x86"
33666
 
+         publicKeyToken="XXXX">
33667
 
+      </assemblyIdentity>
33668
 
+    </dependentAssembly>
33669
 
+  </dependency>
33670
 
+</assembly>
33671
 
+"""
33672
 
+
33673
 
+# A manifest with references to assemblies other than msvcrt.  When processed,
33674
 
+# this assembly should be returned with just the msvcrt part removed.
33675
 
+_MANIFEST_WITH_MULTIPLE_REFERENCES = """\
33676
 
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
33677
 
 <assembly xmlns="urn:schemas-microsoft-com:asm.v1"
33678
 
           manifestVersion="1.0">
33679
 
@@ -115,7 +144,7 @@
33680
 
         manifest = os.path.join(tempdir, 'manifest')
33681
 
         f = open(manifest, 'w')
33682
 
         try:
33683
 
-            f.write(_MANIFEST)
33684
 
+            f.write(_MANIFEST_WITH_MULTIPLE_REFERENCES)
33685
 
         finally:
33686
 
             f.close()
33687
 
 
33688
 
@@ -133,6 +162,20 @@
33689
 
         # makes sure the manifest was properly cleaned
33690
 
         self.assertEqual(content, _CLEANED_MANIFEST)
33691
 
 
33692
 
+    def test_remove_entire_manifest(self):
33693
 
+        from distutils.msvc9compiler import MSVCCompiler
33694
 
+        tempdir = self.mkdtemp()
33695
 
+        manifest = os.path.join(tempdir, 'manifest')
33696
 
+        f = open(manifest, 'w')
33697
 
+        try:
33698
 
+            f.write(_MANIFEST_WITH_ONLY_MSVC_REFERENCE)
33699
 
+        finally:
33700
 
+            f.close()
33701
 
+
33702
 
+        compiler = MSVCCompiler()
33703
 
+        got = compiler._remove_visual_c_ref(manifest)
33704
 
+        self.assertIs(got, None)
33705
 
+
33706
 
 
33707
 
 def test_suite():
33708
 
     return unittest.makeSuite(msvc9compilerTestCase)
33709
 
diff -r 8527427914a2 Lib/distutils/tests/test_register.py
33710
 
--- a/Lib/distutils/tests/test_register.py
33711
 
+++ b/Lib/distutils/tests/test_register.py
33712
 
@@ -1,5 +1,5 @@
33713
 
+# -*- encoding: utf8 -*-
33714
 
 """Tests for distutils.command.register."""
33715
 
-# -*- encoding: utf8 -*-
33716
 
 import sys
33717
 
 import os
33718
 
 import unittest
33719
 
@@ -246,6 +246,24 @@
33720
 
         finally:
33721
 
             del register_module.raw_input
33722
 
 
33723
 
+        # and finally a Unicode test (bug #12114)
33724
 
+        metadata = {'url': u'xxx', 'author': u'\u00c9ric',
33725
 
+                    'author_email': u'xxx', u'name': 'xxx',
33726
 
+                    'version': u'xxx',
33727
 
+                    'description': u'Something about esszet \u00df',
33728
 
+                    'long_description': u'More things about esszet \u00df'}
33729
 
+
33730
 
+        cmd = self._get_cmd(metadata)
33731
 
+        cmd.ensure_finalized()
33732
 
+        cmd.strict = 1
33733
 
+        inputs = RawInputs('1', 'tarek', 'y')
33734
 
+        register_module.raw_input = inputs.__call__
33735
 
+        # let's run the command
33736
 
+        try:
33737
 
+            cmd.run()
33738
 
+        finally:
33739
 
+            del register_module.raw_input
33740
 
+
33741
 
     def test_check_metadata_deprecated(self):
33742
 
         # makes sure make_metadata is deprecated
33743
 
         cmd = self._get_cmd()
33744
 
diff -r 8527427914a2 Lib/distutils/tests/test_sdist.py
33745
 
--- a/Lib/distutils/tests/test_sdist.py
33746
 
+++ b/Lib/distutils/tests/test_sdist.py
33747
 
@@ -1,9 +1,11 @@
33748
 
 """Tests for distutils.command.sdist."""
33749
 
 import os
33750
 
+import tarfile
33751
 
 import unittest
33752
 
-import shutil
33753
 
+import warnings
33754
 
 import zipfile
33755
 
-import tarfile
33756
 
+from os.path import join
33757
 
+from textwrap import dedent
33758
 
 
33759
 
 # zlib is not used here, but if it's not available
33760
 
 # the tests that use zipfile may fail
33761
 
@@ -19,20 +21,15 @@
33762
 
 except ImportError:
33763
 
     UID_GID_SUPPORT = False
33764
 
 
33765
 
-from os.path import join
33766
 
-import sys
33767
 
-import tempfile
33768
 
-import warnings
33769
 
-
33770
 
 from test.test_support import captured_stdout, check_warnings, run_unittest
33771
 
 
33772
 
 from distutils.command.sdist import sdist, show_formats
33773
 
 from distutils.core import Distribution
33774
 
 from distutils.tests.test_config import PyPIRCCommandTestCase
33775
 
-from distutils.errors import DistutilsExecError, DistutilsOptionError
33776
 
+from distutils.errors import DistutilsOptionError
33777
 
 from distutils.spawn import find_executable
33778
 
-from distutils.tests import support
33779
 
 from distutils.log import WARN
33780
 
+from distutils.filelist import FileList
33781
 
 from distutils.archive_util import ARCHIVE_FORMATS
33782
 
 
33783
 
 SETUP_PY = """
33784
 
@@ -89,9 +86,6 @@
33785
 
         dist.include_package_data = True
33786
 
         cmd = sdist(dist)
33787
 
         cmd.dist_dir = 'dist'
33788
 
-        def _warn(*args):
33789
 
-            pass
33790
 
-        cmd.warn = _warn
33791
 
         return dist, cmd
33792
 
 
33793
 
     @unittest.skipUnless(zlib, "requires zlib")
33794
 
@@ -172,6 +166,28 @@
33795
 
         self.assertEqual(result, ['fake-1.0.tar', 'fake-1.0.tar.gz'])
33796
 
 
33797
 
     @unittest.skipUnless(zlib, "requires zlib")
33798
 
+    def test_unicode_metadata_tgz(self):
33799
 
+        """
33800
 
+        Unicode name or version should not break building to tar.gz format.
33801
 
+        Reference issue #11638.
33802
 
+        """
33803
 
+
33804
 
+        # create the sdist command with unicode parameters
33805
 
+        dist, cmd = self.get_cmd({'name': u'fake', 'version': u'1.0'})
33806
 
+
33807
 
+        # create the sdist as gztar and run the command
33808
 
+        cmd.formats = ['gztar']
33809
 
+        cmd.ensure_finalized()
33810
 
+        cmd.run()
33811
 
+
33812
 
+        # The command should have created the .tar.gz file
33813
 
+        dist_folder = join(self.tmp_dir, 'dist')
33814
 
+        result = os.listdir(dist_folder)
33815
 
+        self.assertEqual(result, ['fake-1.0.tar.gz'])
33816
 
+
33817
 
+        os.remove(join(dist_folder, 'fake-1.0.tar.gz'))
33818
 
+
33819
 
+    @unittest.skipUnless(zlib, "requires zlib")
33820
 
     def test_add_defaults(self):
33821
 
 
33822
 
         # http://bugs.python.org/issue2279
33823
 
@@ -246,7 +262,8 @@
33824
 
         # with the `check` subcommand
33825
 
         cmd.ensure_finalized()
33826
 
         cmd.run()
33827
 
-        warnings = self.get_logs(WARN)
33828
 
+        warnings = [msg for msg in self.get_logs(WARN) if
33829
 
+                    msg.startswith('warning: check:')]
33830
 
         self.assertEqual(len(warnings), 2)
33831
 
 
33832
 
         # trying with a complete set of metadata
33833
 
@@ -255,7 +272,8 @@
33834
 
         cmd.ensure_finalized()
33835
 
         cmd.metadata_check = 0
33836
 
         cmd.run()
33837
 
-        warnings = self.get_logs(WARN)
33838
 
+        warnings = [msg for msg in self.get_logs(WARN) if
33839
 
+                    msg.startswith('warning: check:')]
33840
 
         self.assertEqual(len(warnings), 0)
33841
 
 
33842
 
     def test_check_metadata_deprecated(self):
33843
 
@@ -277,7 +295,6 @@
33844
 
         self.assertEqual(len(output), num_formats)
33845
 
 
33846
 
     def test_finalize_options(self):
33847
 
-
33848
 
         dist, cmd = self.get_cmd()
33849
 
         cmd.finalize_options()
33850
 
 
33851
 
@@ -347,6 +364,32 @@
33852
 
         finally:
33853
 
             archive.close()
33854
 
 
33855
 
+    # the following tests make sure there is a nice error message instead
33856
 
+    # of a traceback when parsing an invalid manifest template
33857
 
+
33858
 
+    def _test_template(self, content):
33859
 
+        dist, cmd = self.get_cmd()
33860
 
+        os.chdir(self.tmp_dir)
33861
 
+        self.write_file('MANIFEST.in', content)
33862
 
+        cmd.ensure_finalized()
33863
 
+        cmd.filelist = FileList()
33864
 
+        cmd.read_template()
33865
 
+        warnings = self.get_logs(WARN)
33866
 
+        self.assertEqual(len(warnings), 1)
33867
 
+
33868
 
+    def test_invalid_template_unknown_command(self):
33869
 
+        self._test_template('taunt knights *')
33870
 
+
33871
 
+    def test_invalid_template_wrong_arguments(self):
33872
 
+        # this manifest command takes one argument
33873
 
+        self._test_template('prune')
33874
 
+
33875
 
+    @unittest.skipIf(os.name != 'nt', 'test relevant for Windows only')
33876
 
+    def test_invalid_template_wrong_path(self):
33877
 
+        # on Windows, trailing slashes are not allowed
33878
 
+        # this used to crash instead of raising a warning: #8286
33879
 
+        self._test_template('include examples/')
33880
 
+
33881
 
     @unittest.skipUnless(zlib, "requires zlib")
33882
 
     def test_get_file_list(self):
33883
 
         # make sure MANIFEST is recalculated
33884
 
@@ -355,6 +398,7 @@
33885
 
         # filling data_files by pointing files in package_data
33886
 
         dist.package_data = {'somecode': ['*.txt']}
33887
 
         self.write_file((self.tmp_dir, 'somecode', 'doc.txt'), '#')
33888
 
+        cmd.formats = ['gztar']
33889
 
         cmd.ensure_finalized()
33890
 
         cmd.run()
33891
 
 
33892
 
@@ -405,13 +449,34 @@
33893
 
         self.assertEqual(manifest[0],
33894
 
                          '# file GENERATED by distutils, do NOT edit')
33895
 
 
33896
 
+    @unittest.skipUnless(zlib, 'requires zlib')
33897
 
+    def test_manifest_comments(self):
33898
 
+        # make sure comments don't cause exceptions or wrong includes
33899
 
+        contents = dedent("""\
33900
 
+            # bad.py
33901
 
+            #bad.py
33902
 
+            good.py
33903
 
+            """)
33904
 
+        dist, cmd = self.get_cmd()
33905
 
+        cmd.ensure_finalized()
33906
 
+        self.write_file((self.tmp_dir, cmd.manifest), contents)
33907
 
+        self.write_file((self.tmp_dir, 'good.py'), '# pick me!')
33908
 
+        self.write_file((self.tmp_dir, 'bad.py'), "# don't pick me!")
33909
 
+        self.write_file((self.tmp_dir, '#bad.py'), "# don't pick me!")
33910
 
+        cmd.run()
33911
 
+        self.assertEqual(cmd.filelist.files, ['good.py'])
33912
 
+
33913
 
     @unittest.skipUnless(zlib, "requires zlib")
33914
 
     def test_manual_manifest(self):
33915
 
         # check that a MANIFEST without a marker is left alone
33916
 
         dist, cmd = self.get_cmd()
33917
 
+        cmd.formats = ['gztar']
33918
 
         cmd.ensure_finalized()
33919
 
         self.write_file((self.tmp_dir, cmd.manifest), 'README.manual')
33920
 
+        self.write_file((self.tmp_dir, 'README.manual'),
33921
 
+                         'This project maintains its MANIFEST file itself.')
33922
 
         cmd.run()
33923
 
+        self.assertEqual(cmd.filelist.files, ['README.manual'])
33924
 
 
33925
 
         f = open(cmd.manifest)
33926
 
         try:
33927
 
@@ -422,6 +487,15 @@
33928
 
 
33929
 
         self.assertEqual(manifest, ['README.manual'])
33930
 
 
33931
 
+        archive_name = join(self.tmp_dir, 'dist', 'fake-1.0.tar.gz')
33932
 
+        archive = tarfile.open(archive_name)
33933
 
+        try:
33934
 
+            filenames = [tarinfo.name for tarinfo in archive]
33935
 
+        finally:
33936
 
+            archive.close()
33937
 
+        self.assertEqual(sorted(filenames), ['fake-1.0', 'fake-1.0/PKG-INFO',
33938
 
+                                             'fake-1.0/README.manual'])
33939
 
+
33940
 
 def test_suite():
33941
 
     return unittest.makeSuite(SDistTestCase)
33942
 
 
33943
 
diff -r 8527427914a2 Lib/distutils/util.py
33944
 
--- a/Lib/distutils/util.py
33945
 
+++ b/Lib/distutils/util.py
33946
 
@@ -76,6 +76,11 @@
33947
 
         if release[0] >= "5":           # SunOS 5 == Solaris 2
33948
 
             osname = "solaris"
33949
 
             release = "%d.%s" % (int(release[0]) - 3, release[2:])
33950
 
+            # We can't use "platform.architecture()[0]" because a
33951
 
+            # bootstrap problem. We use a dict to get an error
33952
 
+            # if some suspicious happens.
33953
 
+            bitness = {2147483647:"32bit", 9223372036854775807:"64bit"}
33954
 
+            machine += ".%s" % bitness[sys.maxint]
33955
 
         # fall through to standard osname-release-machine representation
33956
 
     elif osname[:4] == "irix":              # could be "irix64"!
33957
 
         return "%s-%s" % (osname, release)
33958
 
diff -r 8527427914a2 Lib/doctest.py
33959
 
--- a/Lib/doctest.py
33960
 
+++ b/Lib/doctest.py
33961
 
@@ -451,6 +451,25 @@
33962
 
         self.options = options
33963
 
         self.exc_msg = exc_msg
33964
 
 
33965
 
+    def __eq__(self, other):
33966
 
+        if type(self) is not type(other):
33967
 
+            return NotImplemented
33968
 
+
33969
 
+        return self.source == other.source and \
33970
 
+               self.want == other.want and \
33971
 
+               self.lineno == other.lineno and \
33972
 
+               self.indent == other.indent and \
33973
 
+               self.options == other.options and \
33974
 
+               self.exc_msg == other.exc_msg
33975
 
+
33976
 
+    def __ne__(self, other):
33977
 
+        return not self == other
33978
 
+
33979
 
+    def __hash__(self):
33980
 
+        return hash((self.source, self.want, self.lineno, self.indent,
33981
 
+                     self.exc_msg))
33982
 
+
33983
 
+
33984
 
 class DocTest:
33985
 
     """
33986
 
     A collection of doctest examples that should be run in a single
33987
 
@@ -499,6 +518,22 @@
33988
 
         return ('<DocTest %s from %s:%s (%s)>' %
33989
 
                 (self.name, self.filename, self.lineno, examples))
33990
 
 
33991
 
+    def __eq__(self, other):
33992
 
+        if type(self) is not type(other):
33993
 
+            return NotImplemented
33994
 
+
33995
 
+        return self.examples == other.examples and \
33996
 
+               self.docstring == other.docstring and \
33997
 
+               self.globs == other.globs and \
33998
 
+               self.name == other.name and \
33999
 
+               self.filename == other.filename and \
34000
 
+               self.lineno == other.lineno
34001
 
+
34002
 
+    def __ne__(self, other):
34003
 
+        return not self == other
34004
 
+
34005
 
+    def __hash__(self):
34006
 
+        return hash((self.docstring, self.name, self.filename, self.lineno))
34007
 
 
34008
 
     # This lets us sort tests by name:
34009
 
     def __cmp__(self, other):
34010
 
@@ -2252,6 +2287,23 @@
34011
 
     def id(self):
34012
 
         return self._dt_test.name
34013
 
 
34014
 
+    def __eq__(self, other):
34015
 
+        if type(self) is not type(other):
34016
 
+            return NotImplemented
34017
 
+
34018
 
+        return self._dt_test == other._dt_test and \
34019
 
+               self._dt_optionflags == other._dt_optionflags and \
34020
 
+               self._dt_setUp == other._dt_setUp and \
34021
 
+               self._dt_tearDown == other._dt_tearDown and \
34022
 
+               self._dt_checker == other._dt_checker
34023
 
+
34024
 
+    def __ne__(self, other):
34025
 
+        return not self == other
34026
 
+
34027
 
+    def __hash__(self):
34028
 
+        return hash((self._dt_optionflags, self._dt_setUp, self._dt_tearDown,
34029
 
+                     self._dt_checker))
34030
 
+
34031
 
     def __repr__(self):
34032
 
         name = self._dt_test.name.split('.')
34033
 
         return "%s (%s)" % (name[-1], '.'.join(name[:-1]))
34034
 
diff -r 8527427914a2 Lib/filecmp.py
34035
 
--- a/Lib/filecmp.py
34036
 
+++ b/Lib/filecmp.py
34037
 
@@ -48,11 +48,12 @@
34038
 
     if s1[1] != s2[1]:
34039
 
         return False
34040
 
 
34041
 
-    result = _cache.get((f1, f2))
34042
 
-    if result and (s1, s2) == result[:2]:
34043
 
-        return result[2]
34044
 
-    outcome = _do_cmp(f1, f2)
34045
 
-    _cache[f1, f2] = s1, s2, outcome
34046
 
+    outcome = _cache.get((f1, f2, s1, s2))
34047
 
+    if outcome is None:
34048
 
+        outcome = _do_cmp(f1, f2)
34049
 
+        if len(_cache) > 100:      # limit the maximum size of the cache
34050
 
+            _cache.clear()
34051
 
+        _cache[f1, f2, s1, s2] = outcome
34052
 
     return outcome
34053
 
 
34054
 
 def _sig(st):
34055
 
diff -r 8527427914a2 Lib/ftplib.py
34056
 
--- a/Lib/ftplib.py
34057
 
+++ b/Lib/ftplib.py
34058
 
@@ -325,32 +325,39 @@
34059
 
         if self.passiveserver:
34060
 
             host, port = self.makepasv()
34061
 
             conn = socket.create_connection((host, port), self.timeout)
34062
 
-            if rest is not None:
34063
 
-                self.sendcmd("REST %s" % rest)
34064
 
-            resp = self.sendcmd(cmd)
34065
 
-            # Some servers apparently send a 200 reply to
34066
 
-            # a LIST or STOR command, before the 150 reply
34067
 
-            # (and way before the 226 reply). This seems to
34068
 
-            # be in violation of the protocol (which only allows
34069
 
-            # 1xx or error messages for LIST), so we just discard
34070
 
-            # this response.
34071
 
-            if resp[0] == '2':
34072
 
-                resp = self.getresp()
34073
 
-            if resp[0] != '1':
34074
 
-                raise error_reply, resp
34075
 
+            try:
34076
 
+                if rest is not None:
34077
 
+                    self.sendcmd("REST %s" % rest)
34078
 
+                resp = self.sendcmd(cmd)
34079
 
+                # Some servers apparently send a 200 reply to
34080
 
+                # a LIST or STOR command, before the 150 reply
34081
 
+                # (and way before the 226 reply). This seems to
34082
 
+                # be in violation of the protocol (which only allows
34083
 
+                # 1xx or error messages for LIST), so we just discard
34084
 
+                # this response.
34085
 
+                if resp[0] == '2':
34086
 
+                    resp = self.getresp()
34087
 
+                if resp[0] != '1':
34088
 
+                    raise error_reply, resp
34089
 
+            except:
34090
 
+                conn.close()
34091
 
+                raise
34092
 
         else:
34093
 
             sock = self.makeport()
34094
 
-            if rest is not None:
34095
 
-                self.sendcmd("REST %s" % rest)
34096
 
-            resp = self.sendcmd(cmd)
34097
 
-            # See above.
34098
 
-            if resp[0] == '2':
34099
 
-                resp = self.getresp()
34100
 
-            if resp[0] != '1':
34101
 
-                raise error_reply, resp
34102
 
-            conn, sockaddr = sock.accept()
34103
 
-            if self.timeout is not _GLOBAL_DEFAULT_TIMEOUT:
34104
 
-                conn.settimeout(self.timeout)
34105
 
+            try:
34106
 
+                if rest is not None:
34107
 
+                    self.sendcmd("REST %s" % rest)
34108
 
+                resp = self.sendcmd(cmd)
34109
 
+                # See above.
34110
 
+                if resp[0] == '2':
34111
 
+                    resp = self.getresp()
34112
 
+                if resp[0] != '1':
34113
 
+                    raise error_reply, resp
34114
 
+                conn, sockaddr = sock.accept()
34115
 
+                if self.timeout is not _GLOBAL_DEFAULT_TIMEOUT:
34116
 
+                    conn.settimeout(self.timeout)
34117
 
+            finally:
34118
 
+                sock.close()
34119
 
         if resp[:3] == '150':
34120
 
             # this is conditional in case we received a 125
34121
 
             size = parse150(resp)
34122
 
@@ -575,11 +582,11 @@
34123
 
 
34124
 
     def close(self):
34125
 
         '''Close the connection without assuming anything about it.'''
34126
 
-        if self.file:
34127
 
+        if self.file is not None:
34128
 
             self.file.close()
34129
 
+        if self.sock is not None:
34130
 
             self.sock.close()
34131
 
-            self.file = self.sock = None
34132
 
-
34133
 
+        self.file = self.sock = None
34134
 
 
34135
 
 try:
34136
 
     import ssl
34137
 
diff -r 8527427914a2 Lib/gzip.py
34138
 
--- a/Lib/gzip.py
34139
 
+++ b/Lib/gzip.py
34140
 
@@ -88,8 +88,12 @@
34141
 
         if fileobj is None:
34142
 
             fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb')
34143
 
         if filename is None:
34144
 
-            if hasattr(fileobj, 'name'): filename = fileobj.name
34145
 
-            else: filename = ''
34146
 
+            # Issue #13781: os.fdopen() creates a fileobj with a bogus name
34147
 
+            # attribute. Avoid saving this in the gzip header's filename field.
34148
 
+            if hasattr(fileobj, 'name') and fileobj.name != '<fdopen>':
34149
 
+                filename = fileobj.name
34150
 
+            else:
34151
 
+                filename = ''
34152
 
         if mode is None:
34153
 
             if hasattr(fileobj, 'mode'): mode = fileobj.mode
34154
 
             else: mode = 'rb'
34155
 
diff -r 8527427914a2 Lib/heapq.py
34156
 
--- a/Lib/heapq.py
34157
 
+++ b/Lib/heapq.py
34158
 
@@ -193,6 +193,8 @@
34159
 
 
34160
 
     Equivalent to:  sorted(iterable, reverse=True)[:n]
34161
 
     """
34162
 
+    if n < 0:
34163
 
+        return []
34164
 
     it = iter(iterable)
34165
 
     result = list(islice(it, n))
34166
 
     if not result:
34167
 
@@ -209,6 +211,8 @@
34168
 
 
34169
 
     Equivalent to:  sorted(iterable)[:n]
34170
 
     """
34171
 
+    if n < 0:
34172
 
+        return []
34173
 
     if hasattr(iterable, '__len__') and n * 10 <= len(iterable):
34174
 
         # For smaller values of n, the bisect method is faster than a minheap.
34175
 
         # It is also memory efficient, consuming only n elements of space.
34176
 
diff -r 8527427914a2 Lib/httplib.py
34177
 
--- a/Lib/httplib.py
34178
 
+++ b/Lib/httplib.py
34179
 
@@ -715,7 +715,10 @@
34180
 
                 try:
34181
 
                     port = int(host[i+1:])
34182
 
                 except ValueError:
34183
 
-                    raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
34184
 
+                    if host[i+1:] == "":  # http://foo.com:/ == http://foo.com/
34185
 
+                        port = self.default_port
34186
 
+                    else:
34187
 
+                        raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
34188
 
                 host = host[:i]
34189
 
             else:
34190
 
                 port = self.default_port
34191
 
@@ -939,10 +942,10 @@
34192
 
         """Indicate that the last header line has been sent to the server.
34193
 
 
34194
 
         This method sends the request to the server.  The optional
34195
 
-        message_body argument can be used to pass message body
34196
 
+        message_body argument can be used to pass a message body
34197
 
         associated with the request.  The message body will be sent in
34198
 
-        the same packet as the message headers if possible.  The
34199
 
-        message_body should be a string.
34200
 
+        the same packet as the message headers if it is string, otherwise it is
34201
 
+        sent as a separate packet.
34202
 
         """
34203
 
         if self.__state == _CS_REQ_STARTED:
34204
 
             self.__state = _CS_REQ_SENT
34205
 
@@ -1322,71 +1325,3 @@
34206
 
             return L + self._file.readlines()
34207
 
         else:
34208
 
             return L + self._file.readlines(size)
34209
 
-
34210
 
-def test():
34211
 
-    """Test this module.
34212
 
-
34213
 
-    A hodge podge of tests collected here, because they have too many
34214
 
-    external dependencies for the regular test suite.
34215
 
-    """
34216
 
-
34217
 
-    import sys
34218
 
-    import getopt
34219
 
-    opts, args = getopt.getopt(sys.argv[1:], 'd')
34220
 
-    dl = 0
34221
 
-    for o, a in opts:
34222
 
-        if o == '-d': dl = dl + 1
34223
 
-    host = 'www.python.org'
34224
 
-    selector = '/'
34225
 
-    if args[0:]: host = args[0]
34226
 
-    if args[1:]: selector = args[1]
34227
 
-    h = HTTP()
34228
 
-    h.set_debuglevel(dl)
34229
 
-    h.connect(host)
34230
 
-    h.putrequest('GET', selector)
34231
 
-    h.endheaders()
34232
 
-    status, reason, headers = h.getreply()
34233
 
-    print 'status =', status
34234
 
-    print 'reason =', reason
34235
 
-    print "read", len(h.getfile().read())
34236
 
-    print
34237
 
-    if headers:
34238
 
-        for header in headers.headers: print header.strip()
34239
 
-    print
34240
 
-
34241
 
-    # minimal test that code to extract host from url works
34242
 
-    class HTTP11(HTTP):
34243
 
-        _http_vsn = 11
34244
 
-        _http_vsn_str = 'HTTP/1.1'
34245
 
-
34246
 
-    h = HTTP11('www.python.org')
34247
 
-    h.putrequest('GET', 'http://www.python.org/~jeremy/')
34248
 
-    h.endheaders()
34249
 
-    h.getreply()
34250
 
-    h.close()
34251
 
-
34252
 
-    try:
34253
 
-        import ssl
34254
 
-    except ImportError:
34255
 
-        pass
34256
 
-    else:
34257
 
-
34258
 
-        for host, selector in (('sourceforge.net', '/projects/python'),
34259
 
-                               ):
34260
 
-            print "https://%s%s" % (host, selector)
34261
 
-            hs = HTTPS()
34262
 
-            hs.set_debuglevel(dl)
34263
 
-            hs.connect(host)
34264
 
-            hs.putrequest('GET', selector)
34265
 
-            hs.endheaders()
34266
 
-            status, reason, headers = hs.getreply()
34267
 
-            print 'status =', status
34268
 
-            print 'reason =', reason
34269
 
-            print "read", len(hs.getfile().read())
34270
 
-            print
34271
 
-            if headers:
34272
 
-                for header in headers.headers: print header.strip()
34273
 
-            print
34274
 
-
34275
 
-if __name__ == '__main__':
34276
 
-    test()
34277
 
diff -r 8527427914a2 Lib/idlelib/AutoComplete.py
34278
 
--- a/Lib/idlelib/AutoComplete.py
34279
 
+++ b/Lib/idlelib/AutoComplete.py
34280
 
@@ -190,8 +190,7 @@
34281
 
                     bigl = eval("dir()", namespace)
34282
 
                     bigl.sort()
34283
 
                     if "__all__" in bigl:
34284
 
-                        smalll = eval("__all__", namespace)
34285
 
-                        smalll.sort()
34286
 
+                        smalll = sorted(eval("__all__", namespace))
34287
 
                     else:
34288
 
                         smalll = [s for s in bigl if s[:1] != '_']
34289
 
                 else:
34290
 
@@ -200,8 +199,7 @@
34291
 
                         bigl = dir(entity)
34292
 
                         bigl.sort()
34293
 
                         if "__all__" in bigl:
34294
 
-                            smalll = entity.__all__
34295
 
-                            smalll.sort()
34296
 
+                            smalll = sorted(entity.__all__)
34297
 
                         else:
34298
 
                             smalll = [s for s in bigl if s[:1] != '_']
34299
 
                     except:
34300
 
diff -r 8527427914a2 Lib/idlelib/EditorWindow.py
34301
 
--- a/Lib/idlelib/EditorWindow.py
34302
 
+++ b/Lib/idlelib/EditorWindow.py
34303
 
@@ -65,6 +65,50 @@
34304
 
             descr = filename, None, imp.PY_SOURCE
34305
 
     return file, filename, descr
34306
 
 
34307
 
+
34308
 
+class HelpDialog(object):
34309
 
+
34310
 
+    def __init__(self):
34311
 
+        self.parent = None      # parent of help window
34312
 
+        self.dlg = None         # the help window iteself
34313
 
+
34314
 
+    def display(self, parent, near=None):
34315
 
+        """ Display the help dialog.
34316
 
+
34317
 
+            parent - parent widget for the help window
34318
 
+
34319
 
+            near - a Toplevel widget (e.g. EditorWindow or PyShell)
34320
 
+                   to use as a reference for placing the help window
34321
 
+        """
34322
 
+        if self.dlg is None:
34323
 
+            self.show_dialog(parent)
34324
 
+        if near:
34325
 
+            self.nearwindow(near)
34326
 
+
34327
 
+    def show_dialog(self, parent):
34328
 
+        self.parent = parent
34329
 
+        fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'help.txt')
34330
 
+        self.dlg = dlg = textView.view_file(parent,'Help',fn, modal=False)
34331
 
+        dlg.bind('<Destroy>', self.destroy, '+')
34332
 
+
34333
 
+    def nearwindow(self, near):
34334
 
+        # Place the help dialog near the window specified by parent.
34335
 
+        # Note - this may not reposition the window in Metacity
34336
 
+        #  if "/apps/metacity/general/disable_workarounds" is enabled
34337
 
+        dlg = self.dlg
34338
 
+        geom = (near.winfo_rootx() + 10, near.winfo_rooty() + 10)
34339
 
+        dlg.withdraw()
34340
 
+        dlg.geometry("=+%d+%d" % geom)
34341
 
+        dlg.deiconify()
34342
 
+        dlg.lift()
34343
 
+
34344
 
+    def destroy(self, ev=None):
34345
 
+        self.dlg = None
34346
 
+        self.parent = None
34347
 
+
34348
 
+helpDialog = HelpDialog()  # singleton instance
34349
 
+
34350
 
+
34351
 
 class EditorWindow(object):
34352
 
     from idlelib.Percolator import Percolator
34353
 
     from idlelib.ColorDelegator import ColorDelegator
34354
 
@@ -459,8 +503,11 @@
34355
 
         configDialog.ConfigDialog(self.top,'Settings')
34356
 
 
34357
 
     def help_dialog(self, event=None):
34358
 
-        fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'help.txt')
34359
 
-        textView.view_file(self.top,'Help',fn)
34360
 
+        if self.root:
34361
 
+            parent = self.root
34362
 
+        else:
34363
 
+            parent = self.top
34364
 
+        helpDialog.display(parent, near=self.top)
34365
 
 
34366
 
     def python_docs(self, event=None):
34367
 
         if sys.platform[:3] == 'win':
34368
 
@@ -796,11 +843,16 @@
34369
 
         rf_list = [path for path in rf_list if path not in bad_paths]
34370
 
         ulchars = "1234567890ABCDEFGHIJK"
34371
 
         rf_list = rf_list[0:len(ulchars)]
34372
 
-        rf_file = open(self.recent_files_path, 'w')
34373
 
         try:
34374
 
-            rf_file.writelines(rf_list)
34375
 
-        finally:
34376
 
-            rf_file.close()
34377
 
+            with open(self.recent_files_path, 'w') as rf_file:
34378
 
+                rf_file.writelines(rf_list)
34379
 
+        except IOError as err:
34380
 
+            if not getattr(self.root, "recentfilelist_error_displayed", False):
34381
 
+                self.root.recentfilelist_error_displayed = True
34382
 
+                tkMessageBox.showerror(title='IDLE Error',
34383
 
+                    message='Unable to update Recent Files list:\n%s'
34384
 
+                        % str(err),
34385
 
+                    parent=self.text)
34386
 
         # for each edit window instance, construct the recent files menu
34387
 
         for instance in self.top.instance_dict.keys():
34388
 
             menu = instance.recent_files_menu
34389
 
@@ -1130,7 +1182,10 @@
34390
 
         assert have > 0
34391
 
         want = ((have - 1) // self.indentwidth) * self.indentwidth
34392
 
         # Debug prompt is multilined....
34393
 
-        last_line_of_prompt = sys.ps1.split('\n')[-1]
34394
 
+        if self.context_use_ps1:
34395
 
+            last_line_of_prompt = sys.ps1.split('\n')[-1]
34396
 
+        else:
34397
 
+            last_line_of_prompt = ''
34398
 
         ncharsdeleted = 0
34399
 
         while 1:
34400
 
             if chars == last_line_of_prompt:
34401
 
diff -r 8527427914a2 Lib/idlelib/IOBinding.py
34402
 
--- a/Lib/idlelib/IOBinding.py
34403
 
+++ b/Lib/idlelib/IOBinding.py
34404
 
@@ -266,7 +266,7 @@
34405
 
         self.reset_undo()
34406
 
         self.set_filename(filename)
34407
 
         self.text.mark_set("insert", "1.0")
34408
 
-        self.text.see("insert")
34409
 
+        self.text.yview("insert")
34410
 
         self.updaterecentfileslist(filename)
34411
 
         return True
34412
 
 
34413
 
diff -r 8527427914a2 Lib/idlelib/PyShell.py
34414
 
--- a/Lib/idlelib/PyShell.py
34415
 
+++ b/Lib/idlelib/PyShell.py
34416
 
@@ -61,7 +61,7 @@
34417
 
             file = warning_stream
34418
 
         try:
34419
 
             file.write(warnings.formatwarning(message, category, filename,
34420
 
-                                              lineno, file=file, line=line))
34421
 
+                                              lineno, line=line))
34422
 
         except IOError:
34423
 
             pass  ## file (probably __stderr__) is invalid, warning dropped.
34424
 
     warnings.showwarning = idle_showwarning
34425
 
@@ -207,18 +207,26 @@
34426
 
         breaks = self.breakpoints
34427
 
         filename = self.io.filename
34428
 
         try:
34429
 
-            lines = open(self.breakpointPath,"r").readlines()
34430
 
+            with open(self.breakpointPath,"r") as old_file:
34431
 
+                lines = old_file.readlines()
34432
 
         except IOError:
34433
 
             lines = []
34434
 
-        new_file = open(self.breakpointPath,"w")
34435
 
-        for line in lines:
34436
 
-            if not line.startswith(filename + '='):
34437
 
-                new_file.write(line)
34438
 
-        self.update_breakpoints()
34439
 
-        breaks = self.breakpoints
34440
 
-        if breaks:
34441
 
-            new_file.write(filename + '=' + str(breaks) + '\n')
34442
 
-        new_file.close()
34443
 
+        try:
34444
 
+            with open(self.breakpointPath,"w") as new_file:
34445
 
+                for line in lines:
34446
 
+                    if not line.startswith(filename + '='):
34447
 
+                        new_file.write(line)
34448
 
+                self.update_breakpoints()
34449
 
+                breaks = self.breakpoints
34450
 
+                if breaks:
34451
 
+                    new_file.write(filename + '=' + str(breaks) + '\n')
34452
 
+        except IOError as err:
34453
 
+            if not getattr(self.root, "breakpoint_error_displayed", False):
34454
 
+                self.root.breakpoint_error_displayed = True
34455
 
+                tkMessageBox.showerror(title='IDLE Error',
34456
 
+                    message='Unable to update breakpoint list:\n%s'
34457
 
+                        % str(err),
34458
 
+                    parent=self.text)
34459
 
 
34460
 
     def restore_file_breaks(self):
34461
 
         self.text.update()   # this enables setting "BREAK" tags to be visible
34462
 
@@ -344,6 +352,7 @@
34463
 
         self.restarting = False
34464
 
         self.subprocess_arglist = None
34465
 
         self.port = PORT
34466
 
+        self.original_compiler_flags = self.compile.compiler.flags
34467
 
 
34468
 
     rpcclt = None
34469
 
     rpcpid = None
34470
 
@@ -414,11 +423,11 @@
34471
 
         self.rpcclt.register("flist", self.tkconsole.flist)
34472
 
         self.rpcclt.register("linecache", linecache)
34473
 
         self.rpcclt.register("interp", self)
34474
 
-        self.transfer_path()
34475
 
+        self.transfer_path(with_cwd=True)
34476
 
         self.poll_subprocess()
34477
 
         return self.rpcclt
34478
 
 
34479
 
-    def restart_subprocess(self):
34480
 
+    def restart_subprocess(self, with_cwd=False):
34481
 
         if self.restarting:
34482
 
             return self.rpcclt
34483
 
         self.restarting = True
34484
 
@@ -442,7 +451,7 @@
34485
 
         except socket.timeout, err:
34486
 
             self.display_no_subprocess_error()
34487
 
             return None
34488
 
-        self.transfer_path()
34489
 
+        self.transfer_path(with_cwd=with_cwd)
34490
 
         # annotate restart in shell window and mark it
34491
 
         console.text.delete("iomark", "end-1c")
34492
 
         if was_executing:
34493
 
@@ -459,6 +468,7 @@
34494
 
             gui = RemoteDebugger.restart_subprocess_debugger(self.rpcclt)
34495
 
             # reload remote debugger breakpoints for all PyShellEditWindows
34496
 
             debug.load_breakpoints()
34497
 
+        self.compile.compiler.flags = self.original_compiler_flags
34498
 
         self.restarting = False
34499
 
         return self.rpcclt
34500
 
 
34501
 
@@ -491,12 +501,18 @@
34502
 
                 except OSError:
34503
 
                     return
34504
 
 
34505
 
-    def transfer_path(self):
34506
 
+    def transfer_path(self, with_cwd=False):
34507
 
+        if with_cwd:        # Issue 13506
34508
 
+            path = ['']     # include Current Working Directory
34509
 
+            path.extend(sys.path)
34510
 
+        else:
34511
 
+            path = sys.path
34512
 
+
34513
 
         self.runcommand("""if 1:
34514
 
         import sys as _sys
34515
 
         _sys.path = %r
34516
 
         del _sys
34517
 
-        \n""" % (sys.path,))
34518
 
+        \n""" % (path,))
34519
 
 
34520
 
     active_seq = None
34521
 
 
34522
 
@@ -1199,7 +1215,8 @@
34523
 
         self.text.see("restart")
34524
 
 
34525
 
     def restart_shell(self, event=None):
34526
 
-        self.interp.restart_subprocess()
34527
 
+        "Callback for Run/Restart Shell Cntl-F6"
34528
 
+        self.interp.restart_subprocess(with_cwd=True)
34529
 
 
34530
 
     def showprompt(self):
34531
 
         self.resetoutput()
34532
 
diff -r 8527427914a2 Lib/idlelib/ScriptBinding.py
34533
 
--- a/Lib/idlelib/ScriptBinding.py
34534
 
+++ b/Lib/idlelib/ScriptBinding.py
34535
 
@@ -101,7 +101,7 @@
34536
 
             try:
34537
 
                 # If successful, return the compiled code
34538
 
                 return compile(source, filename, "exec")
34539
 
-            except (SyntaxError, OverflowError), err:
34540
 
+            except (SyntaxError, OverflowError, ValueError), err:
34541
 
                 try:
34542
 
                     msg, (errorfilename, lineno, offset, line) = err
34543
 
                     if not errorfilename:
34544
 
@@ -146,10 +146,9 @@
34545
 
             return 'break'
34546
 
         if not self.tabnanny(filename):
34547
 
             return 'break'
34548
 
-        shell = self.shell
34549
 
-        interp = shell.interp
34550
 
+        interp = self.shell.interp
34551
 
         if PyShell.use_subprocess:
34552
 
-            shell.restart_shell()
34553
 
+            interp.restart_subprocess(with_cwd=False)
34554
 
         dirname = os.path.dirname(filename)
34555
 
         # XXX Too often this discards arguments the user just set...
34556
 
         interp.runcommand("""if 1:
34557
 
diff -r 8527427914a2 Lib/idlelib/textView.py
34558
 
--- a/Lib/idlelib/textView.py
34559
 
+++ b/Lib/idlelib/textView.py
34560
 
@@ -9,7 +9,7 @@
34561
 
     """A simple text viewer dialog for IDLE
34562
 
 
34563
 
     """
34564
 
-    def __init__(self, parent, title, text):
34565
 
+    def __init__(self, parent, title, text, modal=True):
34566
 
         """Show the given text in a scrollable window with a 'close' button
34567
 
 
34568
 
         """
34569
 
@@ -24,8 +24,6 @@
34570
 
 
34571
 
         self.CreateWidgets()
34572
 
         self.title(title)
34573
 
-        self.transient(parent)
34574
 
-        self.grab_set()
34575
 
         self.protocol("WM_DELETE_WINDOW", self.Ok)
34576
 
         self.parent = parent
34577
 
         self.textView.focus_set()
34578
 
@@ -34,7 +32,11 @@
34579
 
         self.bind('<Escape>',self.Ok) #dismiss dialog
34580
 
         self.textView.insert(0.0, text)
34581
 
         self.textView.config(state=DISABLED)
34582
 
-        self.wait_window()
34583
 
+
34584
 
+        if modal:
34585
 
+            self.transient(parent)
34586
 
+            self.grab_set()
34587
 
+            self.wait_window()
34588
 
 
34589
 
     def CreateWidgets(self):
34590
 
         frameText = Frame(self, relief=SUNKEN, height=700)
34591
 
@@ -57,10 +59,10 @@
34592
 
         self.destroy()
34593
 
 
34594
 
 
34595
 
-def view_text(parent, title, text):
34596
 
-    TextViewer(parent, title, text)
34597
 
+def view_text(parent, title, text, modal=True):
34598
 
+    return TextViewer(parent, title, text, modal)
34599
 
 
34600
 
-def view_file(parent, title, filename, encoding=None):
34601
 
+def view_file(parent, title, filename, encoding=None, modal=True):
34602
 
     try:
34603
 
         if encoding:
34604
 
             import codecs
34605
 
@@ -73,7 +75,7 @@
34606
 
                                message='Unable to load file %r .' % filename,
34607
 
                                parent=parent)
34608
 
     else:
34609
 
-        return view_text(parent, title, textFile.read())
34610
 
+        return view_text(parent, title, textFile.read(), modal)
34611
 
 
34612
 
 
34613
 
 if __name__ == '__main__':
34614
 
@@ -83,11 +85,15 @@
34615
 
     filename = './textView.py'
34616
 
     text = file(filename, 'r').read()
34617
 
     btn1 = Button(root, text='view_text',
34618
 
-                 command=lambda:view_text(root, 'view_text', text))
34619
 
+                  command=lambda:view_text(root, 'view_text', text))
34620
 
     btn1.pack(side=LEFT)
34621
 
     btn2 = Button(root, text='view_file',
34622
 
                   command=lambda:view_file(root, 'view_file', filename))
34623
 
     btn2.pack(side=LEFT)
34624
 
+    btn3 = Button(root, text='nonmodal view_text',
34625
 
+                  command=lambda:view_text(root, 'nonmodal view_text', text,
34626
 
+                                           modal=False))
34627
 
+    btn3.pack(side=LEFT)
34628
 
     close = Button(root, text='Close', command=root.destroy)
34629
 
     close.pack(side=RIGHT)
34630
 
     root.mainloop()
34631
 
diff -r 8527427914a2 Lib/inspect.py
34632
 
--- a/Lib/inspect.py
34633
 
+++ b/Lib/inspect.py
34634
 
@@ -288,30 +288,21 @@
34635
 
     names = dir(cls)
34636
 
     result = []
34637
 
     for name in names:
34638
 
-        # Get the object associated with the name.
34639
 
+        # Get the object associated with the name, and where it was defined.
34640
 
         # Getting an obj from the __dict__ sometimes reveals more than
34641
 
         # using getattr.  Static and class methods are dramatic examples.
34642
 
-        if name in cls.__dict__:
34643
 
-            obj = cls.__dict__[name]
34644
 
+        # Furthermore, some objects may raise an Exception when fetched with
34645
 
+        # getattr(). This is the case with some descriptors (bug #1785).
34646
 
+        # Thus, we only use getattr() as a last resort.
34647
 
+        homecls = None
34648
 
+        for base in (cls,) + mro:
34649
 
+            if name in base.__dict__:
34650
 
+                obj = base.__dict__[name]
34651
 
+                homecls = base
34652
 
+                break
34653
 
         else:
34654
 
             obj = getattr(cls, name)
34655
 
-
34656
 
-        # Figure out where it was defined.
34657
 
-        homecls = getattr(obj, "__objclass__", None)
34658
 
-        if homecls is None:
34659
 
-            # search the dicts.
34660
 
-            for base in mro:
34661
 
-                if name in base.__dict__:
34662
 
-                    homecls = base
34663
 
-                    break
34664
 
-
34665
 
-        # Get the object again, in order to get it from the defining
34666
 
-        # __dict__ instead of via getattr (if possible).
34667
 
-        if homecls is not None and name in homecls.__dict__:
34668
 
-            obj = homecls.__dict__[name]
34669
 
-
34670
 
-        # Also get the object via getattr.
34671
 
-        obj_via_getattr = getattr(cls, name)
34672
 
+            homecls = getattr(obj, "__objclass__", homecls)
34673
 
 
34674
 
         # Classify the object.
34675
 
         if isinstance(obj, staticmethod):
34676
 
@@ -320,11 +311,18 @@
34677
 
             kind = "class method"
34678
 
         elif isinstance(obj, property):
34679
 
             kind = "property"
34680
 
-        elif (ismethod(obj_via_getattr) or
34681
 
-              ismethoddescriptor(obj_via_getattr)):
34682
 
+        elif ismethoddescriptor(obj):
34683
 
             kind = "method"
34684
 
+        elif isdatadescriptor(obj):
34685
 
+            kind = "data"
34686
 
         else:
34687
 
-            kind = "data"
34688
 
+            obj_via_getattr = getattr(cls, name)
34689
 
+            if (ismethod(obj_via_getattr) or
34690
 
+                ismethoddescriptor(obj_via_getattr)):
34691
 
+                kind = "method"
34692
 
+            else:
34693
 
+                kind = "data"
34694
 
+            obj = obj_via_getattr
34695
 
 
34696
 
         result.append(Attribute(name, kind, homecls, obj))
34697
 
 
34698
 
@@ -524,9 +522,13 @@
34699
 
     or code object.  The source code is returned as a list of all the lines
34700
 
     in the file and the line number indexes a line in that list.  An IOError
34701
 
     is raised if the source code cannot be retrieved."""
34702
 
-    file = getsourcefile(object)
34703
 
-    if not file:
34704
 
+
34705
 
+    file = getfile(object)
34706
 
+    sourcefile = getsourcefile(object)
34707
 
+    if not sourcefile and file[0] + file[-1] != '<>':
34708
 
         raise IOError('source code not available')
34709
 
+    file = sourcefile if sourcefile else file
34710
 
+
34711
 
     module = getmodule(object, file)
34712
 
     if module:
34713
 
         lines = linecache.getlines(file, module.__dict__)
34714
 
diff -r 8527427914a2 Lib/json/tests/test_unicode.py
34715
 
--- a/Lib/json/tests/test_unicode.py
34716
 
+++ b/Lib/json/tests/test_unicode.py
34717
 
@@ -80,6 +80,10 @@
34718
 
         # Issue 10038.
34719
 
         self.assertEqual(type(self.loads('"foo"')), unicode)
34720
 
 
34721
 
+    def test_bad_encoding(self):
34722
 
+        self.assertRaises(UnicodeEncodeError, self.loads, '"a"', u"rat\xe9")
34723
 
+        self.assertRaises(TypeError, self.loads, '"a"', 1)
34724
 
+
34725
 
 
34726
 
 class TestPyUnicode(TestUnicode, PyTest): pass
34727
 
 class TestCUnicode(TestUnicode, CTest): pass
34728
 
diff -r 8527427914a2 Lib/lib-tk/Tix.py
34729
 
--- a/Lib/lib-tk/Tix.py
34730
 
+++ b/Lib/lib-tk/Tix.py
34731
 
@@ -1874,13 +1874,13 @@
34732
 
         return self.tk.call(self, 'info', 'bbox', x, y)
34733
 
 
34734
 
     def move_column(self, from_, to, offset):
34735
 
-        """Moves the the range of columns from position FROM through TO by
34736
 
+        """Moves the range of columns from position FROM through TO by
34737
 
         the distance indicated by OFFSET. For example, move_column(2, 4, 1)
34738
 
         moves the columns 2,3,4 to columns 3,4,5."""
34739
 
         self.tk.call(self, 'move', 'column', from_, to, offset)
34740
 
 
34741
 
     def move_row(self, from_, to, offset):
34742
 
-        """Moves the the range of rows from position FROM through TO by
34743
 
+        """Moves the range of rows from position FROM through TO by
34744
 
         the distance indicated by OFFSET.
34745
 
         For example, move_row(2, 4, 1) moves the rows 2,3,4 to rows 3,4,5."""
34746
 
         self.tk.call(self, 'move', 'row', from_, to, offset)
34747
 
@@ -1939,7 +1939,7 @@
34748
 
               pad0 pixels
34749
 
                      Specifies the paddings to the top of a row.
34750
 
               pad1 pixels
34751
 
-                     Specifies the paddings to the the bottom of a row.
34752
 
+                     Specifies the paddings to the bottom of a row.
34753
 
               size val
34754
 
                      Specifies  the height of a row.
34755
 
                      Val may be: "auto" -- the height of the row  is  set  the
34756
 
diff -r 8527427914a2 Lib/lib-tk/Tkinter.py
34757
 
--- a/Lib/lib-tk/Tkinter.py
34758
 
+++ b/Lib/lib-tk/Tkinter.py
34759
 
@@ -30,7 +30,7 @@
34760
 
 tk.mainloop()
34761
 
 """
34762
 
 
34763
 
-__version__ = "$Revision$"
34764
 
+__version__ = "$Revision: 81008 $"
34765
 
 
34766
 
 import sys
34767
 
 if sys.platform == "win32":
34768
 
diff -r 8527427914a2 Lib/lib-tk/test/runtktests.py
34769
 
--- a/Lib/lib-tk/test/runtktests.py
34770
 
+++ b/Lib/lib-tk/test/runtktests.py
34771
 
@@ -14,6 +14,49 @@
34772
 
 
34773
 
 this_dir_path = os.path.abspath(os.path.dirname(__file__))
34774
 
 
34775
 
+_tk_unavailable = None
34776
 
+
34777
 
+def check_tk_availability():
34778
 
+    """Check that Tk is installed and available."""
34779
 
+    global _tk_unavailable
34780
 
+
34781
 
+    if _tk_unavailable is None:
34782
 
+        _tk_unavailable = False
34783
 
+        if sys.platform == 'darwin':
34784
 
+            # The Aqua Tk implementations on OS X can abort the process if
34785
 
+            # being called in an environment where a window server connection
34786
 
+            # cannot be made, for instance when invoked by a buildbot or ssh
34787
 
+            # process not running under the same user id as the current console
34788
 
+            # user.  To avoid that, raise an exception if the window manager
34789
 
+            # connection is not available.
34790
 
+            from ctypes import cdll, c_int, pointer, Structure
34791
 
+            from ctypes.util import find_library
34792
 
+
34793
 
+            app_services = cdll.LoadLibrary(find_library("ApplicationServices"))
34794
 
+
34795
 
+            if app_services.CGMainDisplayID() == 0:
34796
 
+                _tk_unavailable = "cannot run without OS X window manager"
34797
 
+            else:
34798
 
+                class ProcessSerialNumber(Structure):
34799
 
+                    _fields_ = [("highLongOfPSN", c_int),
34800
 
+                                ("lowLongOfPSN", c_int)]
34801
 
+                psn = ProcessSerialNumber()
34802
 
+                psn_p = pointer(psn)
34803
 
+                if (  (app_services.GetCurrentProcess(psn_p) < 0) or
34804
 
+                      (app_services.SetFrontProcess(psn_p) < 0) ):
34805
 
+                    _tk_unavailable = "cannot run without OS X gui process"
34806
 
+        else:   # not OS X
34807
 
+            import Tkinter
34808
 
+            try:
34809
 
+                Tkinter.Button()
34810
 
+            except Tkinter.TclError as msg:
34811
 
+                # assuming tk is not available
34812
 
+                _tk_unavailable = "tk not available: %s" % msg
34813
 
+
34814
 
+    if _tk_unavailable:
34815
 
+        raise unittest.SkipTest(_tk_unavailable)
34816
 
+    return
34817
 
+
34818
 
 def is_package(path):
34819
 
     for name in os.listdir(path):
34820
 
         if name in ('__init__.py', '__init__.pyc', '__init.pyo'):
34821
 
diff -r 8527427914a2 Lib/lib-tk/test/test_ttk/test_widgets.py
34822
 
--- a/Lib/lib-tk/test/test_ttk/test_widgets.py
34823
 
+++ b/Lib/lib-tk/test/test_ttk/test_widgets.py
34824
 
@@ -2,6 +2,7 @@
34825
 
 import Tkinter
34826
 
 import ttk
34827
 
 from test.test_support import requires, run_unittest
34828
 
+import sys
34829
 
 
34830
 
 import support
34831
 
 from test_functions import MockTclObj, MockStateSpec
34832
 
@@ -560,11 +561,19 @@
34833
 
 
34834
 
         self.nb.pack()
34835
 
         self.nb.wait_visibility()
34836
 
-        self.assertEqual(self.nb.tab('@5,5'), self.nb.tab('current'))
34837
 
+        if sys.platform == 'darwin':
34838
 
+            tb_idx = "@20,5"
34839
 
+        else:
34840
 
+            tb_idx = "@5,5"
34841
 
+        self.assertEqual(self.nb.tab(tb_idx), self.nb.tab('current'))
34842
 
 
34843
 
         for i in range(5, 100, 5):
34844
 
-            if self.nb.tab('@%d, 5' % i, text=None) == 'a':
34845
 
-                break
34846
 
+            try:
34847
 
+                if self.nb.tab('@%d, 5' % i, text=None) == 'a':
34848
 
+                    break
34849
 
+            except Tkinter.TclError:
34850
 
+                pass
34851
 
+
34852
 
         else:
34853
 
             self.fail("Tab with text 'a' not found")
34854
 
 
34855
 
@@ -721,7 +730,10 @@
34856
 
         self.nb.enable_traversal()
34857
 
         self.nb.focus_force()
34858
 
         support.simulate_mouse_click(self.nb, 5, 5)
34859
 
-        self.nb.event_generate('<Alt-a>')
34860
 
+        if sys.platform == 'darwin':
34861
 
+            self.nb.event_generate('<Option-a>')
34862
 
+        else:
34863
 
+            self.nb.event_generate('<Alt-a>')
34864
 
         self.assertEqual(self.nb.select(), str(self.child1))
34865
 
 
34866
 
 
34867
 
@@ -925,7 +937,8 @@
34868
 
         self.assertRaises(Tkinter.TclError, self.tv.heading, '#0',
34869
 
             anchor=1)
34870
 
 
34871
 
-
34872
 
+    # XXX skipping for now; should be fixed to work with newer ttk
34873
 
+    @unittest.skip("skipping pending resolution of Issue #10734")
34874
 
     def test_heading_callback(self):
34875
 
         def simulate_heading_click(x, y):
34876
 
             support.simulate_mouse_click(self.tv, x, y)
34877
 
diff -r 8527427914a2 Lib/lib-tk/turtle.py
34878
 
--- a/Lib/lib-tk/turtle.py
34879
 
+++ b/Lib/lib-tk/turtle.py
34880
 
@@ -27,10 +27,10 @@
34881
 
 kids. It was part of the original Logo programming language developed
34882
 
 by Wally Feurzig and Seymour Papert in 1966.
34883
 
 
34884
 
-Imagine a robotic turtle starting at (0, 0) in the x-y plane. Give it
34885
 
+Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an ``import turtle``, give it
34886
 
 the command turtle.forward(15), and it moves (on-screen!) 15 pixels in
34887
 
 the direction it is facing, drawing a line as it moves. Give it the
34888
 
-command turtle.left(25), and it rotates in-place 25 degrees clockwise.
34889
 
+command turtle.right(25), and it rotates in-place 25 degrees clockwise.
34890
 
 
34891
 
 By combining together these and similar commands, intricate shapes and
34892
 
 pictures can easily be drawn.
34893
 
@@ -96,7 +96,7 @@
34894
 
   docstrings to disc, so it can serve as a template for translations.
34895
 
 
34896
 
 Behind the scenes there are some features included with possible
34897
 
-extensions in in mind. These will be commented and documented elsewhere.
34898
 
+extensions in mind. These will be commented and documented elsewhere.
34899
 
 
34900
 
 """
34901
 
 
34902
 
@@ -859,7 +859,7 @@
34903
 
         >>> poly = ((0,0),(10,-5),(0,10),(-10,-5))
34904
 
         >>> s = Shape("compound")
34905
 
         >>> s.addcomponent(poly, "red", "blue")
34906
 
-        ### .. add more components and then use register_shape()
34907
 
+        >>> # .. add more components and then use register_shape()
34908
 
         """
34909
 
         if self._type != "compound":
34910
 
             raise TurtleGraphicsError("Cannot add component to %s Shape"
34911
 
@@ -958,7 +958,7 @@
34912
 
         No argument.
34913
 
 
34914
 
         Example (for a TurtleScreen instance named screen):
34915
 
-        screen.clear()
34916
 
+        >>> screen.clear()
34917
 
 
34918
 
         Note: this method is not available as function.
34919
 
         """
34920
 
@@ -1030,8 +1030,8 @@
34921
 
         Example (for a TurtleScreen instance named screen):
34922
 
         >>> screen.setworldcoordinates(-10,-0.5,50,1.5)
34923
 
         >>> for _ in range(36):
34924
 
-                left(10)
34925
 
-                forward(0.5)
34926
 
+        ...     left(10)
34927
 
+        ...     forward(0.5)
34928
 
         """
34929
 
         if self.mode() != "world":
34930
 
             self.mode("world")
34931
 
@@ -1136,7 +1136,7 @@
34932
 
         >>> screen.colormode()
34933
 
         1.0
34934
 
         >>> screen.colormode(255)
34935
 
-        >>> turtle.pencolor(240,160,80)
34936
 
+        >>> pencolor(240,160,80)
34937
 
         """
34938
 
         if cmode is None:
34939
 
             return self._colormode
34940
 
@@ -1204,9 +1204,9 @@
34941
 
         >>> screen.tracer(8, 25)
34942
 
         >>> dist = 2
34943
 
         >>> for i in range(200):
34944
 
-                fd(dist)
34945
 
-                rt(90)
34946
 
-                dist += 2
34947
 
+        ...     fd(dist)
34948
 
+        ...     rt(90)
34949
 
+        ...     dist += 2
34950
 
         """
34951
 
         if n is None:
34952
 
             return self._tracing
34953
 
@@ -1233,7 +1233,7 @@
34954
 
         self._delayvalue = int(delay)
34955
 
 
34956
 
     def _incrementudc(self):
34957
 
-        "Increment upadate counter."""
34958
 
+        """Increment upadate counter."""
34959
 
         if not TurtleScreen._RUNNING:
34960
 
             TurtleScreen._RUNNNING = True
34961
 
             raise Terminator
34962
 
@@ -1304,13 +1304,10 @@
34963
 
         Example (for a TurtleScreen instance named screen
34964
 
         and a Turtle instance named turtle):
34965
 
 
34966
 
-        >>> screen.onclick(turtle.goto)
34967
 
-
34968
 
-        ### Subsequently clicking into the TurtleScreen will
34969
 
-        ### make the turtle move to the clicked point.
34970
 
+        >>> screen.onclick(goto)
34971
 
+        >>> # Subsequently clicking into the TurtleScreen will
34972
 
+        >>> # make the turtle move to the clicked point.
34973
 
         >>> screen.onclick(None)
34974
 
-
34975
 
-        ### event-binding will be removed
34976
 
         """
34977
 
         self._onscreenclick(fun, btn, add)
34978
 
 
34979
 
@@ -1324,20 +1321,18 @@
34980
 
         In order to be able to register key-events, TurtleScreen
34981
 
         must have focus. (See method listen.)
34982
 
 
34983
 
-        Example (for a TurtleScreen instance named screen
34984
 
-        and a Turtle instance named turtle):
34985
 
+        Example (for a TurtleScreen instance named screen):
34986
 
 
34987
 
         >>> def f():
34988
 
-                fd(50)
34989
 
-                lt(60)
34990
 
-
34991
 
-
34992
 
+        ...     fd(50)
34993
 
+        ...     lt(60)
34994
 
+        ...
34995
 
         >>> screen.onkey(f, "Up")
34996
 
         >>> screen.listen()
34997
 
 
34998
 
-        ### Subsequently the turtle can be moved by
34999
 
-        ### repeatedly pressing the up-arrow key,
35000
 
-        ### consequently drawing a hexagon
35001
 
+        Subsequently the turtle can be moved by repeatedly pressing
35002
 
+        the up-arrow key, consequently drawing a hexagon
35003
 
+
35004
 
         """
35005
 
         if fun is None:
35006
 
             if key in self._keys:
35007
 
@@ -1369,12 +1364,12 @@
35008
 
 
35009
 
         >>> running = True
35010
 
         >>> def f():
35011
 
-                if running:
35012
 
-                        fd(50)
35013
 
-                        lt(60)
35014
 
-                        screen.ontimer(f, 250)
35015
 
-
35016
 
-        >>> f()   ### makes the turtle marching around
35017
 
+        ...     if running:
35018
 
+        ...             fd(50)
35019
 
+        ...             lt(60)
35020
 
+        ...             screen.ontimer(f, 250)
35021
 
+        ...
35022
 
+        >>> f()   # makes the turtle marching around
35023
 
         >>> running = False
35024
 
         """
35025
 
         self._ontimer(fun, t)
35026
 
@@ -1418,7 +1413,7 @@
35027
 
 
35028
 
         Example (for a Turtle instance named turtle):
35029
 
         >>> turtle.screensize(2000,1500)
35030
 
-            ### e. g. to search for an erroneously escaped turtle ;-)
35031
 
+        >>> # e. g. to search for an erroneously escaped turtle ;-)
35032
 
         """
35033
 
         return self._resize(canvwidth, canvheight, bg)
35034
 
 
35035
 
@@ -2004,7 +1999,7 @@
35036
 
         Example (for a Turtle instance named turtle):
35037
 
         >>> turtle.pensize()
35038
 
         1
35039
 
-        turtle.pensize(10)   # from here on lines of width 10 are drawn
35040
 
+        >>> turtle.pensize(10)   # from here on lines of width 10 are drawn
35041
 
         """
35042
 
         if width is None:
35043
 
             return self._pensize
35044
 
@@ -2516,7 +2511,7 @@
35045
 
 
35046
 
         Example (for a Turtle instance named turtle):
35047
 
         >>> while undobufferentries():
35048
 
-                undo()
35049
 
+        ...     undo()
35050
 
         """
35051
 
         if self.undobuffer is None:
35052
 
             return 0
35053
 
@@ -2592,9 +2587,9 @@
35054
 
         >>> turtle.tracer(8, 25)
35055
 
         >>> dist = 2
35056
 
         >>> for i in range(200):
35057
 
-                turtle.fd(dist)
35058
 
-                turtle.rt(90)
35059
 
-                dist += 2
35060
 
+        ...     turtle.fd(dist)
35061
 
+        ...     turtle.rt(90)
35062
 
+        ...     dist += 2
35063
 
         """
35064
 
         return self.screen.tracer(flag, delay)
35065
 
 
35066
 
@@ -2763,7 +2758,6 @@
35067
 
         >>> turtle.shapesize(5,2)
35068
 
         >>> turtle.tilt(45)
35069
 
         >>> turtle.tiltangle()
35070
 
-        >>>
35071
 
         """
35072
 
         tilt = -self._tilt * (180.0/math.pi) * self._angleOrient
35073
 
         return (tilt / self._degreesPerAU) % self._fullcircle
35074
 
@@ -2963,7 +2957,7 @@
35075
 
 
35076
 
         Example (for a Turtle instance named turtle):
35077
 
         >>> for i in range(8):
35078
 
-                turtle.stamp(); turtle.fd(30)
35079
 
+        ...     turtle.stamp(); turtle.fd(30)
35080
 
         ...
35081
 
         >>> turtle.clearstamps(2)
35082
 
         >>> turtle.clearstamps(-2)
35083
 
@@ -3430,9 +3424,9 @@
35084
 
         Example for the anonymous turtle, i. e. the procedural way:
35085
 
 
35086
 
         >>> def turn(x, y):
35087
 
-                left(360)
35088
 
-
35089
 
-        >>> onclick(turn) # Now clicking into the turtle will turn it.
35090
 
+        ...     left(360)
35091
 
+        ...
35092
 
+        >>> onclick(turn)  # Now clicking into the turtle will turn it.
35093
 
         >>> onclick(None)  # event-binding will be removed
35094
 
         """
35095
 
         self.screen._onclick(self.turtle._item, fun, btn, add)
35096
 
@@ -3448,16 +3442,17 @@
35097
 
 
35098
 
         Example (for a MyTurtle instance named joe):
35099
 
         >>> class MyTurtle(Turtle):
35100
 
-                def glow(self,x,y):
35101
 
-                        self.fillcolor("red")
35102
 
-                def unglow(self,x,y):
35103
 
-                        self.fillcolor("")
35104
 
-
35105
 
+        ...     def glow(self,x,y):
35106
 
+        ...             self.fillcolor("red")
35107
 
+        ...     def unglow(self,x,y):
35108
 
+        ...             self.fillcolor("")
35109
 
+        ...
35110
 
         >>> joe = MyTurtle()
35111
 
         >>> joe.onclick(joe.glow)
35112
 
         >>> joe.onrelease(joe.unglow)
35113
 
-        ### clicking on joe turns fillcolor red,
35114
 
-        ### unclicking turns it to transparent.
35115
 
+
35116
 
+        Clicking on joe turns fillcolor red, unclicking turns it to
35117
 
+        transparent.
35118
 
         """
35119
 
         self.screen._onrelease(self.turtle._item, fun, btn, add)
35120
 
         self._update()
35121
 
@@ -3476,9 +3471,9 @@
35122
 
         Example (for a Turtle instance named turtle):
35123
 
         >>> turtle.ondrag(turtle.goto)
35124
 
 
35125
 
-        ### Subsequently clicking and dragging a Turtle will
35126
 
-        ### move it across the screen thereby producing handdrawings
35127
 
-        ### (if pen is down).
35128
 
+        Subsequently clicking and dragging a Turtle will move it
35129
 
+        across the screen thereby producing handdrawings (if pen is
35130
 
+        down).
35131
 
         """
35132
 
         self.screen._ondrag(self.turtle._item, fun, btn, add)
35133
 
 
35134
 
@@ -3525,10 +3520,11 @@
35135
 
 
35136
 
         Example (for a Turtle instance named turtle):
35137
 
         >>> for i in range(4):
35138
 
-                turtle.fd(50); turtle.lt(80)
35139
 
-
35140
 
+        ...     turtle.fd(50); turtle.lt(80)
35141
 
+        ...
35142
 
         >>> for i in range(8):
35143
 
-                turtle.undo()
35144
 
+        ...     turtle.undo()
35145
 
+        ...
35146
 
         """
35147
 
         if self.undobuffer is None:
35148
 
             return
35149
 
diff -r 8527427914a2 Lib/lib2to3/Grammar.txt
35150
 
--- a/Lib/lib2to3/Grammar.txt
35151
 
+++ b/Lib/lib2to3/Grammar.txt
35152
 
@@ -1,4 +1,4 @@
35153
 
-# Grammar for Python
35154
 
+# Grammar for 2to3. This grammar supports Python 2.x and 3.x.
35155
 
 
35156
 
 # Note:  Changing the grammar specified in this file will most likely
35157
 
 #        require corresponding changes in the parser module
35158
 
diff -r 8527427914a2 Lib/lib2to3/main.py
35159
 
--- a/Lib/lib2to3/main.py
35160
 
+++ b/Lib/lib2to3/main.py
35161
 
@@ -25,12 +25,41 @@
35162
 
 
35163
 
 class StdoutRefactoringTool(refactor.MultiprocessRefactoringTool):
35164
 
     """
35165
 
+    A refactoring tool that can avoid overwriting its input files.
35166
 
     Prints output to stdout.
35167
 
+
35168
 
+    Output files can optionally be written to a different directory and or
35169
 
+    have an extra file suffix appended to their name for use in situations
35170
 
+    where you do not want to replace the input files.
35171
 
     """
35172
 
 
35173
 
-    def __init__(self, fixers, options, explicit, nobackups, show_diffs):
35174
 
+    def __init__(self, fixers, options, explicit, nobackups, show_diffs,
35175
 
+                 input_base_dir='', output_dir='', append_suffix=''):
35176
 
+        """
35177
 
+        Args:
35178
 
+            fixers: A list of fixers to import.
35179
 
+            options: A dict with RefactoringTool configuration.
35180
 
+            explicit: A list of fixers to run even if they are explicit.
35181
 
+            nobackups: If true no backup '.bak' files will be created for those
35182
 
+                files that are being refactored.
35183
 
+            show_diffs: Should diffs of the refactoring be printed to stdout?
35184
 
+            input_base_dir: The base directory for all input files.  This class
35185
 
+                will strip this path prefix off of filenames before substituting
35186
 
+                it with output_dir.  Only meaningful if output_dir is supplied.
35187
 
+                All files processed by refactor() must start with this path.
35188
 
+            output_dir: If supplied, all converted files will be written into
35189
 
+                this directory tree instead of input_base_dir.
35190
 
+            append_suffix: If supplied, all files output by this tool will have
35191
 
+                this appended to their filename.  Useful for changing .py to
35192
 
+                .py3 for example by passing append_suffix='3'.
35193
 
+        """
35194
 
         self.nobackups = nobackups
35195
 
         self.show_diffs = show_diffs
35196
 
+        if input_base_dir and not input_base_dir.endswith(os.sep):
35197
 
+            input_base_dir += os.sep
35198
 
+        self._input_base_dir = input_base_dir
35199
 
+        self._output_dir = output_dir
35200
 
+        self._append_suffix = append_suffix
35201
 
         super(StdoutRefactoringTool, self).__init__(fixers, options, explicit)
35202
 
 
35203
 
     def log_error(self, msg, *args, **kwargs):
35204
 
@@ -38,6 +67,23 @@
35205
 
         self.logger.error(msg, *args, **kwargs)
35206
 
 
35207
 
     def write_file(self, new_text, filename, old_text, encoding):
35208
 
+        orig_filename = filename
35209
 
+        if self._output_dir:
35210
 
+            if filename.startswith(self._input_base_dir):
35211
 
+                filename = os.path.join(self._output_dir,
35212
 
+                                        filename[len(self._input_base_dir):])
35213
 
+            else:
35214
 
+                raise ValueError('filename %s does not start with the '
35215
 
+                                 'input_base_dir %s' % (
35216
 
+                                         filename, self._input_base_dir))
35217
 
+        if self._append_suffix:
35218
 
+            filename += self._append_suffix
35219
 
+        if orig_filename != filename:
35220
 
+            output_dir = os.path.dirname(filename)
35221
 
+            if not os.path.isdir(output_dir):
35222
 
+                os.makedirs(output_dir)
35223
 
+            self.log_message('Writing converted %s to %s.', orig_filename,
35224
 
+                             filename)
35225
 
         if not self.nobackups:
35226
 
             # Make backup
35227
 
             backup = filename + ".bak"
35228
 
@@ -55,6 +101,9 @@
35229
 
         write(new_text, filename, old_text, encoding)
35230
 
         if not self.nobackups:
35231
 
             shutil.copymode(backup, filename)
35232
 
+        if orig_filename != filename:
35233
 
+            # Preserve the file mode in the new output directory.
35234
 
+            shutil.copymode(orig_filename, filename)
35235
 
 
35236
 
     def print_output(self, old, new, filename, equal):
35237
 
         if equal:
35238
 
@@ -114,11 +163,33 @@
35239
 
                       help="Write back modified files")
35240
 
     parser.add_option("-n", "--nobackups", action="store_true", default=False,
35241
 
                       help="Don't write backups for modified files")
35242
 
+    parser.add_option("-o", "--output-dir", action="store", type="str",
35243
 
+                      default="", help="Put output files in this directory "
35244
 
+                      "instead of overwriting the input files.  Requires -n.")
35245
 
+    parser.add_option("-W", "--write-unchanged-files", action="store_true",
35246
 
+                      help="Also write files even if no changes were required"
35247
 
+                      " (useful with --output-dir); implies -w.")
35248
 
+    parser.add_option("--add-suffix", action="store", type="str", default="",
35249
 
+                      help="Append this string to all output filenames."
35250
 
+                      " Requires -n if non-empty.  "
35251
 
+                      "ex: --add-suffix='3' will generate .py3 files.")
35252
 
 
35253
 
     # Parse command line arguments
35254
 
     refactor_stdin = False
35255
 
     flags = {}
35256
 
     options, args = parser.parse_args(args)
35257
 
+    if options.write_unchanged_files:
35258
 
+        flags["write_unchanged_files"] = True
35259
 
+        if not options.write:
35260
 
+            warn("--write-unchanged-files/-W implies -w.")
35261
 
+        options.write = True
35262
 
+    # If we allowed these, the original files would be renamed to backup names
35263
 
+    # but not replaced.
35264
 
+    if options.output_dir and not options.nobackups:
35265
 
+        parser.error("Can't use --output-dir/-o without -n.")
35266
 
+    if options.add_suffix and not options.nobackups:
35267
 
+        parser.error("Can't use --add-suffix without -n.")
35268
 
+
35269
 
     if not options.write and options.no_diffs:
35270
 
         warn("not writing files and not printing diffs; that's not very useful")
35271
 
     if not options.write and options.nobackups:
35272
 
@@ -144,6 +215,7 @@
35273
 
     # Set up logging handler
35274
 
     level = logging.DEBUG if options.verbose else logging.INFO
35275
 
     logging.basicConfig(format='%(name)s: %(message)s', level=level)
35276
 
+    logger = logging.getLogger('lib2to3.main')
35277
 
 
35278
 
     # Initialize the refactoring tool
35279
 
     avail_fixes = set(refactor.get_fixers_from_package(fixer_pkg))
35280
 
@@ -160,8 +232,23 @@
35281
 
     else:
35282
 
         requested = avail_fixes.union(explicit)
35283
 
     fixer_names = requested.difference(unwanted_fixes)
35284
 
-    rt = StdoutRefactoringTool(sorted(fixer_names), flags, sorted(explicit),
35285
 
-                               options.nobackups, not options.no_diffs)
35286
 
+    input_base_dir = os.path.commonprefix(args)
35287
 
+    if (input_base_dir and not input_base_dir.endswith(os.sep)
35288
 
+        and not os.path.isdir(input_base_dir)):
35289
 
+        # One or more similar names were passed, their directory is the base.
35290
 
+        # os.path.commonprefix() is ignorant of path elements, this corrects
35291
 
+        # for that weird API.
35292
 
+        input_base_dir = os.path.dirname(input_base_dir)
35293
 
+    if options.output_dir:
35294
 
+        input_base_dir = input_base_dir.rstrip(os.sep)
35295
 
+        logger.info('Output in %r will mirror the input directory %r layout.',
35296
 
+                    options.output_dir, input_base_dir)
35297
 
+    rt = StdoutRefactoringTool(
35298
 
+            sorted(fixer_names), flags, sorted(explicit),
35299
 
+            options.nobackups, not options.no_diffs,
35300
 
+            input_base_dir=input_base_dir,
35301
 
+            output_dir=options.output_dir,
35302
 
+            append_suffix=options.add_suffix)
35303
 
 
35304
 
     # Refactor all files and directories passed as arguments
35305
 
     if not rt.errors:
35306
 
diff -r 8527427914a2 Lib/lib2to3/refactor.py
35307
 
--- a/Lib/lib2to3/refactor.py
35308
 
+++ b/Lib/lib2to3/refactor.py
35309
 
@@ -173,7 +173,8 @@
35310
 
 
35311
 
 class RefactoringTool(object):
35312
 
 
35313
 
-    _default_options = {"print_function" : False}
35314
 
+    _default_options = {"print_function" : False,
35315
 
+                        "write_unchanged_files" : False}
35316
 
 
35317
 
     CLASS_PREFIX = "Fix" # The prefix for fixer classes
35318
 
     FILE_PREFIX = "fix_" # The prefix for modules with a fixer within
35319
 
@@ -195,6 +196,10 @@
35320
 
             self.grammar = pygram.python_grammar_no_print_statement
35321
 
         else:
35322
 
             self.grammar = pygram.python_grammar
35323
 
+        # When this is True, the refactor*() methods will call write_file() for
35324
 
+        # files processed even if they were not changed during refactoring. If
35325
 
+        # and only if the refactor method's write parameter was True.
35326
 
+        self.write_unchanged_files = self.options.get("write_unchanged_files")
35327
 
         self.errors = []
35328
 
         self.logger = logging.getLogger("RefactoringTool")
35329
 
         self.fixer_log = []
35330
 
@@ -341,13 +346,13 @@
35331
 
         if doctests_only:
35332
 
             self.log_debug("Refactoring doctests in %s", filename)
35333
 
             output = self.refactor_docstring(input, filename)
35334
 
-            if output != input:
35335
 
+            if self.write_unchanged_files or output != input:
35336
 
                 self.processed_file(output, filename, input, write, encoding)
35337
 
             else:
35338
 
                 self.log_debug("No doctest changes in %s", filename)
35339
 
         else:
35340
 
             tree = self.refactor_string(input, filename)
35341
 
-            if tree and tree.was_changed:
35342
 
+            if self.write_unchanged_files or (tree and tree.was_changed):
35343
 
                 # The [:-1] is to take off the \n we added earlier
35344
 
                 self.processed_file(unicode(tree)[:-1], filename,
35345
 
                                     write=write, encoding=encoding)
35346
 
@@ -386,13 +391,13 @@
35347
 
         if doctests_only:
35348
 
             self.log_debug("Refactoring doctests in stdin")
35349
 
             output = self.refactor_docstring(input, "<stdin>")
35350
 
-            if output != input:
35351
 
+            if self.write_unchanged_files or output != input:
35352
 
                 self.processed_file(output, "<stdin>", input)
35353
 
             else:
35354
 
                 self.log_debug("No doctest changes in stdin")
35355
 
         else:
35356
 
             tree = self.refactor_string(input, "<stdin>")
35357
 
-            if tree and tree.was_changed:
35358
 
+            if self.write_unchanged_files or (tree and tree.was_changed):
35359
 
                 self.processed_file(unicode(tree), "<stdin>", input)
35360
 
             else:
35361
 
                 self.log_debug("No changes in stdin")
35362
 
@@ -502,7 +507,7 @@
35363
 
     def processed_file(self, new_text, filename, old_text=None, write=False,
35364
 
                        encoding=None):
35365
 
         """
35366
 
-        Called when a file has been refactored, and there are changes.
35367
 
+        Called when a file has been refactored and there may be changes.
35368
 
         """
35369
 
         self.files.append(filename)
35370
 
         if old_text is None:
35371
 
@@ -513,7 +518,8 @@
35372
 
         self.print_output(old_text, new_text, filename, equal)
35373
 
         if equal:
35374
 
             self.log_debug("No changes to %s", filename)
35375
 
-            return
35376
 
+            if not self.write_unchanged_files:
35377
 
+                return
35378
 
         if write:
35379
 
             self.write_file(new_text, filename, old_text, encoding)
35380
 
         else:
35381
 
diff -r 8527427914a2 Lib/lib2to3/tests/test_main.py
35382
 
--- a/Lib/lib2to3/tests/test_main.py
35383
 
+++ b/Lib/lib2to3/tests/test_main.py
35384
 
@@ -2,17 +2,40 @@
35385
 
 import sys
35386
 
 import codecs
35387
 
 import logging
35388
 
+import os
35389
 
+import re
35390
 
+import shutil
35391
 
 import StringIO
35392
 
+import sys
35393
 
+import tempfile
35394
 
 import unittest
35395
 
 
35396
 
 from lib2to3 import main
35397
 
 
35398
 
 
35399
 
+TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
35400
 
+PY2_TEST_MODULE = os.path.join(TEST_DATA_DIR, "py2_test_grammar.py")
35401
 
+
35402
 
+
35403
 
 class TestMain(unittest.TestCase):
35404
 
 
35405
 
+    if not hasattr(unittest.TestCase, 'assertNotRegex'):
35406
 
+        # This method was only introduced in 3.2.
35407
 
+        def assertNotRegex(self, text, regexp, msg=None):
35408
 
+            import re
35409
 
+            if not hasattr(regexp, 'search'):
35410
 
+                regexp = re.compile(regexp)
35411
 
+            if regexp.search(text):
35412
 
+                self.fail("regexp %s MATCHED text %r" % (regexp.pattern, text))
35413
 
+
35414
 
+    def setUp(self):
35415
 
+        self.temp_dir = None  # tearDown() will rmtree this directory if set.
35416
 
+
35417
 
     def tearDown(self):
35418
 
         # Clean up logging configuration down by main.
35419
 
         del logging.root.handlers[:]
35420
 
+        if self.temp_dir:
35421
 
+            shutil.rmtree(self.temp_dir)
35422
 
 
35423
 
     def run_2to3_capture(self, args, in_capture, out_capture, err_capture):
35424
 
         save_stdin = sys.stdin
35425
 
@@ -39,3 +62,88 @@
35426
 
         self.assertTrue("-print 'nothing'" in output)
35427
 
         self.assertTrue("WARNING: couldn't encode <stdin>'s diff for "
35428
 
                         "your terminal" in err.getvalue())
35429
 
+
35430
 
+    def setup_test_source_trees(self):
35431
 
+        """Setup a test source tree and output destination tree."""
35432
 
+        self.temp_dir = tempfile.mkdtemp()  # tearDown() cleans this up.
35433
 
+        self.py2_src_dir = os.path.join(self.temp_dir, "python2_project")
35434
 
+        self.py3_dest_dir = os.path.join(self.temp_dir, "python3_project")
35435
 
+        os.mkdir(self.py2_src_dir)
35436
 
+        os.mkdir(self.py3_dest_dir)
35437
 
+        # Turn it into a package with a few files.
35438
 
+        self.setup_files = []
35439
 
+        open(os.path.join(self.py2_src_dir, "__init__.py"), "w").close()
35440
 
+        self.setup_files.append("__init__.py")
35441
 
+        shutil.copy(PY2_TEST_MODULE, self.py2_src_dir)
35442
 
+        self.setup_files.append(os.path.basename(PY2_TEST_MODULE))
35443
 
+        self.trivial_py2_file = os.path.join(self.py2_src_dir, "trivial.py")
35444
 
+        self.init_py2_file = os.path.join(self.py2_src_dir, "__init__.py")
35445
 
+        with open(self.trivial_py2_file, "w") as trivial:
35446
 
+            trivial.write("print 'I need a simple conversion.'")
35447
 
+        self.setup_files.append("trivial.py")
35448
 
+
35449
 
+    def test_filename_changing_on_output_single_dir(self):
35450
 
+        """2to3 a single directory with a new output dir and suffix."""
35451
 
+        self.setup_test_source_trees()
35452
 
+        out = StringIO.StringIO()
35453
 
+        err = StringIO.StringIO()
35454
 
+        suffix = "TEST"
35455
 
+        ret = self.run_2to3_capture(
35456
 
+                ["-n", "--add-suffix", suffix, "--write-unchanged-files",
35457
 
+                 "--no-diffs", "--output-dir",
35458
 
+                 self.py3_dest_dir, self.py2_src_dir],
35459
 
+                StringIO.StringIO(""), out, err)
35460
 
+        self.assertEqual(ret, 0)
35461
 
+        stderr = err.getvalue()
35462
 
+        self.assertIn(" implies -w.", stderr)
35463
 
+        self.assertIn(
35464
 
+                "Output in %r will mirror the input directory %r layout" % (
35465
 
+                        self.py3_dest_dir, self.py2_src_dir), stderr)
35466
 
+        self.assertEqual(set(name+suffix for name in self.setup_files),
35467
 
+                         set(os.listdir(self.py3_dest_dir)))
35468
 
+        for name in self.setup_files:
35469
 
+            self.assertIn("Writing converted %s to %s" % (
35470
 
+                    os.path.join(self.py2_src_dir, name),
35471
 
+                    os.path.join(self.py3_dest_dir, name+suffix)), stderr)
35472
 
+        sep = re.escape(os.sep)
35473
 
+        self.assertRegexpMatches(
35474
 
+                stderr, r"No changes to .*/__init__\.py".replace("/", sep))
35475
 
+        self.assertNotRegex(
35476
 
+                stderr, r"No changes to .*/trivial\.py".replace("/", sep))
35477
 
+
35478
 
+    def test_filename_changing_on_output_two_files(self):
35479
 
+        """2to3 two files in one directory with a new output dir."""
35480
 
+        self.setup_test_source_trees()
35481
 
+        err = StringIO.StringIO()
35482
 
+        py2_files = [self.trivial_py2_file, self.init_py2_file]
35483
 
+        expected_files = set(os.path.basename(name) for name in py2_files)
35484
 
+        ret = self.run_2to3_capture(
35485
 
+                ["-n", "-w", "--write-unchanged-files",
35486
 
+                 "--no-diffs", "--output-dir", self.py3_dest_dir] + py2_files,
35487
 
+                StringIO.StringIO(""), StringIO.StringIO(), err)
35488
 
+        self.assertEqual(ret, 0)
35489
 
+        stderr = err.getvalue()
35490
 
+        self.assertIn(
35491
 
+                "Output in %r will mirror the input directory %r layout" % (
35492
 
+                        self.py3_dest_dir, self.py2_src_dir), stderr)
35493
 
+        self.assertEqual(expected_files, set(os.listdir(self.py3_dest_dir)))
35494
 
+
35495
 
+    def test_filename_changing_on_output_single_file(self):
35496
 
+        """2to3 a single file with a new output dir."""
35497
 
+        self.setup_test_source_trees()
35498
 
+        err = StringIO.StringIO()
35499
 
+        ret = self.run_2to3_capture(
35500
 
+                ["-n", "-w", "--no-diffs", "--output-dir", self.py3_dest_dir,
35501
 
+                 self.trivial_py2_file],
35502
 
+                StringIO.StringIO(""), StringIO.StringIO(), err)
35503
 
+        self.assertEqual(ret, 0)
35504
 
+        stderr = err.getvalue()
35505
 
+        self.assertIn(
35506
 
+                "Output in %r will mirror the input directory %r layout" % (
35507
 
+                        self.py3_dest_dir, self.py2_src_dir), stderr)
35508
 
+        self.assertEqual(set([os.path.basename(self.trivial_py2_file)]),
35509
 
+                         set(os.listdir(self.py3_dest_dir)))
35510
 
+
35511
 
+
35512
 
+if __name__ == '__main__':
35513
 
+    unittest.main()
35514
 
diff -r 8527427914a2 Lib/lib2to3/tests/test_refactor.py
35515
 
--- a/Lib/lib2to3/tests/test_refactor.py
35516
 
+++ b/Lib/lib2to3/tests/test_refactor.py
35517
 
@@ -53,6 +53,12 @@
35518
 
         self.assertTrue(rt.driver.grammar is
35519
 
                         pygram.python_grammar_no_print_statement)
35520
 
 
35521
 
+    def test_write_unchanged_files_option(self):
35522
 
+        rt = self.rt()
35523
 
+        self.assertFalse(rt.write_unchanged_files)
35524
 
+        rt = self.rt({"write_unchanged_files" : True})
35525
 
+        self.assertTrue(rt.write_unchanged_files)
35526
 
+
35527
 
     def test_fixer_loading_helpers(self):
35528
 
         contents = ["explicit", "first", "last", "parrot", "preorder"]
35529
 
         non_prefixed = refactor.get_all_fix_names("myfixes")
35530
 
@@ -176,29 +182,59 @@
35531
 
                     "<stdin>", False]
35532
 
         self.assertEqual(results, expected)
35533
 
 
35534
 
-    def check_file_refactoring(self, test_file, fixers=_2TO3_FIXERS):
35535
 
+    def check_file_refactoring(self, test_file, fixers=_2TO3_FIXERS,
35536
 
+                               options=None, mock_log_debug=None,
35537
 
+                               actually_write=True):
35538
 
+        tmpdir = tempfile.mkdtemp(prefix="2to3-test_refactor")
35539
 
+        self.addCleanup(shutil.rmtree, tmpdir)
35540
 
+        # make a copy of the tested file that we can write to
35541
 
+        shutil.copy(test_file, tmpdir)
35542
 
+        test_file = os.path.join(tmpdir, os.path.basename(test_file))
35543
 
+        os.chmod(test_file, 0o644)
35544
 
+
35545
 
         def read_file():
35546
 
             with open(test_file, "rb") as fp:
35547
 
                 return fp.read()
35548
 
+
35549
 
         old_contents = read_file()
35550
 
-        rt = self.rt(fixers=fixers)
35551
 
+        rt = self.rt(fixers=fixers, options=options)
35552
 
+        if mock_log_debug:
35553
 
+            rt.log_debug = mock_log_debug
35554
 
 
35555
 
         rt.refactor_file(test_file)
35556
 
         self.assertEqual(old_contents, read_file())
35557
 
 
35558
 
-        try:
35559
 
-            rt.refactor_file(test_file, True)
35560
 
-            new_contents = read_file()
35561
 
-            self.assertNotEqual(old_contents, new_contents)
35562
 
-        finally:
35563
 
-            with open(test_file, "wb") as fp:
35564
 
-                fp.write(old_contents)
35565
 
+        if not actually_write:
35566
 
+            return
35567
 
+        rt.refactor_file(test_file, True)
35568
 
+        new_contents = read_file()
35569
 
+        self.assertNotEqual(old_contents, new_contents)
35570
 
         return new_contents
35571
 
 
35572
 
     def test_refactor_file(self):
35573
 
         test_file = os.path.join(FIXER_DIR, "parrot_example.py")
35574
 
         self.check_file_refactoring(test_file, _DEFAULT_FIXERS)
35575
 
 
35576
 
+    def test_refactor_file_write_unchanged_file(self):
35577
 
+        test_file = os.path.join(FIXER_DIR, "parrot_example.py")
35578
 
+        debug_messages = []
35579
 
+        def recording_log_debug(msg, *args):
35580
 
+            debug_messages.append(msg % args)
35581
 
+        self.check_file_refactoring(test_file, fixers=(),
35582
 
+                                    options={"write_unchanged_files": True},
35583
 
+                                    mock_log_debug=recording_log_debug,
35584
 
+                                    actually_write=False)
35585
 
+        # Testing that it logged this message when write=False was passed is
35586
 
+        # sufficient to see that it did not bail early after "No changes".
35587
 
+        message_regex = r"Not writing changes to .*%s%s" % (
35588
 
+                os.sep, os.path.basename(test_file))
35589
 
+        for message in debug_messages:
35590
 
+            if "Not writing changes" in message:
35591
 
+                self.assertRegexpMatches(message, message_regex)
35592
 
+                break
35593
 
+        else:
35594
 
+            self.fail("%r not matched in %r" % (message_regex, debug_messages))
35595
 
+
35596
 
     def test_refactor_dir(self):
35597
 
         def check(structure, expected):
35598
 
             def mock_refactor_file(self, f, *args):
35599
 
diff -r 8527427914a2 Lib/locale.py
35600
 
--- a/Lib/locale.py
35601
 
+++ b/Lib/locale.py
35602
 
@@ -135,8 +135,6 @@
35603
 
     grouping = conv[monetary and 'mon_grouping' or 'grouping']
35604
 
     if not grouping:
35605
 
         return (s, 0)
35606
 
-    result = ""
35607
 
-    seps = 0
35608
 
     if s[-1] == ' ':
35609
 
         stripped = s.rstrip()
35610
 
         right_spaces = s[len(stripped):]
35611
 
@@ -331,6 +329,13 @@
35612
 
 # overridden below)
35613
 
 _setlocale = setlocale
35614
 
 
35615
 
+# Avoid relying on the locale-dependent .lower() method
35616
 
+# (see issue #1813).
35617
 
+_ascii_lower_map = ''.join(
35618
 
+    chr(x + 32 if x >= ord('A') and x <= ord('Z') else x)
35619
 
+    for x in range(256)
35620
 
+)
35621
 
+
35622
 
 def normalize(localename):
35623
 
 
35624
 
     """ Returns a normalized locale code for the given locale
35625
 
@@ -348,7 +353,9 @@
35626
 
 
35627
 
     """
35628
 
     # Normalize the locale name and extract the encoding
35629
 
-    fullname = localename.lower()
35630
 
+    if isinstance(localename, unicode):
35631
 
+        localename = localename.encode('ascii')
35632
 
+    fullname = localename.translate(_ascii_lower_map)
35633
 
     if ':' in fullname:
35634
 
         # ':' is sometimes used as encoding delimiter.
35635
 
         fullname = fullname.replace(':', '.')
35636
 
@@ -517,9 +524,10 @@
35637
 
 def setlocale(category, locale=None):
35638
 
 
35639
 
     """ Set the locale for the given category.  The locale can be
35640
 
-        a string, a locale tuple (language code, encoding), or None.
35641
 
+        a string, an iterable of two strings (language code and encoding),
35642
 
+        or None.
35643
 
 
35644
 
-        Locale tuples are converted to strings the locale aliasing
35645
 
+        Iterables are converted to strings using the locale aliasing
35646
 
         engine.  Locale strings are passed directly to the C lib.
35647
 
 
35648
 
         category may be given as one of the LC_* values.
35649
 
diff -r 8527427914a2 Lib/logging/__init__.py
35650
 
--- a/Lib/logging/__init__.py
35651
 
+++ b/Lib/logging/__init__.py
35652
 
@@ -478,8 +478,12 @@
35653
 
             except UnicodeError:
35654
 
                 # Sometimes filenames have non-ASCII chars, which can lead
35655
 
                 # to errors when s is Unicode and record.exc_text is str
35656
 
-                # See issue 8924
35657
 
-                s = s + record.exc_text.decode(sys.getfilesystemencoding())
35658
 
+                # See issue 8924.
35659
 
+                # We also use replace for when there are multiple
35660
 
+                # encodings, e.g. UTF-8 for the filesystem and latin-1
35661
 
+                # for a script. See issue 13232.
35662
 
+                s = s + record.exc_text.decode(sys.getfilesystemencoding(),
35663
 
+                                               'replace')
35664
 
         return s
35665
 
 
35666
 
 #
35667
 
@@ -790,7 +794,7 @@
35668
 
         You could, however, replace this with a custom handler if you wish.
35669
 
         The record which was being processed is passed in to this method.
35670
 
         """
35671
 
-        if raiseExceptions:
35672
 
+        if raiseExceptions and sys.stderr:  # see issue 13807
35673
 
             ei = sys.exc_info()
35674
 
             try:
35675
 
                 traceback.print_exception(ei[0], ei[1], ei[2],
35676
 
@@ -1003,6 +1007,10 @@
35677
 
         placeholder to now point to the logger.
35678
 
         """
35679
 
         rv = None
35680
 
+        if not isinstance(name, basestring):
35681
 
+            raise TypeError('A logger name must be string or Unicode')
35682
 
+        if isinstance(name, unicode):
35683
 
+            name = name.encode('utf-8')
35684
 
         _acquireLock()
35685
 
         try:
35686
 
             if name in self.loggerDict:
35687
 
diff -r 8527427914a2 Lib/logging/config.py
35688
 
--- a/Lib/logging/config.py
35689
 
+++ b/Lib/logging/config.py
35690
 
@@ -211,7 +211,7 @@
35691
 
     #avoid disabling child loggers of explicitly
35692
 
     #named loggers. With a sorted list it is easier
35693
 
     #to find the child loggers.
35694
 
-    existing.sort(key=_encoded)
35695
 
+    existing.sort()
35696
 
     #We'll keep the list of existing loggers
35697
 
     #which are children of named loggers here...
35698
 
     child_loggers = []
35699
 
@@ -589,13 +589,14 @@
35700
 
                 #avoid disabling child loggers of explicitly
35701
 
                 #named loggers. With a sorted list it is easier
35702
 
                 #to find the child loggers.
35703
 
-                existing.sort(key=_encoded)
35704
 
+                existing.sort()
35705
 
                 #We'll keep the list of existing loggers
35706
 
                 #which are children of named loggers here...
35707
 
                 child_loggers = []
35708
 
                 #now set up the new ones...
35709
 
                 loggers = config.get('loggers', EMPTY_DICT)
35710
 
                 for name in loggers:
35711
 
+                    name = _encoded(name)
35712
 
                     if name in existing:
35713
 
                         i = existing.index(name)
35714
 
                         prefixed = name + "."
35715
 
diff -r 8527427914a2 Lib/mailbox.py
35716
 
--- a/Lib/mailbox.py
35717
 
+++ b/Lib/mailbox.py
35718
 
@@ -247,11 +247,9 @@
35719
 
             else:
35720
 
                 raise NoSuchMailboxError(self._path)
35721
 
         self._toc = {}
35722
 
-        self._toc_mtimes = {}
35723
 
-        for subdir in ('cur', 'new'):
35724
 
-            self._toc_mtimes[subdir] = os.path.getmtime(self._paths[subdir])
35725
 
-        self._last_read = time.time()  # Records last time we read cur/new
35726
 
-        self._skewfactor = 0.1         # Adjust if os/fs clocks are skewing
35727
 
+        self._toc_mtimes = {'cur': 0, 'new': 0}
35728
 
+        self._last_read = 0         # Records last time we read cur/new
35729
 
+        self._skewfactor = 0.1      # Adjust if os/fs clocks are skewing
35730
 
 
35731
 
     def add(self, message):
35732
 
         """Add message and return assigned key."""
35733
 
@@ -1854,7 +1852,10 @@
35734
 
 
35735
 
     def close(self):
35736
 
         """Close the file."""
35737
 
-        del self._file
35738
 
+        if hasattr(self, '_file'):
35739
 
+            if hasattr(self._file, 'close'):
35740
 
+                self._file.close()
35741
 
+            del self._file
35742
 
 
35743
 
     def _read(self, size, read_method):
35744
 
         """Read size bytes using read_method."""
35745
 
@@ -1898,6 +1899,12 @@
35746
 
             size = remaining
35747
 
         return _ProxyFile._read(self, size, read_method)
35748
 
 
35749
 
+    def close(self):
35750
 
+        # do *not* close the underlying file object for partial files,
35751
 
+        # since it's global to the mailbox object
35752
 
+        if hasattr(self, '_file'):
35753
 
+            del self._file
35754
 
+
35755
 
 
35756
 
 def _lock_file(f, dotlock=True):
35757
 
     """Lock file f using lockf and dot locking."""
35758
 
diff -r 8527427914a2 Lib/markupbase.py
35759
 
--- a/Lib/markupbase.py
35760
 
+++ b/Lib/markupbase.py
35761
 
@@ -108,6 +108,10 @@
35762
 
                 if decltype == "doctype":
35763
 
                     self.handle_decl(data)
35764
 
                 else:
35765
 
+                    # According to the HTML5 specs sections "8.2.4.44 Bogus
35766
 
+                    # comment state" and "8.2.4.45 Markup declaration open
35767
 
+                    # state", a comment token should be emitted.
35768
 
+                    # Calling unknown_decl provides more flexibility though.
35769
 
                     self.unknown_decl(data)
35770
 
                 return j + 1
35771
 
             if c in "\"'":
35772
 
diff -r 8527427914a2 Lib/msilib/schema.py
35773
 
--- a/Lib/msilib/schema.py
35774
 
+++ b/Lib/msilib/schema.py
35775
 
@@ -958,7 +958,7 @@
35776
 
 (u'ServiceInstall',u'StartType',u'N',0,4,None, None, None, None, u'Type of the service',),
35777
 
 (u'Shortcut',u'Name',u'N',None, None, None, None, u'Filename',None, u'The name of the shortcut to be created.',),
35778
 
 (u'Shortcut',u'Description',u'Y',None, None, None, None, u'Text',None, u'The description for the shortcut.',),
35779
 
-(u'Shortcut',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key into the Component table denoting the component whose selection gates the the shortcut creation/deletion.',),
35780
 
+(u'Shortcut',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key into the Component table denoting the component whose selection gates the shortcut creation/deletion.',),
35781
 
 (u'Shortcut',u'Icon_',u'Y',None, None, u'Icon',1,u'Identifier',None, u'Foreign key into the File table denoting the external icon file for the shortcut.',),
35782
 
 (u'Shortcut',u'IconIndex',u'Y',-32767,32767,None, None, None, None, u'The icon index for the shortcut.',),
35783
 
 (u'Shortcut',u'Directory_',u'N',None, None, u'Directory',1,u'Identifier',None, u'Foreign key into the Directory table denoting the directory where the shortcut file is created.',),
35784
 
diff -r 8527427914a2 Lib/multiprocessing/__init__.py
35785
 
--- a/Lib/multiprocessing/__init__.py
35786
 
+++ b/Lib/multiprocessing/__init__.py
35787
 
@@ -9,7 +9,7 @@
35788
 
 # wrapper for 'threading'.
35789
 
 #
35790
 
 # Try calling `multiprocessing.doc.main()` to read the html
35791
 
-# documentation in in a webbrowser.
35792
 
+# documentation in a webbrowser.
35793
 
 #
35794
 
 #
35795
 
 # Copyright (c) 2006-2008, R Oudkerk
35796
 
diff -r 8527427914a2 Lib/multiprocessing/connection.py
35797
 
--- a/Lib/multiprocessing/connection.py
35798
 
+++ b/Lib/multiprocessing/connection.py
35799
 
@@ -249,10 +249,14 @@
35800
 
     '''
35801
 
     def __init__(self, address, family, backlog=1):
35802
 
         self._socket = socket.socket(getattr(socket, family))
35803
 
-        self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
35804
 
-        self._socket.bind(address)
35805
 
-        self._socket.listen(backlog)
35806
 
-        self._address = self._socket.getsockname()
35807
 
+        try:
35808
 
+            self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
35809
 
+            self._socket.bind(address)
35810
 
+            self._socket.listen(backlog)
35811
 
+            self._address = self._socket.getsockname()
35812
 
+        except socket.error:
35813
 
+            self._socket.close()
35814
 
+            raise
35815
 
         self._family = family
35816
 
         self._last_accepted = None
35817
 
 
35818
 
diff -r 8527427914a2 Lib/multiprocessing/heap.py
35819
 
--- a/Lib/multiprocessing/heap.py
35820
 
+++ b/Lib/multiprocessing/heap.py
35821
 
@@ -101,6 +101,8 @@
35822
 
         self._stop_to_block = {}
35823
 
         self._allocated_blocks = set()
35824
 
         self._arenas = []
35825
 
+        # list of pending blocks to free - see free() comment below
35826
 
+        self._pending_free_blocks = []
35827
 
 
35828
 
     @staticmethod
35829
 
     def _roundup(n, alignment):
35830
 
@@ -175,15 +177,39 @@
35831
 
 
35832
 
         return start, stop
35833
 
 
35834
 
+    def _free_pending_blocks(self):
35835
 
+        # Free all the blocks in the pending list - called with the lock held.
35836
 
+        while True:
35837
 
+            try:
35838
 
+                block = self._pending_free_blocks.pop()
35839
 
+            except IndexError:
35840
 
+                break
35841
 
+            self._allocated_blocks.remove(block)
35842
 
+            self._free(block)
35843
 
+
35844
 
     def free(self, block):
35845
 
         # free a block returned by malloc()
35846
 
+        # Since free() can be called asynchronously by the GC, it could happen
35847
 
+        # that it's called while self._lock is held: in that case,
35848
 
+        # self._lock.acquire() would deadlock (issue #12352). To avoid that, a
35849
 
+        # trylock is used instead, and if the lock can't be acquired
35850
 
+        # immediately, the block is added to a list of blocks to be freed
35851
 
+        # synchronously sometimes later from malloc() or free(), by calling
35852
 
+        # _free_pending_blocks() (appending and retrieving from a list is not
35853
 
+        # strictly thread-safe but under cPython it's atomic thanks to the GIL).
35854
 
         assert os.getpid() == self._lastpid
35855
 
-        self._lock.acquire()
35856
 
-        try:
35857
 
-            self._allocated_blocks.remove(block)
35858
 
-            self._free(block)
35859
 
-        finally:
35860
 
-            self._lock.release()
35861
 
+        if not self._lock.acquire(False):
35862
 
+            # can't acquire the lock right now, add the block to the list of
35863
 
+            # pending blocks to free
35864
 
+            self._pending_free_blocks.append(block)
35865
 
+        else:
35866
 
+            # we hold the lock
35867
 
+            try:
35868
 
+                self._free_pending_blocks()
35869
 
+                self._allocated_blocks.remove(block)
35870
 
+                self._free(block)
35871
 
+            finally:
35872
 
+                self._lock.release()
35873
 
 
35874
 
     def malloc(self, size):
35875
 
         # return a block of right size (possibly rounded up)
35876
 
@@ -191,6 +217,7 @@
35877
 
         if os.getpid() != self._lastpid:
35878
 
             self.__init__()                     # reinitialize after fork
35879
 
         self._lock.acquire()
35880
 
+        self._free_pending_blocks()
35881
 
         try:
35882
 
             size = self._roundup(max(size,1), self._alignment)
35883
 
             (arena, start, stop) = self._malloc(size)
35884
 
diff -r 8527427914a2 Lib/multiprocessing/managers.py
35885
 
--- a/Lib/multiprocessing/managers.py
35886
 
+++ b/Lib/multiprocessing/managers.py
35887
 
@@ -159,7 +159,7 @@
35888
 
         Listener, Client = listener_client[serializer]
35889
 
 
35890
 
         # do authentication later
35891
 
-        self.listener = Listener(address=address, backlog=5)
35892
 
+        self.listener = Listener(address=address, backlog=16)
35893
 
         self.address = self.listener.address
35894
 
 
35895
 
         self.id_to_obj = {'0': (None, ())}
35896
 
diff -r 8527427914a2 Lib/multiprocessing/pool.py
35897
 
--- a/Lib/multiprocessing/pool.py
35898
 
+++ b/Lib/multiprocessing/pool.py
35899
 
@@ -125,6 +125,8 @@
35900
 
                 processes = cpu_count()
35901
 
             except NotImplementedError:
35902
 
                 processes = 1
35903
 
+        if processes < 1:
35904
 
+            raise ValueError("Number of processes must be at least 1")
35905
 
 
35906
 
         if initializer is not None and not hasattr(initializer, '__call__'):
35907
 
             raise TypeError('initializer must be a callable')
35908
 
@@ -292,7 +294,11 @@
35909
 
 
35910
 
     @staticmethod
35911
 
     def _handle_workers(pool):
35912
 
-        while pool._worker_handler._state == RUN and pool._state == RUN:
35913
 
+        thread = threading.current_thread()
35914
 
+
35915
 
+        # Keep maintaining workers until the cache gets drained, unless the pool
35916
 
+        # is terminated.
35917
 
+        while thread._state == RUN or (pool._cache and thread._state != TERMINATE):
35918
 
             pool._maintain_pool()
35919
 
             time.sleep(0.1)
35920
 
         # send sentinel to stop workers
35921
 
diff -r 8527427914a2 Lib/multiprocessing/queues.py
35922
 
--- a/Lib/multiprocessing/queues.py
35923
 
+++ b/Lib/multiprocessing/queues.py
35924
 
@@ -126,7 +126,11 @@
35925
 
             if not self._rlock.acquire(block, timeout):
35926
 
                 raise Empty
35927
 
             try:
35928
 
-                if not self._poll(block and (deadline-time.time()) or 0.0):
35929
 
+                if block:
35930
 
+                    timeout = deadline - time.time()
35931
 
+                    if timeout < 0 or not self._poll(timeout):
35932
 
+                        raise Empty
35933
 
+                elif not self._poll():
35934
 
                     raise Empty
35935
 
                 res = self._recv()
35936
 
                 self._sem.release()
35937
 
@@ -188,13 +192,7 @@
35938
 
         debug('... done self._thread.start()')
35939
 
 
35940
 
         # On process exit we will wait for data to be flushed to pipe.
35941
 
-        #
35942
 
-        # However, if this process created the queue then all
35943
 
-        # processes which use the queue will be descendants of this
35944
 
-        # process.  Therefore waiting for the queue to be flushed
35945
 
-        # is pointless once all the child processes have been joined.
35946
 
-        created_by_this_process = (self._opid == os.getpid())
35947
 
-        if not self._joincancelled and not created_by_this_process:
35948
 
+        if not self._joincancelled:
35949
 
             self._jointhread = Finalize(
35950
 
                 self._thread, Queue._finalize_join,
35951
 
                 [weakref.ref(self._thread)],
35952
 
diff -r 8527427914a2 Lib/ntpath.py
35953
 
--- a/Lib/ntpath.py
35954
 
+++ b/Lib/ntpath.py
35955
 
@@ -521,3 +521,13 @@
35956
 
     if not rel_list:
35957
 
         return curdir
35958
 
     return join(*rel_list)
35959
 
+
35960
 
+try:
35961
 
+    # The genericpath.isdir implementation uses os.stat and checks the mode
35962
 
+    # attribute to tell whether or not the path is a directory.
35963
 
+    # This is overkill on Windows - just pass the path to GetFileAttributes
35964
 
+    # and check the attribute from there.
35965
 
+    from nt import _isdir as isdir
35966
 
+except ImportError:
35967
 
+    # Use genericpath.isdir as imported above.
35968
 
+    pass
35969
 
diff -r 8527427914a2 Lib/pdb.py
35970
 
--- a/Lib/pdb.py
35971
 
+++ b/Lib/pdb.py
35972
 
@@ -1229,7 +1229,7 @@
35973
 
         self._wait_for_mainpyfile = 1
35974
 
         self.mainpyfile = self.canonic(filename)
35975
 
         self._user_requested_quit = 0
35976
 
-        statement = 'execfile( "%s")' % filename
35977
 
+        statement = 'execfile(%r)' % filename
35978
 
         self.run(statement)
35979
 
 
35980
 
 # Simplified interface
35981
 
diff -r 8527427914a2 Lib/pickle.py
35982
 
--- a/Lib/pickle.py
35983
 
+++ b/Lib/pickle.py
35984
 
@@ -24,7 +24,7 @@
35985
 
 
35986
 
 """
35987
 
 
35988
 
-__version__ = "$Revision$"       # Code version
35989
 
+__version__ = "$Revision: 72223 $"       # Code version
35990
 
 
35991
 
 from types import *
35992
 
 from copy_reg import dispatch_table
35993
 
@@ -286,20 +286,20 @@
35994
 
             f(self, obj) # Call unbound method with explicit self
35995
 
             return
35996
 
 
35997
 
-        # Check for a class with a custom metaclass; treat as regular class
35998
 
-        try:
35999
 
-            issc = issubclass(t, TypeType)
36000
 
-        except TypeError: # t is not a class (old Boost; see SF #502085)
36001
 
-            issc = 0
36002
 
-        if issc:
36003
 
-            self.save_global(obj)
36004
 
-            return
36005
 
-
36006
 
         # Check copy_reg.dispatch_table
36007
 
         reduce = dispatch_table.get(t)
36008
 
         if reduce:
36009
 
             rv = reduce(obj)
36010
 
         else:
36011
 
+            # Check for a class with a custom metaclass; treat as regular class
36012
 
+            try:
36013
 
+                issc = issubclass(t, TypeType)
36014
 
+            except TypeError: # t is not a class (old Boost; see SF #502085)
36015
 
+                issc = 0
36016
 
+            if issc:
36017
 
+                self.save_global(obj)
36018
 
+                return
36019
 
+
36020
 
             # Check for a __reduce_ex__ method, fall back to __reduce__
36021
 
             reduce = getattr(obj, "__reduce_ex__", None)
36022
 
             if reduce:
36023
 
diff -r 8527427914a2 Lib/pipes.py
36024
 
--- a/Lib/pipes.py
36025
 
+++ b/Lib/pipes.py
36026
 
@@ -54,8 +54,6 @@
36027
 
 
36028
 
 To create a new template object initialized to a given one:
36029
 
    t2 = t.clone()
36030
 
-
36031
 
-For an example, see the function test() at the end of the file.
36032
 
 """                                     # '
36033
 
 
36034
 
 
36035
 
diff -r 8527427914a2 Lib/pkgutil.py
36036
 
--- a/Lib/pkgutil.py
36037
 
+++ b/Lib/pkgutil.py
36038
 
@@ -194,8 +194,11 @@
36039
 
 
36040
 
         yielded = {}
36041
 
         import inspect
36042
 
-
36043
 
-        filenames = os.listdir(self.path)
36044
 
+        try:
36045
 
+            filenames = os.listdir(self.path)
36046
 
+        except OSError:
36047
 
+            # ignore unreadable directories like import does
36048
 
+            filenames = []
36049
 
         filenames.sort()  # handle packages before same-named modules
36050
 
 
36051
 
         for fn in filenames:
36052
 
@@ -208,7 +211,12 @@
36053
 
 
36054
 
             if not modname and os.path.isdir(path) and '.' not in fn:
36055
 
                 modname = fn
36056
 
-                for fn in os.listdir(path):
36057
 
+                try:
36058
 
+                    dircontents = os.listdir(path)
36059
 
+                except OSError:
36060
 
+                    # ignore unreadable directories like import does
36061
 
+                    dircontents = []
36062
 
+                for fn in dircontents:
36063
 
                     subname = inspect.getmodulename(fn)
36064
 
                     if subname=='__init__':
36065
 
                         ispkg = True
36066
 
diff -r 8527427914a2 Lib/plat-mac/findertools.py
36067
 
--- a/Lib/plat-mac/findertools.py
36068
 
+++ b/Lib/plat-mac/findertools.py
36069
 
@@ -128,7 +128,7 @@
36070
 
 def comment(object, comment=None):
36071
 
     """comment: get or set the Finder-comment of the item, displayed in the 'Get Info' window."""
36072
 
     object = Carbon.File.FSRef(object)
36073
 
-    object_alias = object.FSNewAliasMonimal()
36074
 
+    object_alias = object.FSNewAliasMinimal()
36075
 
     if comment is None:
36076
 
         return _getcomment(object_alias)
36077
 
     else:
36078
 
diff -r 8527427914a2 Lib/platform.py
36079
 
--- a/Lib/platform.py
36080
 
+++ b/Lib/platform.py
36081
 
@@ -183,7 +183,7 @@
36082
 
         elif so:
36083
 
             if lib != 'glibc':
36084
 
                 lib = 'libc'
36085
 
-                if soversion > version:
36086
 
+                if soversion and soversion > version:
36087
 
                     version = soversion
36088
 
                 if threads and version[-len(threads):] != threads:
36089
 
                     version = version + threads
36090
 
@@ -554,7 +554,7 @@
36091
 
 
36092
 
     """ Get additional version information from the Windows Registry
36093
 
         and return a tuple (version,csd,ptype) referring to version
36094
 
-        number, CSD level and OS type (multi/single
36095
 
+        number, CSD level (service pack), and OS type (multi/single
36096
 
         processor).
36097
 
 
36098
 
         As a hint: ptype returns 'Uniprocessor Free' on single
36099
 
@@ -765,6 +765,7 @@
36100
 
                    0x2: 'PowerPC',
36101
 
                    0xa: 'i386'}.get(sysa,'')
36102
 
 
36103
 
+    versioninfo=('', '', '')
36104
 
     return release,versioninfo,machine
36105
 
 
36106
 
 def _mac_ver_xml():
36107
 
diff -r 8527427914a2 Lib/pty.py
36108
 
--- a/Lib/pty.py
36109
 
+++ b/Lib/pty.py
36110
 
@@ -142,15 +142,21 @@
36111
 
     Copies
36112
 
             pty master -> standard output   (master_read)
36113
 
             standard input -> pty master    (stdin_read)"""
36114
 
-    while 1:
36115
 
-        rfds, wfds, xfds = select(
36116
 
-                [master_fd, STDIN_FILENO], [], [])
36117
 
+    fds = [master_fd, STDIN_FILENO]
36118
 
+    while True:
36119
 
+        rfds, wfds, xfds = select(fds, [], [])
36120
 
         if master_fd in rfds:
36121
 
             data = master_read(master_fd)
36122
 
-            os.write(STDOUT_FILENO, data)
36123
 
+            if not data:  # Reached EOF.
36124
 
+                fds.remove(master_fd)
36125
 
+            else:
36126
 
+                os.write(STDOUT_FILENO, data)
36127
 
         if STDIN_FILENO in rfds:
36128
 
             data = stdin_read(STDIN_FILENO)
36129
 
-            _writen(master_fd, data)
36130
 
+            if not data:
36131
 
+                fds.remove(STDIN_FILENO)
36132
 
+            else:
36133
 
+                _writen(master_fd, data)
36134
 
 
36135
 
 def spawn(argv, master_read=_read, stdin_read=_read):
36136
 
     """Create a spawned process."""
36137
 
diff -r 8527427914a2 Lib/pydoc.py
36138
 
--- a/Lib/pydoc.py
36139
 
+++ b/Lib/pydoc.py
36140
 
@@ -37,7 +37,7 @@
36141
 
 __author__ = "Ka-Ping Yee <ping@lfw.org>"
36142
 
 __date__ = "26 February 2001"
36143
 
 
36144
 
-__version__ = "$Revision$"
36145
 
+__version__ = "$Revision: 88564 $"
36146
 
 __credits__ = """Guido van Rossum, for an excellent programming language.
36147
 
 Tommy Burnette, the original creator of manpy.
36148
 
 Paul Prescod, for all his work on onlinehelp.
36149
 
@@ -52,7 +52,7 @@
36150
 
 #     the current directory is changed with os.chdir(), an incorrect
36151
 
 #     path will be displayed.
36152
 
 
36153
 
-import sys, imp, os, re, types, inspect, __builtin__, pkgutil
36154
 
+import sys, imp, os, re, types, inspect, __builtin__, pkgutil, warnings
36155
 
 from repr import Repr
36156
 
 from string import expandtabs, find, join, lower, split, strip, rfind, rstrip
36157
 
 from traceback import extract_tb
36158
 
@@ -212,8 +212,8 @@
36159
 
 def synopsis(filename, cache={}):
36160
 
     """Get the one-line summary out of a module file."""
36161
 
     mtime = os.stat(filename).st_mtime
36162
 
-    lastupdate, result = cache.get(filename, (0, None))
36163
 
-    if lastupdate < mtime:
36164
 
+    lastupdate, result = cache.get(filename, (None, None))
36165
 
+    if lastupdate is None or lastupdate < mtime:
36166
 
         info = inspect.getmoduleinfo(filename)
36167
 
         try:
36168
 
             file = open(filename)
36169
 
@@ -740,8 +740,15 @@
36170
 
                 hr.maybe()
36171
 
                 push(msg)
36172
 
                 for name, kind, homecls, value in ok:
36173
 
-                    push(self.document(getattr(object, name), name, mod,
36174
 
-                                       funcs, classes, mdict, object))
36175
 
+                    try:
36176
 
+                        value = getattr(object, name)
36177
 
+                    except Exception:
36178
 
+                        # Some descriptors may meet a failure in their __get__.
36179
 
+                        # (bug #1785)
36180
 
+                        push(self._docdescriptor(name, value, mod))
36181
 
+                    else:
36182
 
+                        push(self.document(value, name, mod,
36183
 
+                                        funcs, classes, mdict, object))
36184
 
                     push('\n')
36185
 
             return attrs
36186
 
 
36187
 
@@ -781,7 +788,12 @@
36188
 
         mdict = {}
36189
 
         for key, kind, homecls, value in attrs:
36190
 
             mdict[key] = anchor = '#' + name + '-' + key
36191
 
-            value = getattr(object, key)
36192
 
+            try:
36193
 
+                value = getattr(object, name)
36194
 
+            except Exception:
36195
 
+                # Some descriptors may meet a failure in their __get__.
36196
 
+                # (bug #1785)
36197
 
+                pass
36198
 
             try:
36199
 
                 # The value may not be hashable (e.g., a data attr with
36200
 
                 # a dict or list value).
36201
 
@@ -1161,8 +1173,15 @@
36202
 
                 hr.maybe()
36203
 
                 push(msg)
36204
 
                 for name, kind, homecls, value in ok:
36205
 
-                    push(self.document(getattr(object, name),
36206
 
-                                       name, mod, object))
36207
 
+                    try:
36208
 
+                        value = getattr(object, name)
36209
 
+                    except Exception:
36210
 
+                        # Some descriptors may meet a failure in their __get__.
36211
 
+                        # (bug #1785)
36212
 
+                        push(self._docdescriptor(name, value, mod))
36213
 
+                    else:
36214
 
+                        push(self.document(value,
36215
 
+                                        name, mod, object))
36216
 
             return attrs
36217
 
 
36218
 
         def spilldescriptors(msg, attrs, predicate):
36219
 
@@ -1454,13 +1473,14 @@
36220
 
         else: break
36221
 
     if module:
36222
 
         object = module
36223
 
-        for part in parts[n:]:
36224
 
-            try: object = getattr(object, part)
36225
 
-            except AttributeError: return None
36226
 
-        return object
36227
 
     else:
36228
 
-        if hasattr(__builtin__, path):
36229
 
-            return getattr(__builtin__, path)
36230
 
+        object = __builtin__
36231
 
+    for part in parts[n:]:
36232
 
+        try:
36233
 
+            object = getattr(object, part)
36234
 
+        except AttributeError:
36235
 
+            return None
36236
 
+    return object
36237
 
 
36238
 
 # --------------------------------------- interactive interpreter interface
36239
 
 
36240
 
@@ -1967,10 +1987,11 @@
36241
 
         if modname[-9:] == '.__init__':
36242
 
             modname = modname[:-9] + ' (package)'
36243
 
         print modname, desc and '- ' + desc
36244
 
-    try: import warnings
36245
 
-    except ImportError: pass
36246
 
-    else: warnings.filterwarnings('ignore') # ignore problems during import
36247
 
-    ModuleScanner().run(callback, key)
36248
 
+    def onerror(modname):
36249
 
+        pass
36250
 
+    with warnings.catch_warnings():
36251
 
+        warnings.filterwarnings('ignore') # ignore problems during import
36252
 
+        ModuleScanner().run(callback, key, onerror=onerror)
36253
 
 
36254
 
 # --------------------------------------------------- web browser interface
36255
 
 
36256
 
diff -r 8527427914a2 Lib/random.py
36257
 
--- a/Lib/random.py
36258
 
+++ b/Lib/random.py
36259
 
@@ -427,11 +427,9 @@
36260
 
         # lambd: rate lambd = 1/mean
36261
 
         # ('lambda' is a Python reserved word)
36262
 
 
36263
 
-        random = self.random
36264
 
-        u = random()
36265
 
-        while u <= 1e-7:
36266
 
-            u = random()
36267
 
-        return -_log(u)/lambd
36268
 
+        # we use 1-random() instead of random() to preclude the
36269
 
+        # possibility of taking the log of zero.
36270
 
+        return -_log(1.0 - self.random())/lambd
36271
 
 
36272
 
 ## -------------------- von Mises distribution --------------------
36273
 
 
36274
 
diff -r 8527427914a2 Lib/rfc822.py
36275
 
--- a/Lib/rfc822.py
36276
 
+++ b/Lib/rfc822.py
36277
 
@@ -34,7 +34,7 @@
36278
 
 libraries in which tell() discards buffered data before discovering that the
36279
 
 lseek() system call doesn't work.  For maximum portability, you should set the
36280
 
 seekable argument to zero to prevent that initial \code{tell} when passing in
36281
 
-an unseekable object such as a a file object created from a socket object.  If
36282
 
+an unseekable object such as a file object created from a socket object.  If
36283
 
 it is 1 on entry -- which it is by default -- the tell() method of the open
36284
 
 file object is called once; if this raises an exception, seekable is reset to
36285
 
 0.  For other nonzero values of seekable, this test is not made.
36286
 
diff -r 8527427914a2 Lib/sched.py
36287
 
--- a/Lib/sched.py
36288
 
+++ b/Lib/sched.py
36289
 
@@ -88,7 +88,7 @@
36290
 
         restarted.
36291
 
 
36292
 
         It is legal for both the delay function and the action
36293
 
-        function to to modify the queue or to raise an exception;
36294
 
+        function to modify the queue or to raise an exception;
36295
 
         exceptions are not caught but the scheduler's state remains
36296
 
         well-defined so run() may be called again.
36297
 
 
36298
 
diff -r 8527427914a2 Lib/shutil.py
36299
 
--- a/Lib/shutil.py
36300
 
+++ b/Lib/shutil.py
36301
 
@@ -25,7 +25,8 @@
36302
 
 __all__ = ["copyfileobj", "copyfile", "copymode", "copystat", "copy", "copy2",
36303
 
            "copytree", "move", "rmtree", "Error", "SpecialFileError",
36304
 
            "ExecError", "make_archive", "get_archive_formats",
36305
 
-           "register_archive_format", "unregister_archive_format"]
36306
 
+           "register_archive_format", "unregister_archive_format",
36307
 
+           "ignore_patterns"]
36308
 
 
36309
 
 class Error(EnvironmentError):
36310
 
     pass
36311
 
@@ -359,7 +360,8 @@
36312
 
     archive_dir = os.path.dirname(archive_name)
36313
 
 
36314
 
     if not os.path.exists(archive_dir):
36315
 
-        logger.info("creating %s" % archive_dir)
36316
 
+        if logger is not None:
36317
 
+            logger.info("creating %s", archive_dir)
36318
 
         if not dry_run:
36319
 
             os.makedirs(archive_dir)
36320
 
 
36321
 
diff -r 8527427914a2 Lib/site.py
36322
 
--- a/Lib/site.py
36323
 
+++ b/Lib/site.py
36324
 
@@ -312,7 +312,7 @@
36325
 
             # locations.
36326
 
             from sysconfig import get_config_var
36327
 
             framework = get_config_var("PYTHONFRAMEWORK")
36328
 
-            if framework and "/%s.framework/"%(framework,) in prefix:
36329
 
+            if framework:
36330
 
                 sitepackages.append(
36331
 
                         os.path.join("/Library", framework,
36332
 
                             sys.version[:3], "site-packages"))
36333
 
diff -r 8527427914a2 Lib/smtpd.py
36334
 
--- a/Lib/smtpd.py
36335
 
+++ b/Lib/smtpd.py
36336
 
@@ -524,6 +524,16 @@
36337
 
 if __name__ == '__main__':
36338
 
     options = parseargs()
36339
 
     # Become nobody
36340
 
+    classname = options.classname
36341
 
+    if "." in classname:
36342
 
+        lastdot = classname.rfind(".")
36343
 
+        mod = __import__(classname[:lastdot], globals(), locals(), [""])
36344
 
+        classname = classname[lastdot+1:]
36345
 
+    else:
36346
 
+        import __main__ as mod
36347
 
+    class_ = getattr(mod, classname)
36348
 
+    proxy = class_((options.localhost, options.localport),
36349
 
+                   (options.remotehost, options.remoteport))
36350
 
     if options.setuid:
36351
 
         try:
36352
 
             import pwd
36353
 
@@ -539,16 +549,6 @@
36354
 
             print >> sys.stderr, \
36355
 
                   'Cannot setuid "nobody"; try running with -n option.'
36356
 
             sys.exit(1)
36357
 
-    classname = options.classname
36358
 
-    if "." in classname:
36359
 
-        lastdot = classname.rfind(".")
36360
 
-        mod = __import__(classname[:lastdot], globals(), locals(), [""])
36361
 
-        classname = classname[lastdot+1:]
36362
 
-    else:
36363
 
-        import __main__ as mod
36364
 
-    class_ = getattr(mod, classname)
36365
 
-    proxy = class_((options.localhost, options.localport),
36366
 
-                   (options.remotehost, options.remoteport))
36367
 
     try:
36368
 
         asyncore.loop()
36369
 
     except KeyboardInterrupt:
36370
 
diff -r 8527427914a2 Lib/smtplib.py
36371
 
--- a/Lib/smtplib.py
36372
 
+++ b/Lib/smtplib.py
36373
 
@@ -149,6 +149,13 @@
36374
 
     else:
36375
 
         return "<%s>" % m
36376
 
 
36377
 
+def _addr_only(addrstring):
36378
 
+    displayname, addr = email.utils.parseaddr(addrstring)
36379
 
+    if (displayname, addr) == ('', ''):
36380
 
+        # parseaddr couldn't parse it, so use it as is.
36381
 
+        return addrstring
36382
 
+    return addr
36383
 
+
36384
 
 def quotedata(data):
36385
 
     """Quote data for email.
36386
 
 
36387
 
@@ -345,8 +352,10 @@
36388
 
         while 1:
36389
 
             try:
36390
 
                 line = self.file.readline()
36391
 
-            except socket.error:
36392
 
-                line = ''
36393
 
+            except socket.error as e:
36394
 
+                self.close()
36395
 
+                raise SMTPServerDisconnected("Connection unexpectedly closed: "
36396
 
+                                             + str(e))
36397
 
             if line == '':
36398
 
                 self.close()
36399
 
                 raise SMTPServerDisconnected("Connection unexpectedly closed")
36400
 
@@ -497,14 +506,14 @@
36401
 
 
36402
 
     def verify(self, address):
36403
 
         """SMTP 'verify' command -- checks for address validity."""
36404
 
-        self.putcmd("vrfy", quoteaddr(address))
36405
 
+        self.putcmd("vrfy", _addr_only(address))
36406
 
         return self.getreply()
36407
 
     # a.k.a.
36408
 
     vrfy = verify
36409
 
 
36410
 
     def expn(self, address):
36411
 
         """SMTP 'expn' command -- expands a mailing list."""
36412
 
-        self.putcmd("expn", quoteaddr(address))
36413
 
+        self.putcmd("expn", _addr_only(address))
36414
 
         return self.getreply()
36415
 
 
36416
 
     # some useful methods
36417
 
diff -r 8527427914a2 Lib/sqlite3/dump.py
36418
 
--- a/Lib/sqlite3/dump.py
36419
 
+++ b/Lib/sqlite3/dump.py
36420
 
@@ -1,6 +1,12 @@
36421
 
 # Mimic the sqlite3 console shell's .dump command
36422
 
 # Author: Paul Kippes <kippesp@gmail.com>
36423
 
 
36424
 
+# Every identifier in sql is quoted based on a comment in sqlite
36425
 
+# documentation "SQLite adds new keywords from time to time when it
36426
 
+# takes on new features. So to prevent your code from being broken by
36427
 
+# future enhancements, you should normally quote any identifier that
36428
 
+# is an English language word, even if you do not have to."
36429
 
+
36430
 
 def _iterdump(connection):
36431
 
     """
36432
 
     Returns an iterator to the dump of the database in an SQL text format.
36433
 
@@ -15,49 +21,49 @@
36434
 
 
36435
 
     # sqlite_master table contains the SQL CREATE statements for the database.
36436
 
     q = """
36437
 
-        SELECT name, type, sql
36438
 
-        FROM sqlite_master
36439
 
-            WHERE sql NOT NULL AND
36440
 
-            type == 'table'
36441
 
+        SELECT "name", "type", "sql"
36442
 
+        FROM "sqlite_master"
36443
 
+            WHERE "sql" NOT NULL AND
36444
 
+            "type" == 'table'
36445
 
         """
36446
 
     schema_res = cu.execute(q)
36447
 
-    for table_name, type, sql in schema_res.fetchall():
36448
 
+    for table_name, type, sql in sorted(schema_res.fetchall()):
36449
 
         if table_name == 'sqlite_sequence':
36450
 
-            yield('DELETE FROM sqlite_sequence;')
36451
 
+            yield('DELETE FROM "sqlite_sequence";')
36452
 
         elif table_name == 'sqlite_stat1':
36453
 
-            yield('ANALYZE sqlite_master;')
36454
 
+            yield('ANALYZE "sqlite_master";')
36455
 
         elif table_name.startswith('sqlite_'):
36456
 
             continue
36457
 
         # NOTE: Virtual table support not implemented
36458
 
         #elif sql.startswith('CREATE VIRTUAL TABLE'):
36459
 
         #    qtable = table_name.replace("'", "''")
36460
 
         #    yield("INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)"\
36461
 
-        #        "VALUES('table','%s','%s',0,'%s');" %
36462
 
+        #        "VALUES('table','{0}','{0}',0,'{1}');".format(
36463
 
         #        qtable,
36464
 
-        #        qtable,
36465
 
-        #        sql.replace("''"))
36466
 
+        #        sql.replace("''")))
36467
 
         else:
36468
 
-            yield('%s;' % sql)
36469
 
+            yield('{0};'.format(sql))
36470
 
 
36471
 
         # Build the insert statement for each row of the current table
36472
 
-        res = cu.execute("PRAGMA table_info('%s')" % table_name)
36473
 
+        table_name_ident = table_name.replace('"', '""')
36474
 
+        res = cu.execute('PRAGMA table_info("{0}")'.format(table_name_ident))
36475
 
         column_names = [str(table_info[1]) for table_info in res.fetchall()]
36476
 
-        q = "SELECT 'INSERT INTO \"%(tbl_name)s\" VALUES("
36477
 
-        q += ",".join(["'||quote(" + col + ")||'" for col in column_names])
36478
 
-        q += ")' FROM '%(tbl_name)s'"
36479
 
-        query_res = cu.execute(q % {'tbl_name': table_name})
36480
 
+        q = """SELECT 'INSERT INTO "{0}" VALUES({1})' FROM "{0}";""".format(
36481
 
+            table_name_ident,
36482
 
+            ",".join("""'||quote("{0}")||'""".format(col.replace('"', '""')) for col in column_names))
36483
 
+        query_res = cu.execute(q)
36484
 
         for row in query_res:
36485
 
-            yield("%s;" % row[0])
36486
 
+            yield("{0};".format(row[0]))
36487
 
 
36488
 
     # Now when the type is 'index', 'trigger', or 'view'
36489
 
     q = """
36490
 
-        SELECT name, type, sql
36491
 
-        FROM sqlite_master
36492
 
-            WHERE sql NOT NULL AND
36493
 
-            type IN ('index', 'trigger', 'view')
36494
 
+        SELECT "name", "type", "sql"
36495
 
+        FROM "sqlite_master"
36496
 
+            WHERE "sql" NOT NULL AND
36497
 
+            "type" IN ('index', 'trigger', 'view')
36498
 
         """
36499
 
     schema_res = cu.execute(q)
36500
 
     for name, type, sql in schema_res.fetchall():
36501
 
-        yield('%s;' % sql)
36502
 
+        yield('{0};'.format(sql))
36503
 
 
36504
 
     yield('COMMIT;')
36505
 
diff -r 8527427914a2 Lib/sqlite3/test/dbapi.py
36506
 
--- a/Lib/sqlite3/test/dbapi.py
36507
 
+++ b/Lib/sqlite3/test/dbapi.py
36508
 
@@ -203,6 +203,13 @@
36509
 
     def CheckExecuteArgString(self):
36510
 
         self.cu.execute("insert into test(name) values (?)", ("Hugo",))
36511
 
 
36512
 
+    def CheckExecuteArgStringWithZeroByte(self):
36513
 
+        self.cu.execute("insert into test(name) values (?)", ("Hu\x00go",))
36514
 
+
36515
 
+        self.cu.execute("select name from test where id=?", (self.cu.lastrowid,))
36516
 
+        row = self.cu.fetchone()
36517
 
+        self.assertEqual(row[0], "Hu\x00go")
36518
 
+
36519
 
     def CheckExecuteWrongNoOfArgs1(self):
36520
 
         # too many parameters
36521
 
         try:
36522
 
diff -r 8527427914a2 Lib/sqlite3/test/dump.py
36523
 
--- a/Lib/sqlite3/test/dump.py
36524
 
+++ b/Lib/sqlite3/test/dump.py
36525
 
@@ -13,6 +13,14 @@
36526
 
 
36527
 
     def CheckTableDump(self):
36528
 
         expected_sqls = [
36529
 
+                """CREATE TABLE "index"("index" blob);"""
36530
 
+                ,
36531
 
+                """INSERT INTO "index" VALUES(X'01');"""
36532
 
+                ,
36533
 
+                """CREATE TABLE "quoted""table"("quoted""field" text);"""
36534
 
+                ,
36535
 
+                """INSERT INTO "quoted""table" VALUES('quoted''value');"""
36536
 
+                ,
36537
 
                 "CREATE TABLE t1(id integer primary key, s1 text, " \
36538
 
                 "t1_i1 integer not null, i2 integer, unique (s1), " \
36539
 
                 "constraint t1_idx1 unique (i2));"
36540
 
diff -r 8527427914a2 Lib/sqlite3/test/factory.py
36541
 
--- a/Lib/sqlite3/test/factory.py
36542
 
+++ b/Lib/sqlite3/test/factory.py
36543
 
@@ -189,13 +189,52 @@
36544
 
     def tearDown(self):
36545
 
         self.con.close()
36546
 
 
36547
 
+class TextFactoryTestsWithEmbeddedZeroBytes(unittest.TestCase):
36548
 
+    def setUp(self):
36549
 
+        self.con = sqlite.connect(":memory:")
36550
 
+        self.con.execute("create table test (value text)")
36551
 
+        self.con.execute("insert into test (value) values (?)", ("a\x00b",))
36552
 
+
36553
 
+    def CheckString(self):
36554
 
+        # text_factory defaults to unicode
36555
 
+        row = self.con.execute("select value from test").fetchone()
36556
 
+        self.assertIs(type(row[0]), unicode)
36557
 
+        self.assertEqual(row[0], "a\x00b")
36558
 
+
36559
 
+    def CheckCustom(self):
36560
 
+        # A custom factory should receive an str argument
36561
 
+        self.con.text_factory = lambda x: x
36562
 
+        row = self.con.execute("select value from test").fetchone()
36563
 
+        self.assertIs(type(row[0]), str)
36564
 
+        self.assertEqual(row[0], "a\x00b")
36565
 
+
36566
 
+    def CheckOptimizedUnicodeAsString(self):
36567
 
+        # ASCII -> str argument
36568
 
+        self.con.text_factory = sqlite.OptimizedUnicode
36569
 
+        row = self.con.execute("select value from test").fetchone()
36570
 
+        self.assertIs(type(row[0]), str)
36571
 
+        self.assertEqual(row[0], "a\x00b")
36572
 
+
36573
 
+    def CheckOptimizedUnicodeAsUnicode(self):
36574
 
+        # Non-ASCII -> unicode argument
36575
 
+        self.con.text_factory = sqlite.OptimizedUnicode
36576
 
+        self.con.execute("delete from test")
36577
 
+        self.con.execute("insert into test (value) values (?)", (u'�\0�',))
36578
 
+        row = self.con.execute("select value from test").fetchone()
36579
 
+        self.assertIs(type(row[0]), unicode)
36580
 
+        self.assertEqual(row[0], u"�\x00�")
36581
 
+
36582
 
+    def tearDown(self):
36583
 
+        self.con.close()
36584
 
+
36585
 
 def suite():
36586
 
     connection_suite = unittest.makeSuite(ConnectionFactoryTests, "Check")
36587
 
     cursor_suite = unittest.makeSuite(CursorFactoryTests, "Check")
36588
 
     row_suite_compat = unittest.makeSuite(RowFactoryTestsBackwardsCompat, "Check")
36589
 
     row_suite = unittest.makeSuite(RowFactoryTests, "Check")
36590
 
     text_suite = unittest.makeSuite(TextFactoryTests, "Check")
36591
 
-    return unittest.TestSuite((connection_suite, cursor_suite, row_suite_compat, row_suite, text_suite))
36592
 
+    text_zero_bytes_suite = unittest.makeSuite(TextFactoryTestsWithEmbeddedZeroBytes, "Check")
36593
 
+    return unittest.TestSuite((connection_suite, cursor_suite, row_suite_compat, row_suite, text_suite, text_zero_bytes_suite))
36594
 
 
36595
 
 def test():
36596
 
     runner = unittest.TextTestRunner()
36597
 
diff -r 8527427914a2 Lib/sqlite3/test/regression.py
36598
 
--- a/Lib/sqlite3/test/regression.py
36599
 
+++ b/Lib/sqlite3/test/regression.py
36600
 
@@ -264,6 +264,28 @@
36601
 
         """
36602
 
         self.assertRaises(sqlite.Warning, self.con, 1)
36603
 
 
36604
 
+    def CheckRecursiveCursorUse(self):
36605
 
+        """
36606
 
+        http://bugs.python.org/issue10811
36607
 
+
36608
 
+        Recursively using a cursor, such as when reusing it from a generator led to segfaults.
36609
 
+        Now we catch recursive cursor usage and raise a ProgrammingError.
36610
 
+        """
36611
 
+        con = sqlite.connect(":memory:")
36612
 
+
36613
 
+        cur = con.cursor()
36614
 
+        cur.execute("create table a (bar)")
36615
 
+        cur.execute("create table b (baz)")
36616
 
+
36617
 
+        def foo():
36618
 
+            cur.execute("insert into a (bar) values (?)", (1,))
36619
 
+            yield 1
36620
 
+
36621
 
+        with self.assertRaises(sqlite.ProgrammingError):
36622
 
+            cur.executemany("insert into b (baz) values (?)",
36623
 
+                            ((i,) for i in foo()))
36624
 
+
36625
 
+
36626
 
 def suite():
36627
 
     regression_suite = unittest.makeSuite(RegressionTests, "Check")
36628
 
     return unittest.TestSuite((regression_suite,))
36629
 
diff -r 8527427914a2 Lib/ssl.py
36630
 
--- a/Lib/ssl.py
36631
 
+++ b/Lib/ssl.py
36632
 
@@ -81,8 +81,9 @@
36633
 
 }
36634
 
 try:
36635
 
     from _ssl import PROTOCOL_SSLv2
36636
 
+    _SSLv2_IF_EXISTS = PROTOCOL_SSLv2
36637
 
 except ImportError:
36638
 
-    pass
36639
 
+    _SSLv2_IF_EXISTS = None
36640
 
 else:
36641
 
     _PROTOCOL_NAMES[PROTOCOL_SSLv2] = "SSLv2"
36642
 
 
36643
 
@@ -91,6 +92,11 @@
36644
 
 import base64        # for DER-to-PEM translation
36645
 
 import errno
36646
 
 
36647
 
+# Disable weak or insecure ciphers by default
36648
 
+# (OpenSSL's default setting is 'DEFAULT:!aNULL:!eNULL')
36649
 
+_DEFAULT_CIPHERS = 'DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2'
36650
 
+
36651
 
+
36652
 
 class SSLSocket(socket):
36653
 
 
36654
 
     """This class implements a subtype of socket.socket that wraps
36655
 
@@ -112,6 +118,9 @@
36656
 
             except AttributeError:
36657
 
                 pass
36658
 
 
36659
 
+        if ciphers is None and ssl_version != _SSLv2_IF_EXISTS:
36660
 
+            ciphers = _DEFAULT_CIPHERS
36661
 
+
36662
 
         if certfile and not keyfile:
36663
 
             keyfile = certfile
36664
 
         # see if it's connected
36665
 
diff -r 8527427914a2 Lib/stat.py
36666
 
--- a/Lib/stat.py
36667
 
+++ b/Lib/stat.py
36668
 
@@ -87,6 +87,8 @@
36669
 
 UF_APPEND    = 0x00000004
36670
 
 UF_OPAQUE    = 0x00000008
36671
 
 UF_NOUNLINK  = 0x00000010
36672
 
+UF_COMPRESSED = 0x00000020  # OS X: file is hfs-compressed
36673
 
+UF_HIDDEN    = 0x00008000   # OS X: file should not be displayed
36674
 
 SF_ARCHIVED  = 0x00010000
36675
 
 SF_IMMUTABLE = 0x00020000
36676
 
 SF_APPEND    = 0x00040000
36677
 
diff -r 8527427914a2 Lib/subprocess.py
36678
 
--- a/Lib/subprocess.py
36679
 
+++ b/Lib/subprocess.py
36680
 
@@ -460,7 +460,7 @@
36681
 
 def _cleanup():
36682
 
     for inst in _active[:]:
36683
 
         res = inst._internal_poll(_deadstate=sys.maxint)
36684
 
-        if res is not None and res >= 0:
36685
 
+        if res is not None:
36686
 
             try:
36687
 
                 _active.remove(inst)
36688
 
             except ValueError:
36689
 
@@ -476,7 +476,7 @@
36690
 
     while True:
36691
 
         try:
36692
 
             return func(*args)
36693
 
-        except OSError, e:
36694
 
+        except (OSError, IOError) as e:
36695
 
             if e.errno == errno.EINTR:
36696
 
                 continue
36697
 
             raise
36698
 
@@ -707,7 +707,10 @@
36699
 
 
36700
 
 
36701
 
     def __del__(self, _maxint=sys.maxint, _active=_active):
36702
 
-        if not self._child_created:
36703
 
+        # If __init__ hasn't had a chance to execute (e.g. if it
36704
 
+        # was passed an undeclared keyword argument), we don't
36705
 
+        # have a _child_created attribute at all.
36706
 
+        if not getattr(self, '_child_created', False):
36707
 
             # We didn't get to successfully create a child process.
36708
 
             return
36709
 
         # In case the child hasn't been waited on, check if it's done.
36710
 
@@ -740,10 +743,10 @@
36711
 
                             raise
36712
 
                 self.stdin.close()
36713
 
             elif self.stdout:
36714
 
-                stdout = self.stdout.read()
36715
 
+                stdout = _eintr_retry_call(self.stdout.read)
36716
 
                 self.stdout.close()
36717
 
             elif self.stderr:
36718
 
-                stderr = self.stderr.read()
36719
 
+                stderr = _eintr_retry_call(self.stderr.read)
36720
 
                 self.stderr.close()
36721
 
             self.wait()
36722
 
             return (stdout, stderr)
36723
 
@@ -1032,7 +1035,7 @@
36724
 
             if stdin is None:
36725
 
                 pass
36726
 
             elif stdin == PIPE:
36727
 
-                p2cread, p2cwrite = os.pipe()
36728
 
+                p2cread, p2cwrite = self.pipe_cloexec()
36729
 
             elif isinstance(stdin, int):
36730
 
                 p2cread = stdin
36731
 
             else:
36732
 
@@ -1042,7 +1045,7 @@
36733
 
             if stdout is None:
36734
 
                 pass
36735
 
             elif stdout == PIPE:
36736
 
-                c2pread, c2pwrite = os.pipe()
36737
 
+                c2pread, c2pwrite = self.pipe_cloexec()
36738
 
             elif isinstance(stdout, int):
36739
 
                 c2pwrite = stdout
36740
 
             else:
36741
 
@@ -1052,7 +1055,7 @@
36742
 
             if stderr is None:
36743
 
                 pass
36744
 
             elif stderr == PIPE:
36745
 
-                errread, errwrite = os.pipe()
36746
 
+                errread, errwrite = self.pipe_cloexec()
36747
 
             elif stderr == STDOUT:
36748
 
                 errwrite = c2pwrite
36749
 
             elif isinstance(stderr, int):
36750
 
@@ -1079,6 +1082,18 @@
36751
 
                 fcntl.fcntl(fd, fcntl.F_SETFD, old & ~cloexec_flag)
36752
 
 
36753
 
 
36754
 
+        def pipe_cloexec(self):
36755
 
+            """Create a pipe with FDs set CLOEXEC."""
36756
 
+            # Pipes' FDs are set CLOEXEC by default because we don't want them
36757
 
+            # to be inherited by other subprocesses: the CLOEXEC flag is removed
36758
 
+            # from the child's FDs by _dup2(), between fork() and exec().
36759
 
+            # This is not atomic: we would need the pipe2() syscall for that.
36760
 
+            r, w = os.pipe()
36761
 
+            self._set_cloexec_flag(r)
36762
 
+            self._set_cloexec_flag(w)
36763
 
+            return r, w
36764
 
+
36765
 
+
36766
 
         def _close_fds(self, but):
36767
 
             if hasattr(os, 'closerange'):
36768
 
                 os.closerange(3, but)
36769
 
@@ -1117,11 +1132,9 @@
36770
 
             # For transferring possible exec failure from child to parent
36771
 
             # The first char specifies the exception type: 0 means
36772
 
             # OSError, 1 means some other error.
36773
 
-            errpipe_read, errpipe_write = os.pipe()
36774
 
+            errpipe_read, errpipe_write = self.pipe_cloexec()
36775
 
             try:
36776
 
                 try:
36777
 
-                    self._set_cloexec_flag(errpipe_write)
36778
 
-
36779
 
                     gc_was_enabled = gc.isenabled()
36780
 
                     # Disable gc to avoid bug where gc -> file_dealloc ->
36781
 
                     # write to stderr -> hang.  http://bugs.python.org/issue1336
36782
 
@@ -1145,6 +1158,14 @@
36783
 
                                 os.close(errread)
36784
 
                             os.close(errpipe_read)
36785
 
 
36786
 
+                            # When duping fds, if there arises a situation
36787
 
+                            # where one of the fds is either 0, 1 or 2, it
36788
 
+                            # is possible that it is overwritten (#12607).
36789
 
+                            if c2pwrite == 0:
36790
 
+                                c2pwrite = os.dup(c2pwrite)
36791
 
+                            if errwrite == 0 or errwrite == 1:
36792
 
+                                errwrite = os.dup(errwrite)
36793
 
+
36794
 
                             # Dup fds for child
36795
 
                             def _dup2(a, b):
36796
 
                                 # dup2() removes the CLOEXEC flag but
36797
 
diff -r 8527427914a2 Lib/sysconfig.py
36798
 
--- a/Lib/sysconfig.py
36799
 
+++ b/Lib/sysconfig.py
36800
 
@@ -176,8 +176,9 @@
36801
 
     if sys.platform == "darwin":
36802
 
         framework = get_config_var("PYTHONFRAMEWORK")
36803
 
         if framework:
36804
 
-            return joinuser("~", "Library", framework, "%d.%d"%(
36805
 
-                sys.version_info[:2]))
36806
 
+            return env_base if env_base else \
36807
 
+                               joinuser("~", "Library", framework, "%d.%d"
36808
 
+                                            % (sys.version_info[:2]))
36809
 
 
36810
 
     return env_base if env_base else joinuser("~", ".local")
36811
 
 
36812
 
@@ -582,6 +583,11 @@
36813
 
         if release[0] >= "5":           # SunOS 5 == Solaris 2
36814
 
             osname = "solaris"
36815
 
             release = "%d.%s" % (int(release[0]) - 3, release[2:])
36816
 
+            # We can't use "platform.architecture()[0]" because a
36817
 
+            # bootstrap problem. We use a dict to get an error
36818
 
+            # if some suspicious happens.
36819
 
+            bitness = {2147483647:"32bit", 9223372036854775807:"64bit"}
36820
 
+            machine += ".%s" % bitness[sys.maxint]
36821
 
         # fall through to standard osname-release-machine representation
36822
 
     elif osname[:4] == "irix":              # could be "irix64"!
36823
 
         return "%s-%s" % (osname, release)
36824
 
diff -r 8527427914a2 Lib/tarfile.py
36825
 
--- a/Lib/tarfile.py
36826
 
+++ b/Lib/tarfile.py
36827
 
@@ -30,7 +30,7 @@
36828
 
 """Read from and write to tar format archives.
36829
 
 """
36830
 
 
36831
 
-__version__ = "$Revision$"
36832
 
+__version__ = "$Revision: 85213 $"
36833
 
 # $Source$
36834
 
 
36835
 
 version     = "0.9.0"
36836
 
@@ -454,6 +454,8 @@
36837
 
                                             0)
36838
 
         timestamp = struct.pack("<L", long(time.time()))
36839
 
         self.__write("\037\213\010\010%s\002\377" % timestamp)
36840
 
+        if type(self.name) is unicode:
36841
 
+            self.name = self.name.encode("iso-8859-1", "replace")
36842
 
         if self.name.endswith(".gz"):
36843
 
             self.name = self.name[:-3]
36844
 
         self.__write(self.name + NUL)
36845
 
@@ -627,7 +629,7 @@
36846
 
     def getcomptype(self):
36847
 
         if self.buf.startswith("\037\213\010"):
36848
 
             return "gz"
36849
 
-        if self.buf.startswith("BZh91"):
36850
 
+        if self.buf[0:3] == "BZh" and self.buf[4:10] == "1AY&SY":
36851
 
             return "bz2"
36852
 
         return "tar"
36853
 
 
36854
 
@@ -2264,17 +2266,11 @@
36855
 
             try:
36856
 
                 g = grp.getgrnam(tarinfo.gname)[2]
36857
 
             except KeyError:
36858
 
-                try:
36859
 
-                    g = grp.getgrgid(tarinfo.gid)[2]
36860
 
-                except KeyError:
36861
 
-                    g = os.getgid()
36862
 
+                g = tarinfo.gid
36863
 
             try:
36864
 
                 u = pwd.getpwnam(tarinfo.uname)[2]
36865
 
             except KeyError:
36866
 
-                try:
36867
 
-                    u = pwd.getpwuid(tarinfo.uid)[2]
36868
 
-                except KeyError:
36869
 
-                    u = os.getuid()
36870
 
+                u = tarinfo.uid
36871
 
             try:
36872
 
                 if tarinfo.issym() and hasattr(os, "lchown"):
36873
 
                     os.lchown(targetpath, u, g)
36874
 
diff -r 8527427914a2 Lib/tempfile.py
36875
 
--- a/Lib/tempfile.py
36876
 
+++ b/Lib/tempfile.py
36877
 
@@ -118,9 +118,16 @@
36878
 
 
36879
 
     def __init__(self):
36880
 
         self.mutex = _allocate_lock()
36881
 
-        self.rng = _Random()
36882
 
         self.normcase = _os.path.normcase
36883
 
 
36884
 
+    @property
36885
 
+    def rng(self):
36886
 
+        cur_pid = _os.getpid()
36887
 
+        if cur_pid != getattr(self, '_rng_pid', None):
36888
 
+            self._rng = _Random()
36889
 
+            self._rng_pid = cur_pid
36890
 
+        return self._rng
36891
 
+
36892
 
     def __iter__(self):
36893
 
         return self
36894
 
 
36895
 
diff -r 8527427914a2 Lib/test/cjkencodings/iso2022_jp-utf8.txt
36896
 
--- /dev/null
36897
 
+++ b/Lib/test/cjkencodings/iso2022_jp-utf8.txt
36898
 
@@ -0,0 +1,7 @@
36899
 
+Python の開発は、1990 年ごろから開始されています。
36900
 
+開発者の Guido van Rossum は教育用のプログラミング言語「ABC」の開発に参加していましたが、ABC は実用上の目的にはあまり適していませんでした。
36901
 
+このため、Guido はより実用的なプログラミング言語の開発を開始し、英国 BBS 放送のコメディ番組「モンティ パイソン」のファンである Guido はこの言語を「Python」と名づけました。
36902
 
+このような背景から生まれた Python の言語設計は、「シンプル」で「習得が容易」という目標に重点が置かれています。
36903
 
+多くのスクリプト系言語ではユーザの目先の利便性を優先して色々な機能を言語要素として取り入れる場合が多いのですが、Python ではそういった小細工が追加されることはあまりありません。
36904
 
+言語自体の機能は最小限に押さえ、必要な機能は拡張モジュールとして追加する、というのが Python のポリシーです。
36905
 
+
36906
 
diff -r 8527427914a2 Lib/test/cjkencodings/iso2022_jp.txt
36907
 
--- /dev/null
36908
 
+++ b/Lib/test/cjkencodings/iso2022_jp.txt
36909
 
@@ -0,0 +1,7 @@
36910
 
+Python $B$N3+H/$O!"(B1990 $BG/$4$m$+$i3+;O$5$l$F$$$^$9!#(B
36911
 
+$B3+H/<T$N(B Guido van Rossum $B$O650iMQ$N%W%m%0%i%_%s%08@8l!V(BABC$B!W$N3+H/$K;22C$7$F$$$^$7$?$,!"(BABC $B$O<BMQ>e$NL\E*$K$O$"$^$jE,$7$F$$$^$;$s$G$7$?!#(B
36912
 
+$B$3$N$?$a!"(BGuido $B$O$h$j<BMQE*$J%W%m%0%i%_%s%08@8l$N3+H/$r3+;O$7!"1Q9q(B BBS $BJ|Aw$N%3%a%G%#HVAH!V%b%s%F%#(B $B%Q%$%=%s!W$N%U%!%s$G$"$k(B Guido $B$O$3$N8@8l$r!V(BPython$B!W$HL>$E$1$^$7$?!#(B
36913
 
+$B$3$N$h$&$JGX7J$+$i@8$^$l$?(B Python $B$N8@8l@_7W$O!"!V%7%s%W%k!W$G!V=,F@$,MF0W!W$H$$$&L\I8$K=EE@$,CV$+$l$F$$$^$9!#(B
36914
 
+$BB?$/$N%9%/%j%W%H7O8@8l$G$O%f!<%6$NL\@h$NMxJX@-$rM%@h$7$F?'!9$J5!G=$r8@8lMWAG$H$7$F<h$jF~$l$k>l9g$,B?$$$N$G$9$,!"(BPython $B$G$O$=$&$$$C$?>.:Y9)$,DI2C$5$l$k$3$H$O$"$^$j$"$j$^$;$s!#(B
36915
 
+$B8@8l<+BN$N5!G=$O:G>.8B$K2!$5$(!"I,MW$J5!G=$O3HD%%b%8%e!<%k$H$7$FDI2C$9$k!"$H$$$&$N$,(B Python $B$N%]%j%7!<$G$9!#(B
36916
 
+
36917
 
diff -r 8527427914a2 Lib/test/cjkencodings/iso2022_kr-utf8.txt
36918
 
--- /dev/null
36919
 
+++ b/Lib/test/cjkencodings/iso2022_kr-utf8.txt
36920
 
@@ -0,0 +1,7 @@
36921
 
+◎ 파이썬(Python)은 배우기 쉽고, 강력한 프로그래밍 언어입니다. 파이썬은
36922
 
+효율적인 고수준 데이터 구조와 간단하지만 효율적인 객체지향프로그래밍을
36923
 
+지원합니다. 파이썬의 우아(優雅)한 문법과 동적 타이핑, 그리고 인터프리팅
36924
 
+환경은 파이썬을 스크립팅과 여러 분야에서와 대부분의 플랫폼에서의 빠른
36925
 
+애플리케이션 개발을 할 수 있는 이상적인 언어로 만들어줍니다.
36926
 
+
36927
 
+☆첫가끝: 날아라 쓩~ 큼! 금없이 전니다. 그런거 다.
36928
 
diff -r 8527427914a2 Lib/test/cjkencodings/iso2022_kr.txt
36929
 
--- /dev/null
36930
 
+++ b/Lib/test/cjkencodings/iso2022_kr.txt
36931
 
@@ -0,0 +1,7 @@
36932
 
+$)C!] FD@L=c(Python)@: 9h?l1b =10m, 0-7BGQ GA7N1W7!9V >p>n@T4O4Y. FD@L=c@:
36933
 
+H?@2@{@N 0m<vAX 5%@LEM 18A6?M 0#4\GOAv88 H?@2@{@N 04C<AvGbGA7N1W7!9V@;
36934
 
+Av?xGU4O4Y. FD@L=c@G ?l>F(iPd:)GQ 9.9}0z 5?@{ E8@LGN, 1W8.0m @NEMGA8.FC
36935
 
+H/0f@: FD@L=c@; =:E)83FC0z ?)7/ :P>_?!<-?M 4k:N:P@G GC7'F{?!<-@G :|8%
36936
 
+>VGC8.DI@L<G 039_@; GR <v @V4B @L;s@{@N >p>n7N 885i>nA]4O4Y.
36937
 
+
36938
 
+!YC90!3!: 3/>F6s >1~ E-! 1]>x@L @|4O4Y. 1W710E 4Y.
36939
 
diff -r 8527427914a2 Lib/test/decimaltestdata/extra.decTest
36940
 
--- a/Lib/test/decimaltestdata/extra.decTest
36941
 
+++ b/Lib/test/decimaltestdata/extra.decTest
36942
 
@@ -222,12 +222,25 @@
36943
 
 extr1701 power 100.0 -557.71e-742888888 -> 1.000000000000000 Inexact Rounded
36944
 
 extr1702 power 10 1e-100 -> 1.000000000000000 Inexact Rounded
36945
 
 
36946
 
+-- Another one (see issue #12080).  Thanks again to Stefan Krah.
36947
 
+extr1703 power 4 -1.2e-999999999 -> 1.000000000000000 Inexact Rounded
36948
 
+
36949
 
 -- A couple of interesting exact cases for power.  Note that the specification
36950
 
 -- requires these to be reported as Inexact.
36951
 
 extr1710 power 1e375 56e-3 -> 1.000000000000000E+21 Inexact Rounded
36952
 
 extr1711 power 10000 0.75 -> 1000.000000000000 Inexact Rounded
36953
 
 extr1712 power 1e-24 0.875 -> 1.000000000000000E-21 Inexact Rounded
36954
 
 
36955
 
+-- Some more exact cases, exercising power with negative second argument.
36956
 
+extr1720 power 400 -0.5 -> 0.05000000000000000 Inexact Rounded
36957
 
+extr1721 power 4096 -0.75 -> 0.001953125000000000 Inexact Rounded
36958
 
+extr1722 power 625e4 -0.25 -> 0.02000000000000000 Inexact Rounded
36959
 
+
36960
 
+-- Nonexact cases, to exercise some of the early exit conditions from
36961
 
+-- _power_exact.
36962
 
+extr1730 power 2048 -0.75 -> 0.003284751622084822 Inexact Rounded
36963
 
+
36964
 
+
36965
 
 -- Tests for the is_* boolean operations
36966
 
 precision: 9
36967
 
 maxExponent: 999
36968
 
diff -r 8527427914a2 Lib/test/nokia.pem
36969
 
--- /dev/null
36970
 
+++ b/Lib/test/nokia.pem
36971
 
@@ -0,0 +1,31 @@
36972
 
+# Certificate for projects.developer.nokia.com:443 (see issue 13034)
36973
 
+-----BEGIN CERTIFICATE-----
36974
 
+MIIFLDCCBBSgAwIBAgIQLubqdkCgdc7lAF9NfHlUmjANBgkqhkiG9w0BAQUFADCB
36975
 
+vDELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL
36976
 
+ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2Ug
36977
 
+YXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykxMDE2MDQGA1UEAxMt
36978
 
+VmVyaVNpZ24gQ2xhc3MgMyBJbnRlcm5hdGlvbmFsIFNlcnZlciBDQSAtIEczMB4X
36979
 
+DTExMDkyMTAwMDAwMFoXDTEyMDkyMDIzNTk1OVowcTELMAkGA1UEBhMCRkkxDjAM
36980
 
+BgNVBAgTBUVzcG9vMQ4wDAYDVQQHFAVFc3BvbzEOMAwGA1UEChQFTm9raWExCzAJ
36981
 
+BgNVBAsUAkJJMSUwIwYDVQQDFBxwcm9qZWN0cy5kZXZlbG9wZXIubm9raWEuY29t
36982
 
+MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCr92w1bpHYSYxUEx8N/8Iddda2
36983
 
+lYi+aXNtQfV/l2Fw9Ykv3Ipw4nLeGTj18FFlAZgMdPRlgrzF/NNXGw/9l3/qKdow
36984
 
+CypkQf8lLaxb9Ze1E/KKmkRJa48QTOqvo6GqKuTI6HCeGlG1RxDb8YSKcQWLiytn
36985
 
+yj3Wp4MgRQO266xmMQIDAQABo4IB9jCCAfIwQQYDVR0RBDowOIIccHJvamVjdHMu
36986
 
+ZGV2ZWxvcGVyLm5va2lhLmNvbYIYcHJvamVjdHMuZm9ydW0ubm9raWEuY29tMAkG
36987
 
+A1UdEwQCMAAwCwYDVR0PBAQDAgWgMEEGA1UdHwQ6MDgwNqA0oDKGMGh0dHA6Ly9T
36988
 
+VlJJbnRsLUczLWNybC52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNybDBEBgNVHSAE
36989
 
+PTA7MDkGC2CGSAGG+EUBBxcDMCowKAYIKwYBBQUHAgEWHGh0dHBzOi8vd3d3LnZl
36990
 
+cmlzaWduLmNvbS9ycGEwKAYDVR0lBCEwHwYJYIZIAYb4QgQBBggrBgEFBQcDAQYI
36991
 
+KwYBBQUHAwIwcgYIKwYBBQUHAQEEZjBkMCQGCCsGAQUFBzABhhhodHRwOi8vb2Nz
36992
 
+cC52ZXJpc2lnbi5jb20wPAYIKwYBBQUHMAKGMGh0dHA6Ly9TVlJJbnRsLUczLWFp
36993
 
+YS52ZXJpc2lnbi5jb20vU1ZSSW50bEczLmNlcjBuBggrBgEFBQcBDARiMGChXqBc
36994
 
+MFowWDBWFglpbWFnZS9naWYwITAfMAcGBSsOAwIaBBRLa7kolgYMu9BSOJsprEsH
36995
 
+iyEFGDAmFiRodHRwOi8vbG9nby52ZXJpc2lnbi5jb20vdnNsb2dvMS5naWYwDQYJ
36996
 
+KoZIhvcNAQEFBQADggEBACQuPyIJqXwUyFRWw9x5yDXgMW4zYFopQYOw/ItRY522
36997
 
+O5BsySTh56BWS6mQB07XVfxmYUGAvRQDA5QHpmY8jIlNwSmN3s8RKo+fAtiNRlcL
36998
 
+x/mWSfuMs3D/S6ev3D6+dpEMZtjrhOdctsarMKp8n/hPbwhAbg5hVjpkW5n8vz2y
36999
 
+0KxvvkA1AxpLwpVv7OlK17ttzIHw8bp9HTlHBU5s8bKz4a565V/a5HI0CSEv/+0y
37000
 
+ko4/ghTnZc1CkmUngKKeFMSah/mT/xAh8XnE2l1AazFa8UKuYki1e+ArHaGZc4ix
37001
 
+UYOtiRphwfuYQhRZ7qX9q2MMkCMI65XNK/SaFrAbbG0=
37002
 
+-----END CERTIFICATE-----
37003
 
diff -r 8527427914a2 Lib/test/pickletester.py
37004
 
--- a/Lib/test/pickletester.py
37005
 
+++ b/Lib/test/pickletester.py
37006
 
@@ -124,6 +124,21 @@
37007
 
 class use_metaclass(object):
37008
 
     __metaclass__ = metaclass
37009
 
 
37010
 
+class pickling_metaclass(type):
37011
 
+    def __eq__(self, other):
37012
 
+        return (type(self) == type(other) and
37013
 
+                self.reduce_args == other.reduce_args)
37014
 
+
37015
 
+    def __reduce__(self):
37016
 
+        return (create_dynamic_class, self.reduce_args)
37017
 
+
37018
 
+    __hash__ = None
37019
 
+
37020
 
+def create_dynamic_class(name, bases):
37021
 
+    result = pickling_metaclass(name, bases, dict())
37022
 
+    result.reduce_args = (name, bases)
37023
 
+    return result
37024
 
+
37025
 
 # DATA0 .. DATA2 are the pickles we expect under the various protocols, for
37026
 
 # the object returned by create_data().
37027
 
 
37028
 
@@ -609,6 +624,14 @@
37029
 
             b = self.loads(s)
37030
 
             self.assertEqual(a.__class__, b.__class__)
37031
 
 
37032
 
+    def test_dynamic_class(self):
37033
 
+        a = create_dynamic_class("my_dynamic_class", (object,))
37034
 
+        copy_reg.pickle(pickling_metaclass, pickling_metaclass.__reduce__)
37035
 
+        for proto in protocols:
37036
 
+            s = self.dumps(a, proto)
37037
 
+            b = self.loads(s)
37038
 
+            self.assertEqual(a, b)
37039
 
+
37040
 
     def test_structseq(self):
37041
 
         import time
37042
 
         import os
37043
 
diff -r 8527427914a2 Lib/test/regex_tests.py
37044
 
--- a/Lib/test/regex_tests.py
37045
 
+++ /dev/null
37046
 
@@ -1,287 +0,0 @@
37047
 
-# Regex test suite and benchmark suite v1.5a2
37048
 
-# Due to the use of r"aw" strings, this file will
37049
 
-# only work with Python 1.5 or higher.
37050
 
-
37051
 
-# The 3 possible outcomes for each pattern
37052
 
-[SUCCEED, FAIL, SYNTAX_ERROR] = range(3)
37053
 
-
37054
 
-# Benchmark suite (needs expansion)
37055
 
-#
37056
 
-# The benchmark suite does not test correctness, just speed.  The
37057
 
-# first element of each tuple is the regex pattern; the second is a
37058
 
-# string to match it against.  The benchmarking code will embed the
37059
 
-# second string inside several sizes of padding, to test how regex
37060
 
-# matching performs on large strings.
37061
 
-
37062
 
-benchmarks = [
37063
 
-        ('Python', 'Python'),                     # Simple text literal
37064
 
-        ('.*Python', 'Python'),                   # Bad text literal
37065
 
-        ('.*Python.*', 'Python'),                 # Worse text literal
37066
 
-        ('.*\\(Python\\)', 'Python'),             # Bad text literal with grouping
37067
 
-
37068
 
-        ('(Python\\|Perl\\|Tcl', 'Perl'),          # Alternation
37069
 
-        ('\\(Python\\|Perl\\|Tcl\\)', 'Perl'),     # Grouped alternation
37070
 
-        ('\\(Python\\)\\1', 'PythonPython'),       # Backreference
37071
 
-#       ('\\([0a-z][a-z]*,\\)+', 'a5,b7,c9,'),     # Disable the fastmap optimization
37072
 
-        ('\\([a-z][a-z0-9]*,\\)+', 'a5,b7,c9,')    # A few sets
37073
 
-]
37074
 
-
37075
 
-# Test suite (for verifying correctness)
37076
 
-#
37077
 
-# The test suite is a list of 5- or 3-tuples.  The 5 parts of a
37078
 
-# complete tuple are:
37079
 
-# element 0: a string containing the pattern
37080
 
-#         1: the string to match against the pattern
37081
 
-#         2: the expected result (SUCCEED, FAIL, SYNTAX_ERROR)
37082
 
-#         3: a string that will be eval()'ed to produce a test string.
37083
 
-#            This is an arbitrary Python expression; the available
37084
 
-#            variables are "found" (the whole match), and "g1", "g2", ...
37085
 
-#            up to "g10" contain the contents of each group, or the
37086
 
-#            string 'None' if the group wasn't given a value.
37087
 
-#         4: The expected result of evaluating the expression.
37088
 
-#            If the two don't match, an error is reported.
37089
 
-#
37090
 
-# If the regex isn't expected to work, the latter two elements can be omitted.
37091
 
-
37092
 
-tests = [
37093
 
-('abc', 'abc', SUCCEED,
37094
 
- 'found', 'abc'),
37095
 
-('abc', 'xbc', FAIL),
37096
 
-('abc', 'axc', FAIL),
37097
 
-('abc', 'abx', FAIL),
37098
 
-('abc', 'xabcy', SUCCEED,
37099
 
- 'found', 'abc'),
37100
 
-('abc', 'ababc', SUCCEED,
37101
 
- 'found', 'abc'),
37102
 
-('ab*c', 'abc', SUCCEED,
37103
 
- 'found', 'abc'),
37104
 
-('ab*bc', 'abc', SUCCEED,
37105
 
- 'found', 'abc'),
37106
 
-('ab*bc', 'abbc', SUCCEED,
37107
 
- 'found', 'abbc'),
37108
 
-('ab*bc', 'abbbbc', SUCCEED,
37109
 
- 'found', 'abbbbc'),
37110
 
-('ab+bc', 'abbc', SUCCEED,
37111
 
- 'found', 'abbc'),
37112
 
-('ab+bc', 'abc', FAIL),
37113
 
-('ab+bc', 'abq', FAIL),
37114
 
-('ab+bc', 'abbbbc', SUCCEED,
37115
 
- 'found', 'abbbbc'),
37116
 
-('ab?bc', 'abbc', SUCCEED,
37117
 
- 'found', 'abbc'),
37118
 
-('ab?bc', 'abc', SUCCEED,
37119
 
- 'found', 'abc'),
37120
 
-('ab?bc', 'abbbbc', FAIL),
37121
 
-('ab?c', 'abc', SUCCEED,
37122
 
- 'found', 'abc'),
37123
 
-('^abc$', 'abc', SUCCEED,
37124
 
- 'found', 'abc'),
37125
 
-('^abc$', 'abcc', FAIL),
37126
 
-('^abc', 'abcc', SUCCEED,
37127
 
- 'found', 'abc'),
37128
 
-('^abc$', 'aabc', FAIL),
37129
 
-('abc$', 'aabc', SUCCEED,
37130
 
- 'found', 'abc'),
37131
 
-('^', 'abc', SUCCEED,
37132
 
- 'found+"-"', '-'),
37133
 
-('$', 'abc', SUCCEED,
37134
 
- 'found+"-"', '-'),
37135
 
-('a.c', 'abc', SUCCEED,
37136
 
- 'found', 'abc'),
37137
 
-('a.c', 'axc', SUCCEED,
37138
 
- 'found', 'axc'),
37139
 
-('a.*c', 'axyzc', SUCCEED,
37140
 
- 'found', 'axyzc'),
37141
 
-('a.*c', 'axyzd', FAIL),
37142
 
-('a[bc]d', 'abc', FAIL),
37143
 
-('a[bc]d', 'abd', SUCCEED,
37144
 
- 'found', 'abd'),
37145
 
-('a[b-d]e', 'abd', FAIL),
37146
 
-('a[b-d]e', 'ace', SUCCEED,
37147
 
- 'found', 'ace'),
37148
 
-('a[b-d]', 'aac', SUCCEED,
37149
 
- 'found', 'ac'),
37150
 
-('a[-b]', 'a-', SUCCEED,
37151
 
- 'found', 'a-'),
37152
 
-('a[b-]', 'a-', SUCCEED,
37153
 
- 'found', 'a-'),
37154
 
-('a[]b', '-', SYNTAX_ERROR),
37155
 
-('a[', '-', SYNTAX_ERROR),
37156
 
-('a\\', '-', SYNTAX_ERROR),
37157
 
-('abc\\)', '-', SYNTAX_ERROR),
37158
 
-('\\(abc', '-', SYNTAX_ERROR),
37159
 
-('a]', 'a]', SUCCEED,
37160
 
- 'found', 'a]'),
37161
 
-('a[]]b', 'a]b', SUCCEED,
37162
 
- 'found', 'a]b'),
37163
 
-('a[^bc]d', 'aed', SUCCEED,
37164
 
- 'found', 'aed'),
37165
 
-('a[^bc]d', 'abd', FAIL),
37166
 
-('a[^-b]c', 'adc', SUCCEED,
37167
 
- 'found', 'adc'),
37168
 
-('a[^-b]c', 'a-c', FAIL),
37169
 
-('a[^]b]c', 'a]c', FAIL),
37170
 
-('a[^]b]c', 'adc', SUCCEED,
37171
 
- 'found', 'adc'),
37172
 
-('\\ba\\b', 'a-', SUCCEED,
37173
 
- '"-"', '-'),
37174
 
-('\\ba\\b', '-a', SUCCEED,
37175
 
- '"-"', '-'),
37176
 
-('\\ba\\b', '-a-', SUCCEED,
37177
 
- '"-"', '-'),
37178
 
-('\\by\\b', 'xy', FAIL),
37179
 
-('\\by\\b', 'yz', FAIL),
37180
 
-('\\by\\b', 'xyz', FAIL),
37181
 
-('ab\\|cd', 'abc', SUCCEED,
37182
 
- 'found', 'ab'),
37183
 
-('ab\\|cd', 'abcd', SUCCEED,
37184
 
- 'found', 'ab'),
37185
 
-('\\(\\)ef', 'def', SUCCEED,
37186
 
- 'found+"-"+g1', 'ef-'),
37187
 
-('$b', 'b', FAIL),
37188
 
-('a(b', 'a(b', SUCCEED,
37189
 
- 'found+"-"+g1', 'a(b-None'),
37190
 
-('a(*b', 'ab', SUCCEED,
37191
 
- 'found', 'ab'),
37192
 
-('a(*b', 'a((b', SUCCEED,
37193
 
- 'found', 'a((b'),
37194
 
-('a\\\\b', 'a\\b', SUCCEED,
37195
 
- 'found', 'a\\b'),
37196
 
-('\\(\\(a\\)\\)', 'abc', SUCCEED,
37197
 
- 'found+"-"+g1+"-"+g2', 'a-a-a'),
37198
 
-('\\(a\\)b\\(c\\)', 'abc', SUCCEED,
37199
 
- 'found+"-"+g1+"-"+g2', 'abc-a-c'),
37200
 
-('a+b+c', 'aabbabc', SUCCEED,
37201
 
- 'found', 'abc'),
37202
 
-('\\(a+\\|b\\)*', 'ab', SUCCEED,
37203
 
- 'found+"-"+g1', 'ab-b'),
37204
 
-('\\(a+\\|b\\)+', 'ab', SUCCEED,
37205
 
- 'found+"-"+g1', 'ab-b'),
37206
 
-('\\(a+\\|b\\)?', 'ab', SUCCEED,
37207
 
- 'found+"-"+g1', 'a-a'),
37208
 
-('\\)\\(', '-', SYNTAX_ERROR),
37209
 
-('[^ab]*', 'cde', SUCCEED,
37210
 
- 'found', 'cde'),
37211
 
-('abc', '', FAIL),
37212
 
-('a*', '', SUCCEED,
37213
 
- 'found', ''),
37214
 
-('a\\|b\\|c\\|d\\|e', 'e', SUCCEED,
37215
 
- 'found', 'e'),
37216
 
-('\\(a\\|b\\|c\\|d\\|e\\)f', 'ef', SUCCEED,
37217
 
- 'found+"-"+g1', 'ef-e'),
37218
 
-('abcd*efg', 'abcdefg', SUCCEED,
37219
 
- 'found', 'abcdefg'),
37220
 
-('ab*', 'xabyabbbz', SUCCEED,
37221
 
- 'found', 'ab'),
37222
 
-('ab*', 'xayabbbz', SUCCEED,
37223
 
- 'found', 'a'),
37224
 
-('\\(ab\\|cd\\)e', 'abcde', SUCCEED,
37225
 
- 'found+"-"+g1', 'cde-cd'),
37226
 
-('[abhgefdc]ij', 'hij', SUCCEED,
37227
 
- 'found', 'hij'),
37228
 
-('^\\(ab\\|cd\\)e', 'abcde', FAIL,
37229
 
- 'xg1y', 'xy'),
37230
 
-('\\(abc\\|\\)ef', 'abcdef', SUCCEED,
37231
 
- 'found+"-"+g1', 'ef-'),
37232
 
-('\\(a\\|b\\)c*d', 'abcd', SUCCEED,
37233
 
- 'found+"-"+g1', 'bcd-b'),
37234
 
-('\\(ab\\|ab*\\)bc', 'abc', SUCCEED,
37235
 
- 'found+"-"+g1', 'abc-a'),
37236
 
-('a\\([bc]*\\)c*', 'abc', SUCCEED,
37237
 
- 'found+"-"+g1', 'abc-bc'),
37238
 
-('a\\([bc]*\\)\\(c*d\\)', 'abcd', SUCCEED,
37239
 
- 'found+"-"+g1+"-"+g2', 'abcd-bc-d'),
37240
 
-('a\\([bc]+\\)\\(c*d\\)', 'abcd', SUCCEED,
37241
 
- 'found+"-"+g1+"-"+g2', 'abcd-bc-d'),
37242
 
-('a\\([bc]*\\)\\(c+d\\)', 'abcd', SUCCEED,
37243
 
- 'found+"-"+g1+"-"+g2', 'abcd-b-cd'),
37244
 
-('a[bcd]*dcdcde', 'adcdcde', SUCCEED,
37245
 
- 'found', 'adcdcde'),
37246
 
-('a[bcd]+dcdcde', 'adcdcde', FAIL),
37247
 
-('\\(ab\\|a\\)b*c', 'abc', SUCCEED,
37248
 
- 'found+"-"+g1', 'abc-ab'),
37249
 
-('\\(\\(a\\)\\(b\\)c\\)\\(d\\)', 'abcd', SUCCEED,
37250
 
- 'g1+"-"+g2+"-"+g3+"-"+g4', 'abc-a-b-d'),
37251
 
-('[a-zA-Z_][a-zA-Z0-9_]*', 'alpha', SUCCEED,
37252
 
- 'found', 'alpha'),
37253
 
-('^a\\(bc+\\|b[eh]\\)g\\|.h$', 'abh', SUCCEED,
37254
 
- 'found+"-"+g1', 'bh-None'),
37255
 
-('\\(bc+d$\\|ef*g.\\|h?i\\(j\\|k\\)\\)', 'effgz', SUCCEED,
37256
 
- 'found+"-"+g1+"-"+g2', 'effgz-effgz-None'),
37257
 
-('\\(bc+d$\\|ef*g.\\|h?i\\(j\\|k\\)\\)', 'ij', SUCCEED,
37258
 
- 'found+"-"+g1+"-"+g2', 'ij-ij-j'),
37259
 
-('\\(bc+d$\\|ef*g.\\|h?i\\(j\\|k\\)\\)', 'effg', FAIL),
37260
 
-('\\(bc+d$\\|ef*g.\\|h?i\\(j\\|k\\)\\)', 'bcdd', FAIL),
37261
 
-('\\(bc+d$\\|ef*g.\\|h?i\\(j\\|k\\)\\)', 'reffgz', SUCCEED,
37262
 
- 'found+"-"+g1+"-"+g2', 'effgz-effgz-None'),
37263
 
-('\\(\\(\\(\\(\\(\\(\\(\\(\\(a\\)\\)\\)\\)\\)\\)\\)\\)\\)', 'a', SUCCEED,
37264
 
- 'found', 'a'),
37265
 
-('multiple words of text', 'uh-uh', FAIL),
37266
 
-('multiple words', 'multiple words, yeah', SUCCEED,
37267
 
- 'found', 'multiple words'),
37268
 
-('\\(.*\\)c\\(.*\\)', 'abcde', SUCCEED,
37269
 
- 'found+"-"+g1+"-"+g2', 'abcde-ab-de'),
37270
 
-('(\\(.*\\), \\(.*\\))', '(a, b)', SUCCEED,
37271
 
- 'g2+"-"+g1', 'b-a'),
37272
 
-('[k]', 'ab', FAIL),
37273
 
-('a[-]?c', 'ac', SUCCEED,
37274
 
- 'found', 'ac'),
37275
 
-('\\(abc\\)\\1', 'abcabc', SUCCEED,
37276
 
- 'g1', 'abc'),
37277
 
-('\\([a-c]*\\)\\1', 'abcabc', SUCCEED,
37278
 
- 'g1', 'abc'),
37279
 
-('^\\(.+\\)?B', 'AB', SUCCEED,
37280
 
- 'g1', 'A'),
37281
 
-('\\(a+\\).\\1$', 'aaaaa', SUCCEED,
37282
 
- 'found+"-"+g1', 'aaaaa-aa'),
37283
 
-('^\\(a+\\).\\1$', 'aaaa', FAIL),
37284
 
-('\\(abc\\)\\1', 'abcabc', SUCCEED,
37285
 
- 'found+"-"+g1', 'abcabc-abc'),
37286
 
-('\\([a-c]+\\)\\1', 'abcabc', SUCCEED,
37287
 
- 'found+"-"+g1', 'abcabc-abc'),
37288
 
-('\\(a\\)\\1', 'aa', SUCCEED,
37289
 
- 'found+"-"+g1', 'aa-a'),
37290
 
-('\\(a+\\)\\1', 'aa', SUCCEED,
37291
 
- 'found+"-"+g1', 'aa-a'),
37292
 
-('\\(a+\\)+\\1', 'aa', SUCCEED,
37293
 
- 'found+"-"+g1', 'aa-a'),
37294
 
-('\\(a\\).+\\1', 'aba', SUCCEED,
37295
 
- 'found+"-"+g1', 'aba-a'),
37296
 
-('\\(a\\)ba*\\1', 'aba', SUCCEED,
37297
 
- 'found+"-"+g1', 'aba-a'),
37298
 
-('\\(aa\\|a\\)a\\1$', 'aaa', SUCCEED,
37299
 
- 'found+"-"+g1', 'aaa-a'),
37300
 
-('\\(a\\|aa\\)a\\1$', 'aaa', SUCCEED,
37301
 
- 'found+"-"+g1', 'aaa-a'),
37302
 
-('\\(a+\\)a\\1$', 'aaa', SUCCEED,
37303
 
- 'found+"-"+g1', 'aaa-a'),
37304
 
-('\\([abc]*\\)\\1', 'abcabc', SUCCEED,
37305
 
- 'found+"-"+g1', 'abcabc-abc'),
37306
 
-('\\(a\\)\\(b\\)c\\|ab', 'ab', SUCCEED,
37307
 
- 'found+"-"+g1+"-"+g2', 'ab-None-None'),
37308
 
-('\\(a\\)+x', 'aaax', SUCCEED,
37309
 
- 'found+"-"+g1', 'aaax-a'),
37310
 
-('\\([ac]\\)+x', 'aacx', SUCCEED,
37311
 
- 'found+"-"+g1', 'aacx-c'),
37312
 
-('\\([^/]*/\\)*sub1/', 'd:msgs/tdir/sub1/trial/away.cpp', SUCCEED,
37313
 
- 'found+"-"+g1', 'd:msgs/tdir/sub1/-tdir/'),
37314
 
-('\\([^.]*\\)\\.\\([^:]*\\):[T ]+\\(.*\\)', 'track1.title:TBlah blah blah', SUCCEED,
37315
 
- 'found+"-"+g1+"-"+g2+"-"+g3', 'track1.title:TBlah blah blah-track1-title-Blah blah blah'),
37316
 
-('\\([^N]*N\\)+', 'abNNxyzN', SUCCEED,
37317
 
- 'found+"-"+g1', 'abNNxyzN-xyzN'),
37318
 
-('\\([^N]*N\\)+', 'abNNxyz', SUCCEED,
37319
 
- 'found+"-"+g1', 'abNN-N'),
37320
 
-('\\([abc]*\\)x', 'abcx', SUCCEED,
37321
 
- 'found+"-"+g1', 'abcx-abc'),
37322
 
-('\\([abc]*\\)x', 'abc', FAIL),
37323
 
-('\\([xyz]*\\)x', 'abcx', SUCCEED,
37324
 
- 'found+"-"+g1', 'x-'),
37325
 
-('\\(a\\)+b\\|aac', 'aac', SUCCEED,
37326
 
- 'found+"-"+g1', 'aac-None'),
37327
 
-('\<a', 'a', SUCCEED, 'found', 'a'),
37328
 
-('\<a', '!', FAIL),
37329
 
-('a\<b', 'ab', FAIL),
37330
 
-('a\>', 'ab', FAIL),
37331
 
-('a\>', 'a!', SUCCEED, 'found', 'a'),
37332
 
-('a\>', 'a', SUCCEED, 'found', 'a'),
37333
 
-]
37334
 
diff -r 8527427914a2 Lib/test/regrtest.py
37335
 
--- a/Lib/test/regrtest.py
37336
 
+++ b/Lib/test/regrtest.py
37337
 
@@ -1076,6 +1076,13 @@
37338
 
     filecmp._cache.clear()
37339
 
     struct._clearcache()
37340
 
     doctest.master = None
37341
 
+    try:
37342
 
+        import ctypes
37343
 
+    except ImportError:
37344
 
+        # Don't worry about resetting the cache if ctypes is not supported
37345
 
+        pass
37346
 
+    else:
37347
 
+        ctypes._reset_cache()
37348
 
 
37349
 
     # Collect cyclic trash.
37350
 
     gc.collect()
37351
 
diff -r 8527427914a2 Lib/test/svn_python_org_https_cert.pem
37352
 
--- a/Lib/test/svn_python_org_https_cert.pem
37353
 
+++ /dev/null
37354
 
@@ -1,31 +0,0 @@
37355
 
------BEGIN CERTIFICATE-----
37356
 
-MIIFQTCCBCmgAwIBAgIQL2qw7lpsHqTLcBh1PVjsaTANBgkqhkiG9w0BAQUFADCB
37357
 
-lzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug
37358
 
-Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho
37359
 
-dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3Qt
37360
 
-SGFyZHdhcmUwHhcNMDcwNDEwMDAwMDAwWhcNMTAwNDA5MjM1OTU5WjCBvjELMAkG
37361
 
-A1UEBhMCVVMxDjAMBgNVBBETBTAxOTM4MRYwFAYDVQQIEw1NYXNzYWNodXNldHRz
37362
 
-MREwDwYDVQQHEwhJcHN3aXRjaDEMMAoGA1UECRMDbi9hMQwwCgYDVQQSEwM2NTMx
37363
 
-IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMRowGAYDVQQLExFD
37364
 
-b21vZG8gSW5zdGFudFNTTDEXMBUGA1UEAxMOc3ZuLnB5dGhvbi5vcmcwgZ8wDQYJ
37365
 
-KoZIhvcNAQEBBQADgY0AMIGJAoGBAMFOfFeLpiIN9UzTCehCgQ4W3ufaq524qPoX
37366
 
-00iNDiI/ehd6kC0BXIP5/y9lPoMn7nRsjdjczUaVmlPWG8BhvADK3ZZIm7m/3mZW
37367
 
-O/+C5vGE9YuOqIKe0VoNz/cZaYkz+C2xmOwDTp6a+ls29jjUfoxMd9gtGtuOp7s+
37368
 
-IouVD3wZAgMBAAGjggHiMIIB3jAfBgNVHSMEGDAWgBShcl8mGyiYQ5VdBzfVhZad
37369
 
-S9LDRTAdBgNVHQ4EFgQUkeNAqLbnKq86W/ghBV9xfC+7h9swDgYDVR0PAQH/BAQD
37370
 
-AgWgMAwGA1UdEwEB/wQCMAAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMC
37371
 
-MBEGCWCGSAGG+EIBAQQEAwIGwDBGBgNVHSAEPzA9MDsGDCsGAQQBsjEBAgEDBDAr
37372
 
-MCkGCCsGAQUFBwIBFh1odHRwczovL3NlY3VyZS5jb21vZG8ubmV0L0NQUzB7BgNV
37373
 
-HR8EdDByMDigNqA0hjJodHRwOi8vY3JsLmNvbW9kb2NhLmNvbS9VVE4tVVNFUkZp
37374
 
-cnN0LUhhcmR3YXJlLmNybDA2oDSgMoYwaHR0cDovL2NybC5jb21vZG8ubmV0L1VU
37375
 
-Ti1VU0VSRmlyc3QtSGFyZHdhcmUuY3JsMIGGBggrBgEFBQcBAQR6MHgwOwYIKwYB
37376
 
-BQUHMAKGL2h0dHA6Ly9jcnQuY29tb2RvY2EuY29tL1VUTkFkZFRydXN0U2VydmVy
37377
 
-Q0EuY3J0MDkGCCsGAQUFBzAChi1odHRwOi8vY3J0LmNvbW9kby5uZXQvVVROQWRk
37378
 
-VHJ1c3RTZXJ2ZXJDQS5jcnQwDQYJKoZIhvcNAQEFBQADggEBAFBxEOeKr5+vurzE
37379
 
-6DiP4THhQsp+LA0+tnZ5rkV7RODAmF6strjONl3FKWGSqrucWNnFTo/HMgrgZJHQ
37380
 
-CunxrJf4J5CVz/CvGlfdBDmCpYz5agc8b7EJhmM2WoWSqC+5CYIXuRzUuYcKWjPt
37381
 
-3LV312Zil4BaeZ+wv4SKR8cL8jsB/sj8QxLxrZjOGXtVX3J95AnrY7BMDjuCBDxx
37382
 
-dUUOUJpdJ4undAG1of0ZsPOGJ5viSJYNeJ9iOjSua24mfZ2aQ/mULirnqF8Gkr38
37383
 
-CMlC8io5ct5NnLgkWmPr0FS5UyalLeWXiopS6hMofvu952VGLyacLgMl7d9S5AaL
37384
 
-mxMHHeo=
37385
 
------END CERTIFICATE-----
37386
 
diff -r 8527427914a2 Lib/test/test_StringIO.py
37387
 
--- a/Lib/test/test_StringIO.py
37388
 
+++ b/Lib/test/test_StringIO.py
37389
 
@@ -4,6 +4,7 @@
37390
 
 import StringIO
37391
 
 import cStringIO
37392
 
 import types
37393
 
+import array
37394
 
 from test import test_support
37395
 
 
37396
 
 
37397
 
@@ -127,6 +128,34 @@
37398
 
 class TestcStringIO(TestGenericStringIO):
37399
 
     MODULE = cStringIO
37400
 
 
37401
 
+    def test_array_support(self):
37402
 
+        # Issue #1730114: cStringIO should accept array objects
37403
 
+        a = array.array('B', [0,1,2])
37404
 
+        f = self.MODULE.StringIO(a)
37405
 
+        self.assertEqual(f.getvalue(), '\x00\x01\x02')
37406
 
+
37407
 
+    def test_unicode(self):
37408
 
+
37409
 
+        if not test_support.have_unicode: return
37410
 
+
37411
 
+        # The cStringIO module converts Unicode strings to character
37412
 
+        # strings when writing them to cStringIO objects.
37413
 
+        # Check that this works.
37414
 
+
37415
 
+        f = self.MODULE.StringIO()
37416
 
+        f.write(u'abcde')
37417
 
+        s = f.getvalue()
37418
 
+        self.assertEqual(s, 'abcde')
37419
 
+        self.assertEqual(type(s), str)
37420
 
+
37421
 
+        f = self.MODULE.StringIO(u'abcde')
37422
 
+        s = f.getvalue()
37423
 
+        self.assertEqual(s, 'abcde')
37424
 
+        self.assertEqual(type(s), str)
37425
 
+
37426
 
+        self.assertRaises(UnicodeEncodeError, self.MODULE.StringIO, u'\xf4')
37427
 
+
37428
 
+
37429
 
 import sys
37430
 
 if sys.platform.startswith('java'):
37431
 
     # Jython doesn't have a buffer object, so we just do a useless
37432
 
diff -r 8527427914a2 Lib/test/test_aifc.py
37433
 
--- a/Lib/test/test_aifc.py
37434
 
+++ b/Lib/test/test_aifc.py
37435
 
@@ -1,6 +1,7 @@
37436
 
 from test.test_support import findfile, run_unittest, TESTFN
37437
 
 import unittest
37438
 
 import os
37439
 
+import io
37440
 
 
37441
 
 import aifc
37442
 
 
37443
 
@@ -107,8 +108,45 @@
37444
 
         self.assertEqual(testfile.closed, True)
37445
 
 
37446
 
 
37447
 
+class AIFCLowLevelTest(unittest.TestCase):
37448
 
+
37449
 
+    def test_read_written(self):
37450
 
+        def read_written(self, what):
37451
 
+            f = io.BytesIO()
37452
 
+            getattr(aifc, '_write_' + what)(f, x)
37453
 
+            f.seek(0)
37454
 
+            return getattr(aifc, '_read_' + what)(f)
37455
 
+        for x in (-1, 0, 0.1, 1):
37456
 
+            self.assertEqual(read_written(x, 'float'), x)
37457
 
+        for x in (float('NaN'), float('Inf')):
37458
 
+            self.assertEqual(read_written(x, 'float'), aifc._HUGE_VAL)
37459
 
+        for x in (b'', b'foo', b'a' * 255):
37460
 
+            self.assertEqual(read_written(x, 'string'), x)
37461
 
+        for x in (-0x7FFFFFFF, -1, 0, 1, 0x7FFFFFFF):
37462
 
+            self.assertEqual(read_written(x, 'long'), x)
37463
 
+        for x in (0, 1, 0xFFFFFFFF):
37464
 
+            self.assertEqual(read_written(x, 'ulong'), x)
37465
 
+        for x in (-0x7FFF, -1, 0, 1, 0x7FFF):
37466
 
+            self.assertEqual(read_written(x, 'short'), x)
37467
 
+        for x in (0, 1, 0xFFFF):
37468
 
+            self.assertEqual(read_written(x, 'ushort'), x)
37469
 
+
37470
 
+    def test_read_raises(self):
37471
 
+        f = io.BytesIO(b'\x00')
37472
 
+        self.assertRaises(EOFError, aifc._read_ulong, f)
37473
 
+        self.assertRaises(EOFError, aifc._read_long, f)
37474
 
+        self.assertRaises(EOFError, aifc._read_ushort, f)
37475
 
+        self.assertRaises(EOFError, aifc._read_short, f)
37476
 
+
37477
 
+    def test_write_long_string_raises(self):
37478
 
+        f = io.BytesIO()
37479
 
+        with self.assertRaises(ValueError):
37480
 
+            aifc._write_string(f, b'too long' * 255)
37481
 
+
37482
 
+
37483
 
 def test_main():
37484
 
     run_unittest(AIFCTest)
37485
 
+    run_unittest(AIFCLowLevelTest)
37486
 
 
37487
 
 
37488
 
 if __name__ == "__main__":
37489
 
diff -r 8527427914a2 Lib/test/test_argparse.py
37490
 
--- a/Lib/test/test_argparse.py
37491
 
+++ b/Lib/test/test_argparse.py
37492
 
@@ -1509,6 +1509,8 @@
37493
 
         return self.name == other.name
37494
 
 
37495
 
 
37496
 
+@unittest.skipIf(hasattr(os, 'geteuid') and os.geteuid() == 0,
37497
 
+                 "non-root user required")
37498
 
 class TestFileTypeW(TempDirMixin, ParserTestCase):
37499
 
     """Test the FileType option/argument type for writing files"""
37500
 
 
37501
 
@@ -2133,8 +2135,9 @@
37502
 
         parents = [self.abcd_parent, self.wxyz_parent]
37503
 
         parser = ErrorRaisingArgumentParser(parents=parents)
37504
 
         parser_help = parser.format_help()
37505
 
+        progname = self.main_program
37506
 
         self.assertEqual(parser_help, textwrap.dedent('''\
37507
 
-            usage: {} [-h] [-b B] [--d D] [--w W] [-y Y] a z
37508
 
+            usage: {}{}[-h] [-b B] [--d D] [--w W] [-y Y] a z
37509
 
 
37510
 
             positional arguments:
37511
 
               a
37512
 
@@ -2150,7 +2153,7 @@
37513
 
 
37514
 
             x:
37515
 
               -y Y
37516
 
-        '''.format(self.main_program)))
37517
 
+        '''.format(progname, ' ' if progname else '' )))
37518
 
 
37519
 
     def test_groups_parents(self):
37520
 
         parent = ErrorRaisingArgumentParser(add_help=False)
37521
 
@@ -2166,8 +2169,9 @@
37522
 
             ['-y', 'Y', '-z', 'Z'])
37523
 
 
37524
 
         parser_help = parser.format_help()
37525
 
+        progname = self.main_program
37526
 
         self.assertEqual(parser_help, textwrap.dedent('''\
37527
 
-            usage: {} [-h] [-w W] [-x X] [-y Y | -z Z]
37528
 
+            usage: {}{}[-h] [-w W] [-x X] [-y Y | -z Z]
37529
 
 
37530
 
             optional arguments:
37531
 
               -h, --help  show this help message and exit
37532
 
@@ -2179,7 +2183,7 @@
37533
 
 
37534
 
               -w W
37535
 
               -x X
37536
 
-        '''.format(self.main_program)))
37537
 
+        '''.format(progname, ' ' if progname else '' )))
37538
 
 
37539
 
 # ==============================
37540
 
 # Mutually exclusive group tests
37541
 
diff -r 8527427914a2 Lib/test/test_array.py
37542
 
--- a/Lib/test/test_array.py
37543
 
+++ b/Lib/test/test_array.py
37544
 
@@ -4,6 +4,7 @@
37545
 
 """
37546
 
 
37547
 
 import unittest
37548
 
+import warnings
37549
 
 from test import test_support
37550
 
 from weakref import proxy
37551
 
 import array, cStringIO
37552
 
@@ -783,7 +784,9 @@
37553
 
 
37554
 
     def test_subclass_with_kwargs(self):
37555
 
         # SF bug #1486663 -- this used to erroneously raise a TypeError
37556
 
-        ArraySubclassWithKwargs('b', newarg=1)
37557
 
+        with warnings.catch_warnings():
37558
 
+            warnings.filterwarnings("ignore", '', DeprecationWarning)
37559
 
+            ArraySubclassWithKwargs('b', newarg=1)
37560
 
 
37561
 
 
37562
 
 class StringTest(BaseTest):
37563
 
diff -r 8527427914a2 Lib/test/test_ast.py
37564
 
--- a/Lib/test/test_ast.py
37565
 
+++ b/Lib/test/test_ast.py
37566
 
@@ -20,10 +20,24 @@
37567
 
 # These tests are compiled through "exec"
37568
 
 # There should be atleast one test per statement
37569
 
 exec_tests = [
37570
 
+    # None
37571
 
+    "None",
37572
 
     # FunctionDef
37573
 
     "def f(): pass",
37574
 
+    # FunctionDef with arg
37575
 
+    "def f(a): pass",
37576
 
+    # FunctionDef with arg and default value
37577
 
+    "def f(a=0): pass",
37578
 
+    # FunctionDef with varargs
37579
 
+    "def f(*args): pass",
37580
 
+    # FunctionDef with kwargs
37581
 
+    "def f(**kwargs): pass",
37582
 
+    # FunctionDef with all kind of args
37583
 
+    "def f(a, b=1, c=None, d=[], e={}, *args, **kwargs): pass",
37584
 
     # ClassDef
37585
 
     "class C:pass",
37586
 
+    # ClassDef, new style class
37587
 
+    "class C(object): pass",
37588
 
     # Return
37589
 
     "def f():return 1",
37590
 
     # Delete
37591
 
@@ -68,6 +82,27 @@
37592
 
     "for a,b in c: pass",
37593
 
     "[(a,b) for a,b in c]",
37594
 
     "((a,b) for a,b in c)",
37595
 
+    "((a,b) for (a,b) in c)",
37596
 
+    # Multiline generator expression (test for .lineno & .col_offset)
37597
 
+    """(
37598
 
+    (
37599
 
+    Aa
37600
 
+    ,
37601
 
+       Bb
37602
 
+    )
37603
 
+    for
37604
 
+    Aa
37605
 
+    ,
37606
 
+    Bb in Cc
37607
 
+    )""",
37608
 
+    # dictcomp
37609
 
+    "{a : b for w in x for m in p if g}",
37610
 
+    # dictcomp with naked tuple
37611
 
+    "{a : b for v,w in x}",
37612
 
+    # setcomp
37613
 
+    "{r for l in x if g}",
37614
 
+    # setcomp with naked tuple
37615
 
+    "{r for l,m in x}",
37616
 
 ]
37617
 
 
37618
 
 # These are compiled through "single"
37619
 
@@ -80,6 +115,8 @@
37620
 
 # These are compiled through "eval"
37621
 
 # It should test all expressions
37622
 
 eval_tests = [
37623
 
+  # None
37624
 
+  "None",
37625
 
   # BoolOp
37626
 
   "a and b",
37627
 
   # BinOp
37628
 
@@ -90,6 +127,16 @@
37629
 
   "lambda:None",
37630
 
   # Dict
37631
 
   "{ 1:2 }",
37632
 
+  # Empty dict
37633
 
+  "{}",
37634
 
+  # Set
37635
 
+  "{None,}",
37636
 
+  # Multiline dict (test for .lineno & .col_offset)
37637
 
+  """{
37638
 
+      1
37639
 
+        :
37640
 
+          2
37641
 
+     }""",
37642
 
   # ListComp
37643
 
   "[a for b in c if d]",
37644
 
   # GeneratorExp
37645
 
@@ -114,8 +161,14 @@
37646
 
   "v",
37647
 
   # List
37648
 
   "[1,2,3]",
37649
 
+  # Empty list
37650
 
+  "[]",
37651
 
   # Tuple
37652
 
   "1,2,3",
37653
 
+  # Tuple
37654
 
+  "(1,2,3)",
37655
 
+  # Empty tuple
37656
 
+  "()",
37657
 
   # Combination
37658
 
   "a.b.c.d(a.b[1:2])",
37659
 
 
37660
 
@@ -141,6 +194,23 @@
37661
 
             elif value is not None:
37662
 
                 self._assertTrueorder(value, parent_pos)
37663
 
 
37664
 
+    def test_AST_objects(self):
37665
 
+        x = ast.AST()
37666
 
+        self.assertEqual(x._fields, ())
37667
 
+
37668
 
+        with self.assertRaises(AttributeError):
37669
 
+            x.vararg
37670
 
+
37671
 
+        with self.assertRaises(AttributeError):
37672
 
+            x.foobar = 21
37673
 
+
37674
 
+        with self.assertRaises(AttributeError):
37675
 
+            ast.AST(lineno=2)
37676
 
+
37677
 
+        with self.assertRaises(TypeError):
37678
 
+            # "_ast.AST constructor takes 0 positional arguments"
37679
 
+            ast.AST(2)
37680
 
+
37681
 
     def test_snippets(self):
37682
 
         for input, output, kind in ((exec_tests, exec_results, "exec"),
37683
 
                                     (single_tests, single_results, "single"),
37684
 
@@ -169,7 +239,83 @@
37685
 
         self.assertTrue(issubclass(ast.comprehension, ast.AST))
37686
 
         self.assertTrue(issubclass(ast.Gt, ast.AST))
37687
 
 
37688
 
+    def test_field_attr_existence(self):
37689
 
+        for name, item in ast.__dict__.iteritems():
37690
 
+            if isinstance(item, type) and name != 'AST' and name[0].isupper():
37691
 
+                x = item()
37692
 
+                if isinstance(x, ast.AST):
37693
 
+                    self.assertEqual(type(x._fields), tuple)
37694
 
+
37695
 
+    def test_arguments(self):
37696
 
+        x = ast.arguments()
37697
 
+        self.assertEqual(x._fields, ('args', 'vararg', 'kwarg', 'defaults'))
37698
 
+
37699
 
+        with self.assertRaises(AttributeError):
37700
 
+            x.vararg
37701
 
+
37702
 
+        x = ast.arguments(1, 2, 3, 4)
37703
 
+        self.assertEqual(x.vararg, 2)
37704
 
+
37705
 
+    def test_field_attr_writable(self):
37706
 
+        x = ast.Num()
37707
 
+        # We can assign to _fields
37708
 
+        x._fields = 666
37709
 
+        self.assertEqual(x._fields, 666)
37710
 
+
37711
 
+    def test_classattrs(self):
37712
 
+        x = ast.Num()
37713
 
+        self.assertEqual(x._fields, ('n',))
37714
 
+
37715
 
+        with self.assertRaises(AttributeError):
37716
 
+            x.n
37717
 
+
37718
 
+        x = ast.Num(42)
37719
 
+        self.assertEqual(x.n, 42)
37720
 
+
37721
 
+        with self.assertRaises(AttributeError):
37722
 
+            x.lineno
37723
 
+
37724
 
+        with self.assertRaises(AttributeError):
37725
 
+            x.foobar
37726
 
+
37727
 
+        x = ast.Num(lineno=2)
37728
 
+        self.assertEqual(x.lineno, 2)
37729
 
+
37730
 
+        x = ast.Num(42, lineno=0)
37731
 
+        self.assertEqual(x.lineno, 0)
37732
 
+        self.assertEqual(x._fields, ('n',))
37733
 
+        self.assertEqual(x.n, 42)
37734
 
+
37735
 
+        self.assertRaises(TypeError, ast.Num, 1, 2)
37736
 
+        self.assertRaises(TypeError, ast.Num, 1, 2, lineno=0)
37737
 
+
37738
 
+    def test_module(self):
37739
 
+        body = [ast.Num(42)]
37740
 
+        x = ast.Module(body)
37741
 
+        self.assertEqual(x.body, body)
37742
 
+
37743
 
     def test_nodeclasses(self):
37744
 
+        # Zero arguments constructor explicitely allowed
37745
 
+        x = ast.BinOp()
37746
 
+        self.assertEqual(x._fields, ('left', 'op', 'right'))
37747
 
+
37748
 
+        # Random attribute allowed too
37749
 
+        x.foobarbaz = 5
37750
 
+        self.assertEqual(x.foobarbaz, 5)
37751
 
+
37752
 
+        n1 = ast.Num(1)
37753
 
+        n3 = ast.Num(3)
37754
 
+        addop = ast.Add()
37755
 
+        x = ast.BinOp(n1, addop, n3)
37756
 
+        self.assertEqual(x.left, n1)
37757
 
+        self.assertEqual(x.op, addop)
37758
 
+        self.assertEqual(x.right, n3)
37759
 
+
37760
 
+        x = ast.BinOp(1, 2, 3)
37761
 
+        self.assertEqual(x.left, 1)
37762
 
+        self.assertEqual(x.op, 2)
37763
 
+        self.assertEqual(x.right, 3)
37764
 
+
37765
 
         x = ast.BinOp(1, 2, 3, lineno=0)
37766
 
         self.assertEqual(x.left, 1)
37767
 
         self.assertEqual(x.op, 2)
37768
 
@@ -178,6 +324,12 @@
37769
 
 
37770
 
         # node raises exception when not given enough arguments
37771
 
         self.assertRaises(TypeError, ast.BinOp, 1, 2)
37772
 
+        # node raises exception when given too many arguments
37773
 
+        self.assertRaises(TypeError, ast.BinOp, 1, 2, 3, 4)
37774
 
+        # node raises exception when not given enough arguments
37775
 
+        self.assertRaises(TypeError, ast.BinOp, 1, 2, lineno=0)
37776
 
+        # node raises exception when given too many arguments
37777
 
+        self.assertRaises(TypeError, ast.BinOp, 1, 2, 3, 4, lineno=0)
37778
 
 
37779
 
         # can set attributes through kwargs too
37780
 
         x = ast.BinOp(left=1, op=2, right=3, lineno=0)
37781
 
@@ -186,8 +338,14 @@
37782
 
         self.assertEqual(x.right, 3)
37783
 
         self.assertEqual(x.lineno, 0)
37784
 
 
37785
 
+        # Random kwargs also allowed
37786
 
+        x = ast.BinOp(1, 2, 3, foobarbaz=42)
37787
 
+        self.assertEqual(x.foobarbaz, 42)
37788
 
+
37789
 
+    def test_no_fields(self):
37790
 
         # this used to fail because Sub._fields was None
37791
 
         x = ast.Sub()
37792
 
+        self.assertEqual(x._fields, ())
37793
 
 
37794
 
     def test_pickling(self):
37795
 
         import pickle
37796
 
@@ -204,6 +362,20 @@
37797
 
                     ast2 = mod.loads(mod.dumps(ast, protocol))
37798
 
                     self.assertEqual(to_tuple(ast2), to_tuple(ast))
37799
 
 
37800
 
+    def test_invalid_identitifer(self):
37801
 
+        m = ast.Module([ast.Expr(ast.Name(u"x", ast.Load()))])
37802
 
+        ast.fix_missing_locations(m)
37803
 
+        with self.assertRaises(TypeError) as cm:
37804
 
+            compile(m, "<test>", "exec")
37805
 
+        self.assertIn("identifier must be of type str", str(cm.exception))
37806
 
+
37807
 
+    def test_invalid_string(self):
37808
 
+        m = ast.Module([ast.Expr(ast.Str(43))])
37809
 
+        ast.fix_missing_locations(m)
37810
 
+        with self.assertRaises(TypeError) as cm:
37811
 
+            compile(m, "<test>", "exec")
37812
 
+        self.assertIn("string must be of type str or uni", str(cm.exception))
37813
 
+
37814
 
 
37815
 
 class ASTHelpers_Test(unittest.TestCase):
37816
 
 
37817
 
@@ -330,8 +502,15 @@
37818
 
 
37819
 
 #### EVERYTHING BELOW IS GENERATED #####
37820
 
 exec_results = [
37821
 
+('Module', [('Expr', (1, 0), ('Name', (1, 0), 'None', ('Load',)))]),
37822
 
 ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Pass', (1, 9))], [])]),
37823
 
+('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [('Name', (1, 6), 'a', ('Param',))], None, None, []), [('Pass', (1, 10))], [])]),
37824
 
+('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [('Name', (1, 6), 'a', ('Param',))], None, None, [('Num', (1, 8), 0)]), [('Pass', (1, 12))], [])]),
37825
 
+('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], 'args', None, []), [('Pass', (1, 14))], [])]),
37826
 
+('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, 'kwargs', []), [('Pass', (1, 17))], [])]),
37827
 
+('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [('Name', (1, 6), 'a', ('Param',)), ('Name', (1, 9), 'b', ('Param',)), ('Name', (1, 14), 'c', ('Param',)), ('Name', (1, 22), 'd', ('Param',)), ('Name', (1, 28), 'e', ('Param',))], 'args', 'kwargs', [('Num', (1, 11), 1), ('Name', (1, 16), 'None', ('Load',)), ('List', (1, 24), [], ('Load',)), ('Dict', (1, 30), [], [])]), [('Pass', (1, 52))], [])]),
37828
 
 ('Module', [('ClassDef', (1, 0), 'C', [], [('Pass', (1, 8))], [])]),
37829
 
+('Module', [('ClassDef', (1, 0), 'C', [('Name', (1, 8), 'object', ('Load',))], [('Pass', (1, 17))], [])]),
37830
 
 ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Return', (1, 8), ('Num', (1, 15), 1))], [])]),
37831
 
 ('Module', [('Delete', (1, 0), [('Name', (1, 4), 'v', ('Del',))])]),
37832
 
 ('Module', [('Assign', (1, 0), [('Name', (1, 0), 'v', ('Store',))], ('Num', (1, 4), 1))]),
37833
 
@@ -355,16 +534,26 @@
37834
 
 ('Module', [('For', (1, 0), ('Tuple', (1, 4), [('Name', (1, 4), 'a', ('Store',)), ('Name', (1, 6), 'b', ('Store',))], ('Store',)), ('Name', (1, 11), 'c', ('Load',)), [('Pass', (1, 14))], [])]),
37835
 
 ('Module', [('Expr', (1, 0), ('ListComp', (1, 1), ('Tuple', (1, 2), [('Name', (1, 2), 'a', ('Load',)), ('Name', (1, 4), 'b', ('Load',))], ('Load',)), [('comprehension', ('Tuple', (1, 11), [('Name', (1, 11), 'a', ('Store',)), ('Name', (1, 13), 'b', ('Store',))], ('Store',)), ('Name', (1, 18), 'c', ('Load',)), [])]))]),
37836
 
 ('Module', [('Expr', (1, 0), ('GeneratorExp', (1, 1), ('Tuple', (1, 2), [('Name', (1, 2), 'a', ('Load',)), ('Name', (1, 4), 'b', ('Load',))], ('Load',)), [('comprehension', ('Tuple', (1, 11), [('Name', (1, 11), 'a', ('Store',)), ('Name', (1, 13), 'b', ('Store',))], ('Store',)), ('Name', (1, 18), 'c', ('Load',)), [])]))]),
37837
 
+('Module', [('Expr', (1, 0), ('GeneratorExp', (1, 1), ('Tuple', (1, 2), [('Name', (1, 2), 'a', ('Load',)), ('Name', (1, 4), 'b', ('Load',))], ('Load',)), [('comprehension', ('Tuple', (1, 12), [('Name', (1, 12), 'a', ('Store',)), ('Name', (1, 14), 'b', ('Store',))], ('Store',)), ('Name', (1, 20), 'c', ('Load',)), [])]))]),
37838
 
+('Module', [('Expr', (1, 0), ('GeneratorExp', (2, 4), ('Tuple', (3, 4), [('Name', (3, 4), 'Aa', ('Load',)), ('Name', (5, 7), 'Bb', ('Load',))], ('Load',)), [('comprehension', ('Tuple', (8, 4), [('Name', (8, 4), 'Aa', ('Store',)), ('Name', (10, 4), 'Bb', ('Store',))], ('Store',)), ('Name', (10, 10), 'Cc', ('Load',)), [])]))]),
37839
 
+('Module', [('Expr', (1, 0), ('DictComp', (1, 1), ('Name', (1, 1), 'a', ('Load',)), ('Name', (1, 5), 'b', ('Load',)), [('comprehension', ('Name', (1, 11), 'w', ('Store',)), ('Name', (1, 16), 'x', ('Load',)), []), ('comprehension', ('Name', (1, 22), 'm', ('Store',)), ('Name', (1, 27), 'p', ('Load',)), [('Name', (1, 32), 'g', ('Load',))])]))]),
37840
 
+('Module', [('Expr', (1, 0), ('DictComp', (1, 1), ('Name', (1, 1), 'a', ('Load',)), ('Name', (1, 5), 'b', ('Load',)), [('comprehension', ('Tuple', (1, 11), [('Name', (1, 11), 'v', ('Store',)), ('Name', (1, 13), 'w', ('Store',))], ('Store',)), ('Name', (1, 18), 'x', ('Load',)), [])]))]),
37841
 
+('Module', [('Expr', (1, 0), ('SetComp', (1, 1), ('Name', (1, 1), 'r', ('Load',)), [('comprehension', ('Name', (1, 7), 'l', ('Store',)), ('Name', (1, 12), 'x', ('Load',)), [('Name', (1, 17), 'g', ('Load',))])]))]),
37842
 
+('Module', [('Expr', (1, 0), ('SetComp', (1, 1), ('Name', (1, 1), 'r', ('Load',)), [('comprehension', ('Tuple', (1, 7), [('Name', (1, 7), 'l', ('Store',)), ('Name', (1, 9), 'm', ('Store',))], ('Store',)), ('Name', (1, 14), 'x', ('Load',)), [])]))]),
37843
 
 ]
37844
 
 single_results = [
37845
 
 ('Interactive', [('Expr', (1, 0), ('BinOp', (1, 0), ('Num', (1, 0), 1), ('Add',), ('Num', (1, 2), 2)))]),
37846
 
 ]
37847
 
 eval_results = [
37848
 
+('Expression', ('Name', (1, 0), 'None', ('Load',))),
37849
 
 ('Expression', ('BoolOp', (1, 0), ('And',), [('Name', (1, 0), 'a', ('Load',)), ('Name', (1, 6), 'b', ('Load',))])),
37850
 
 ('Expression', ('BinOp', (1, 0), ('Name', (1, 0), 'a', ('Load',)), ('Add',), ('Name', (1, 4), 'b', ('Load',)))),
37851
 
 ('Expression', ('UnaryOp', (1, 0), ('Not',), ('Name', (1, 4), 'v', ('Load',)))),
37852
 
 ('Expression', ('Lambda', (1, 0), ('arguments', [], None, None, []), ('Name', (1, 7), 'None', ('Load',)))),
37853
 
 ('Expression', ('Dict', (1, 0), [('Num', (1, 2), 1)], [('Num', (1, 4), 2)])),
37854
 
+('Expression', ('Dict', (1, 0), [], [])),
37855
 
+('Expression', ('Set', (1, 0), [('Name', (1, 1), 'None', ('Load',))])),
37856
 
+('Expression', ('Dict', (1, 0), [('Num', (2, 6), 1)], [('Num', (4, 10), 2)])),
37857
 
 ('Expression', ('ListComp', (1, 1), ('Name', (1, 1), 'a', ('Load',)), [('comprehension', ('Name', (1, 7), 'b', ('Store',)), ('Name', (1, 12), 'c', ('Load',)), [('Name', (1, 17), 'd', ('Load',))])])),
37858
 
 ('Expression', ('GeneratorExp', (1, 1), ('Name', (1, 1), 'a', ('Load',)), [('comprehension', ('Name', (1, 7), 'b', ('Store',)), ('Name', (1, 12), 'c', ('Load',)), [('Name', (1, 17), 'd', ('Load',))])])),
37859
 
 ('Expression', ('Compare', (1, 0), ('Num', (1, 0), 1), [('Lt',), ('Lt',)], [('Num', (1, 4), 2), ('Num', (1, 8), 3)])),
37860
 
@@ -376,7 +565,10 @@
37861
 
 ('Expression', ('Subscript', (1, 0), ('Name', (1, 0), 'a', ('Load',)), ('Slice', ('Name', (1, 2), 'b', ('Load',)), ('Name', (1, 4), 'c', ('Load',)), None), ('Load',))),
37862
 
 ('Expression', ('Name', (1, 0), 'v', ('Load',))),
37863
 
 ('Expression', ('List', (1, 0), [('Num', (1, 1), 1), ('Num', (1, 3), 2), ('Num', (1, 5), 3)], ('Load',))),
37864
 
+('Expression', ('List', (1, 0), [], ('Load',))),
37865
 
 ('Expression', ('Tuple', (1, 0), [('Num', (1, 0), 1), ('Num', (1, 2), 2), ('Num', (1, 4), 3)], ('Load',))),
37866
 
+('Expression', ('Tuple', (1, 1), [('Num', (1, 1), 1), ('Num', (1, 3), 2), ('Num', (1, 5), 3)], ('Load',))),
37867
 
+('Expression', ('Tuple', (1, 0), [], ('Load',))),
37868
 
 ('Expression', ('Call', (1, 0), ('Attribute', (1, 0), ('Attribute', (1, 0), ('Attribute', (1, 0), ('Name', (1, 0), 'a', ('Load',)), 'b', ('Load',)), 'c', ('Load',)), 'd', ('Load',)), [('Subscript', (1, 8), ('Attribute', (1, 8), ('Name', (1, 8), 'a', ('Load',)), 'b', ('Load',)), ('Slice', ('Num', (1, 12), 1), ('Num', (1, 14), 2), None), ('Load',))], [], None, None)),
37869
 
 ]
37870
 
 main()
37871
 
diff -r 8527427914a2 Lib/test/test_audioop.py
37872
 
--- a/Lib/test/test_audioop.py
37873
 
+++ b/Lib/test/test_audioop.py
37874
 
@@ -2,18 +2,19 @@
37875
 
 import unittest
37876
 
 from test.test_support import run_unittest
37877
 
 
37878
 
+endian = 'big' if audioop.getsample('\0\1', 2, 0) == 1 else 'little'
37879
 
 
37880
 
 def gendata1():
37881
 
     return '\0\1\2'
37882
 
 
37883
 
 def gendata2():
37884
 
-    if audioop.getsample('\0\1', 2, 0) == 1:
37885
 
+    if endian == 'big':
37886
 
         return '\0\0\0\1\0\2'
37887
 
     else:
37888
 
         return '\0\0\1\0\2\0'
37889
 
 
37890
 
 def gendata4():
37891
 
-    if audioop.getsample('\0\0\0\1', 4, 0) == 1:
37892
 
+    if endian == 'big':
37893
 
         return '\0\0\0\0\0\0\0\1\0\0\0\2'
37894
 
     else:
37895
 
         return '\0\0\0\0\1\0\0\0\2\0\0\0'
37896
 
@@ -21,9 +22,9 @@
37897
 
 data = [gendata1(), gendata2(), gendata4()]
37898
 
 
37899
 
 INVALID_DATA = [
37900
 
-    ('abc', 0),
37901
 
-    ('abc', 2),
37902
 
-    ('abc', 4),
37903
 
+    (b'abc', 0),
37904
 
+    (b'abc', 2),
37905
 
+    (b'abc', 4),
37906
 
 ]
37907
 
 
37908
 
 
37909
 
@@ -94,7 +95,9 @@
37910
 
 
37911
 
     def test_adpcm2lin(self):
37912
 
         # Very cursory test
37913
 
-        self.assertEqual(audioop.adpcm2lin('\0\0', 1, None), ('\0\0\0\0', (0,0)))
37914
 
+        self.assertEqual(audioop.adpcm2lin(b'\0\0', 1, None), (b'\0' * 4, (0,0)))
37915
 
+        self.assertEqual(audioop.adpcm2lin(b'\0\0', 2, None), (b'\0' * 8, (0,0)))
37916
 
+        self.assertEqual(audioop.adpcm2lin(b'\0\0', 4, None), (b'\0' * 16, (0,0)))
37917
 
 
37918
 
     def test_lin2adpcm(self):
37919
 
         # Very cursory test
37920
 
@@ -109,6 +112,16 @@
37921
 
         # Cursory
37922
 
         d = audioop.lin2alaw(data[0], 1)
37923
 
         self.assertEqual(audioop.alaw2lin(d, 1), data[0])
37924
 
+        if endian == 'big':
37925
 
+            self.assertEqual(audioop.alaw2lin(d, 2),
37926
 
+                             b'\x00\x08\x01\x08\x02\x10')
37927
 
+            self.assertEqual(audioop.alaw2lin(d, 4),
37928
 
+                             b'\x00\x08\x00\x00\x01\x08\x00\x00\x02\x10\x00\x00')
37929
 
+        else:
37930
 
+            self.assertEqual(audioop.alaw2lin(d, 2),
37931
 
+                             b'\x08\x00\x08\x01\x10\x02')
37932
 
+            self.assertEqual(audioop.alaw2lin(d, 4),
37933
 
+                             b'\x00\x00\x08\x00\x00\x00\x08\x01\x00\x00\x10\x02')
37934
 
 
37935
 
     def test_lin2ulaw(self):
37936
 
         self.assertEqual(audioop.lin2ulaw(data[0], 1), '\xff\xe7\xdb')
37937
 
@@ -119,6 +132,16 @@
37938
 
         # Cursory
37939
 
         d = audioop.lin2ulaw(data[0], 1)
37940
 
         self.assertEqual(audioop.ulaw2lin(d, 1), data[0])
37941
 
+        if endian == 'big':
37942
 
+            self.assertEqual(audioop.ulaw2lin(d, 2),
37943
 
+                             b'\x00\x00\x01\x04\x02\x0c')
37944
 
+            self.assertEqual(audioop.ulaw2lin(d, 4),
37945
 
+                             b'\x00\x00\x00\x00\x01\x04\x00\x00\x02\x0c\x00\x00')
37946
 
+        else:
37947
 
+            self.assertEqual(audioop.ulaw2lin(d, 2),
37948
 
+                             b'\x00\x00\x04\x01\x0c\x02')
37949
 
+            self.assertEqual(audioop.ulaw2lin(d, 4),
37950
 
+                             b'\x00\x00\x00\x00\x00\x00\x04\x01\x00\x00\x0c\x02')
37951
 
 
37952
 
     def test_mul(self):
37953
 
         data2 = []
37954
 
@@ -193,10 +216,15 @@
37955
 
             self.assertRaises(audioop.error, audioop.lin2lin, data, size, size2)
37956
 
             self.assertRaises(audioop.error, audioop.ratecv, data, size, 1, 1, 1, state)
37957
 
             self.assertRaises(audioop.error, audioop.lin2ulaw, data, size)
37958
 
+            self.assertRaises(audioop.error, audioop.lin2alaw, data, size)
37959
 
+            self.assertRaises(audioop.error, audioop.lin2adpcm, data, size, state)
37960
 
+
37961
 
+    def test_wrongsize(self):
37962
 
+        data = b'abc'
37963
 
+        state = None
37964
 
+        for size in (-1, 3, 5):
37965
 
             self.assertRaises(audioop.error, audioop.ulaw2lin, data, size)
37966
 
-            self.assertRaises(audioop.error, audioop.lin2alaw, data, size)
37967
 
             self.assertRaises(audioop.error, audioop.alaw2lin, data, size)
37968
 
-            self.assertRaises(audioop.error, audioop.lin2adpcm, data, size, state)
37969
 
             self.assertRaises(audioop.error, audioop.adpcm2lin, data, size, state)
37970
 
 
37971
 
 def test_main():
37972
 
diff -r 8527427914a2 Lib/test/test_bool.py
37973
 
--- a/Lib/test/test_bool.py
37974
 
+++ b/Lib/test/test_bool.py
37975
 
@@ -180,9 +180,8 @@
37976
 
         self.assertIs(hasattr([], "wobble"), False)
37977
 
 
37978
 
     def test_callable(self):
37979
 
-        with test_support.check_py3k_warnings():
37980
 
-            self.assertIs(callable(len), True)
37981
 
-            self.assertIs(callable(1), False)
37982
 
+        self.assertIs(callable(len), True)
37983
 
+        self.assertIs(callable(1), False)
37984
 
 
37985
 
     def test_isinstance(self):
37986
 
         self.assertIs(isinstance(True, bool), True)
37987
 
diff -r 8527427914a2 Lib/test/test_cfgparser.py
37988
 
--- a/Lib/test/test_cfgparser.py
37989
 
+++ b/Lib/test/test_cfgparser.py
37990
 
@@ -529,6 +529,28 @@
37991
 
 class SafeConfigParserTestCaseNoValue(SafeConfigParserTestCase):
37992
 
     allow_no_value = True
37993
 
 
37994
 
+class TestChainMap(unittest.TestCase):
37995
 
+    def test_issue_12717(self):
37996
 
+        d1 = dict(red=1, green=2)
37997
 
+        d2 = dict(green=3, blue=4)
37998
 
+        dcomb = d2.copy()
37999
 
+        dcomb.update(d1)
38000
 
+        cm = ConfigParser._Chainmap(d1, d2)
38001
 
+        self.assertIsInstance(cm.keys(), list)
38002
 
+        self.assertEqual(set(cm.keys()), set(dcomb.keys()))      # keys()
38003
 
+        self.assertEqual(set(cm.values()), set(dcomb.values()))  # values()
38004
 
+        self.assertEqual(set(cm.items()), set(dcomb.items()))    # items()
38005
 
+        self.assertEqual(set(cm), set(dcomb))                    # __iter__ ()
38006
 
+        self.assertEqual(cm, dcomb)                              # __eq__()
38007
 
+        self.assertEqual([cm[k] for k in dcomb], dcomb.values()) # __getitem__()
38008
 
+        klist = 'red green blue black brown'.split()
38009
 
+        self.assertEqual([cm.get(k, 10) for k in klist],
38010
 
+                         [dcomb.get(k, 10) for k in klist])      # get()
38011
 
+        self.assertEqual([k in cm for k in klist],
38012
 
+                         [k in dcomb for k in klist])            # __contains__()
38013
 
+        with test_support.check_py3k_warnings():
38014
 
+            self.assertEqual([cm.has_key(k) for k in klist],
38015
 
+                             [dcomb.has_key(k) for k in klist])  # has_key()
38016
 
 
38017
 
 class Issue7005TestCase(unittest.TestCase):
38018
 
     """Test output when None is set() as a value and allow_no_value == False.
38019
 
@@ -582,6 +604,122 @@
38020
 
                          "o4 = 1\n\n")
38021
 
 
38022
 
 
38023
 
+class ExceptionPicklingTestCase(unittest.TestCase):
38024
 
+    """Tests for issue #13760: ConfigParser exceptions are not picklable."""
38025
 
+
38026
 
+    def test_error(self):
38027
 
+        import pickle
38028
 
+        e1 = ConfigParser.Error('value')
38029
 
+        pickled = pickle.dumps(e1)
38030
 
+        e2 = pickle.loads(pickled)
38031
 
+        self.assertEqual(e1.message, e2.message)
38032
 
+        self.assertEqual(repr(e1), repr(e2))
38033
 
+
38034
 
+    def test_nosectionerror(self):
38035
 
+        import pickle
38036
 
+        e1 = ConfigParser.NoSectionError('section')
38037
 
+        pickled = pickle.dumps(e1)
38038
 
+        e2 = pickle.loads(pickled)
38039
 
+        self.assertEqual(e1.message, e2.message)
38040
 
+        self.assertEqual(e1.args, e2.args)
38041
 
+        self.assertEqual(e1.section, e2.section)
38042
 
+        self.assertEqual(repr(e1), repr(e2))
38043
 
+
38044
 
+    def test_nooptionerror(self):
38045
 
+        import pickle
38046
 
+        e1 = ConfigParser.NoOptionError('option', 'section')
38047
 
+        pickled = pickle.dumps(e1)
38048
 
+        e2 = pickle.loads(pickled)
38049
 
+        self.assertEqual(e1.message, e2.message)
38050
 
+        self.assertEqual(e1.args, e2.args)
38051
 
+        self.assertEqual(e1.section, e2.section)
38052
 
+        self.assertEqual(e1.option, e2.option)
38053
 
+        self.assertEqual(repr(e1), repr(e2))
38054
 
+
38055
 
+    def test_duplicatesectionerror(self):
38056
 
+        import pickle
38057
 
+        e1 = ConfigParser.DuplicateSectionError('section')
38058
 
+        pickled = pickle.dumps(e1)
38059
 
+        e2 = pickle.loads(pickled)
38060
 
+        self.assertEqual(e1.message, e2.message)
38061
 
+        self.assertEqual(e1.args, e2.args)
38062
 
+        self.assertEqual(e1.section, e2.section)
38063
 
+        self.assertEqual(repr(e1), repr(e2))
38064
 
+
38065
 
+    def test_interpolationerror(self):
38066
 
+        import pickle
38067
 
+        e1 = ConfigParser.InterpolationError('option', 'section', 'msg')
38068
 
+        pickled = pickle.dumps(e1)
38069
 
+        e2 = pickle.loads(pickled)
38070
 
+        self.assertEqual(e1.message, e2.message)
38071
 
+        self.assertEqual(e1.args, e2.args)
38072
 
+        self.assertEqual(e1.section, e2.section)
38073
 
+        self.assertEqual(e1.option, e2.option)
38074
 
+        self.assertEqual(repr(e1), repr(e2))
38075
 
+
38076
 
+    def test_interpolationmissingoptionerror(self):
38077
 
+        import pickle
38078
 
+        e1 = ConfigParser.InterpolationMissingOptionError('option', 'section',
38079
 
+            'rawval', 'reference')
38080
 
+        pickled = pickle.dumps(e1)
38081
 
+        e2 = pickle.loads(pickled)
38082
 
+        self.assertEqual(e1.message, e2.message)
38083
 
+        self.assertEqual(e1.args, e2.args)
38084
 
+        self.assertEqual(e1.section, e2.section)
38085
 
+        self.assertEqual(e1.option, e2.option)
38086
 
+        self.assertEqual(e1.reference, e2.reference)
38087
 
+        self.assertEqual(repr(e1), repr(e2))
38088
 
+
38089
 
+    def test_interpolationsyntaxerror(self):
38090
 
+        import pickle
38091
 
+        e1 = ConfigParser.InterpolationSyntaxError('option', 'section', 'msg')
38092
 
+        pickled = pickle.dumps(e1)
38093
 
+        e2 = pickle.loads(pickled)
38094
 
+        self.assertEqual(e1.message, e2.message)
38095
 
+        self.assertEqual(e1.args, e2.args)
38096
 
+        self.assertEqual(e1.section, e2.section)
38097
 
+        self.assertEqual(e1.option, e2.option)
38098
 
+        self.assertEqual(repr(e1), repr(e2))
38099
 
+
38100
 
+    def test_interpolationdeptherror(self):
38101
 
+        import pickle
38102
 
+        e1 = ConfigParser.InterpolationDepthError('option', 'section',
38103
 
+            'rawval')
38104
 
+        pickled = pickle.dumps(e1)
38105
 
+        e2 = pickle.loads(pickled)
38106
 
+        self.assertEqual(e1.message, e2.message)
38107
 
+        self.assertEqual(e1.args, e2.args)
38108
 
+        self.assertEqual(e1.section, e2.section)
38109
 
+        self.assertEqual(e1.option, e2.option)
38110
 
+        self.assertEqual(repr(e1), repr(e2))
38111
 
+
38112
 
+    def test_parsingerror(self):
38113
 
+        import pickle
38114
 
+        e1 = ConfigParser.ParsingError('source')
38115
 
+        e1.append(1, 'line1')
38116
 
+        e1.append(2, 'line2')
38117
 
+        e1.append(3, 'line3')
38118
 
+        pickled = pickle.dumps(e1)
38119
 
+        e2 = pickle.loads(pickled)
38120
 
+        self.assertEqual(e1.message, e2.message)
38121
 
+        self.assertEqual(e1.args, e2.args)
38122
 
+        self.assertEqual(e1.filename, e2.filename)
38123
 
+        self.assertEqual(e1.errors, e2.errors)
38124
 
+        self.assertEqual(repr(e1), repr(e2))
38125
 
+
38126
 
+    def test_missingsectionheadererror(self):
38127
 
+        import pickle
38128
 
+        e1 = ConfigParser.MissingSectionHeaderError('filename', 123, 'line')
38129
 
+        pickled = pickle.dumps(e1)
38130
 
+        e2 = pickle.loads(pickled)
38131
 
+        self.assertEqual(e1.message, e2.message)
38132
 
+        self.assertEqual(e1.args, e2.args)
38133
 
+        self.assertEqual(e1.line, e2.line)
38134
 
+        self.assertEqual(e1.filename, e2.filename)
38135
 
+        self.assertEqual(e1.lineno, e2.lineno)
38136
 
+        self.assertEqual(repr(e1), repr(e2))
38137
 
+
38138
 
+
38139
 
 def test_main():
38140
 
     test_support.run_unittest(
38141
 
         ConfigParserTestCase,
38142
 
@@ -591,6 +729,8 @@
38143
 
         SafeConfigParserTestCaseNoValue,
38144
 
         SortedTestCase,
38145
 
         Issue7005TestCase,
38146
 
+        TestChainMap,
38147
 
+        ExceptionPicklingTestCase,
38148
 
         )
38149
 
 
38150
 
 
38151
 
diff -r 8527427914a2 Lib/test/test_cgi.py
38152
 
--- a/Lib/test/test_cgi.py
38153
 
+++ b/Lib/test/test_cgi.py
38154
 
@@ -377,6 +377,9 @@
38155
 
         self.assertEqual(
38156
 
             cgi.parse_header('attachment; filename="strange;name";size=123;'),
38157
 
             ("attachment", {"filename": "strange;name", "size": "123"}))
38158
 
+        self.assertEqual(
38159
 
+            cgi.parse_header('form-data; name="files"; filename="fo\\"o;bar"'),
38160
 
+            ("form-data", {"name": "files", "filename": 'fo"o;bar'}))
38161
 
 
38162
 
 
38163
 
 def test_main():
38164
 
diff -r 8527427914a2 Lib/test/test_class.py
38165
 
--- a/Lib/test/test_class.py
38166
 
+++ b/Lib/test/test_class.py
38167
 
@@ -350,6 +350,19 @@
38168
 
         AllTests.__delslice__ = delslice
38169
 
 
38170
 
 
38171
 
+    @test_support.cpython_only
38172
 
+    def testDelItem(self):
38173
 
+        class A:
38174
 
+            ok = False
38175
 
+            def __delitem__(self, key):
38176
 
+                self.ok = True
38177
 
+        a = A()
38178
 
+        # Subtle: we need to call PySequence_SetItem, not PyMapping_SetItem.
38179
 
+        from _testcapi import sequence_delitem
38180
 
+        sequence_delitem(a, 2)
38181
 
+        self.assertTrue(a.ok)
38182
 
+
38183
 
+
38184
 
     def testUnaryOps(self):
38185
 
         testme = AllTests()
38186
 
 
38187
 
diff -r 8527427914a2 Lib/test/test_codecencodings_iso2022.py
38188
 
--- /dev/null
38189
 
+++ b/Lib/test/test_codecencodings_iso2022.py
38190
 
@@ -0,0 +1,46 @@
38191
 
+#!/usr/bin/env python
38192
 
+#
38193
 
+# Codec encoding tests for ISO 2022 encodings.
38194
 
+
38195
 
+from test import test_support
38196
 
+from test import test_multibytecodec_support
38197
 
+import unittest
38198
 
+
38199
 
+COMMON_CODEC_TESTS = (
38200
 
+        # invalid bytes
38201
 
+        (b'ab\xFFcd', 'replace', u'ab\uFFFDcd'),
38202
 
+        (b'ab\x1Bdef', 'replace', u'ab\x1Bdef'),
38203
 
+        (b'ab\x1B$def', 'replace', u'ab\uFFFD'),
38204
 
+    )
38205
 
+
38206
 
+class Test_ISO2022_JP(test_multibytecodec_support.TestBase, unittest.TestCase):
38207
 
+    encoding = 'iso2022_jp'
38208
 
+    tstring = test_multibytecodec_support.load_teststring('iso2022_jp')
38209
 
+    codectests = COMMON_CODEC_TESTS + (
38210
 
+        (b'ab\x1BNdef', 'replace', u'ab\x1BNdef'),
38211
 
+    )
38212
 
+
38213
 
+class Test_ISO2022_JP2(test_multibytecodec_support.TestBase, unittest.TestCase):
38214
 
+    encoding = 'iso2022_jp_2'
38215
 
+    tstring = test_multibytecodec_support.load_teststring('iso2022_jp')
38216
 
+    codectests = COMMON_CODEC_TESTS + (
38217
 
+        (b'ab\x1BNdef', 'replace', u'abdef'),
38218
 
+    )
38219
 
+
38220
 
+class Test_ISO2022_KR(test_multibytecodec_support.TestBase, unittest.TestCase):
38221
 
+    encoding = 'iso2022_kr'
38222
 
+    tstring = test_multibytecodec_support.load_teststring('iso2022_kr')
38223
 
+    codectests = COMMON_CODEC_TESTS + (
38224
 
+        (b'ab\x1BNdef', 'replace', u'ab\x1BNdef'),
38225
 
+    )
38226
 
+
38227
 
+    # iso2022_kr.txt cannot be used to test "chunk coding": the escape
38228
 
+    # sequence is only written on the first line
38229
 
+    def test_chunkcoding(self):
38230
 
+        pass
38231
 
+
38232
 
+def test_main():
38233
 
+    test_support.run_unittest(__name__)
38234
 
+
38235
 
+if __name__ == "__main__":
38236
 
+    test_main()
38237
 
diff -r 8527427914a2 Lib/test/test_codecs.py
38238
 
--- a/Lib/test/test_codecs.py
38239
 
+++ b/Lib/test/test_codecs.py
38240
 
@@ -1,6 +1,7 @@
38241
 
 from test import test_support
38242
 
 import unittest
38243
 
 import codecs
38244
 
+import locale
38245
 
 import sys, StringIO, _testcapi
38246
 
 
38247
 
 class Queue(object):
38248
 
@@ -1153,6 +1154,19 @@
38249
 
         self.assertRaises(TypeError, codecs.getwriter)
38250
 
         self.assertRaises(LookupError, codecs.getwriter, "__spam__")
38251
 
 
38252
 
+    def test_lookup_issue1813(self):
38253
 
+        # Issue #1813: under Turkish locales, lookup of some codecs failed
38254
 
+        # because 'I' is lowercased as a dotless "i"
38255
 
+        oldlocale = locale.getlocale(locale.LC_CTYPE)
38256
 
+        self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)
38257
 
+        try:
38258
 
+            locale.setlocale(locale.LC_CTYPE, 'tr_TR')
38259
 
+        except locale.Error:
38260
 
+            # Unsupported locale on this system
38261
 
+            self.skipTest('test needs Turkish locale')
38262
 
+        c = codecs.lookup('ASCII')
38263
 
+        self.assertEqual(c.name, 'ascii')
38264
 
+
38265
 
 class StreamReaderTest(unittest.TestCase):
38266
 
 
38267
 
     def setUp(self):
38268
 
diff -r 8527427914a2 Lib/test/test_collections.py
38269
 
--- a/Lib/test/test_collections.py
38270
 
+++ b/Lib/test/test_collections.py
38271
 
@@ -78,12 +78,12 @@
38272
 
         self.assertRaises(TypeError, eval, 'Point(XXX=1, y=2)', locals())   # wrong keyword argument
38273
 
         self.assertRaises(TypeError, eval, 'Point(x=1)', locals())          # missing keyword argument
38274
 
         self.assertEqual(repr(p), 'Point(x=11, y=22)')
38275
 
-        self.assertNotIn('__dict__', dir(p))                              # verify instance has no dict
38276
 
         self.assertNotIn('__weakref__', dir(p))
38277
 
         self.assertEqual(p, Point._make([11, 22]))                          # test _make classmethod
38278
 
         self.assertEqual(p._fields, ('x', 'y'))                             # test _fields attribute
38279
 
         self.assertEqual(p._replace(x=1), (1, 22))                          # test _replace method
38280
 
         self.assertEqual(p._asdict(), dict(x=11, y=22))                     # test _asdict method
38281
 
+        self.assertEqual(vars(p), p._asdict())                              # verify that vars() works
38282
 
 
38283
 
         try:
38284
 
             p._replace(x=1, error=2)
38285
 
diff -r 8527427914a2 Lib/test/test_csv.py
38286
 
--- a/Lib/test/test_csv.py
38287
 
+++ b/Lib/test/test_csv.py
38288
 
@@ -207,6 +207,18 @@
38289
 
             fileobj.close()
38290
 
             os.unlink(name)
38291
 
 
38292
 
+    def test_write_float(self):
38293
 
+        # Issue 13573: loss of precision because csv.writer
38294
 
+        # uses str() for floats instead of repr()
38295
 
+        orig_row = [1.234567890123, 1.0/7.0, 'abc']
38296
 
+        f = StringIO()
38297
 
+        c = csv.writer(f, quoting=csv.QUOTE_NONNUMERIC)
38298
 
+        c.writerow(orig_row)
38299
 
+        f.seek(0)
38300
 
+        c = csv.reader(f, quoting=csv.QUOTE_NONNUMERIC)
38301
 
+        new_row = next(c)
38302
 
+        self.assertEqual(orig_row, new_row)
38303
 
+
38304
 
     def _read_test(self, input, expect, **kwargs):
38305
 
         reader = csv.reader(input, **kwargs)
38306
 
         result = list(reader)
38307
 
@@ -784,7 +796,7 @@
38308
 
         try:
38309
 
             writer = csv.writer(fileobj, dialect="excel")
38310
 
             writer.writerow(a)
38311
 
-            expected = ",".join([str(i) for i in a])+"\r\n"
38312
 
+            expected = ",".join([repr(i) for i in a])+"\r\n"
38313
 
             fileobj.seek(0)
38314
 
             self.assertEqual(fileobj.read(), expected)
38315
 
         finally:
38316
 
@@ -800,7 +812,7 @@
38317
 
         try:
38318
 
             writer = csv.writer(fileobj, dialect="excel")
38319
 
             writer.writerow(a)
38320
 
-            expected = ",".join([str(i) for i in a])+"\r\n"
38321
 
+            expected = ",".join([repr(i) for i in a])+"\r\n"
38322
 
             fileobj.seek(0)
38323
 
             self.assertEqual(fileobj.read(), expected)
38324
 
         finally:
38325
 
diff -r 8527427914a2 Lib/test/test_defaultdict.py
38326
 
--- a/Lib/test/test_defaultdict.py
38327
 
+++ b/Lib/test/test_defaultdict.py
38328
 
@@ -171,6 +171,8 @@
38329
 
         finally:
38330
 
             os.remove(tfn)
38331
 
 
38332
 
+    def test_callable_arg(self):
38333
 
+        self.assertRaises(TypeError, defaultdict, {})
38334
 
 
38335
 
 def test_main():
38336
 
     test_support.run_unittest(TestDefaultDict)
38337
 
diff -r 8527427914a2 Lib/test/test_descr.py
38338
 
--- a/Lib/test/test_descr.py
38339
 
+++ b/Lib/test/test_descr.py
38340
 
@@ -4581,6 +4581,14 @@
38341
 
         with self.assertRaises(TypeError):
38342
 
             str.__add__(fake_str, "abc")
38343
 
 
38344
 
+    def test_repr_as_str(self):
38345
 
+        # Issue #11603: crash or infinite loop when rebinding __str__ as
38346
 
+        # __repr__.
38347
 
+        class Foo(object):
38348
 
+            pass
38349
 
+        Foo.__repr__ = Foo.__str__
38350
 
+        foo = Foo()
38351
 
+        str(foo)
38352
 
 
38353
 
 class DictProxyTests(unittest.TestCase):
38354
 
     def setUp(self):
38355
 
@@ -4589,6 +4597,10 @@
38356
 
                 pass
38357
 
         self.C = C
38358
 
 
38359
 
+    def test_repr(self):
38360
 
+        self.assertIn('dict_proxy({', repr(vars(self.C)))
38361
 
+        self.assertIn("'meth':", repr(vars(self.C)))
38362
 
+
38363
 
     def test_iter_keys(self):
38364
 
         # Testing dict-proxy iterkeys...
38365
 
         keys = [ key for key in self.C.__dict__.iterkeys() ]
38366
 
diff -r 8527427914a2 Lib/test/test_dis.py
38367
 
--- a/Lib/test/test_dis.py
38368
 
+++ b/Lib/test/test_dis.py
38369
 
@@ -54,7 +54,7 @@
38370
 
 
38371
 
 dis_bug1333982 = """\
38372
 
  %-4d         0 LOAD_CONST               1 (0)
38373
 
-              3 POP_JUMP_IF_TRUE        38
38374
 
+              3 POP_JUMP_IF_TRUE        41
38375
 
               6 LOAD_GLOBAL              0 (AssertionError)
38376
 
               9 BUILD_LIST               0
38377
 
              12 LOAD_FAST                0 (x)
38378
 
@@ -67,10 +67,11 @@
38379
 
 
38380
 
  %-4d   >>   31 LOAD_CONST               2 (1)
38381
 
              34 BINARY_ADD
38382
 
-             35 RAISE_VARARGS            2
38383
 
+             35 CALL_FUNCTION            1
38384
 
+             38 RAISE_VARARGS            1
38385
 
 
38386
 
- %-4d   >>   38 LOAD_CONST               0 (None)
38387
 
-             41 RETURN_VALUE
38388
 
+ %-4d   >>   41 LOAD_CONST               0 (None)
38389
 
+             44 RETURN_VALUE
38390
 
 """%(bug1333982.func_code.co_firstlineno + 1,
38391
 
      bug1333982.func_code.co_firstlineno + 2,
38392
 
      bug1333982.func_code.co_firstlineno + 3)
38393
 
diff -r 8527427914a2 Lib/test/test_doctest.py
38394
 
--- a/Lib/test/test_doctest.py
38395
 
+++ b/Lib/test/test_doctest.py
38396
 
@@ -258,6 +258,21 @@
38397
 
     >>> e = doctest.Example('raise X()', '', exc_msg)
38398
 
     >>> e.exc_msg
38399
 
     '\n'
38400
 
+
38401
 
+Compare `Example`:
38402
 
+    >>> example = doctest.Example('print 1', '1\n')
38403
 
+    >>> same_example = doctest.Example('print 1', '1\n')
38404
 
+    >>> other_example = doctest.Example('print 42', '42\n')
38405
 
+    >>> example == same_example
38406
 
+    True
38407
 
+    >>> example != same_example
38408
 
+    False
38409
 
+    >>> hash(example) == hash(same_example)
38410
 
+    True
38411
 
+    >>> example == other_example
38412
 
+    False
38413
 
+    >>> example != other_example
38414
 
+    True
38415
 
 """
38416
 
 
38417
 
 def test_DocTest(): r"""
38418
 
@@ -347,6 +362,50 @@
38419
 
     Traceback (most recent call last):
38420
 
     ValueError: line 2 of the docstring for some_test lacks blank after ...: '...print 1'
38421
 
 
38422
 
+Compare `DocTest`:
38423
 
+
38424
 
+    >>> docstring = '''
38425
 
+    ...     >>> print 12
38426
 
+    ...     12
38427
 
+    ... '''
38428
 
+    >>> test = parser.get_doctest(docstring, globs, 'some_test',
38429
 
+    ...                           'some_test', 20)
38430
 
+    >>> same_test = parser.get_doctest(docstring, globs, 'some_test',
38431
 
+    ...                                'some_test', 20)
38432
 
+    >>> test == same_test
38433
 
+    True
38434
 
+    >>> test != same_test
38435
 
+    False
38436
 
+    >>> hash(test) == hash(same_test)
38437
 
+    True
38438
 
+    >>> docstring = '''
38439
 
+    ...     >>> print 42
38440
 
+    ...     42
38441
 
+    ... '''
38442
 
+    >>> other_test = parser.get_doctest(docstring, globs, 'other_test',
38443
 
+    ...                                 'other_file', 10)
38444
 
+    >>> test == other_test
38445
 
+    False
38446
 
+    >>> test != other_test
38447
 
+    True
38448
 
+
38449
 
+Compare `DocTestCase`:
38450
 
+
38451
 
+    >>> DocTestCase = doctest.DocTestCase
38452
 
+    >>> test_case = DocTestCase(test)
38453
 
+    >>> same_test_case = DocTestCase(same_test)
38454
 
+    >>> other_test_case = DocTestCase(other_test)
38455
 
+    >>> test_case == same_test_case
38456
 
+    True
38457
 
+    >>> test_case != same_test_case
38458
 
+    False
38459
 
+    >>> hash(test_case) == hash(same_test_case)
38460
 
+    True
38461
 
+    >>> test == other_test_case
38462
 
+    False
38463
 
+    >>> test != other_test_case
38464
 
+    True
38465
 
+
38466
 
 """
38467
 
 
38468
 
 def test_DocTestFinder(): r"""
38469
 
diff -r 8527427914a2 Lib/test/test_epoll.py
38470
 
--- a/Lib/test/test_epoll.py
38471
 
+++ b/Lib/test/test_epoll.py
38472
 
@@ -36,6 +36,7 @@
38473
 
 except IOError, e:
38474
 
     if e.errno == errno.ENOSYS:
38475
 
         raise unittest.SkipTest("kernel doesn't support epoll()")
38476
 
+    raise
38477
 
 
38478
 
 class TestEPoll(unittest.TestCase):
38479
 
 
38480
 
diff -r 8527427914a2 Lib/test/test_exceptions.py
38481
 
--- a/Lib/test/test_exceptions.py
38482
 
+++ b/Lib/test/test_exceptions.py
38483
 
@@ -464,6 +464,20 @@
38484
 
             self.assertTrue(e is RuntimeError, e)
38485
 
             self.assertIn("maximum recursion depth exceeded", str(v))
38486
 
 
38487
 
+    def test_new_returns_invalid_instance(self):
38488
 
+        # See issue #11627.
38489
 
+        class MyException(Exception):
38490
 
+            def __new__(cls, *args):
38491
 
+                return object()
38492
 
+
38493
 
+        with self.assertRaises(TypeError):
38494
 
+            raise MyException
38495
 
+
38496
 
+    def test_assert_with_tuple_arg(self):
38497
 
+        try:
38498
 
+            assert False, (3,)
38499
 
+        except AssertionError as e:
38500
 
+            self.assertEqual(str(e), "(3,)")
38501
 
 
38502
 
 
38503
 
 # Helper class used by TestSameStrAndUnicodeMsg
38504
 
diff -r 8527427914a2 Lib/test/test_fcntl.py
38505
 
--- a/Lib/test/test_fcntl.py
38506
 
+++ b/Lib/test/test_fcntl.py
38507
 
@@ -27,12 +27,8 @@
38508
 
         else:
38509
 
             start_len = "qq"
38510
 
 
38511
 
-    if sys.platform in ('netbsd1', 'netbsd2', 'netbsd3',
38512
 
-                        'Darwin1.2', 'darwin',
38513
 
-                        'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5',
38514
 
-                        'freebsd6', 'freebsd7', 'freebsd8',
38515
 
-                        'bsdos2', 'bsdos3', 'bsdos4',
38516
 
-                        'openbsd', 'openbsd2', 'openbsd3', 'openbsd4'):
38517
 
+    if (sys.platform.startswith(('netbsd', 'freebsd', 'openbsd', 'bsdos'))
38518
 
+        or sys.platform == 'darwin'):
38519
 
         if struct.calcsize('l') == 8:
38520
 
             off_t = 'l'
38521
 
             pid_t = 'i'
38522
 
diff -r 8527427914a2 Lib/test/test_float.py
38523
 
--- a/Lib/test/test_float.py
38524
 
+++ b/Lib/test/test_float.py
38525
 
@@ -164,6 +164,12 @@
38526
 
         self.assertAlmostEqual(float(FooUnicode('8')), 9.)
38527
 
         self.assertAlmostEqual(float(FooStr('8')), 9.)
38528
 
 
38529
 
+    def test_is_integer(self):
38530
 
+        self.assertFalse((1.1).is_integer())
38531
 
+        self.assertTrue((1.).is_integer())
38532
 
+        self.assertFalse(float("nan").is_integer())
38533
 
+        self.assertFalse(float("inf").is_integer())
38534
 
+
38535
 
     def test_floatasratio(self):
38536
 
         for f, ratio in [
38537
 
                 (0.875, (7, 8)),
38538
 
diff -r 8527427914a2 Lib/test/test_ftplib.py
38539
 
--- a/Lib/test/test_ftplib.py
38540
 
+++ b/Lib/test/test_ftplib.py
38541
 
@@ -667,7 +667,7 @@
38542
 
     def setUp(self):
38543
 
         self.evt = threading.Event()
38544
 
         self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
38545
 
-        self.sock.settimeout(3)
38546
 
+        self.sock.settimeout(10)
38547
 
         self.port = test_support.bind_port(self.sock)
38548
 
         threading.Thread(target=self.server, args=(self.evt,self.sock)).start()
38549
 
         # Wait for the server to be ready.
38550
 
diff -r 8527427914a2 Lib/test/test_gdb.py
38551
 
--- a/Lib/test/test_gdb.py
38552
 
+++ b/Lib/test/test_gdb.py
38553
 
@@ -32,6 +32,14 @@
38554
 
 if gdbpy_version == '':
38555
 
     raise unittest.SkipTest("gdb not built with embedded python support")
38556
 
 
38557
 
+def python_is_optimized():
38558
 
+    cflags = sysconfig.get_config_vars()['PY_CFLAGS']
38559
 
+    final_opt = ""
38560
 
+    for opt in cflags.split():
38561
 
+        if opt.startswith('-O'):
38562
 
+            final_opt = opt
38563
 
+    return (final_opt and final_opt != '-O0')
38564
 
+
38565
 
 def gdb_has_frame_select():
38566
 
     # Does this build of gdb have gdb.Frame.select ?
38567
 
     cmd = "--eval-command=python print(dir(gdb.Frame))"
38568
 
@@ -543,6 +551,8 @@
38569
 
                                  re.DOTALL),
38570
 
                         'Unexpected gdb representation: %r\n%s' % (gdb_output, gdb_output))
38571
 
 
38572
 
+@unittest.skipIf(python_is_optimized(),
38573
 
+                 "Python was compiled with optimizations")
38574
 
 class PyListTests(DebuggerTests):
38575
 
     def assertListing(self, expected, actual):
38576
 
         self.assertEndsWith(actual, expected)
38577
 
@@ -585,6 +595,8 @@
38578
 
 
38579
 
 class StackNavigationTests(DebuggerTests):
38580
 
     @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
38581
 
+    @unittest.skipIf(python_is_optimized(),
38582
 
+                     "Python was compiled with optimizations")
38583
 
     def test_pyup_command(self):
38584
 
         'Verify that the "py-up" command works'
38585
 
         bt = self.get_stack_trace(script=self.get_sample_script(),
38586
 
@@ -612,6 +624,8 @@
38587
 
                             'Unable to find an older python frame\n')
38588
 
 
38589
 
     @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
38590
 
+    @unittest.skipIf(python_is_optimized(),
38591
 
+                     "Python was compiled with optimizations")
38592
 
     def test_up_then_down(self):
38593
 
         'Verify "py-up" followed by "py-down"'
38594
 
         bt = self.get_stack_trace(script=self.get_sample_script(),
38595
 
@@ -625,6 +639,8 @@
38596
 
 $''')
38597
 
 
38598
 
 class PyBtTests(DebuggerTests):
38599
 
+    @unittest.skipIf(python_is_optimized(),
38600
 
+                     "Python was compiled with optimizations")
38601
 
     def test_basic_command(self):
38602
 
         'Verify that the "py-bt" command works'
38603
 
         bt = self.get_stack_trace(script=self.get_sample_script(),
38604
 
@@ -636,10 +652,12 @@
38605
 
 #[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 4, in foo \(a=1, b=2, c=3\)
38606
 
     bar\(a, b, c\)
38607
 
 #[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 12, in <module> \(\)
38608
 
-foo\(1, 2, 3\)
38609
 
+    foo\(1, 2, 3\)
38610
 
 ''')
38611
 
 
38612
 
 class PyPrintTests(DebuggerTests):
38613
 
+    @unittest.skipIf(python_is_optimized(),
38614
 
+                     "Python was compiled with optimizations")
38615
 
     def test_basic_command(self):
38616
 
         'Verify that the "py-print" command works'
38617
 
         bt = self.get_stack_trace(script=self.get_sample_script(),
38618
 
@@ -648,18 +666,24 @@
38619
 
                                     r".*\nlocal 'args' = \(1, 2, 3\)\n.*")
38620
 
 
38621
 
     @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
38622
 
+    @unittest.skipIf(python_is_optimized(),
38623
 
+                     "Python was compiled with optimizations")
38624
 
     def test_print_after_up(self):
38625
 
         bt = self.get_stack_trace(script=self.get_sample_script(),
38626
 
                                   cmds_after_breakpoint=['py-up', 'py-print c', 'py-print b', 'py-print a'])
38627
 
         self.assertMultilineMatches(bt,
38628
 
                                     r".*\nlocal 'c' = 3\nlocal 'b' = 2\nlocal 'a' = 1\n.*")
38629
 
 
38630
 
+    @unittest.skipIf(python_is_optimized(),
38631
 
+                     "Python was compiled with optimizations")
38632
 
     def test_printing_global(self):
38633
 
         bt = self.get_stack_trace(script=self.get_sample_script(),
38634
 
                                   cmds_after_breakpoint=['py-print __name__'])
38635
 
         self.assertMultilineMatches(bt,
38636
 
                                     r".*\nglobal '__name__' = '__main__'\n.*")
38637
 
 
38638
 
+    @unittest.skipIf(python_is_optimized(),
38639
 
+                     "Python was compiled with optimizations")
38640
 
     def test_printing_builtin(self):
38641
 
         bt = self.get_stack_trace(script=self.get_sample_script(),
38642
 
                                   cmds_after_breakpoint=['py-print len'])
38643
 
@@ -667,6 +691,8 @@
38644
 
                                     r".*\nbuiltin 'len' = <built-in function len>\n.*")
38645
 
 
38646
 
 class PyLocalsTests(DebuggerTests):
38647
 
+    @unittest.skipIf(python_is_optimized(),
38648
 
+                     "Python was compiled with optimizations")
38649
 
     def test_basic_command(self):
38650
 
         bt = self.get_stack_trace(script=self.get_sample_script(),
38651
 
                                   cmds_after_breakpoint=['py-locals'])
38652
 
@@ -674,6 +700,8 @@
38653
 
                                     r".*\nargs = \(1, 2, 3\)\n.*")
38654
 
 
38655
 
     @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
38656
 
+    @unittest.skipIf(python_is_optimized(),
38657
 
+                     "Python was compiled with optimizations")
38658
 
     def test_locals_after_up(self):
38659
 
         bt = self.get_stack_trace(script=self.get_sample_script(),
38660
 
                                   cmds_after_breakpoint=['py-up', 'py-locals'])
38661
 
@@ -681,15 +709,6 @@
38662
 
                                     r".*\na = 1\nb = 2\nc = 3\n.*")
38663
 
 
38664
 
 def test_main():
38665
 
-    cflags = sysconfig.get_config_vars()['PY_CFLAGS']
38666
 
-    final_opt = ""
38667
 
-    for opt in cflags.split():
38668
 
-        if opt.startswith('-O'):
38669
 
-            final_opt = opt
38670
 
-    if final_opt and final_opt != '-O0':
38671
 
-        raise unittest.SkipTest("Python was built with compiler optimizations, "
38672
 
-                                "tests can't reliably succeed")
38673
 
-
38674
 
     run_unittest(PrettyPrintTests,
38675
 
                  PyListTests,
38676
 
                  StackNavigationTests,
38677
 
diff -r 8527427914a2 Lib/test/test_grammar.py
38678
 
--- a/Lib/test/test_grammar.py
38679
 
+++ b/Lib/test/test_grammar.py
38680
 
@@ -551,13 +551,35 @@
38681
 
         assert 1, 1
38682
 
         assert lambda x:x
38683
 
         assert 1, lambda x:x+1
38684
 
+
38685
 
+        try:
38686
 
+            assert True
38687
 
+        except AssertionError as e:
38688
 
+            self.fail("'assert True' should not have raised an AssertionError")
38689
 
+
38690
 
+        try:
38691
 
+            assert True, 'this should always pass'
38692
 
+        except AssertionError as e:
38693
 
+            self.fail("'assert True, msg' should not have "
38694
 
+                      "raised an AssertionError")
38695
 
+
38696
 
+    # these tests fail if python is run with -O, so check __debug__
38697
 
+    @unittest.skipUnless(__debug__, "Won't work if __debug__ is False")
38698
 
+    def testAssert2(self):
38699
 
         try:
38700
 
             assert 0, "msg"
38701
 
         except AssertionError, e:
38702
 
             self.assertEqual(e.args[0], "msg")
38703
 
         else:
38704
 
-            if __debug__:
38705
 
-                self.fail("AssertionError not raised by assert 0")
38706
 
+            self.fail("AssertionError not raised by assert 0")
38707
 
+
38708
 
+        try:
38709
 
+            assert False
38710
 
+        except AssertionError as e:
38711
 
+            self.assertEqual(len(e.args), 0)
38712
 
+        else:
38713
 
+            self.fail("AssertionError not raised by 'assert False'")
38714
 
+
38715
 
 
38716
 
     ### compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef
38717
 
     # Tested below
38718
 
diff -r 8527427914a2 Lib/test/test_gzip.py
38719
 
--- a/Lib/test/test_gzip.py
38720
 
+++ b/Lib/test/test_gzip.py
38721
 
@@ -274,6 +274,14 @@
38722
 
             d = f.read()
38723
 
             self.assertEqual(d, data1 * 50, "Incorrect data in file")
38724
 
 
38725
 
+    def test_fileobj_from_fdopen(self):
38726
 
+        # Issue #13781: Creating a GzipFile using a fileobj from os.fdopen()
38727
 
+        # should not embed the fake filename "<fdopen>" in the output file.
38728
 
+        fd = os.open(self.filename, os.O_WRONLY | os.O_CREAT)
38729
 
+        with os.fdopen(fd, "wb") as f:
38730
 
+            with gzip.GzipFile(fileobj=f, mode="w") as g:
38731
 
+                self.assertEqual(g.name, "")
38732
 
+
38733
 
 def test_main(verbose=None):
38734
 
     test_support.run_unittest(TestGzip)
38735
 
 
38736
 
diff -r 8527427914a2 Lib/test/test_htmlparser.py
38737
 
--- a/Lib/test/test_htmlparser.py
38738
 
+++ b/Lib/test/test_htmlparser.py
38739
 
@@ -114,7 +114,7 @@
38740
 
 <Img sRc='Bar' isMAP>sample
38741
 
 text
38742
 
 &#x201C;
38743
 
-<!--comment2a-- --comment2b--><!>
38744
 
+<!--comment2a-- --comment2b-->
38745
 
 </Html>
38746
 
 """, [
38747
 
     ("data", "\n"),
38748
 
@@ -142,24 +142,6 @@
38749
 
             ("data", " foo"),
38750
 
             ])
38751
 
 
38752
 
-    def test_doctype_decl(self):
38753
 
-        inside = """\
38754
 
-DOCTYPE html [
38755
 
-  <!ELEMENT html - O EMPTY>
38756
 
-  <!ATTLIST html
38757
 
-      version CDATA #IMPLIED
38758
 
-      profile CDATA 'DublinCore'>
38759
 
-  <!NOTATION datatype SYSTEM 'http://xml.python.org/notations/python-module'>
38760
 
-  <!ENTITY myEntity 'internal parsed entity'>
38761
 
-  <!ENTITY anEntity SYSTEM 'http://xml.python.org/entities/something.xml'>
38762
 
-  <!ENTITY % paramEntity 'name|name|name'>
38763
 
-  %paramEntity;
38764
 
-  <!-- comment -->
38765
 
-]"""
38766
 
-        self._run_check("<!%s>" % inside, [
38767
 
-            ("decl", inside),
38768
 
-            ])
38769
 
-
38770
 
     def test_bad_nesting(self):
38771
 
         # Strangely, this *is* supposed to test that overlapping
38772
 
         # elements are allowed.  HTMLParser is more geared toward
38773
 
@@ -181,62 +163,9 @@
38774
 
             ("data", "this < text > contains < bare>pointy< brackets"),
38775
 
             ])
38776
 
 
38777
 
-    def test_attr_syntax(self):
38778
 
-        output = [
38779
 
-          ("starttag", "a", [("b", "v"), ("c", "v"), ("d", "v"), ("e", None)])
38780
 
-          ]
38781
 
-        self._run_check("""<a b='v' c="v" d=v e>""", output)
38782
 
-        self._run_check("""<a  b = 'v' c = "v" d = v e>""", output)
38783
 
-        self._run_check("""<a\nb\n=\n'v'\nc\n=\n"v"\nd\n=\nv\ne>""", output)
38784
 
-        self._run_check("""<a\tb\t=\t'v'\tc\t=\t"v"\td\t=\tv\te>""", output)
38785
 
-
38786
 
-    def test_attr_values(self):
38787
 
-        self._run_check("""<a b='xxx\n\txxx' c="yyy\t\nyyy" d='\txyz\n'>""",
38788
 
-                        [("starttag", "a", [("b", "xxx\n\txxx"),
38789
 
-                                            ("c", "yyy\t\nyyy"),
38790
 
-                                            ("d", "\txyz\n")])
38791
 
-                         ])
38792
 
-        self._run_check("""<a b='' c="">""", [
38793
 
-            ("starttag", "a", [("b", ""), ("c", "")]),
38794
 
-            ])
38795
 
-        # Regression test for SF patch #669683.
38796
 
-        self._run_check("<e a=rgb(1,2,3)>", [
38797
 
-            ("starttag", "e", [("a", "rgb(1,2,3)")]),
38798
 
-            ])
38799
 
-        # Regression test for SF bug #921657.
38800
 
-        self._run_check("<a href=mailto:xyz@example.com>", [
38801
 
-            ("starttag", "a", [("href", "mailto:xyz@example.com")]),
38802
 
-            ])
38803
 
-
38804
 
-    def test_attr_nonascii(self):
38805
 
-        # see issue 7311
38806
 
-        self._run_check(u"<img src=/foo/bar.png alt=\u4e2d\u6587>", [
38807
 
-            ("starttag", "img", [("src", "/foo/bar.png"),
38808
 
-                                 ("alt", u"\u4e2d\u6587")]),
38809
 
-            ])
38810
 
-        self._run_check(u"<a title='\u30c6\u30b9\u30c8' "
38811
 
-                        u"href='\u30c6\u30b9\u30c8.html'>", [
38812
 
-            ("starttag", "a", [("title", u"\u30c6\u30b9\u30c8"),
38813
 
-                               ("href", u"\u30c6\u30b9\u30c8.html")]),
38814
 
-            ])
38815
 
-        self._run_check(u'<a title="\u30c6\u30b9\u30c8" '
38816
 
-                        u'href="\u30c6\u30b9\u30c8.html">', [
38817
 
-            ("starttag", "a", [("title", u"\u30c6\u30b9\u30c8"),
38818
 
-                               ("href", u"\u30c6\u30b9\u30c8.html")]),
38819
 
-            ])
38820
 
-
38821
 
-    def test_attr_entity_replacement(self):
38822
 
-        self._run_check("""<a b='&amp;&gt;&lt;&quot;&apos;'>""", [
38823
 
-            ("starttag", "a", [("b", "&><\"'")]),
38824
 
-            ])
38825
 
-
38826
 
-    def test_attr_funky_names(self):
38827
 
-        self._run_check("""<a a.b='v' c:d=v e-f=v>""", [
38828
 
-            ("starttag", "a", [("a.b", "v"), ("c:d", "v"), ("e-f", "v")]),
38829
 
-            ])
38830
 
-
38831
 
     def test_illegal_declarations(self):
38832
 
-        self._parse_error('<!spacer type="block" height="25">')
38833
 
+        self._run_check('<!spacer type="block" height="25">',
38834
 
+                        [('comment', 'spacer type="block" height="25"')])
38835
 
 
38836
 
     def test_starttag_end_boundary(self):
38837
 
         self._run_check("""<a b='<'>""", [("starttag", "a", [("b", "<")])])
38838
 
@@ -273,23 +202,46 @@
38839
 
         self._run_check(["<!--abc-->", ""], output)
38840
 
 
38841
 
     def test_starttag_junk_chars(self):
38842
 
-        self._parse_error("</>")
38843
 
-        self._parse_error("</$>")
38844
 
-        self._parse_error("</")
38845
 
-        self._parse_error("</a")
38846
 
-        self._parse_error("<a<a>")
38847
 
-        self._parse_error("</a<a>")
38848
 
-        self._parse_error("<!")
38849
 
-        self._parse_error("<a $>")
38850
 
-        self._parse_error("<a")
38851
 
-        self._parse_error("<a foo='bar'")
38852
 
-        self._parse_error("<a foo='bar")
38853
 
-        self._parse_error("<a foo='>'")
38854
 
-        self._parse_error("<a foo='>")
38855
 
-        self._parse_error("<a foo=>")
38856
 
+        self._run_check("</>", [])
38857
 
+        self._run_check("</$>", [('comment', '$')])
38858
 
+        self._run_check("</", [('data', '</')])
38859
 
+        self._run_check("</a", [('data', '</a')])
38860
 
+        # XXX this might be wrong
38861
 
+        self._run_check("<a<a>", [('data', '<a'), ('starttag', 'a', [])])
38862
 
+        self._run_check("</a<a>", [('endtag', 'a<a')])
38863
 
+        self._run_check("<!", [('data', '<!')])
38864
 
+        self._run_check("<a", [('data', '<a')])
38865
 
+        self._run_check("<a foo='bar'", [('data', "<a foo='bar'")])
38866
 
+        self._run_check("<a foo='bar", [('data', "<a foo='bar")])
38867
 
+        self._run_check("<a foo='>'", [('data', "<a foo='>'")])
38868
 
+        self._run_check("<a foo='>", [('data', "<a foo='>")])
38869
 
+
38870
 
+    def test_valid_doctypes(self):
38871
 
+        # from http://www.w3.org/QA/2002/04/valid-dtd-list.html
38872
 
+        dtds = ['HTML',  # HTML5 doctype
38873
 
+                ('HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" '
38874
 
+                 '"http://www.w3.org/TR/html4/strict.dtd"'),
38875
 
+                ('HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" '
38876
 
+                 '"http://www.w3.org/TR/html4/loose.dtd"'),
38877
 
+                ('html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '
38878
 
+                 '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"'),
38879
 
+                ('html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" '
38880
 
+                 '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"'),
38881
 
+                ('math PUBLIC "-//W3C//DTD MathML 2.0//EN" '
38882
 
+                 '"http://www.w3.org/Math/DTD/mathml2/mathml2.dtd"'),
38883
 
+                ('html PUBLIC "-//W3C//DTD '
38884
 
+                 'XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" '
38885
 
+                 '"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"'),
38886
 
+                ('svg PUBLIC "-//W3C//DTD SVG 1.1//EN" '
38887
 
+                 '"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"'),
38888
 
+                'html PUBLIC "-//IETF//DTD HTML 2.0//EN"',
38889
 
+                'html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"']
38890
 
+        for dtd in dtds:
38891
 
+            self._run_check("<!DOCTYPE %s>" % dtd,
38892
 
+                            [('decl', 'DOCTYPE ' + dtd)])
38893
 
 
38894
 
     def test_declaration_junk_chars(self):
38895
 
-        self._parse_error("<!DOCTYPE foo $ >")
38896
 
+        self._run_check("<!DOCTYPE foo $ >", [('decl', 'DOCTYPE foo $ ')])
38897
 
 
38898
 
     def test_startendtag(self):
38899
 
         self._run_check("<p/>", [
38900
 
@@ -305,6 +257,44 @@
38901
 
             ("endtag", "p"),
38902
 
             ])
38903
 
 
38904
 
+    def test_invalid_end_tags(self):
38905
 
+        # A collection of broken end tags. <br> is used as separator.
38906
 
+        # see http://www.w3.org/TR/html5/tokenization.html#end-tag-open-state
38907
 
+        # and #13993
38908
 
+        html = ('<br></label</p><br></div end tmAd-leaderBoard><br></<h4><br>'
38909
 
+                '</li class="unit"><br></li\r\n\t\t\t\t\t\t</ul><br></><br>')
38910
 
+        expected = [('starttag', 'br', []),
38911
 
+                    # < is part of the name, / is discarded, p is an attribute
38912
 
+                    ('endtag', 'label<'),
38913
 
+                    ('starttag', 'br', []),
38914
 
+                    # text and attributes are discarded
38915
 
+                    ('endtag', 'div'),
38916
 
+                    ('starttag', 'br', []),
38917
 
+                    # comment because the first char after </ is not a-zA-Z
38918
 
+                    ('comment', '<h4'),
38919
 
+                    ('starttag', 'br', []),
38920
 
+                    # attributes are discarded
38921
 
+                    ('endtag', 'li'),
38922
 
+                    ('starttag', 'br', []),
38923
 
+                    # everything till ul (included) is discarded
38924
 
+                    ('endtag', 'li'),
38925
 
+                    ('starttag', 'br', []),
38926
 
+                    # </> is ignored
38927
 
+                    ('starttag', 'br', [])]
38928
 
+        self._run_check(html, expected)
38929
 
+
38930
 
+    def test_broken_invalid_end_tag(self):
38931
 
+        # This is technically wrong (the "> shouldn't be included in the 'data')
38932
 
+        # but is probably not worth fixing it (in addition to all the cases of
38933
 
+        # the previous test, it would require a full attribute parsing).
38934
 
+        # see #13993
38935
 
+        html = '<b>This</b attr=">"> confuses the parser'
38936
 
+        expected = [('starttag', 'b', []),
38937
 
+                    ('data', 'This'),
38938
 
+                    ('endtag', 'b'),
38939
 
+                    ('data', '"> confuses the parser')]
38940
 
+        self._run_check(html, expected)
38941
 
+
38942
 
     def test_get_starttag_text(self):
38943
 
         s = """<foo:bar   \n   one="1"\ttwo=2   >"""
38944
 
         self._run_check_extra(s, [
38945
 
@@ -312,23 +302,56 @@
38946
 
             ("starttag_text", s)])
38947
 
 
38948
 
     def test_cdata_content(self):
38949
 
-        s = """<script> <!-- not a comment --> &not-an-entity-ref; </script>"""
38950
 
-        self._run_check(s, [
38951
 
-            ("starttag", "script", []),
38952
 
-            ("data", " <!-- not a comment --> &not-an-entity-ref; "),
38953
 
-            ("endtag", "script"),
38954
 
-            ])
38955
 
-        s = """<script> <not a='start tag'> </script>"""
38956
 
-        self._run_check(s, [
38957
 
-            ("starttag", "script", []),
38958
 
-            ("data", " <not a='start tag'> "),
38959
 
-            ("endtag", "script"),
38960
 
-            ])
38961
 
+        contents = [
38962
 
+            '<!-- not a comment --> &not-an-entity-ref;',
38963
 
+            "<not a='start tag'>",
38964
 
+            '<a href="" /> <p> <span></span>',
38965
 
+            'foo = "</scr" + "ipt>";',
38966
 
+            'foo = "</SCRIPT" + ">";',
38967
 
+            'foo = <\n/script> ',
38968
 
+            '<!-- document.write("</scr" + "ipt>"); -->',
38969
 
+            ('\n//<![CDATA[\n'
38970
 
+             'document.write(\'<s\'+\'cript type="text/javascript" '
38971
 
+             'src="http://www.example.org/r=\'+new '
38972
 
+             'Date().getTime()+\'"><\\/s\'+\'cript>\');\n//]]>'),
38973
 
+            '\n<!-- //\nvar foo = 3.14;\n// -->\n',
38974
 
+            'foo = "</sty" + "le>";',
38975
 
+            u'<!-- \u2603 -->',
38976
 
+            # these two should be invalid according to the HTML 5 spec,
38977
 
+            # section 8.1.2.2
38978
 
+            #'foo = </\nscript>',
38979
 
+            #'foo = </ script>',
38980
 
+        ]
38981
 
+        elements = ['script', 'style', 'SCRIPT', 'STYLE', 'Script', 'Style']
38982
 
+        for content in contents:
38983
 
+            for element in elements:
38984
 
+                element_lower = element.lower()
38985
 
+                s = u'<{element}>{content}</{element}>'.format(element=element,
38986
 
+                                                               content=content)
38987
 
+                self._run_check(s, [("starttag", element_lower, []),
38988
 
+                                    ("data", content),
38989
 
+                                    ("endtag", element_lower)])
38990
 
 
38991
 
-    def test_entityrefs_in_attributes(self):
38992
 
-        self._run_check("<html foo='&euro;&amp;&#97;&#x61;&unsupported;'>", [
38993
 
-                ("starttag", "html", [("foo", u"\u20AC&aa&unsupported;")])
38994
 
-                ])
38995
 
+    def test_cdata_with_closing_tags(self):
38996
 
+        # see issue #13358
38997
 
+        # make sure that HTMLParser calls handle_data only once for each CDATA.
38998
 
+        # The normal event collector normalizes the events in get_events,
38999
 
+        # so we override it to return the original list of events.
39000
 
+        class Collector(EventCollector):
39001
 
+            def get_events(self):
39002
 
+                return self.events
39003
 
+
39004
 
+        content = """<!-- not a comment --> &not-an-entity-ref;
39005
 
+                  <a href="" /> </p><p> &amp; <span></span></style>
39006
 
+                  '</script' + '>' </html> </head> </scripter>!"""
39007
 
+        for element in [' script', 'script ', ' script ',
39008
 
+                        '\nscript', 'script\n', '\nscript\n']:
39009
 
+            s = u'<script>{content}</{element}>'.format(element=element,
39010
 
+                                                        content=content)
39011
 
+            self._run_check(s, [("starttag", "script", []),
39012
 
+                                ("data", content),
39013
 
+                                ("endtag", "script")],
39014
 
+                            collector=Collector)
39015
 
 
39016
 
     def test_malformatted_charref(self):
39017
 
         self._run_check("<p>&#bad;</p>", [
39018
 
@@ -343,8 +366,213 @@
39019
 
         self.assertEqual(parser.unescape('&#0038;'),'&')
39020
 
 
39021
 
 
39022
 
+
39023
 
+class AttributesTestCase(TestCaseBase):
39024
 
+
39025
 
+    def test_attr_syntax(self):
39026
 
+        output = [
39027
 
+          ("starttag", "a", [("b", "v"), ("c", "v"), ("d", "v"), ("e", None)])
39028
 
+        ]
39029
 
+        self._run_check("""<a b='v' c="v" d=v e>""", output)
39030
 
+        self._run_check("""<a  b = 'v' c = "v" d = v e>""", output)
39031
 
+        self._run_check("""<a\nb\n=\n'v'\nc\n=\n"v"\nd\n=\nv\ne>""", output)
39032
 
+        self._run_check("""<a\tb\t=\t'v'\tc\t=\t"v"\td\t=\tv\te>""", output)
39033
 
+
39034
 
+    def test_attr_values(self):
39035
 
+        self._run_check("""<a b='xxx\n\txxx' c="yyy\t\nyyy" d='\txyz\n'>""",
39036
 
+                        [("starttag", "a", [("b", "xxx\n\txxx"),
39037
 
+                                            ("c", "yyy\t\nyyy"),
39038
 
+                                            ("d", "\txyz\n")])])
39039
 
+        self._run_check("""<a b='' c="">""",
39040
 
+                        [("starttag", "a", [("b", ""), ("c", "")])])
39041
 
+        # Regression test for SF patch #669683.
39042
 
+        self._run_check("<e a=rgb(1,2,3)>",
39043
 
+                        [("starttag", "e", [("a", "rgb(1,2,3)")])])
39044
 
+        # Regression test for SF bug #921657.
39045
 
+        self._run_check(
39046
 
+            "<a href=mailto:xyz@example.com>",
39047
 
+            [("starttag", "a", [("href", "mailto:xyz@example.com")])])
39048
 
+
39049
 
+    def test_attr_nonascii(self):
39050
 
+        # see issue 7311
39051
 
+        self._run_check(
39052
 
+            u"<img src=/foo/bar.png alt=\u4e2d\u6587>",
39053
 
+            [("starttag", "img", [("src", "/foo/bar.png"),
39054
 
+                                  ("alt", u"\u4e2d\u6587")])])
39055
 
+        self._run_check(
39056
 
+            u"<a title='\u30c6\u30b9\u30c8' href='\u30c6\u30b9\u30c8.html'>",
39057
 
+            [("starttag", "a", [("title", u"\u30c6\u30b9\u30c8"),
39058
 
+                                ("href", u"\u30c6\u30b9\u30c8.html")])])
39059
 
+        self._run_check(
39060
 
+            u'<a title="\u30c6\u30b9\u30c8" href="\u30c6\u30b9\u30c8.html">',
39061
 
+            [("starttag", "a", [("title", u"\u30c6\u30b9\u30c8"),
39062
 
+                                ("href", u"\u30c6\u30b9\u30c8.html")])])
39063
 
+
39064
 
+    def test_attr_entity_replacement(self):
39065
 
+        self._run_check(
39066
 
+            "<a b='&amp;&gt;&lt;&quot;&apos;'>",
39067
 
+            [("starttag", "a", [("b", "&><\"'")])])
39068
 
+
39069
 
+    def test_attr_funky_names(self):
39070
 
+        self._run_check(
39071
 
+            "<a a.b='v' c:d=v e-f=v>",
39072
 
+            [("starttag", "a", [("a.b", "v"), ("c:d", "v"), ("e-f", "v")])])
39073
 
+        self._run_check(
39074
 
+            "<a $><b $=%><c \=/>",
39075
 
+            [("starttag", "a", [("$", None)]),
39076
 
+             ("starttag", "b", [("$", "%")]),
39077
 
+             ("starttag", "c", [("\\", "/")])])
39078
 
+
39079
 
+    def test_entityrefs_in_attributes(self):
39080
 
+        self._run_check(
39081
 
+            "<html foo='&euro;&amp;&#97;&#x61;&unsupported;'>",
39082
 
+            [("starttag", "html", [("foo", u"\u20AC&aa&unsupported;")])])
39083
 
+
39084
 
+    def test_entities_in_attribute_value(self):
39085
 
+        # see #1200313
39086
 
+        for entity in ['&', '&amp;', '&#38;', '&#x26;']:
39087
 
+            self._run_check('<a href="%s">' % entity,
39088
 
+                            [("starttag", "a", [("href", "&")])])
39089
 
+            self._run_check("<a href='%s'>" % entity,
39090
 
+                            [("starttag", "a", [("href", "&")])])
39091
 
+            self._run_check("<a href=%s>" % entity,
39092
 
+                            [("starttag", "a", [("href", "&")])])
39093
 
+
39094
 
+    def test_malformed_attributes(self):
39095
 
+        # see #13357
39096
 
+        html = (
39097
 
+            "<a href=test'style='color:red;bad1'>test - bad1</a>"
39098
 
+            "<a href=test'+style='color:red;ba2'>test - bad2</a>"
39099
 
+            "<a href=test'&nbsp;style='color:red;bad3'>test - bad3</a>"
39100
 
+            "<a href = test'&nbsp;style='color:red;bad4'  >test - bad4</a>"
39101
 
+        )
39102
 
+        expected = [
39103
 
+            ('starttag', 'a', [('href', "test'style='color:red;bad1'")]),
39104
 
+            ('data', 'test - bad1'), ('endtag', 'a'),
39105
 
+            ('starttag', 'a', [('href', "test'+style='color:red;ba2'")]),
39106
 
+            ('data', 'test - bad2'), ('endtag', 'a'),
39107
 
+            ('starttag', 'a', [('href', u"test'\xa0style='color:red;bad3'")]),
39108
 
+            ('data', 'test - bad3'), ('endtag', 'a'),
39109
 
+            ('starttag', 'a', [('href', u"test'\xa0style='color:red;bad4'")]),
39110
 
+            ('data', 'test - bad4'), ('endtag', 'a')
39111
 
+        ]
39112
 
+        self._run_check(html, expected)
39113
 
+
39114
 
+    def test_malformed_adjacent_attributes(self):
39115
 
+        # see #12629
39116
 
+        self._run_check('<x><y z=""o"" /></x>',
39117
 
+                        [('starttag', 'x', []),
39118
 
+                            ('startendtag', 'y', [('z', ''), ('o""', None)]),
39119
 
+                            ('endtag', 'x')])
39120
 
+        self._run_check('<x><y z="""" /></x>',
39121
 
+                        [('starttag', 'x', []),
39122
 
+                            ('startendtag', 'y', [('z', ''), ('""', None)]),
39123
 
+                            ('endtag', 'x')])
39124
 
+
39125
 
+    # see #755670 for the following 3 tests
39126
 
+    def test_adjacent_attributes(self):
39127
 
+        self._run_check('<a width="100%"cellspacing=0>',
39128
 
+                        [("starttag", "a",
39129
 
+                          [("width", "100%"), ("cellspacing","0")])])
39130
 
+
39131
 
+        self._run_check('<a id="foo"class="bar">',
39132
 
+                        [("starttag", "a",
39133
 
+                          [("id", "foo"), ("class","bar")])])
39134
 
+
39135
 
+    def test_missing_attribute_value(self):
39136
 
+        self._run_check('<a v=>',
39137
 
+                        [("starttag", "a", [("v", "")])])
39138
 
+
39139
 
+    def test_javascript_attribute_value(self):
39140
 
+        self._run_check("<a href=javascript:popup('/popup/help.html')>",
39141
 
+                        [("starttag", "a",
39142
 
+                          [("href", "javascript:popup('/popup/help.html')")])])
39143
 
+
39144
 
+    def test_end_tag_in_attribute_value(self):
39145
 
+        # see #1745761
39146
 
+        self._run_check("<a href='http://www.example.org/\">;'>spam</a>",
39147
 
+                        [("starttag", "a",
39148
 
+                          [("href", "http://www.example.org/\">;")]),
39149
 
+                         ("data", "spam"), ("endtag", "a")])
39150
 
+
39151
 
+    def test_comments(self):
39152
 
+        html = ("<!-- I'm a valid comment -->"
39153
 
+                '<!--me too!-->'
39154
 
+                '<!------>'
39155
 
+                '<!---->'
39156
 
+                '<!----I have many hyphens---->'
39157
 
+                '<!-- I have a > in the middle -->'
39158
 
+                '<!-- and I have -- in the middle! -->')
39159
 
+        expected = [('comment', " I'm a valid comment "),
39160
 
+                    ('comment', 'me too!'),
39161
 
+                    ('comment', '--'),
39162
 
+                    ('comment', ''),
39163
 
+                    ('comment', '--I have many hyphens--'),
39164
 
+                    ('comment', ' I have a > in the middle '),
39165
 
+                    ('comment', ' and I have -- in the middle! ')]
39166
 
+        self._run_check(html, expected)
39167
 
+
39168
 
+    def test_broken_comments(self):
39169
 
+        html = ('<! not really a comment >'
39170
 
+                '<! not a comment either -->'
39171
 
+                '<! -- close enough -->'
39172
 
+                '<!><!<-- this was an empty comment>'
39173
 
+                '<!!! another bogus comment !!!>')
39174
 
+        expected = [
39175
 
+            ('comment', ' not really a comment '),
39176
 
+            ('comment', ' not a comment either --'),
39177
 
+            ('comment', ' -- close enough --'),
39178
 
+            ('comment', ''),
39179
 
+            ('comment', '<-- this was an empty comment'),
39180
 
+            ('comment', '!! another bogus comment !!!'),
39181
 
+        ]
39182
 
+        self._run_check(html, expected)
39183
 
+
39184
 
+    def test_condcoms(self):
39185
 
+        html = ('<!--[if IE & !(lte IE 8)]>aren\'t<![endif]-->'
39186
 
+                '<!--[if IE 8]>condcoms<![endif]-->'
39187
 
+                '<!--[if lte IE 7]>pretty?<![endif]-->')
39188
 
+        expected = [('comment', "[if IE & !(lte IE 8)]>aren't<![endif]"),
39189
 
+                    ('comment', '[if IE 8]>condcoms<![endif]'),
39190
 
+                    ('comment', '[if lte IE 7]>pretty?<![endif]')]
39191
 
+        self._run_check(html, expected)
39192
 
+
39193
 
+    def test_broken_condcoms(self):
39194
 
+        # these condcoms are missing the '--' after '<!' and before the '>'
39195
 
+        html = ('<![if !(IE)]>broken condcom<![endif]>'
39196
 
+                '<![if ! IE]><link href="favicon.tiff"/><![endif]>'
39197
 
+                '<![if !IE 6]><img src="firefox.png" /><![endif]>'
39198
 
+                '<![if !ie 6]><b>foo</b><![endif]>'
39199
 
+                '<![if (!IE)|(lt IE 9)]><img src="mammoth.bmp" /><![endif]>')
39200
 
+        # According to the HTML5 specs sections "8.2.4.44 Bogus comment state"
39201
 
+        # and "8.2.4.45 Markup declaration open state", comment tokens should
39202
 
+        # be emitted instead of 'unknown decl', but calling unknown_decl
39203
 
+        # provides more flexibility.
39204
 
+        # See also Lib/_markupbase.py:parse_declaration
39205
 
+        expected = [
39206
 
+            ('unknown decl', 'if !(IE)'),
39207
 
+            ('data', 'broken condcom'),
39208
 
+            ('unknown decl', 'endif'),
39209
 
+            ('unknown decl', 'if ! IE'),
39210
 
+            ('startendtag', 'link', [('href', 'favicon.tiff')]),
39211
 
+            ('unknown decl', 'endif'),
39212
 
+            ('unknown decl', 'if !IE 6'),
39213
 
+            ('startendtag', 'img', [('src', 'firefox.png')]),
39214
 
+            ('unknown decl', 'endif'),
39215
 
+            ('unknown decl', 'if !ie 6'),
39216
 
+            ('starttag', 'b', []),
39217
 
+            ('data', 'foo'),
39218
 
+            ('endtag', 'b'),
39219
 
+            ('unknown decl', 'endif'),
39220
 
+            ('unknown decl', 'if (!IE)|(lt IE 9)'),
39221
 
+            ('startendtag', 'img', [('src', 'mammoth.bmp')]),
39222
 
+            ('unknown decl', 'endif')
39223
 
+        ]
39224
 
+        self._run_check(html, expected)
39225
 
+
39226
 
+
39227
 
 def test_main():
39228
 
-    test_support.run_unittest(HTMLParserTestCase)
39229
 
+    test_support.run_unittest(HTMLParserTestCase, AttributesTestCase)
39230
 
 
39231
 
 
39232
 
 if __name__ == "__main__":
39233
 
diff -r 8527427914a2 Lib/test/test_httplib.py
39234
 
--- a/Lib/test/test_httplib.py
39235
 
+++ b/Lib/test/test_httplib.py
39236
 
@@ -152,13 +152,15 @@
39237
 
     def test_host_port(self):
39238
 
         # Check invalid host_port
39239
 
 
39240
 
-        for hp in ("www.python.org:abc", "www.python.org:"):
39241
 
+        # Note that httplib does not accept user:password@ in the host-port.
39242
 
+        for hp in ("www.python.org:abc", "user:password@www.python.org"):
39243
 
             self.assertRaises(httplib.InvalidURL, httplib.HTTP, hp)
39244
 
 
39245
 
         for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b",
39246
 
                           8000),
39247
 
                          ("www.python.org:80", "www.python.org", 80),
39248
 
                          ("www.python.org", "www.python.org", 80),
39249
 
+                         ("www.python.org:", "www.python.org", 80),
39250
 
                          ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 80)):
39251
 
             http = httplib.HTTP(hp)
39252
 
             c = http._conn
39253
 
@@ -439,6 +441,28 @@
39254
 
             h = httplib.HTTPSConnection(HOST, TimeoutTest.PORT, timeout=30)
39255
 
             self.assertEqual(h.timeout, 30)
39256
 
 
39257
 
+    @unittest.skipIf(not hasattr(httplib, 'HTTPS'), 'httplib.HTTPS not available')
39258
 
+    def test_host_port(self):
39259
 
+        # Check invalid host_port
39260
 
+
39261
 
+        # Note that httplib does not accept user:password@ in the host-port.
39262
 
+        for hp in ("www.python.org:abc", "user:password@www.python.org"):
39263
 
+            self.assertRaises(httplib.InvalidURL, httplib.HTTP, hp)
39264
 
+
39265
 
+        for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b",
39266
 
+                          8000),
39267
 
+                         ("pypi.python.org:443", "pypi.python.org", 443),
39268
 
+                         ("pypi.python.org", "pypi.python.org", 443),
39269
 
+                         ("pypi.python.org:", "pypi.python.org", 443),
39270
 
+                         ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 443)):
39271
 
+            http = httplib.HTTPS(hp)
39272
 
+            c = http._conn
39273
 
+            if h != c.host:
39274
 
+                self.fail("Host incorrectly parsed: %s != %s" % (h, c.host))
39275
 
+            if p != c.port:
39276
 
+                self.fail("Port incorrectly parsed: %s != %s" % (p, c.host))
39277
 
+
39278
 
+
39279
 
 def test_main(verbose=None):
39280
 
     test_support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest,
39281
 
                               HTTPSTimeoutTest, SourceAddressTest)
39282
 
diff -r 8527427914a2 Lib/test/test_httpservers.py
39283
 
--- a/Lib/test/test_httpservers.py
39284
 
+++ b/Lib/test/test_httpservers.py
39285
 
@@ -324,8 +324,10 @@
39286
 
         f = open(os.path.join(self.tempdir_name, 'index.html'), 'w')
39287
 
         response = self.request('/' + self.tempdir_name + '/')
39288
 
         self.check_status_and_reason(response, 200)
39289
 
-        if os.name == 'posix':
39290
 
-            # chmod won't work as expected on Windows platforms
39291
 
+
39292
 
+        # chmod() doesn't work as expected on Windows, and filesystem
39293
 
+        # permissions are ignored by root on Unix.
39294
 
+        if os.name == 'posix' and os.geteuid() != 0:
39295
 
             os.chmod(self.tempdir, 0)
39296
 
             response = self.request(self.tempdir_name + '/')
39297
 
             self.check_status_and_reason(response, 404)
39298
 
@@ -370,6 +372,9 @@
39299
 
                           form.getfirst("bacon"))
39300
 
 """
39301
 
 
39302
 
+
39303
 
+@unittest.skipIf(hasattr(os, 'geteuid') and os.geteuid() == 0,
39304
 
+        "This test can't be run reliably as root (issue #13308).")
39305
 
 class CGIHTTPServerTestCase(BaseTestCase):
39306
 
     class request_handler(NoLogRequestHandler, CGIHTTPRequestHandler):
39307
 
         pass
39308
 
diff -r 8527427914a2 Lib/test/test_import.py
39309
 
--- a/Lib/test/test_import.py
39310
 
+++ b/Lib/test/test_import.py
39311
 
@@ -1,3 +1,4 @@
39312
 
+import errno
39313
 
 import imp
39314
 
 import marshal
39315
 
 import os
39316
 
@@ -263,7 +264,43 @@
39317
 
                   import imp
39318
 
             sys.argv.insert(0, C())
39319
 
             """))
39320
 
-        script_helper.assert_python_ok(testfn)
39321
 
+        try:
39322
 
+            script_helper.assert_python_ok(testfn)
39323
 
+        finally:
39324
 
+            unlink(testfn)
39325
 
+
39326
 
+    def test_bug7732(self):
39327
 
+        source = TESTFN + '.py'
39328
 
+        os.mkdir(source)
39329
 
+        try:
39330
 
+            self.assertRaises((ImportError, IOError),
39331
 
+                              imp.find_module, TESTFN, ["."])
39332
 
+        finally:
39333
 
+            os.rmdir(source)
39334
 
+
39335
 
+    def test_timestamp_overflow(self):
39336
 
+        # A modification timestamp larger than 2**32 should not be a problem
39337
 
+        # when importing a module (issue #11235).
39338
 
+        sys.path.insert(0, os.curdir)
39339
 
+        try:
39340
 
+            source = TESTFN + ".py"
39341
 
+            compiled = source + ('c' if __debug__ else 'o')
39342
 
+            with open(source, 'w') as f:
39343
 
+                pass
39344
 
+            try:
39345
 
+                os.utime(source, (2 ** 33 - 5, 2 ** 33 - 5))
39346
 
+            except OverflowError:
39347
 
+                self.skipTest("cannot set modification time to large integer")
39348
 
+            except OSError as e:
39349
 
+                if e.errno != getattr(errno, 'EOVERFLOW', None):
39350
 
+                    raise
39351
 
+                self.skipTest("cannot set modification time to large integer ({})".format(e))
39352
 
+            __import__(TESTFN)
39353
 
+            # The pyc file was created.
39354
 
+            os.stat(compiled)
39355
 
+        finally:
39356
 
+            del sys.path[0]
39357
 
+            remove_files(TESTFN)
39358
 
 
39359
 
 
39360
 
 class PycRewritingTests(unittest.TestCase):
39361
 
diff -r 8527427914a2 Lib/test/test_inspect.py
39362
 
--- a/Lib/test/test_inspect.py
39363
 
+++ b/Lib/test/test_inspect.py
39364
 
@@ -295,6 +295,23 @@
39365
 
         del sys.modules[name]
39366
 
         inspect.getmodule(compile('a=10','','single'))
39367
 
 
39368
 
+    def test_proceed_with_fake_filename(self):
39369
 
+        '''doctest monkeypatches linecache to enable inspection'''
39370
 
+        fn, source = '<test>', 'def x(): pass\n'
39371
 
+        getlines = linecache.getlines
39372
 
+        def monkey(filename, module_globals=None):
39373
 
+            if filename == fn:
39374
 
+                return source.splitlines(True)
39375
 
+            else:
39376
 
+                return getlines(filename, module_globals)
39377
 
+        linecache.getlines = monkey
39378
 
+        try:
39379
 
+            ns = {}
39380
 
+            exec compile(source, fn, 'single') in ns
39381
 
+            inspect.getsource(ns["x"])
39382
 
+        finally:
39383
 
+            linecache.getlines = getlines
39384
 
+
39385
 
 class TestDecorators(GetSourceBase):
39386
 
     fodderFile = mod2
39387
 
 
39388
 
@@ -387,10 +404,37 @@
39389
 
         self.assertEqual(inspect.findsource(co), (lines,0))
39390
 
         self.assertEqual(inspect.getsource(co), lines[0])
39391
 
 
39392
 
+
39393
 
+class _BrokenDataDescriptor(object):
39394
 
+    """
39395
 
+    A broken data descriptor. See bug #1785.
39396
 
+    """
39397
 
+    def __get__(*args):
39398
 
+        raise AssertionError("should not __get__ data descriptors")
39399
 
+
39400
 
+    def __set__(*args):
39401
 
+        raise RuntimeError
39402
 
+
39403
 
+    def __getattr__(*args):
39404
 
+        raise AssertionError("should not __getattr__ data descriptors")
39405
 
+
39406
 
+
39407
 
+class _BrokenMethodDescriptor(object):
39408
 
+    """
39409
 
+    A broken method descriptor. See bug #1785.
39410
 
+    """
39411
 
+    def __get__(*args):
39412
 
+        raise AssertionError("should not __get__ method descriptors")
39413
 
+
39414
 
+    def __getattr__(*args):
39415
 
+        raise AssertionError("should not __getattr__ method descriptors")
39416
 
+
39417
 
+
39418
 
 # Helper for testing classify_class_attrs.
39419
 
 def attrs_wo_objs(cls):
39420
 
     return [t[:3] for t in inspect.classify_class_attrs(cls)]
39421
 
 
39422
 
+
39423
 
 class TestClassesAndFunctions(unittest.TestCase):
39424
 
     def test_classic_mro(self):
39425
 
         # Test classic-class method resolution order.
39426
 
@@ -477,6 +521,9 @@
39427
 
 
39428
 
             datablob = '1'
39429
 
 
39430
 
+            dd = _BrokenDataDescriptor()
39431
 
+            md = _BrokenMethodDescriptor()
39432
 
+
39433
 
         attrs = attrs_wo_objs(A)
39434
 
         self.assertIn(('s', 'static method', A), attrs, 'missing static method')
39435
 
         self.assertIn(('c', 'class method', A), attrs, 'missing class method')
39436
 
@@ -484,6 +531,8 @@
39437
 
         self.assertIn(('m', 'method', A), attrs, 'missing plain method')
39438
 
         self.assertIn(('m1', 'method', A), attrs, 'missing plain method')
39439
 
         self.assertIn(('datablob', 'data', A), attrs, 'missing data')
39440
 
+        self.assertIn(('md', 'method', A), attrs, 'missing method descriptor')
39441
 
+        self.assertIn(('dd', 'data', A), attrs, 'missing data descriptor')
39442
 
 
39443
 
         class B(A):
39444
 
             def m(self): pass
39445
 
@@ -495,6 +544,8 @@
39446
 
         self.assertIn(('m', 'method', B), attrs, 'missing plain method')
39447
 
         self.assertIn(('m1', 'method', A), attrs, 'missing plain method')
39448
 
         self.assertIn(('datablob', 'data', A), attrs, 'missing data')
39449
 
+        self.assertIn(('md', 'method', A), attrs, 'missing method descriptor')
39450
 
+        self.assertIn(('dd', 'data', A), attrs, 'missing data descriptor')
39451
 
 
39452
 
 
39453
 
         class C(A):
39454
 
@@ -508,6 +559,8 @@
39455
 
         self.assertIn(('m', 'method', C), attrs, 'missing plain method')
39456
 
         self.assertIn(('m1', 'method', A), attrs, 'missing plain method')
39457
 
         self.assertIn(('datablob', 'data', A), attrs, 'missing data')
39458
 
+        self.assertIn(('md', 'method', A), attrs, 'missing method descriptor')
39459
 
+        self.assertIn(('dd', 'data', A), attrs, 'missing data descriptor')
39460
 
 
39461
 
         class D(B, C):
39462
 
             def m1(self): pass
39463
 
@@ -522,6 +575,8 @@
39464
 
         self.assertIn(('m', 'method', B), attrs, 'missing plain method')
39465
 
         self.assertIn(('m1', 'method', D), attrs, 'missing plain method')
39466
 
         self.assertIn(('datablob', 'data', A), attrs, 'missing data')
39467
 
+        self.assertIn(('md', 'method', A), attrs, 'missing method descriptor')
39468
 
+        self.assertIn(('dd', 'data', A), attrs, 'missing data descriptor')
39469
 
 
39470
 
 
39471
 
     def test_classify_oldstyle(self):
39472
 
@@ -537,6 +592,38 @@
39473
 
         """
39474
 
         self._classify_test(True)
39475
 
 
39476
 
+    def test_classify_builtin_types(self):
39477
 
+        # Simple sanity check that all built-in types can have their
39478
 
+        # attributes classified.
39479
 
+        for name in dir(__builtin__):
39480
 
+            builtin = getattr(__builtin__, name)
39481
 
+            if isinstance(builtin, type):
39482
 
+                inspect.classify_class_attrs(builtin)
39483
 
+
39484
 
+    def test_getmembers_method(self):
39485
 
+        # Old-style classes
39486
 
+        class B:
39487
 
+            def f(self):
39488
 
+                pass
39489
 
+
39490
 
+        self.assertIn(('f', B.f), inspect.getmembers(B))
39491
 
+        # contrary to spec, ismethod() is also True for unbound methods
39492
 
+        # (see #1785)
39493
 
+        self.assertIn(('f', B.f), inspect.getmembers(B, inspect.ismethod))
39494
 
+        b = B()
39495
 
+        self.assertIn(('f', b.f), inspect.getmembers(b))
39496
 
+        self.assertIn(('f', b.f), inspect.getmembers(b, inspect.ismethod))
39497
 
+
39498
 
+        # New-style classes
39499
 
+        class B(object):
39500
 
+            def f(self):
39501
 
+                pass
39502
 
+
39503
 
+        self.assertIn(('f', B.f), inspect.getmembers(B))
39504
 
+        self.assertIn(('f', B.f), inspect.getmembers(B, inspect.ismethod))
39505
 
+        b = B()
39506
 
+        self.assertIn(('f', b.f), inspect.getmembers(b))
39507
 
+        self.assertIn(('f', b.f), inspect.getmembers(b, inspect.ismethod))
39508
 
 
39509
 
 
39510
 
 class TestGetcallargsFunctions(unittest.TestCase):
39511
 
diff -r 8527427914a2 Lib/test/test_io.py
39512
 
--- a/Lib/test/test_io.py
39513
 
+++ b/Lib/test/test_io.py
39514
 
@@ -43,6 +43,10 @@
39515
 
     import threading
39516
 
 except ImportError:
39517
 
     threading = None
39518
 
+try:
39519
 
+    import fcntl
39520
 
+except ImportError:
39521
 
+    fcntl = None
39522
 
 
39523
 
 __metaclass__ = type
39524
 
 bytes = support.py3k_bytes
39525
 
@@ -228,9 +232,14 @@
39526
 
             except ValueError:
39527
 
                 pass
39528
 
             else:
39529
 
-                self._blocker_char = None
39530
 
-                self._write_stack.append(b[:n])
39531
 
-                raise self.BlockingIOError(0, "test blocking", n)
39532
 
+                if n > 0:
39533
 
+                    # write data up to the first blocker
39534
 
+                    self._write_stack.append(b[:n])
39535
 
+                    return n
39536
 
+                else:
39537
 
+                    # cancel blocker and indicate would block
39538
 
+                    self._blocker_char = None
39539
 
+                    return None
39540
 
         self._write_stack.append(b)
39541
 
         return len(b)
39542
 
 
39543
 
@@ -585,7 +594,24 @@
39544
 
         self.assertEqual(rawio.read(2), b"")
39545
 
 
39546
 
 class CIOTest(IOTest):
39547
 
-    pass
39548
 
+
39549
 
+    def test_IOBase_finalize(self):
39550
 
+        # Issue #12149: segmentation fault on _PyIOBase_finalize when both a
39551
 
+        # class which inherits IOBase and an object of this class are caught
39552
 
+        # in a reference cycle and close() is already in the method cache.
39553
 
+        class MyIO(self.IOBase):
39554
 
+            def close(self):
39555
 
+                pass
39556
 
+
39557
 
+        # create an instance to populate the method cache
39558
 
+        MyIO()
39559
 
+        obj = MyIO()
39560
 
+        obj.obj = obj
39561
 
+        wr = weakref.ref(obj)
39562
 
+        del MyIO
39563
 
+        del obj
39564
 
+        support.gc_collect()
39565
 
+        self.assertTrue(wr() is None, wr)
39566
 
 
39567
 
 class PyIOTest(IOTest):
39568
 
     test_array_writes = unittest.skip(
39569
 
@@ -1350,15 +1376,18 @@
39570
 
         rw.seek(0, 0)
39571
 
         self.assertEqual(b"asdf", rw.read(4))
39572
 
 
39573
 
-        rw.write(b"asdf")
39574
 
+        rw.write(b"123f")
39575
 
         rw.seek(0, 0)
39576
 
-        self.assertEqual(b"asdfasdfl", rw.read())
39577
 
+        self.assertEqual(b"asdf123fl", rw.read())
39578
 
         self.assertEqual(9, rw.tell())
39579
 
         rw.seek(-4, 2)
39580
 
         self.assertEqual(5, rw.tell())
39581
 
         rw.seek(2, 1)
39582
 
         self.assertEqual(7, rw.tell())
39583
 
         self.assertEqual(b"fl", rw.read(11))
39584
 
+        rw.flush()
39585
 
+        self.assertEqual(b"asdf123fl", raw.getvalue())
39586
 
+
39587
 
         self.assertRaises(TypeError, rw.seek, 0.0)
39588
 
 
39589
 
     def check_flush_and_read(self, read_func):
39590
 
@@ -1503,6 +1532,44 @@
39591
 
         BufferedReaderTest.test_misbehaved_io(self)
39592
 
         BufferedWriterTest.test_misbehaved_io(self)
39593
 
 
39594
 
+    def test_interleaved_read_write(self):
39595
 
+        # Test for issue #12213
39596
 
+        with self.BytesIO(b'abcdefgh') as raw:
39597
 
+            with self.tp(raw, 100) as f:
39598
 
+                f.write(b"1")
39599
 
+                self.assertEqual(f.read(1), b'b')
39600
 
+                f.write(b'2')
39601
 
+                self.assertEqual(f.read1(1), b'd')
39602
 
+                f.write(b'3')
39603
 
+                buf = bytearray(1)
39604
 
+                f.readinto(buf)
39605
 
+                self.assertEqual(buf, b'f')
39606
 
+                f.write(b'4')
39607
 
+                self.assertEqual(f.peek(1), b'h')
39608
 
+                f.flush()
39609
 
+                self.assertEqual(raw.getvalue(), b'1b2d3f4h')
39610
 
+
39611
 
+        with self.BytesIO(b'abc') as raw:
39612
 
+            with self.tp(raw, 100) as f:
39613
 
+                self.assertEqual(f.read(1), b'a')
39614
 
+                f.write(b"2")
39615
 
+                self.assertEqual(f.read(1), b'c')
39616
 
+                f.flush()
39617
 
+                self.assertEqual(raw.getvalue(), b'a2c')
39618
 
+
39619
 
+    def test_interleaved_readline_write(self):
39620
 
+        with self.BytesIO(b'ab\ncdef\ng\n') as raw:
39621
 
+            with self.tp(raw) as f:
39622
 
+                f.write(b'1')
39623
 
+                self.assertEqual(f.readline(), b'b\n')
39624
 
+                f.write(b'2')
39625
 
+                self.assertEqual(f.readline(), b'def\n')
39626
 
+                f.write(b'3')
39627
 
+                self.assertEqual(f.readline(), b'\n')
39628
 
+                f.flush()
39629
 
+                self.assertEqual(raw.getvalue(), b'1b\n2def\n3\n')
39630
 
+
39631
 
+
39632
 
 class CBufferedRandomTest(CBufferedReaderTest, CBufferedWriterTest, BufferedRandomTest):
39633
 
     tp = io.BufferedRandom
39634
 
 
39635
 
@@ -2280,6 +2347,21 @@
39636
 
         with self.open(support.TESTFN, "rb") as f:
39637
 
             self.assertEqual(f.read(), b"456def")
39638
 
 
39639
 
+    def test_rwpair_cleared_before_textio(self):
39640
 
+        # Issue 13070: TextIOWrapper's finalization would crash when called
39641
 
+        # after the reference to the underlying BufferedRWPair's writer got
39642
 
+        # cleared by the GC.
39643
 
+        for i in range(1000):
39644
 
+            b1 = self.BufferedRWPair(self.MockRawIO(), self.MockRawIO())
39645
 
+            t1 = self.TextIOWrapper(b1, encoding="ascii")
39646
 
+            b2 = self.BufferedRWPair(self.MockRawIO(), self.MockRawIO())
39647
 
+            t2 = self.TextIOWrapper(b2, encoding="ascii")
39648
 
+            # circular references
39649
 
+            t1.buddy = t2
39650
 
+            t2.buddy = t1
39651
 
+        support.gc_collect()
39652
 
+
39653
 
+
39654
 
 class PyTextIOWrapperTest(TextIOWrapperTest):
39655
 
     pass
39656
 
 
39657
 
@@ -2537,6 +2619,68 @@
39658
 
         # baseline "io" module.
39659
 
         self._check_abc_inheritance(io)
39660
 
 
39661
 
+    @unittest.skipUnless(fcntl, 'fcntl required for this test')
39662
 
+    def test_nonblock_pipe_write_bigbuf(self):
39663
 
+        self._test_nonblock_pipe_write(16*1024)
39664
 
+
39665
 
+    @unittest.skipUnless(fcntl, 'fcntl required for this test')
39666
 
+    def test_nonblock_pipe_write_smallbuf(self):
39667
 
+        self._test_nonblock_pipe_write(1024)
39668
 
+
39669
 
+    def _set_non_blocking(self, fd):
39670
 
+        flags = fcntl.fcntl(fd, fcntl.F_GETFL)
39671
 
+        self.assertNotEqual(flags, -1)
39672
 
+        res = fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
39673
 
+        self.assertEqual(res, 0)
39674
 
+
39675
 
+    def _test_nonblock_pipe_write(self, bufsize):
39676
 
+        sent = []
39677
 
+        received = []
39678
 
+        r, w = os.pipe()
39679
 
+        self._set_non_blocking(r)
39680
 
+        self._set_non_blocking(w)
39681
 
+
39682
 
+        # To exercise all code paths in the C implementation we need
39683
 
+        # to play with buffer sizes.  For instance, if we choose a
39684
 
+        # buffer size less than or equal to _PIPE_BUF (4096 on Linux)
39685
 
+        # then we will never get a partial write of the buffer.
39686
 
+        rf = self.open(r, mode='rb', closefd=True, buffering=bufsize)
39687
 
+        wf = self.open(w, mode='wb', closefd=True, buffering=bufsize)
39688
 
+
39689
 
+        with rf, wf:
39690
 
+            for N in 9999, 73, 7574:
39691
 
+                try:
39692
 
+                    i = 0
39693
 
+                    while True:
39694
 
+                        msg = bytes([i % 26 + 97]) * N
39695
 
+                        sent.append(msg)
39696
 
+                        wf.write(msg)
39697
 
+                        i += 1
39698
 
+
39699
 
+                except self.BlockingIOError as e:
39700
 
+                    self.assertEqual(e.args[0], errno.EAGAIN)
39701
 
+                    sent[-1] = sent[-1][:e.characters_written]
39702
 
+                    received.append(rf.read())
39703
 
+                    msg = b'BLOCKED'
39704
 
+                    wf.write(msg)
39705
 
+                    sent.append(msg)
39706
 
+
39707
 
+            while True:
39708
 
+                try:
39709
 
+                    wf.flush()
39710
 
+                    break
39711
 
+                except self.BlockingIOError as e:
39712
 
+                    self.assertEqual(e.args[0], errno.EAGAIN)
39713
 
+                    self.assertEqual(e.characters_written, 0)
39714
 
+                    received.append(rf.read())
39715
 
+
39716
 
+            received += iter(rf.read, None)
39717
 
+
39718
 
+        sent, received = b''.join(sent), b''.join(received)
39719
 
+        self.assertTrue(sent == received)
39720
 
+        self.assertTrue(wf.closed)
39721
 
+        self.assertTrue(rf.closed)
39722
 
+
39723
 
 class CMiscIOTest(MiscIOTest):
39724
 
     io = io
39725
 
 
39726
 
@@ -2557,6 +2701,8 @@
39727
 
         1 // 0
39728
 
 
39729
 
     @unittest.skipUnless(threading, 'Threading required for this test.')
39730
 
+    @unittest.skipIf(sys.platform in ('freebsd5', 'freebsd6', 'freebsd7'),
39731
 
+                     'issue #12429: skip test on FreeBSD <= 7')
39732
 
     def check_interrupted_write(self, item, bytes, **fdopen_kwargs):
39733
 
         """Check that a partial write, when it gets interrupted, properly
39734
 
         invokes the signal handler, and bubbles up the exception raised
39735
 
@@ -2610,7 +2756,7 @@
39736
 
         def on_alarm(*args):
39737
 
             # Will be called reentrantly from the same thread
39738
 
             wio.write(data)
39739
 
-            1/0
39740
 
+            1//0
39741
 
         signal.signal(signal.SIGALRM, on_alarm)
39742
 
         r, w = os.pipe()
39743
 
         wio = self.io.open(w, **fdopen_kwargs)
39744
 
diff -r 8527427914a2 Lib/test/test_itertools.py
39745
 
--- a/Lib/test/test_itertools.py
39746
 
+++ b/Lib/test/test_itertools.py
39747
 
@@ -137,7 +137,8 @@
39748
 
                 self.assertEqual(result, list(combinations2(values, r))) # matches second pure python version
39749
 
                 self.assertEqual(result, list(combinations3(values, r))) # matches second pure python version
39750
 
 
39751
 
-        # Test implementation detail:  tuple re-use
39752
 
+    @test_support.impl_detail("tuple reuse is specific to CPython")
39753
 
+    def test_combinations_tuple_reuse(self):
39754
 
         self.assertEqual(len(set(map(id, combinations('abcde', 3)))), 1)
39755
 
         self.assertNotEqual(len(set(map(id, list(combinations('abcde', 3))))), 1)
39756
 
 
39757
 
@@ -207,7 +208,9 @@
39758
 
                 self.assertEqual(result, list(cwr1(values, r)))         # matches first pure python version
39759
 
                 self.assertEqual(result, list(cwr2(values, r)))         # matches second pure python version
39760
 
 
39761
 
-        # Test implementation detail:  tuple re-use
39762
 
+    @test_support.impl_detail("tuple reuse is specific to CPython")
39763
 
+    def test_combinations_with_replacement_tuple_reuse(self):
39764
 
+        cwr = combinations_with_replacement
39765
 
         self.assertEqual(len(set(map(id, cwr('abcde', 3)))), 1)
39766
 
         self.assertNotEqual(len(set(map(id, list(cwr('abcde', 3))))), 1)
39767
 
 
39768
 
@@ -271,7 +274,8 @@
39769
 
                     self.assertEqual(result, list(permutations(values, None))) # test r as None
39770
 
                     self.assertEqual(result, list(permutations(values)))       # test default r
39771
 
 
39772
 
-        # Test implementation detail:  tuple re-use
39773
 
+    @test_support.impl_detail("tuple resuse is CPython specific")
39774
 
+    def test_permutations_tuple_reuse(self):
39775
 
         self.assertEqual(len(set(map(id, permutations('abcde', 3)))), 1)
39776
 
         self.assertNotEqual(len(set(map(id, list(permutations('abcde', 3))))), 1)
39777
 
 
39778
 
@@ -526,11 +530,13 @@
39779
 
         self.assertEqual(list(izip()), zip())
39780
 
         self.assertRaises(TypeError, izip, 3)
39781
 
         self.assertRaises(TypeError, izip, range(3), 3)
39782
 
-        # Check tuple re-use (implementation detail)
39783
 
         self.assertEqual([tuple(list(pair)) for pair in izip('abc', 'def')],
39784
 
                          zip('abc', 'def'))
39785
 
         self.assertEqual([pair for pair in izip('abc', 'def')],
39786
 
                          zip('abc', 'def'))
39787
 
+
39788
 
+    @test_support.impl_detail("tuple reuse is specific to CPython")
39789
 
+    def test_izip_tuple_resuse(self):
39790
 
         ids = map(id, izip('abc', 'def'))
39791
 
         self.assertEqual(min(ids), max(ids))
39792
 
         ids = map(id, list(izip('abc', 'def')))
39793
 
@@ -575,11 +581,13 @@
39794
 
             else:
39795
 
                 self.fail('Did not raise Type in:  ' + stmt)
39796
 
 
39797
 
-        # Check tuple re-use (implementation detail)
39798
 
         self.assertEqual([tuple(list(pair)) for pair in izip_longest('abc', 'def')],
39799
 
                          zip('abc', 'def'))
39800
 
         self.assertEqual([pair for pair in izip_longest('abc', 'def')],
39801
 
                          zip('abc', 'def'))
39802
 
+
39803
 
+    @test_support.impl_detail("tuple reuse is specific to CPython")
39804
 
+    def test_izip_longest_tuple_reuse(self):
39805
 
         ids = map(id, izip_longest('abc', 'def'))
39806
 
         self.assertEqual(min(ids), max(ids))
39807
 
         ids = map(id, list(izip_longest('abc', 'def')))
39808
 
@@ -683,7 +691,8 @@
39809
 
             args = map(iter, args)
39810
 
             self.assertEqual(len(list(product(*args))), expected_len)
39811
 
 
39812
 
-        # Test implementation detail:  tuple re-use
39813
 
+    @test_support.impl_detail("tuple reuse is specific to CPython")
39814
 
+    def test_product_tuple_reuse(self):
39815
 
         self.assertEqual(len(set(map(id, product('abc', 'def')))), 1)
39816
 
         self.assertNotEqual(len(set(map(id, list(product('abc', 'def'))))), 1)
39817
 
 
39818
 
diff -r 8527427914a2 Lib/test/test_locale.py
39819
 
--- a/Lib/test/test_locale.py
39820
 
+++ b/Lib/test/test_locale.py
39821
 
@@ -396,6 +396,24 @@
39822
 
         # crasher from bug #7419
39823
 
         self.assertRaises(locale.Error, locale.setlocale, 12345)
39824
 
 
39825
 
+    def test_getsetlocale_issue1813(self):
39826
 
+        # Issue #1813: setting and getting the locale under a Turkish locale
39827
 
+        oldlocale = locale.getlocale()
39828
 
+        self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)
39829
 
+        try:
39830
 
+            locale.setlocale(locale.LC_CTYPE, 'tr_TR')
39831
 
+        except locale.Error:
39832
 
+            # Unsupported locale on this system
39833
 
+            self.skipTest('test needs Turkish locale')
39834
 
+        loc = locale.getlocale()
39835
 
+        locale.setlocale(locale.LC_CTYPE, loc)
39836
 
+        self.assertEqual(loc, locale.getlocale())
39837
 
+
39838
 
+    def test_normalize_issue12752(self):
39839
 
+        # Issue #1813 caused a regression where locale.normalize() would no
39840
 
+        # longer accept unicode strings.
39841
 
+        self.assertEqual(locale.normalize(u'en_US'), 'en_US.ISO8859-1')
39842
 
+
39843
 
 
39844
 
 def test_main():
39845
 
     tests = [
39846
 
diff -r 8527427914a2 Lib/test/test_logging.py
39847
 
--- a/Lib/test/test_logging.py
39848
 
+++ b/Lib/test/test_logging.py
39849
 
@@ -272,6 +272,8 @@
39850
 
             ('INF.BADPARENT', 'INFO', '4'),
39851
 
         ])
39852
 
 
39853
 
+    def test_invalid_name(self):
39854
 
+        self.assertRaises(TypeError, logging.getLogger, any)
39855
 
 
39856
 
 class BasicFilterTest(BaseTest):
39857
 
 
39858
 
diff -r 8527427914a2 Lib/test/test_mailbox.py
39859
 
--- a/Lib/test/test_mailbox.py
39860
 
+++ b/Lib/test/test_mailbox.py
39861
 
@@ -174,6 +174,13 @@
39862
 
         self.assertEqual(self._box.get_file(key1).read().replace(os.linesep, '\n'),
39863
 
                          _sample_message)
39864
 
 
39865
 
+    def test_get_file_can_be_closed_twice(self):
39866
 
+        # Issue 11700
39867
 
+        key = self._box.add(_sample_message)
39868
 
+        f = self._box.get_file(key)
39869
 
+        f.close()
39870
 
+        f.close()
39871
 
+
39872
 
     def test_iterkeys(self):
39873
 
         # Get keys using iterkeys()
39874
 
         self._check_iteration(self._box.iterkeys, do_keys=True, do_values=False)
39875
 
@@ -676,6 +683,25 @@
39876
 
                                           key1: os.path.join('new', key1),
39877
 
                                           key2: os.path.join('new', key2)})
39878
 
 
39879
 
+    def test_refresh_after_safety_period(self):
39880
 
+        # Issue #13254: Call _refresh after the "file system safety
39881
 
+        # period" of 2 seconds has passed; _toc should still be
39882
 
+        # updated because this is the first call to _refresh.
39883
 
+        key0 = self._box.add(self._template % 0)
39884
 
+        key1 = self._box.add(self._template % 1)
39885
 
+
39886
 
+        self._box = self._factory(self._path)
39887
 
+        self.assertEqual(self._box._toc, {})
39888
 
+
39889
 
+        # Emulate sleeping. Instead of sleeping for 2 seconds, use the
39890
 
+        # skew factor to make _refresh think that the filesystem
39891
 
+        # safety period has passed and re-reading the _toc is only
39892
 
+        # required if mtimes differ.
39893
 
+        self._box._skewfactor = -3
39894
 
+
39895
 
+        self._box._refresh()
39896
 
+        self.assertEqual(sorted(self._box._toc.keys()), sorted([key0, key1]))
39897
 
+
39898
 
     def test_lookup(self):
39899
 
         # Look up message subpaths in the TOC
39900
 
         self.assertRaises(KeyError, lambda: self._box._lookup('foo'))
39901
 
@@ -751,6 +777,8 @@
39902
 
         self.assertFalse((perms & 0111)) # Execute bits should all be off.
39903
 
 
39904
 
     def test_reread(self):
39905
 
+        # Do an initial unconditional refresh
39906
 
+        self._box._refresh()
39907
 
 
39908
 
         # Put the last modified times more than two seconds into the past
39909
 
         # (because mtime may have only a two second granularity).
39910
 
@@ -762,7 +790,12 @@
39911
 
         # refresh is done unconditionally if called for within
39912
 
         # two-second-plus-a-bit of the last one, just in case the mbox has
39913
 
         # changed; so now we have to wait for that interval to expire.
39914
 
-        time.sleep(2.01 + self._box._skewfactor)
39915
 
+        #
39916
 
+        # Because this is a test, emulate sleeping. Instead of
39917
 
+        # sleeping for 2 seconds, use the skew factor to make _refresh
39918
 
+        # think that 2 seconds have passed and re-reading the _toc is
39919
 
+        # only required if mtimes differ.
39920
 
+        self._box._skewfactor = -3
39921
 
 
39922
 
         # Re-reading causes the ._toc attribute to be assigned a new dictionary
39923
 
         # object, so we'll check that the ._toc attribute isn't a different
39924
 
@@ -775,7 +808,8 @@
39925
 
         self.assertFalse(refreshed())
39926
 
 
39927
 
         # Now, write something into cur and remove it.  This changes
39928
 
-        # the mtime and should cause a re-read.
39929
 
+        # the mtime and should cause a re-read. Note that "sleep
39930
 
+        # emulation" is still in effect, as skewfactor is -3.
39931
 
         filename = os.path.join(self._path, 'cur', 'stray-file')
39932
 
         f = open(filename, 'w')
39933
 
         f.close()
39934
 
@@ -831,26 +865,37 @@
39935
 
             self.assertEqual(contents, f.read())
39936
 
         self._box = self._factory(self._path)
39937
 
 
39938
 
+    @unittest.skipUnless(hasattr(os, 'fork'), "Test needs fork().")
39939
 
+    @unittest.skipUnless(hasattr(socket, 'socketpair'), "Test needs socketpair().")
39940
 
     def test_lock_conflict(self):
39941
 
-        # Fork off a subprocess that will lock the file for 2 seconds,
39942
 
-        # unlock it, and then exit.
39943
 
-        if not hasattr(os, 'fork'):
39944
 
-            return
39945
 
+        # Fork off a child process that will lock the mailbox temporarily,
39946
 
+        # unlock it and exit.
39947
 
+        c, p = socket.socketpair()
39948
 
+        self.addCleanup(c.close)
39949
 
+        self.addCleanup(p.close)
39950
 
+
39951
 
         pid = os.fork()
39952
 
         if pid == 0:
39953
 
-            # In the child, lock the mailbox.
39954
 
-            self._box.lock()
39955
 
-            time.sleep(2)
39956
 
-            self._box.unlock()
39957
 
-            os._exit(0)
39958
 
+            # child
39959
 
+            try:
39960
 
+                # lock the mailbox, and signal the parent it can proceed
39961
 
+                self._box.lock()
39962
 
+                c.send(b'c')
39963
 
 
39964
 
-        # In the parent, sleep a bit to give the child time to acquire
39965
 
-        # the lock.
39966
 
-        time.sleep(0.5)
39967
 
+                # wait until the parent is done, and unlock the mailbox
39968
 
+                c.recv(1)
39969
 
+                self._box.unlock()
39970
 
+            finally:
39971
 
+                os._exit(0)
39972
 
+
39973
 
+        # In the parent, wait until the child signals it locked the mailbox.
39974
 
+        p.recv(1)
39975
 
         try:
39976
 
             self.assertRaises(mailbox.ExternalClashError,
39977
 
                               self._box.lock)
39978
 
         finally:
39979
 
+            # Signal the child it can now release the lock and exit.
39980
 
+            p.send(b'p')
39981
 
             # Wait for child to exit.  Locking should now succeed.
39982
 
             exited_pid, status = os.waitpid(pid, 0)
39983
 
 
39984
 
@@ -1670,7 +1715,8 @@
39985
 
     def _test_close(self, proxy):
39986
 
         # Close a file
39987
 
         proxy.close()
39988
 
-        self.assertRaises(AttributeError, lambda: proxy.close())
39989
 
+        # Issue 11700 subsequent closes should be a no-op, not an error.
39990
 
+        proxy.close()
39991
 
 
39992
 
 
39993
 
 class TestProxyFile(TestProxyFileBase):
39994
 
diff -r 8527427914a2 Lib/test/test_minidom.py
39995
 
--- a/Lib/test/test_minidom.py
39996
 
+++ b/Lib/test/test_minidom.py
39997
 
@@ -439,6 +439,40 @@
39998
 
         dom.unlink()
39999
 
         self.confirm(domstr == str.replace("\n", "\r\n"))
40000
 
 
40001
 
+    def test_toprettyxml_with_text_nodes(self):
40002
 
+        # see issue #4147, text nodes are not indented
40003
 
+        decl = '<?xml version="1.0" ?>\n'
40004
 
+        self.assertEqual(parseString('<B>A</B>').toprettyxml(),
40005
 
+                         decl + '<B>A</B>\n')
40006
 
+        self.assertEqual(parseString('<C>A<B>A</B></C>').toprettyxml(),
40007
 
+                         decl + '<C>\n\tA\n\t<B>A</B>\n</C>\n')
40008
 
+        self.assertEqual(parseString('<C><B>A</B>A</C>').toprettyxml(),
40009
 
+                         decl + '<C>\n\t<B>A</B>\n\tA\n</C>\n')
40010
 
+        self.assertEqual(parseString('<C><B>A</B><B>A</B></C>').toprettyxml(),
40011
 
+                         decl + '<C>\n\t<B>A</B>\n\t<B>A</B>\n</C>\n')
40012
 
+        self.assertEqual(parseString('<C><B>A</B>A<B>A</B></C>').toprettyxml(),
40013
 
+                         decl + '<C>\n\t<B>A</B>\n\tA\n\t<B>A</B>\n</C>\n')
40014
 
+
40015
 
+    def test_toprettyxml_with_adjacent_text_nodes(self):
40016
 
+        # see issue #4147, adjacent text nodes are indented normally
40017
 
+        dom = Document()
40018
 
+        elem = dom.createElement(u'elem')
40019
 
+        elem.appendChild(dom.createTextNode(u'TEXT'))
40020
 
+        elem.appendChild(dom.createTextNode(u'TEXT'))
40021
 
+        dom.appendChild(elem)
40022
 
+        decl = '<?xml version="1.0" ?>\n'
40023
 
+        self.assertEqual(dom.toprettyxml(),
40024
 
+                         decl + '<elem>\n\tTEXT\n\tTEXT\n</elem>\n')
40025
 
+
40026
 
+    def test_toprettyxml_preserves_content_of_text_node(self):
40027
 
+        # see issue #4147
40028
 
+        for str in ('<B>A</B>', '<A><B>C</B></A>'):
40029
 
+            dom = parseString(str)
40030
 
+            dom2 = parseString(dom.toprettyxml())
40031
 
+            self.assertEqual(
40032
 
+                dom.getElementsByTagName('B')[0].childNodes[0].toxml(),
40033
 
+                dom2.getElementsByTagName('B')[0].childNodes[0].toxml())
40034
 
+
40035
 
     def testProcessingInstruction(self):
40036
 
         dom = parseString('<e><?mypi \t\n data \t\n ?></e>')
40037
 
         pi = dom.documentElement.firstChild
40038
 
diff -r 8527427914a2 Lib/test/test_multibytecodec_support.py
40039
 
--- a/Lib/test/test_multibytecodec_support.py
40040
 
+++ b/Lib/test/test_multibytecodec_support.py
40041
 
@@ -44,13 +44,24 @@
40042
 
 
40043
 
     def test_errorhandle(self):
40044
 
         for source, scheme, expected in self.codectests:
40045
 
-            if type(source) == type(''):
40046
 
+            if isinstance(source, bytes):
40047
 
                 func = self.decode
40048
 
             else:
40049
 
                 func = self.encode
40050
 
             if expected:
40051
 
                 result = func(source, scheme)[0]
40052
 
-                self.assertEqual(result, expected)
40053
 
+                if func is self.decode:
40054
 
+                    self.assertTrue(type(result) is unicode, type(result))
40055
 
+                    self.assertEqual(result, expected,
40056
 
+                                     '%r.decode(%r, %r)=%r != %r'
40057
 
+                                     % (source, self.encoding, scheme, result,
40058
 
+                                        expected))
40059
 
+                else:
40060
 
+                    self.assertTrue(type(result) is bytes, type(result))
40061
 
+                    self.assertEqual(result, expected,
40062
 
+                                     '%r.encode(%r, %r)=%r != %r'
40063
 
+                                     % (source, self.encoding, scheme, result,
40064
 
+                                        expected))
40065
 
             else:
40066
 
                 self.assertRaises(UnicodeError, func, source, scheme)
40067
 
 
40068
 
@@ -251,6 +262,7 @@
40069
 
     pass_enctest = []
40070
 
     pass_dectest = []
40071
 
     supmaps = []
40072
 
+    codectests = []
40073
 
 
40074
 
     def __init__(self, *args, **kw):
40075
 
         unittest.TestCase.__init__(self, *args, **kw)
40076
 
@@ -329,6 +341,30 @@
40077
 
                 self.fail('Decoding failed while testing %s -> %s: %s' % (
40078
 
                             repr(csetch), repr(unich), exc.reason))
40079
 
 
40080
 
+    def test_errorhandle(self):
40081
 
+        for source, scheme, expected in self.codectests:
40082
 
+            if isinstance(source, bytes):
40083
 
+                func = source.decode
40084
 
+            else:
40085
 
+                func = source.encode
40086
 
+            if expected:
40087
 
+                if isinstance(source, bytes):
40088
 
+                    result = func(self.encoding, scheme)
40089
 
+                    self.assertTrue(type(result) is unicode, type(result))
40090
 
+                    self.assertEqual(result, expected,
40091
 
+                                     '%r.decode(%r, %r)=%r != %r'
40092
 
+                                     % (source, self.encoding, scheme, result,
40093
 
+                                        expected))
40094
 
+                else:
40095
 
+                    result = func(self.encoding, scheme)
40096
 
+                    self.assertTrue(type(result) is bytes, type(result))
40097
 
+                    self.assertEqual(result, expected,
40098
 
+                                     '%r.encode(%r, %r)=%r != %r'
40099
 
+                                     % (source, self.encoding, scheme, result,
40100
 
+                                        expected))
40101
 
+            else:
40102
 
+                self.assertRaises(UnicodeError, func, self.encoding, scheme)
40103
 
+
40104
 
 def load_teststring(name):
40105
 
     dir = os.path.join(os.path.dirname(__file__), 'cjkencodings')
40106
 
     with open(os.path.join(dir, name + '.txt'), 'rb') as f:
40107
 
diff -r 8527427914a2 Lib/test/test_multiprocessing.py
40108
 
--- a/Lib/test/test_multiprocessing.py
40109
 
+++ b/Lib/test/test_multiprocessing.py
40110
 
@@ -15,6 +15,7 @@
40111
 
 import socket
40112
 
 import random
40113
 
 import logging
40114
 
+import errno
40115
 
 from test import test_support
40116
 
 from StringIO import StringIO
40117
 
 _multiprocessing = test_support.import_module('_multiprocessing')
40118
 
@@ -35,11 +36,22 @@
40119
 
 from multiprocessing import util
40120
 
 
40121
 
 try:
40122
 
+    from multiprocessing import reduction
40123
 
+    HAS_REDUCTION = True
40124
 
+except ImportError:
40125
 
+    HAS_REDUCTION = False
40126
 
+
40127
 
+try:
40128
 
     from multiprocessing.sharedctypes import Value, copy
40129
 
     HAS_SHAREDCTYPES = True
40130
 
 except ImportError:
40131
 
     HAS_SHAREDCTYPES = False
40132
 
 
40133
 
+try:
40134
 
+    import msvcrt
40135
 
+except ImportError:
40136
 
+    msvcrt = None
40137
 
+
40138
 
 #
40139
 
 #
40140
 
 #
40141
 
@@ -68,6 +80,11 @@
40142
 
 
40143
 
 WIN32 = (sys.platform == "win32")
40144
 
 
40145
 
+try:
40146
 
+    MAXFD = os.sysconf("SC_OPEN_MAX")
40147
 
+except:
40148
 
+    MAXFD = 256
40149
 
+
40150
 
 #
40151
 
 # Some tests require ctypes
40152
 
 #
40153
 
@@ -78,6 +95,22 @@
40154
 
     Structure = object
40155
 
     c_int = c_double = None
40156
 
 
40157
 
+
40158
 
+def check_enough_semaphores():
40159
 
+    """Check that the system supports enough semaphores to run the test."""
40160
 
+    # minimum number of semaphores available according to POSIX
40161
 
+    nsems_min = 256
40162
 
+    try:
40163
 
+        nsems = os.sysconf("SC_SEM_NSEMS_MAX")
40164
 
+    except (AttributeError, ValueError):
40165
 
+        # sysconf not available or setting not available
40166
 
+        return
40167
 
+    if nsems == -1 or nsems >= nsems_min:
40168
 
+        return
40169
 
+    raise unittest.SkipTest("The OS doesn't support enough semaphores "
40170
 
+                            "to run the test (required: %d)." % nsems_min)
40171
 
+
40172
 
+
40173
 
 #
40174
 
 # Creates a wrapper for a function which records the time it takes to finish
40175
 
 #
40176
 
@@ -253,6 +286,7 @@
40177
 
         p = self.Process(target=time.sleep, args=(DELTA,))
40178
 
         self.assertNotIn(p, self.active_children())
40179
 
 
40180
 
+        p.daemon = True
40181
 
         p.start()
40182
 
         self.assertIn(p, self.active_children())
40183
 
 
40184
 
@@ -323,6 +357,7 @@
40185
 
 
40186
 
     def test_subclassing(self):
40187
 
         uppercaser = _UpperCaser()
40188
 
+        uppercaser.daemon = True
40189
 
         uppercaser.start()
40190
 
         self.assertEqual(uppercaser.submit('hello'), 'HELLO')
40191
 
         self.assertEqual(uppercaser.submit('world'), 'WORLD')
40192
 
@@ -501,6 +536,7 @@
40193
 
 
40194
 
         # fork process
40195
 
         p = self.Process(target=self._test_fork, args=(queue,))
40196
 
+        p.daemon = True
40197
 
         p.start()
40198
 
 
40199
 
         # check that all expected items are in the queue
40200
 
@@ -541,6 +577,7 @@
40201
 
                    for i in xrange(4)]
40202
 
 
40203
 
         for p in workers:
40204
 
+            p.daemon = True
40205
 
             p.start()
40206
 
 
40207
 
         for i in xrange(10):
40208
 
@@ -805,7 +842,9 @@
40209
 
 
40210
 
         #self.assertEqual(event.is_set(), False)
40211
 
 
40212
 
-        self.Process(target=self._test_event, args=(event,)).start()
40213
 
+        p = self.Process(target=self._test_event, args=(event,))
40214
 
+        p.daemon = True
40215
 
+        p.start()
40216
 
         self.assertEqual(wait(), True)
40217
 
 
40218
 
 #
40219
 
@@ -845,6 +884,7 @@
40220
 
             self.assertEqual(sv.value, cv[1])
40221
 
 
40222
 
         proc = self.Process(target=self._test, args=(values,))
40223
 
+        proc.daemon = True
40224
 
         proc.start()
40225
 
         proc.join()
40226
 
 
40227
 
@@ -908,6 +948,7 @@
40228
 
         self.f(seq)
40229
 
 
40230
 
         p = self.Process(target=self.f, args=(arr,))
40231
 
+        p.daemon = True
40232
 
         p.start()
40233
 
         p.join()
40234
 
 
40235
 
@@ -1085,6 +1126,9 @@
40236
 
         self.assertEqual(sorted(it), map(sqr, range(1000)))
40237
 
 
40238
 
     def test_make_pool(self):
40239
 
+        self.assertRaises(ValueError, multiprocessing.Pool, -1)
40240
 
+        self.assertRaises(ValueError, multiprocessing.Pool, 0)
40241
 
+
40242
 
         p = multiprocessing.Pool(3)
40243
 
         self.assertEqual(3, len(p._pool))
40244
 
         p.close()
40245
 
@@ -1140,6 +1184,20 @@
40246
 
         p.close()
40247
 
         p.join()
40248
 
 
40249
 
+    def test_pool_worker_lifetime_early_close(self):
40250
 
+        # Issue #10332: closing a pool whose workers have limited lifetimes
40251
 
+        # before all the tasks completed would make join() hang.
40252
 
+        p = multiprocessing.Pool(3, maxtasksperchild=1)
40253
 
+        results = []
40254
 
+        for i in range(6):
40255
 
+            results.append(p.apply_async(sqr, (i, 0.3)))
40256
 
+        p.close()
40257
 
+        p.join()
40258
 
+        # check the results
40259
 
+        for (j, res) in enumerate(results):
40260
 
+            self.assertEqual(res.get(), sqr(j))
40261
 
+
40262
 
+
40263
 
 #
40264
 
 # Test that manager has expected number of shared objects left
40265
 
 #
40266
 
@@ -1271,6 +1329,7 @@
40267
 
         manager.start()
40268
 
 
40269
 
         p = self.Process(target=self._putter, args=(manager.address, authkey))
40270
 
+        p.daemon = True
40271
 
         p.start()
40272
 
 
40273
 
         manager2 = QueueManager2(
40274
 
@@ -1312,6 +1371,7 @@
40275
 
         manager.start()
40276
 
 
40277
 
         p = self.Process(target=self._putter, args=(manager.address, authkey))
40278
 
+        p.daemon = True
40279
 
         p.start()
40280
 
         queue = manager.get_queue()
40281
 
         self.assertEqual(queue.get(), 'hello world')
40282
 
@@ -1435,6 +1495,7 @@
40283
 
         conn, child_conn = self.Pipe()
40284
 
 
40285
 
         p = self.Process(target=self._echo, args=(child_conn,))
40286
 
+        p.daemon = True
40287
 
         p.start()
40288
 
         child_conn.close()    # this might complete before child initializes
40289
 
 
40290
 
@@ -1478,6 +1539,98 @@
40291
 
 
40292
 
         self.assertRaises(ValueError, a.send_bytes, msg, 4, -1)
40293
 
 
40294
 
+    @classmethod
40295
 
+    def _is_fd_assigned(cls, fd):
40296
 
+        try:
40297
 
+            os.fstat(fd)
40298
 
+        except OSError as e:
40299
 
+            if e.errno == errno.EBADF:
40300
 
+                return False
40301
 
+            raise
40302
 
+        else:
40303
 
+            return True
40304
 
+
40305
 
+    @classmethod
40306
 
+    def _writefd(cls, conn, data, create_dummy_fds=False):
40307
 
+        if create_dummy_fds:
40308
 
+            for i in range(0, 256):
40309
 
+                if not cls._is_fd_assigned(i):
40310
 
+                    os.dup2(conn.fileno(), i)
40311
 
+        fd = reduction.recv_handle(conn)
40312
 
+        if msvcrt:
40313
 
+            fd = msvcrt.open_osfhandle(fd, os.O_WRONLY)
40314
 
+        os.write(fd, data)
40315
 
+        os.close(fd)
40316
 
+
40317
 
+    @unittest.skipUnless(HAS_REDUCTION, "test needs multiprocessing.reduction")
40318
 
+    def test_fd_transfer(self):
40319
 
+        if self.TYPE != 'processes':
40320
 
+            self.skipTest("only makes sense with processes")
40321
 
+        conn, child_conn = self.Pipe(duplex=True)
40322
 
+
40323
 
+        p = self.Process(target=self._writefd, args=(child_conn, b"foo"))
40324
 
+        p.daemon = True
40325
 
+        p.start()
40326
 
+        with open(test_support.TESTFN, "wb") as f:
40327
 
+            fd = f.fileno()
40328
 
+            if msvcrt:
40329
 
+                fd = msvcrt.get_osfhandle(fd)
40330
 
+            reduction.send_handle(conn, fd, p.pid)
40331
 
+        p.join()
40332
 
+        with open(test_support.TESTFN, "rb") as f:
40333
 
+            self.assertEqual(f.read(), b"foo")
40334
 
+
40335
 
+    @unittest.skipUnless(HAS_REDUCTION, "test needs multiprocessing.reduction")
40336
 
+    @unittest.skipIf(sys.platform == "win32",
40337
 
+                     "test semantics don't make sense on Windows")
40338
 
+    @unittest.skipIf(MAXFD <= 256,
40339
 
+                     "largest assignable fd number is too small")
40340
 
+    @unittest.skipUnless(hasattr(os, "dup2"),
40341
 
+                         "test needs os.dup2()")
40342
 
+    def test_large_fd_transfer(self):
40343
 
+        # With fd > 256 (issue #11657)
40344
 
+        if self.TYPE != 'processes':
40345
 
+            self.skipTest("only makes sense with processes")
40346
 
+        conn, child_conn = self.Pipe(duplex=True)
40347
 
+
40348
 
+        p = self.Process(target=self._writefd, args=(child_conn, b"bar", True))
40349
 
+        p.daemon = True
40350
 
+        p.start()
40351
 
+        with open(test_support.TESTFN, "wb") as f:
40352
 
+            fd = f.fileno()
40353
 
+            for newfd in range(256, MAXFD):
40354
 
+                if not self._is_fd_assigned(newfd):
40355
 
+                    break
40356
 
+            else:
40357
 
+                self.fail("could not find an unassigned large file descriptor")
40358
 
+            os.dup2(fd, newfd)
40359
 
+            try:
40360
 
+                reduction.send_handle(conn, newfd, p.pid)
40361
 
+            finally:
40362
 
+                os.close(newfd)
40363
 
+        p.join()
40364
 
+        with open(test_support.TESTFN, "rb") as f:
40365
 
+            self.assertEqual(f.read(), b"bar")
40366
 
+
40367
 
+    @classmethod
40368
 
+    def _send_data_without_fd(self, conn):
40369
 
+        os.write(conn.fileno(), b"\0")
40370
 
+
40371
 
+    @unittest.skipUnless(HAS_REDUCTION, "test needs multiprocessing.reduction")
40372
 
+    @unittest.skipIf(sys.platform == "win32", "doesn't make sense on Windows")
40373
 
+    def test_missing_fd_transfer(self):
40374
 
+        # Check that exception is raised when received data is not
40375
 
+        # accompanied by a file descriptor in ancillary data.
40376
 
+        if self.TYPE != 'processes':
40377
 
+            self.skipTest("only makes sense with processes")
40378
 
+        conn, child_conn = self.Pipe(duplex=True)
40379
 
+
40380
 
+        p = self.Process(target=self._send_data_without_fd, args=(child_conn,))
40381
 
+        p.daemon = True
40382
 
+        p.start()
40383
 
+        self.assertRaises(RuntimeError, reduction.recv_handle, conn)
40384
 
+        p.join()
40385
 
+
40386
 
 class _TestListenerClient(BaseTestCase):
40387
 
 
40388
 
     ALLOWED_TYPES = ('processes', 'threads')
40389
 
@@ -1548,11 +1701,13 @@
40390
 
 
40391
 
         lconn, lconn0 = self.Pipe()
40392
 
         lp = self.Process(target=self._listener, args=(lconn0, families))
40393
 
+        lp.daemon = True
40394
 
         lp.start()
40395
 
         lconn0.close()
40396
 
 
40397
 
         rconn, rconn0 = self.Pipe()
40398
 
         rp = self.Process(target=self._remote, args=(rconn0,))
40399
 
+        rp.daemon = True
40400
 
         rp.start()
40401
 
         rconn0.close()
40402
 
 
40403
 
@@ -1612,6 +1767,8 @@
40404
 
         # verify the state of the heap
40405
 
         all = []
40406
 
         occupied = 0
40407
 
+        heap._lock.acquire()
40408
 
+        self.addCleanup(heap._lock.release)
40409
 
         for L in heap._len_to_seq.values():
40410
 
             for arena, start, stop in L:
40411
 
                 all.append((heap._arenas.index(arena), start, stop,
40412
 
@@ -1629,6 +1786,28 @@
40413
 
             self.assertTrue((arena != narena and nstart == 0) or
40414
 
                             (stop == nstart))
40415
 
 
40416
 
+    def test_free_from_gc(self):
40417
 
+        # Check that freeing of blocks by the garbage collector doesn't deadlock
40418
 
+        # (issue #12352).
40419
 
+        # Make sure the GC is enabled, and set lower collection thresholds to
40420
 
+        # make collections more frequent (and increase the probability of
40421
 
+        # deadlock).
40422
 
+        if not gc.isenabled():
40423
 
+            gc.enable()
40424
 
+            self.addCleanup(gc.disable)
40425
 
+        thresholds = gc.get_threshold()
40426
 
+        self.addCleanup(gc.set_threshold, *thresholds)
40427
 
+        gc.set_threshold(10)
40428
 
+
40429
 
+        # perform numerous block allocations, with cyclic references to make
40430
 
+        # sure objects are collected asynchronously by the gc
40431
 
+        for i in range(5000):
40432
 
+            a = multiprocessing.heap.BufferWrapper(1)
40433
 
+            b = multiprocessing.heap.BufferWrapper(1)
40434
 
+            # circular references
40435
 
+            a.buddy = b
40436
 
+            b.buddy = a
40437
 
+
40438
 
 #
40439
 
 #
40440
 
 #
40441
 
@@ -1666,6 +1845,7 @@
40442
 
         string.value = latin('hello')
40443
 
 
40444
 
         p = self.Process(target=self._double, args=(x, y, foo, arr, string))
40445
 
+        p.daemon = True
40446
 
         p.start()
40447
 
         p.join()
40448
 
 
40449
 
@@ -1738,6 +1918,7 @@
40450
 
         conn, child_conn = self.Pipe()
40451
 
 
40452
 
         p = self.Process(target=self._test_finalize, args=(child_conn,))
40453
 
+        p.daemon = True
40454
 
         p.start()
40455
 
         p.join()
40456
 
 
40457
 
@@ -1757,10 +1938,12 @@
40458
 
             'multiprocessing', 'multiprocessing.connection',
40459
 
             'multiprocessing.heap', 'multiprocessing.managers',
40460
 
             'multiprocessing.pool', 'multiprocessing.process',
40461
 
-            'multiprocessing.reduction',
40462
 
             'multiprocessing.synchronize', 'multiprocessing.util'
40463
 
             ]
40464
 
 
40465
 
+        if HAS_REDUCTION:
40466
 
+            modules.append('multiprocessing.reduction')
40467
 
+
40468
 
         if c_int is not None:
40469
 
             # This module requires _ctypes
40470
 
             modules.append('multiprocessing.sharedctypes')
40471
 
@@ -1807,12 +1990,16 @@
40472
 
         reader, writer = multiprocessing.Pipe(duplex=False)
40473
 
 
40474
 
         logger.setLevel(LEVEL1)
40475
 
-        self.Process(target=self._test_level, args=(writer,)).start()
40476
 
+        p = self.Process(target=self._test_level, args=(writer,))
40477
 
+        p.daemon = True
40478
 
+        p.start()
40479
 
         self.assertEqual(LEVEL1, reader.recv())
40480
 
 
40481
 
         logger.setLevel(logging.NOTSET)
40482
 
         root_logger.setLevel(LEVEL2)
40483
 
-        self.Process(target=self._test_level, args=(writer,)).start()
40484
 
+        p = self.Process(target=self._test_level, args=(writer,))
40485
 
+        p.daemon = True
40486
 
+        p.start()
40487
 
         self.assertEqual(LEVEL2, reader.recv())
40488
 
 
40489
 
         root_logger.setLevel(root_level)
40490
 
@@ -1998,6 +2185,7 @@
40491
 
 def _TestProcess(q):
40492
 
     queue = multiprocessing.Queue()
40493
 
     subProc = multiprocessing.Process(target=_ThisSubProcess, args=(queue,))
40494
 
+    subProc.daemon = True
40495
 
     subProc.start()
40496
 
     subProc.join()
40497
 
 
40498
 
@@ -2064,6 +2252,8 @@
40499
 
         except OSError:
40500
 
             raise unittest.SkipTest("OSError raises on RLock creation, see issue 3111!")
40501
 
 
40502
 
+    check_enough_semaphores()
40503
 
+
40504
 
     if run is None:
40505
 
         from test.test_support import run_unittest as run
40506
 
 
40507
 
diff -r 8527427914a2 Lib/test/test_os.py
40508
 
--- a/Lib/test/test_os.py
40509
 
+++ b/Lib/test/test_os.py
40510
 
@@ -361,6 +361,20 @@
40511
 
                 value = popen.read().strip()
40512
 
                 self.assertEqual(value, "World")
40513
 
 
40514
 
+    # On FreeBSD < 7 and OS X < 10.6, unsetenv() doesn't return a value (issue
40515
 
+    # #13415).
40516
 
+    @unittest.skipIf(sys.platform.startswith(('freebsd', 'darwin')),
40517
 
+                     "due to known OS bug: see issue #13415")
40518
 
+    def test_unset_error(self):
40519
 
+        if sys.platform == "win32":
40520
 
+            # an environment variable is limited to 32,767 characters
40521
 
+            key = 'x' * 50000
40522
 
+            self.assertRaises(ValueError, os.environ.__delitem__, key)
40523
 
+        else:
40524
 
+            # "=" is not allowed in a variable name
40525
 
+            key = 'key='
40526
 
+            self.assertRaises(OSError, os.environ.__delitem__, key)
40527
 
+
40528
 
 class WalkTests(unittest.TestCase):
40529
 
     """Tests for os.walk()."""
40530
 
 
40531
 
diff -r 8527427914a2 Lib/test/test_pdb.py
40532
 
--- a/Lib/test/test_pdb.py
40533
 
+++ b/Lib/test/test_pdb.py
40534
 
@@ -3,6 +3,9 @@
40535
 
 
40536
 
 import imp
40537
 
 import sys
40538
 
+import os
40539
 
+import unittest
40540
 
+import subprocess
40541
 
 
40542
 
 from test import test_support
40543
 
 # This little helper class is essential for testing pdb under doctest.
40544
 
@@ -277,11 +280,36 @@
40545
 
     4
40546
 
     """
40547
 
 
40548
 
+class ModuleInitTester(unittest.TestCase):
40549
 
+
40550
 
+    def test_filename_correct(self):
40551
 
+        """
40552
 
+        In issue 7750, it was found that if the filename has a sequence that
40553
 
+        resolves to an escape character in a Python string (such as \t), it
40554
 
+        will be treated as the escaped character.
40555
 
+        """
40556
 
+        # the test_fn must contain something like \t
40557
 
+        # on Windows, this will create 'test_mod.py' in the current directory.
40558
 
+        # on Unix, this will create '.\test_mod.py' in the current directory.
40559
 
+        test_fn = '.\\test_mod.py'
40560
 
+        code = 'print("testing pdb")'
40561
 
+        with open(test_fn, 'w') as f:
40562
 
+            f.write(code)
40563
 
+        self.addCleanup(os.remove, test_fn)
40564
 
+        cmd = [sys.executable, '-m', 'pdb', test_fn,]
40565
 
+        proc = subprocess.Popen(cmd,
40566
 
+            stdout=subprocess.PIPE,
40567
 
+            stdin=subprocess.PIPE,
40568
 
+            stderr=subprocess.STDOUT,
40569
 
+            )
40570
 
+        stdout, stderr = proc.communicate('quit\n')
40571
 
+        self.assertIn(code, stdout, "pdb munged the filename")
40572
 
+
40573
 
 
40574
 
 def test_main():
40575
 
     from test import test_pdb
40576
 
     test_support.run_doctest(test_pdb, verbosity=True)
40577
 
-
40578
 
+    test_support.run_unittest(ModuleInitTester)
40579
 
 
40580
 
 if __name__ == '__main__':
40581
 
     test_main()
40582
 
diff -r 8527427914a2 Lib/test/test_pkgutil.py
40583
 
--- a/Lib/test/test_pkgutil.py
40584
 
+++ b/Lib/test/test_pkgutil.py
40585
 
@@ -15,11 +15,11 @@
40586
 
 
40587
 
     def setUp(self):
40588
 
         self.dirname = tempfile.mkdtemp()
40589
 
+        self.addCleanup(shutil.rmtree, self.dirname)
40590
 
         sys.path.insert(0, self.dirname)
40591
 
 
40592
 
     def tearDown(self):
40593
 
         del sys.path[0]
40594
 
-        shutil.rmtree(self.dirname)
40595
 
 
40596
 
     def test_getdata_filesys(self):
40597
 
         pkg = 'test_getdata_filesys'
40598
 
@@ -78,6 +78,17 @@
40599
 
 
40600
 
         del sys.modules[pkg]
40601
 
 
40602
 
+    def test_unreadable_dir_on_syspath(self):
40603
 
+        # issue7367 - walk_packages failed if unreadable dir on sys.path
40604
 
+        package_name = "unreadable_package"
40605
 
+        d = os.path.join(self.dirname, package_name)
40606
 
+        # this does not appear to create an unreadable dir on Windows
40607
 
+        #   but the test should not fail anyway
40608
 
+        os.mkdir(d, 0)
40609
 
+        self.addCleanup(os.rmdir, d)
40610
 
+        for t in pkgutil.walk_packages(path=[self.dirname]):
40611
 
+            self.fail("unexpected package found")
40612
 
+
40613
 
 class PkgutilPEP302Tests(unittest.TestCase):
40614
 
 
40615
 
     class MyTestLoader(object):
40616
 
diff -r 8527427914a2 Lib/test/test_platform.py
40617
 
--- a/Lib/test/test_platform.py
40618
 
+++ b/Lib/test/test_platform.py
40619
 
@@ -191,7 +191,7 @@
40620
 
             self.assertEqual(res[1], ('', '', ''))
40621
 
 
40622
 
             if sys.byteorder == 'little':
40623
 
-                self.assertEqual(res[2], 'i386')
40624
 
+                self.assertIn(res[2], ('i386', 'x86_64'))
40625
 
             else:
40626
 
                 self.assertEqual(res[2], 'PowerPC')
40627
 
 
40628
 
diff -r 8527427914a2 Lib/test/test_poplib.py
40629
 
--- a/Lib/test/test_poplib.py
40630
 
+++ b/Lib/test/test_poplib.py
40631
 
@@ -281,32 +281,34 @@
40632
 
     def setUp(self):
40633
 
         self.evt = threading.Event()
40634
 
         self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
40635
 
-        self.sock.settimeout(3)
40636
 
+        self.sock.settimeout(60)  # Safety net. Look issue 11812
40637
 
         self.port = test_support.bind_port(self.sock)
40638
 
-        threading.Thread(target=self.server, args=(self.evt,self.sock)).start()
40639
 
-        time.sleep(.1)
40640
 
+        self.thread = threading.Thread(target=self.server, args=(self.evt,self.sock))
40641
 
+        self.thread.setDaemon(True)
40642
 
+        self.thread.start()
40643
 
+        self.evt.wait()
40644
 
 
40645
 
     def tearDown(self):
40646
 
-        self.evt.wait()
40647
 
+        self.thread.join()
40648
 
+        del self.thread  # Clear out any dangling Thread objects.
40649
 
 
40650
 
     def server(self, evt, serv):
40651
 
         serv.listen(5)
40652
 
+        evt.set()
40653
 
         try:
40654
 
             conn, addr = serv.accept()
40655
 
+            conn.send("+ Hola mundo\n")
40656
 
+            conn.close()
40657
 
         except socket.timeout:
40658
 
             pass
40659
 
-        else:
40660
 
-            conn.send("+ Hola mundo\n")
40661
 
-            conn.close()
40662
 
         finally:
40663
 
             serv.close()
40664
 
-            evt.set()
40665
 
 
40666
 
     def testTimeoutDefault(self):
40667
 
         self.assertTrue(socket.getdefaulttimeout() is None)
40668
 
         socket.setdefaulttimeout(30)
40669
 
         try:
40670
 
-            pop = poplib.POP3("localhost", self.port)
40671
 
+            pop = poplib.POP3(HOST, self.port)
40672
 
         finally:
40673
 
             socket.setdefaulttimeout(None)
40674
 
         self.assertEqual(pop.sock.gettimeout(), 30)
40675
 
@@ -323,7 +325,7 @@
40676
 
         pop.sock.close()
40677
 
 
40678
 
     def testTimeoutValue(self):
40679
 
-        pop = poplib.POP3("localhost", self.port, timeout=30)
40680
 
+        pop = poplib.POP3(HOST, self.port, timeout=30)
40681
 
         self.assertEqual(pop.sock.gettimeout(), 30)
40682
 
         pop.sock.close()
40683
 
 
40684
 
diff -r 8527427914a2 Lib/test/test_posix.py
40685
 
--- a/Lib/test/test_posix.py
40686
 
+++ b/Lib/test/test_posix.py
40687
 
@@ -11,10 +11,14 @@
40688
 
 import os
40689
 
 import pwd
40690
 
 import shutil
40691
 
+import stat
40692
 
 import sys
40693
 
+import tempfile
40694
 
 import unittest
40695
 
 import warnings
40696
 
 
40697
 
+_DUMMY_SYMLINK = os.path.join(tempfile.gettempdir(),
40698
 
+                              test_support.TESTFN + '-dummy-symlink')
40699
 
 
40700
 
 warnings.filterwarnings('ignore', '.* potential security risk .*',
40701
 
                         RuntimeWarning)
40702
 
@@ -25,9 +29,11 @@
40703
 
         # create empty file
40704
 
         fp = open(test_support.TESTFN, 'w+')
40705
 
         fp.close()
40706
 
+        self.teardown_files = [ test_support.TESTFN ]
40707
 
 
40708
 
     def tearDown(self):
40709
 
-        os.unlink(test_support.TESTFN)
40710
 
+        for teardown_file in self.teardown_files:
40711
 
+            os.unlink(teardown_file)
40712
 
 
40713
 
     def testNoArgFunctions(self):
40714
 
         # test posix functions which take no arguments and have
40715
 
@@ -258,7 +264,7 @@
40716
 
     def test_lchown(self):
40717
 
         os.unlink(test_support.TESTFN)
40718
 
         # create a symlink
40719
 
-        os.symlink('/tmp/dummy-symlink-target', test_support.TESTFN)
40720
 
+        os.symlink(_DUMMY_SYMLINK, test_support.TESTFN)
40721
 
         self._test_all_chown_common(posix.lchown, test_support.TESTFN)
40722
 
 
40723
 
     def test_chdir(self):
40724
 
@@ -315,17 +321,49 @@
40725
 
             posix.utime(test_support.TESTFN, (int(now), int(now)))
40726
 
             posix.utime(test_support.TESTFN, (now, now))
40727
 
 
40728
 
+    def _test_chflags_regular_file(self, chflags_func, target_file):
40729
 
+        st = os.stat(target_file)
40730
 
+        self.assertTrue(hasattr(st, 'st_flags'))
40731
 
+        chflags_func(target_file, st.st_flags | stat.UF_IMMUTABLE)
40732
 
+        try:
40733
 
+            new_st = os.stat(target_file)
40734
 
+            self.assertEqual(st.st_flags | stat.UF_IMMUTABLE, new_st.st_flags)
40735
 
+            try:
40736
 
+                fd = open(target_file, 'w+')
40737
 
+            except IOError as e:
40738
 
+                self.assertEqual(e.errno, errno.EPERM)
40739
 
+        finally:
40740
 
+            posix.chflags(target_file, st.st_flags)
40741
 
+
40742
 
+    @unittest.skipUnless(hasattr(posix, 'chflags'), 'test needs os.chflags()')
40743
 
     def test_chflags(self):
40744
 
-        if hasattr(posix, 'chflags'):
40745
 
-            st = os.stat(test_support.TESTFN)
40746
 
-            if hasattr(st, 'st_flags'):
40747
 
-                posix.chflags(test_support.TESTFN, st.st_flags)
40748
 
+        self._test_chflags_regular_file(posix.chflags, test_support.TESTFN)
40749
 
 
40750
 
-    def test_lchflags(self):
40751
 
-        if hasattr(posix, 'lchflags'):
40752
 
-            st = os.stat(test_support.TESTFN)
40753
 
-            if hasattr(st, 'st_flags'):
40754
 
-                posix.lchflags(test_support.TESTFN, st.st_flags)
40755
 
+    @unittest.skipUnless(hasattr(posix, 'lchflags'), 'test needs os.lchflags()')
40756
 
+    def test_lchflags_regular_file(self):
40757
 
+        self._test_chflags_regular_file(posix.lchflags, test_support.TESTFN)
40758
 
+
40759
 
+    @unittest.skipUnless(hasattr(posix, 'lchflags'), 'test needs os.lchflags()')
40760
 
+    def test_lchflags_symlink(self):
40761
 
+        testfn_st = os.stat(test_support.TESTFN)
40762
 
+
40763
 
+        self.assertTrue(hasattr(testfn_st, 'st_flags'))
40764
 
+
40765
 
+        os.symlink(test_support.TESTFN, _DUMMY_SYMLINK)
40766
 
+        self.teardown_files.append(_DUMMY_SYMLINK)
40767
 
+        dummy_symlink_st = os.lstat(_DUMMY_SYMLINK)
40768
 
+
40769
 
+        posix.lchflags(_DUMMY_SYMLINK,
40770
 
+                       dummy_symlink_st.st_flags | stat.UF_IMMUTABLE)
40771
 
+        try:
40772
 
+            new_testfn_st = os.stat(test_support.TESTFN)
40773
 
+            new_dummy_symlink_st = os.lstat(_DUMMY_SYMLINK)
40774
 
+
40775
 
+            self.assertEqual(testfn_st.st_flags, new_testfn_st.st_flags)
40776
 
+            self.assertEqual(dummy_symlink_st.st_flags | stat.UF_IMMUTABLE,
40777
 
+                             new_dummy_symlink_st.st_flags)
40778
 
+        finally:
40779
 
+            posix.lchflags(_DUMMY_SYMLINK, dummy_symlink_st.st_flags)
40780
 
 
40781
 
     def test_getcwd_long_pathnames(self):
40782
 
         if hasattr(posix, 'getcwd'):
40783
 
diff -r 8527427914a2 Lib/test/test_pty.py
40784
 
--- a/Lib/test/test_pty.py
40785
 
+++ b/Lib/test/test_pty.py
40786
 
@@ -8,7 +8,9 @@
40787
 
 import pty
40788
 
 import os
40789
 
 import sys
40790
 
+import select
40791
 
 import signal
40792
 
+import socket
40793
 
 import unittest
40794
 
 
40795
 
 TEST_STRING_1 = "I wish to buy a fish license.\n"
40796
 
@@ -193,8 +195,95 @@
40797
 
 
40798
 
         # pty.fork() passed.
40799
 
 
40800
 
+
40801
 
+class SmallPtyTests(unittest.TestCase):
40802
 
+    """These tests don't spawn children or hang."""
40803
 
+
40804
 
+    def setUp(self):
40805
 
+        self.orig_stdin_fileno = pty.STDIN_FILENO
40806
 
+        self.orig_stdout_fileno = pty.STDOUT_FILENO
40807
 
+        self.orig_pty_select = pty.select
40808
 
+        self.fds = []  # A list of file descriptors to close.
40809
 
+        self.select_rfds_lengths = []
40810
 
+        self.select_rfds_results = []
40811
 
+
40812
 
+    def tearDown(self):
40813
 
+        pty.STDIN_FILENO = self.orig_stdin_fileno
40814
 
+        pty.STDOUT_FILENO = self.orig_stdout_fileno
40815
 
+        pty.select = self.orig_pty_select
40816
 
+        for fd in self.fds:
40817
 
+            try:
40818
 
+                os.close(fd)
40819
 
+            except:
40820
 
+                pass
40821
 
+
40822
 
+    def _pipe(self):
40823
 
+        pipe_fds = os.pipe()
40824
 
+        self.fds.extend(pipe_fds)
40825
 
+        return pipe_fds
40826
 
+
40827
 
+    def _mock_select(self, rfds, wfds, xfds):
40828
 
+        # This will raise IndexError when no more expected calls exist.
40829
 
+        self.assertEqual(self.select_rfds_lengths.pop(0), len(rfds))
40830
 
+        return self.select_rfds_results.pop(0), [], []
40831
 
+
40832
 
+    def test__copy_to_each(self):
40833
 
+        """Test the normal data case on both master_fd and stdin."""
40834
 
+        read_from_stdout_fd, mock_stdout_fd = self._pipe()
40835
 
+        pty.STDOUT_FILENO = mock_stdout_fd
40836
 
+        mock_stdin_fd, write_to_stdin_fd = self._pipe()
40837
 
+        pty.STDIN_FILENO = mock_stdin_fd
40838
 
+        socketpair = socket.socketpair()
40839
 
+        masters = [s.fileno() for s in socketpair]
40840
 
+        self.fds.extend(masters)
40841
 
+
40842
 
+        # Feed data.  Smaller than PIPEBUF.  These writes will not block.
40843
 
+        os.write(masters[1], b'from master')
40844
 
+        os.write(write_to_stdin_fd, b'from stdin')
40845
 
+
40846
 
+        # Expect two select calls, the last one will cause IndexError
40847
 
+        pty.select = self._mock_select
40848
 
+        self.select_rfds_lengths.append(2)
40849
 
+        self.select_rfds_results.append([mock_stdin_fd, masters[0]])
40850
 
+        self.select_rfds_lengths.append(2)
40851
 
+
40852
 
+        with self.assertRaises(IndexError):
40853
 
+            pty._copy(masters[0])
40854
 
+
40855
 
+        # Test that the right data went to the right places.
40856
 
+        rfds = select.select([read_from_stdout_fd, masters[1]], [], [], 0)[0]
40857
 
+        self.assertEqual([read_from_stdout_fd, masters[1]], rfds)
40858
 
+        self.assertEqual(os.read(read_from_stdout_fd, 20), b'from master')
40859
 
+        self.assertEqual(os.read(masters[1], 20), b'from stdin')
40860
 
+
40861
 
+    def test__copy_eof_on_all(self):
40862
 
+        """Test the empty read EOF case on both master_fd and stdin."""
40863
 
+        read_from_stdout_fd, mock_stdout_fd = self._pipe()
40864
 
+        pty.STDOUT_FILENO = mock_stdout_fd
40865
 
+        mock_stdin_fd, write_to_stdin_fd = self._pipe()
40866
 
+        pty.STDIN_FILENO = mock_stdin_fd
40867
 
+        socketpair = socket.socketpair()
40868
 
+        masters = [s.fileno() for s in socketpair]
40869
 
+        self.fds.extend(masters)
40870
 
+
40871
 
+        os.close(masters[1])
40872
 
+        socketpair[1].close()
40873
 
+        os.close(write_to_stdin_fd)
40874
 
+
40875
 
+        # Expect two select calls, the last one will cause IndexError
40876
 
+        pty.select = self._mock_select
40877
 
+        self.select_rfds_lengths.append(2)
40878
 
+        self.select_rfds_results.append([mock_stdin_fd, masters[0]])
40879
 
+        # We expect that both fds were removed from the fds list as they
40880
 
+        # both encountered an EOF before the second select call.
40881
 
+        self.select_rfds_lengths.append(0)
40882
 
+
40883
 
+        with self.assertRaises(IndexError):
40884
 
+            pty._copy(masters[0])
40885
 
+
40886
 
+
40887
 
 def test_main(verbose=None):
40888
 
-    run_unittest(PtyTest)
40889
 
+    run_unittest(SmallPtyTests, PtyTest)
40890
 
 
40891
 
 if __name__ == "__main__":
40892
 
     test_main()
40893
 
diff -r 8527427914a2 Lib/test/test_py_compile.py
40894
 
--- /dev/null
40895
 
+++ b/Lib/test/test_py_compile.py
40896
 
@@ -0,0 +1,54 @@
40897
 
+import imp
40898
 
+import os
40899
 
+import py_compile
40900
 
+import shutil
40901
 
+import tempfile
40902
 
+import unittest
40903
 
+
40904
 
+from test import test_support
40905
 
+
40906
 
+class PyCompileTests(unittest.TestCase):
40907
 
+
40908
 
+    def setUp(self):
40909
 
+        self.directory = tempfile.mkdtemp()
40910
 
+        self.source_path = os.path.join(self.directory, '_test.py')
40911
 
+        self.pyc_path = self.source_path + 'c'
40912
 
+        self.cwd_drive = os.path.splitdrive(os.getcwd())[0]
40913
 
+        # In these tests we compute relative paths.  When using Windows, the
40914
 
+        # current working directory path and the 'self.source_path' might be
40915
 
+        # on different drives.  Therefore we need to switch to the drive where
40916
 
+        # the temporary source file lives.
40917
 
+        drive = os.path.splitdrive(self.source_path)[0]
40918
 
+        if drive:
40919
 
+            os.chdir(drive)
40920
 
+
40921
 
+        with open(self.source_path, 'w') as file:
40922
 
+            file.write('x = 123\n')
40923
 
+
40924
 
+    def tearDown(self):
40925
 
+        shutil.rmtree(self.directory)
40926
 
+        if self.cwd_drive:
40927
 
+            os.chdir(self.cwd_drive)
40928
 
+
40929
 
+    def test_absolute_path(self):
40930
 
+        py_compile.compile(self.source_path, self.pyc_path)
40931
 
+        self.assertTrue(os.path.exists(self.pyc_path))
40932
 
+
40933
 
+    def test_cwd(self):
40934
 
+        cwd = os.getcwd()
40935
 
+        os.chdir(self.directory)
40936
 
+        py_compile.compile(os.path.basename(self.source_path),
40937
 
+                           os.path.basename(self.pyc_path))
40938
 
+        os.chdir(cwd)
40939
 
+        self.assertTrue(os.path.exists(self.pyc_path))
40940
 
+
40941
 
+    def test_relative_path(self):
40942
 
+        py_compile.compile(os.path.relpath(self.source_path),
40943
 
+                           os.path.relpath(self.pyc_path))
40944
 
+        self.assertTrue(os.path.exists(self.pyc_path))
40945
 
+
40946
 
+def test_main():
40947
 
+    test_support.run_unittest(PyCompileTests)
40948
 
+
40949
 
+if __name__ == "__main__":
40950
 
+    test_main()
40951
 
diff -r 8527427914a2 Lib/test/test_pydoc.py
40952
 
--- a/Lib/test/test_pydoc.py
40953
 
+++ b/Lib/test/test_pydoc.py
40954
 
@@ -1,8 +1,7 @@
40955
 
+import os
40956
 
 import sys
40957
 
-import os
40958
 
-import os.path
40959
 
 import difflib
40960
 
-import subprocess
40961
 
+import __builtin__
40962
 
 import re
40963
 
 import pydoc
40964
 
 import inspect
40965
 
@@ -10,10 +9,10 @@
40966
 
 import unittest
40967
 
 import xml.etree
40968
 
 import test.test_support
40969
 
-from contextlib import contextmanager
40970
 
 from collections import namedtuple
40971
 
+from test.script_helper import assert_python_ok
40972
 
 from test.test_support import (
40973
 
-    TESTFN, forget, rmtree, EnvironmentVarGuard, reap_children, captured_stdout)
40974
 
+    TESTFN, rmtree, reap_children, captured_stdout)
40975
 
 
40976
 
 from test import pydoc_mod
40977
 
 
40978
 
@@ -176,17 +175,15 @@
40979
 
 # output pattern for module with bad imports
40980
 
 badimport_pattern = "problem in %s - <type 'exceptions.ImportError'>: No module named %s"
40981
 
 
40982
 
-def run_pydoc(module_name, *args):
40983
 
+def run_pydoc(module_name, *args, **env):
40984
 
     """
40985
 
     Runs pydoc on the specified module. Returns the stripped
40986
 
     output of pydoc.
40987
 
     """
40988
 
-    cmd = [sys.executable, pydoc.__file__, " ".join(args), module_name]
40989
 
-    try:
40990
 
-        output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
40991
 
-        return output.strip()
40992
 
-    finally:
40993
 
-        reap_children()
40994
 
+    args = args + (module_name,)
40995
 
+    # do not write bytecode files to avoid caching errors
40996
 
+    rc, out, err = assert_python_ok('-B', pydoc.__file__, *args, **env)
40997
 
+    return out.strip()
40998
 
 
40999
 
 def get_pydoc_html(module):
41000
 
     "Returns pydoc generated output as html"
41001
 
@@ -259,42 +256,6 @@
41002
 
         self.assertEqual(expected, result,
41003
 
             "documentation for missing module found")
41004
 
 
41005
 
-    def test_badimport(self):
41006
 
-        # This tests the fix for issue 5230, where if pydoc found the module
41007
 
-        # but the module had an internal import error pydoc would report no doc
41008
 
-        # found.
41009
 
-        modname = 'testmod_xyzzy'
41010
 
-        testpairs = (
41011
 
-            ('i_am_not_here', 'i_am_not_here'),
41012
 
-            ('test.i_am_not_here_either', 'i_am_not_here_either'),
41013
 
-            ('test.i_am_not_here.neither_am_i', 'i_am_not_here.neither_am_i'),
41014
 
-            ('i_am_not_here.{}'.format(modname), 'i_am_not_here.{}'.format(modname)),
41015
 
-            ('test.{}'.format(modname), modname),
41016
 
-            )
41017
 
-
41018
 
-        @contextmanager
41019
 
-        def newdirinpath(dir):
41020
 
-            os.mkdir(dir)
41021
 
-            sys.path.insert(0, dir)
41022
 
-            yield
41023
 
-            sys.path.pop(0)
41024
 
-            rmtree(dir)
41025
 
-
41026
 
-        with newdirinpath(TESTFN), EnvironmentVarGuard() as env:
41027
 
-            env['PYTHONPATH'] = TESTFN
41028
 
-            fullmodname = os.path.join(TESTFN, modname)
41029
 
-            sourcefn = fullmodname + os.extsep + "py"
41030
 
-            for importstring, expectedinmsg in testpairs:
41031
 
-                f = open(sourcefn, 'w')
41032
 
-                f.write("import {}\n".format(importstring))
41033
 
-                f.close()
41034
 
-                try:
41035
 
-                    result = run_pydoc(modname)
41036
 
-                finally:
41037
 
-                    forget(modname)
41038
 
-                expected = badimport_pattern % (modname, expectedinmsg)
41039
 
-                self.assertEqual(expected, result)
41040
 
-
41041
 
     def test_input_strip(self):
41042
 
         missing_module = " test.i_am_not_here "
41043
 
         result = run_pydoc(missing_module)
41044
 
@@ -317,6 +278,55 @@
41045
 
                          "<type 'exceptions.Exception'>")
41046
 
 
41047
 
 
41048
 
+class PydocImportTest(unittest.TestCase):
41049
 
+
41050
 
+    def setUp(self):
41051
 
+        self.test_dir = os.mkdir(TESTFN)
41052
 
+        self.addCleanup(rmtree, TESTFN)
41053
 
+
41054
 
+    def test_badimport(self):
41055
 
+        # This tests the fix for issue 5230, where if pydoc found the module
41056
 
+        # but the module had an internal import error pydoc would report no doc
41057
 
+        # found.
41058
 
+        modname = 'testmod_xyzzy'
41059
 
+        testpairs = (
41060
 
+            ('i_am_not_here', 'i_am_not_here'),
41061
 
+            ('test.i_am_not_here_either', 'i_am_not_here_either'),
41062
 
+            ('test.i_am_not_here.neither_am_i', 'i_am_not_here.neither_am_i'),
41063
 
+            ('i_am_not_here.{}'.format(modname),
41064
 
+             'i_am_not_here.{}'.format(modname)),
41065
 
+            ('test.{}'.format(modname), modname),
41066
 
+            )
41067
 
+
41068
 
+        sourcefn = os.path.join(TESTFN, modname) + os.extsep + "py"
41069
 
+        for importstring, expectedinmsg in testpairs:
41070
 
+            with open(sourcefn, 'w') as f:
41071
 
+                f.write("import {}\n".format(importstring))
41072
 
+            result = run_pydoc(modname, PYTHONPATH=TESTFN)
41073
 
+            expected = badimport_pattern % (modname, expectedinmsg)
41074
 
+            self.assertEqual(expected, result)
41075
 
+
41076
 
+    def test_apropos_with_bad_package(self):
41077
 
+        # Issue 7425 - pydoc -k failed when bad package on path
41078
 
+        pkgdir = os.path.join(TESTFN, "syntaxerr")
41079
 
+        os.mkdir(pkgdir)
41080
 
+        badsyntax = os.path.join(pkgdir, "__init__") + os.extsep + "py"
41081
 
+        with open(badsyntax, 'w') as f:
41082
 
+            f.write("invalid python syntax = $1\n")
41083
 
+        result = run_pydoc('zqwykjv', '-k', PYTHONPATH=TESTFN)
41084
 
+        self.assertEqual('', result)
41085
 
+
41086
 
+    def test_apropos_with_unreadable_dir(self):
41087
 
+        # Issue 7367 - pydoc -k failed when unreadable dir on path
41088
 
+        self.unreadable_dir = os.path.join(TESTFN, "unreadable")
41089
 
+        os.mkdir(self.unreadable_dir, 0)
41090
 
+        self.addCleanup(os.rmdir, self.unreadable_dir)
41091
 
+        # Note, on Windows the directory appears to be still
41092
 
+        #   readable so this is not really testing the issue there
41093
 
+        result = run_pydoc('zqwykjv', '-k', PYTHONPATH=TESTFN)
41094
 
+        self.assertEqual('', result)
41095
 
+
41096
 
+
41097
 
 class TestDescriptions(unittest.TestCase):
41098
 
 
41099
 
     def test_module(self):
41100
 
@@ -357,11 +367,32 @@
41101
 
         self.assertEqual(sorted(pydoc.Helper.keywords),
41102
 
                          sorted(keyword.kwlist))
41103
 
 
41104
 
+    def test_builtin(self):
41105
 
+        for name in ('str', 'str.translate', '__builtin__.str',
41106
 
+                     '__builtin__.str.translate'):
41107
 
+            # test low-level function
41108
 
+            self.assertIsNotNone(pydoc.locate(name))
41109
 
+            # test high-level function
41110
 
+            try:
41111
 
+                pydoc.render_doc(name)
41112
 
+            except ImportError:
41113
 
+                self.fail('finding the doc of {!r} failed'.format(o))
41114
 
+
41115
 
+        for name in ('not__builtin__', 'strrr', 'strr.translate',
41116
 
+                     'str.trrrranslate', '__builtin__.strrr',
41117
 
+                     '__builtin__.str.trrranslate'):
41118
 
+            self.assertIsNone(pydoc.locate(name))
41119
 
+            self.assertRaises(ImportError, pydoc.render_doc, name)
41120
 
+
41121
 
 
41122
 
 def test_main():
41123
 
-    test.test_support.run_unittest(PyDocDocTest,
41124
 
-                                   TestDescriptions,
41125
 
-                                   TestHelper)
41126
 
+    try:
41127
 
+        test.test_support.run_unittest(PyDocDocTest,
41128
 
+                                       PydocImportTest,
41129
 
+                                       TestDescriptions,
41130
 
+                                       TestHelper)
41131
 
+    finally:
41132
 
+        reap_children()
41133
 
 
41134
 
 if __name__ == "__main__":
41135
 
     test_main()
41136
 
diff -r 8527427914a2 Lib/test/test_robotparser.py
41137
 
--- a/Lib/test/test_robotparser.py
41138
 
+++ b/Lib/test/test_robotparser.py
41139
 
@@ -1,5 +1,6 @@
41140
 
 import unittest, StringIO, robotparser
41141
 
 from test import test_support
41142
 
+from urllib2 import urlopen, HTTPError
41143
 
 
41144
 
 class RobotTestCase(unittest.TestCase):
41145
 
     def __init__(self, index, parser, url, good, agent):
41146
 
@@ -234,13 +235,27 @@
41147
 
         test_support.requires('network')
41148
 
         with test_support.transient_internet('mueblesmoraleda.com'):
41149
 
             url = 'http://mueblesmoraleda.com'
41150
 
+            robots_url = url + "/robots.txt"
41151
 
+            # First check the URL is usable for our purposes, since the
41152
 
+            # test site is a bit flaky.
41153
 
+            try:
41154
 
+                urlopen(robots_url)
41155
 
+            except HTTPError as e:
41156
 
+                if e.code not in {401, 403}:
41157
 
+                    self.skipTest(
41158
 
+                        "%r should return a 401 or 403 HTTP error, not %r"
41159
 
+                        % (robots_url, e.code))
41160
 
+            else:
41161
 
+                self.skipTest(
41162
 
+                    "%r should return a 401 or 403 HTTP error, not succeed"
41163
 
+                    % (robots_url))
41164
 
             parser = robotparser.RobotFileParser()
41165
 
             parser.set_url(url)
41166
 
             try:
41167
 
                 parser.read()
41168
 
             except IOError:
41169
 
                 self.skipTest('%s is unavailable' % url)
41170
 
-            self.assertEqual(parser.can_fetch("*", url+"/robots.txt"), False)
41171
 
+            self.assertEqual(parser.can_fetch("*", robots_url), False)
41172
 
 
41173
 
     def testPythonOrg(self):
41174
 
         test_support.requires('network')
41175
 
diff -r 8527427914a2 Lib/test/test_shutil.py
41176
 
--- a/Lib/test/test_shutil.py
41177
 
+++ b/Lib/test/test_shutil.py
41178
 
@@ -349,6 +349,8 @@
41179
 
         self.write_file([tmpdir, 'sub', 'file3'], 'xxx')
41180
 
 
41181
 
         tmpdir2 = self.mkdtemp()
41182
 
+        # force shutil to create the directory
41183
 
+        os.rmdir(tmpdir2)
41184
 
         unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0],
41185
 
                             "source and target should be on same drive")
41186
 
 
41187
 
@@ -464,6 +466,8 @@
41188
 
         self.write_file([tmpdir, 'file2'], 'xxx')
41189
 
 
41190
 
         tmpdir2 = self.mkdtemp()
41191
 
+        # force shutil to create the directory
41192
 
+        os.rmdir(tmpdir2)
41193
 
         base_name = os.path.join(tmpdir2, 'archive')
41194
 
         _make_zipfile(base_name, tmpdir)
41195
 
 
41196
 
diff -r 8527427914a2 Lib/test/test_site.py
41197
 
--- a/Lib/test/test_site.py
41198
 
+++ b/Lib/test/test_site.py
41199
 
@@ -24,7 +24,7 @@
41200
 
 else:
41201
 
     raise unittest.SkipTest("importation of site.py suppressed")
41202
 
 
41203
 
-if not os.path.isdir(site.USER_SITE):
41204
 
+if site.ENABLE_USER_SITE and not os.path.isdir(site.USER_SITE):
41205
 
     # need to add user site directory for tests
41206
 
     os.makedirs(site.USER_SITE)
41207
 
     site.addsitedir(site.USER_SITE)
41208
 
@@ -161,6 +161,8 @@
41209
 
         finally:
41210
 
             pth_file.cleanup()
41211
 
 
41212
 
+    @unittest.skipUnless(site.ENABLE_USER_SITE, "requires access to PEP 370 "
41213
 
+                          "user-site (site.ENABLE_USER_SITE)")
41214
 
     def test_s_option(self):
41215
 
         usersite = site.USER_SITE
41216
 
         self.assertIn(usersite, sys.path)
41217
 
@@ -226,7 +228,19 @@
41218
 
             self.assertEqual(len(dirs), 1)
41219
 
             wanted = os.path.join('xoxo', 'Lib', 'site-packages')
41220
 
             self.assertEqual(dirs[0], wanted)
41221
 
+        elif (sys.platform == "darwin" and
41222
 
+            sysconfig.get_config_var("PYTHONFRAMEWORK")):
41223
 
+            # OS X framework builds
41224
 
+            site.PREFIXES = ['Python.framework']
41225
 
+            dirs = site.getsitepackages()
41226
 
+            self.assertEqual(len(dirs), 3)
41227
 
+            wanted = os.path.join('/Library',
41228
 
+                                  sysconfig.get_config_var("PYTHONFRAMEWORK"),
41229
 
+                                  sys.version[:3],
41230
 
+                                  'site-packages')
41231
 
+            self.assertEqual(dirs[2], wanted)
41232
 
         elif os.sep == '/':
41233
 
+            # OS X non-framwework builds, Linux, FreeBSD, etc
41234
 
             self.assertEqual(len(dirs), 2)
41235
 
             wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],
41236
 
                                   'site-packages')
41237
 
@@ -234,24 +248,12 @@
41238
 
             wanted = os.path.join('xoxo', 'lib', 'site-python')
41239
 
             self.assertEqual(dirs[1], wanted)
41240
 
         else:
41241
 
+            # other platforms
41242
 
             self.assertEqual(len(dirs), 2)
41243
 
             self.assertEqual(dirs[0], 'xoxo')
41244
 
             wanted = os.path.join('xoxo', 'lib', 'site-packages')
41245
 
             self.assertEqual(dirs[1], wanted)
41246
 
 
41247
 
-        # let's try the specific Apple location
41248
 
-        if (sys.platform == "darwin" and
41249
 
-            sysconfig.get_config_var("PYTHONFRAMEWORK")):
41250
 
-            site.PREFIXES = ['Python.framework']
41251
 
-            dirs = site.getsitepackages()
41252
 
-            self.assertEqual(len(dirs), 4)
41253
 
-            wanted = os.path.join('~', 'Library', 'Python',
41254
 
-                                  sys.version[:3], 'site-packages')
41255
 
-            self.assertEqual(dirs[2], os.path.expanduser(wanted))
41256
 
-            wanted = os.path.join('/Library', 'Python', sys.version[:3],
41257
 
-                                  'site-packages')
41258
 
-            self.assertEqual(dirs[3], wanted)
41259
 
-
41260
 
 class PthFile(object):
41261
 
     """Helper class for handling testing of .pth files"""
41262
 
 
41263
 
diff -r 8527427914a2 Lib/test/test_smtplib.py
41264
 
--- a/Lib/test/test_smtplib.py
41265
 
+++ b/Lib/test/test_smtplib.py
41266
 
@@ -330,15 +330,14 @@
41267
 
         self.push(resp)
41268
 
 
41269
 
     def smtp_VRFY(self, arg):
41270
 
-        raw_addr = email.utils.parseaddr(arg)[1]
41271
 
-        quoted_addr = smtplib.quoteaddr(arg)
41272
 
-        if raw_addr in sim_users:
41273
 
-            self.push('250 %s %s' % (sim_users[raw_addr], quoted_addr))
41274
 
+        # For max compatibility smtplib should be sending the raw address.
41275
 
+        if arg in sim_users:
41276
 
+            self.push('250 %s %s' % (sim_users[arg], smtplib.quoteaddr(arg)))
41277
 
         else:
41278
 
             self.push('550 No such user: %s' % arg)
41279
 
 
41280
 
     def smtp_EXPN(self, arg):
41281
 
-        list_name = email.utils.parseaddr(arg)[1].lower()
41282
 
+        list_name = arg.lower()
41283
 
         if list_name in sim_lists:
41284
 
             user_list = sim_lists[list_name]
41285
 
             for n, user_email in enumerate(user_list):
41286
 
@@ -454,7 +453,7 @@
41287
 
             self.assertEqual(smtp.vrfy(email), expected_known)
41288
 
 
41289
 
         u = 'nobody@nowhere.com'
41290
 
-        expected_unknown = (550, 'No such user: %s' % smtplib.quoteaddr(u))
41291
 
+        expected_unknown = (550, 'No such user: %s' % u)
41292
 
         self.assertEqual(smtp.vrfy(u), expected_unknown)
41293
 
         smtp.quit()
41294
 
 
41295
 
diff -r 8527427914a2 Lib/test/test_socket.py
41296
 
--- a/Lib/test/test_socket.py
41297
 
+++ b/Lib/test/test_socket.py
41298
 
@@ -145,11 +145,10 @@
41299
 
 
41300
 
     def clientRun(self, test_func):
41301
 
         self.server_ready.wait()
41302
 
+        self.clientSetUp()
41303
 
         self.client_ready.set()
41304
 
-        self.clientSetUp()
41305
 
-        with test_support.check_py3k_warnings():
41306
 
-            if not callable(test_func):
41307
 
-                raise TypeError("test_func must be a callable function.")
41308
 
+        if not callable(test_func):
41309
 
+            raise TypeError("test_func must be a callable function.")
41310
 
         try:
41311
 
             test_func()
41312
 
         except Exception, strerror:
41313
 
@@ -707,6 +706,16 @@
41314
 
         srv.listen(0)
41315
 
         srv.close()
41316
 
 
41317
 
+    @unittest.skipUnless(SUPPORTS_IPV6, 'IPv6 required for this test.')
41318
 
+    def test_flowinfo(self):
41319
 
+        self.assertRaises(OverflowError, socket.getnameinfo,
41320
 
+                          ('::1',0, 0xffffffff), 0)
41321
 
+        s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
41322
 
+        try:
41323
 
+            self.assertRaises(OverflowError, s.bind, ('::1', 0, -10))
41324
 
+        finally:
41325
 
+            s.close()
41326
 
+
41327
 
 
41328
 
 @unittest.skipUnless(thread, 'Threading required for this test.')
41329
 
 class BasicTCPTest(SocketConnectedTest):
41330
 
@@ -1380,7 +1389,7 @@
41331
 
             # no alarm can be pending.  Safe to restore old handler.
41332
 
             signal.signal(signal.SIGALRM, old_alarm)
41333
 
 
41334
 
-class UDPTimeoutTest(SocketTCPTest):
41335
 
+class UDPTimeoutTest(SocketUDPTest):
41336
 
 
41337
 
     def testUDPTimeout(self):
41338
 
         def raise_timeout(*args, **kwargs):
41339
 
diff -r 8527427914a2 Lib/test/test_socketserver.py
41340
 
--- a/Lib/test/test_socketserver.py
41341
 
+++ b/Lib/test/test_socketserver.py
41342
 
@@ -66,7 +66,7 @@
41343
 
     """Test all socket servers."""
41344
 
 
41345
 
     def setUp(self):
41346
 
-        signal_alarm(20)  # Kill deadlocks after 20 seconds.
41347
 
+        signal_alarm(60)  # Kill deadlocks after 60 seconds.
41348
 
         self.port_seed = 0
41349
 
         self.test_files = []
41350
 
 
41351
 
@@ -123,7 +123,6 @@
41352
 
         self.assertEqual(server.server_address, server.socket.getsockname())
41353
 
         return server
41354
 
 
41355
 
-    @unittest.skipUnless(threading, 'Threading required for this test.')
41356
 
     @reap_threads
41357
 
     def run_server(self, svrcls, hdlrbase, testfunc):
41358
 
         server = self.make_server(self.pickaddr(svrcls.address_family),
41359
 
@@ -281,4 +280,3 @@
41360
 
 
41361
 
 if __name__ == "__main__":
41362
 
     test_main()
41363
 
-    signal_alarm(3)  # Shutdown shouldn't take more than 3 seconds.
41364
 
diff -r 8527427914a2 Lib/test/test_ssl.py
41365
 
--- a/Lib/test/test_ssl.py
41366
 
+++ b/Lib/test/test_ssl.py
41367
 
@@ -110,6 +110,23 @@
41368
 
         p = ssl._ssl._test_decode_cert(CERTFILE, False)
41369
 
         if test_support.verbose:
41370
 
             sys.stdout.write("\n" + pprint.pformat(p) + "\n")
41371
 
+        self.assertEqual(p['subject'],
41372
 
+                         ((('countryName', u'US'),),
41373
 
+                          (('stateOrProvinceName', u'Delaware'),),
41374
 
+                          (('localityName', u'Wilmington'),),
41375
 
+                          (('organizationName', u'Python Software Foundation'),),
41376
 
+                          (('organizationalUnitName', u'SSL'),),
41377
 
+                          (('commonName', u'somemachine.python.org'),)),
41378
 
+                        )
41379
 
+        # Issue #13034: the subjectAltName in some certificates
41380
 
+        # (notably projects.developer.nokia.com:443) wasn't parsed
41381
 
+        p = ssl._ssl._test_decode_cert(NOKIACERT)
41382
 
+        if test_support.verbose:
41383
 
+            sys.stdout.write("\n" + pprint.pformat(p) + "\n")
41384
 
+        self.assertEqual(p['subjectAltName'],
41385
 
+                         (('DNS', 'projects.developer.nokia.com'),
41386
 
+                          ('DNS', 'projects.forum.nokia.com'))
41387
 
+                        )
41388
 
 
41389
 
     def test_DER_to_PEM(self):
41390
 
         with open(SVN_PYTHON_ORG_ROOT_CERT, 'r') as f:
41391
 
@@ -400,10 +417,11 @@
41392
 
                                                    ca_certs=self.server.cacerts,
41393
 
                                                    cert_reqs=self.server.certreqs,
41394
 
                                                    ciphers=self.server.ciphers)
41395
 
-                except ssl.SSLError:
41396
 
+                except ssl.SSLError as e:
41397
 
                     # XXX Various errors can have happened here, for example
41398
 
                     # a mismatching protocol version, an invalid certificate,
41399
 
                     # or a low-level bug. This should be made more discriminating.
41400
 
+                    self.server.conn_errors.append(e)
41401
 
                     if self.server.chatty:
41402
 
                         handle_error("\n server:  bad connection attempt from " +
41403
 
                                      str(self.sock.getpeername()) + ":\n")
41404
 
@@ -512,9 +530,19 @@
41405
 
                     sys.stdout.write(' server:  wrapped server socket as %s\n' % str(self.sock))
41406
 
             self.port = test_support.bind_port(self.sock)
41407
 
             self.active = False
41408
 
+            self.conn_errors = []
41409
 
             threading.Thread.__init__(self)
41410
 
             self.daemon = True
41411
 
 
41412
 
+        def __enter__(self):
41413
 
+            self.start(threading.Event())
41414
 
+            self.flag.wait()
41415
 
+            return self
41416
 
+
41417
 
+        def __exit__(self, *args):
41418
 
+            self.stop()
41419
 
+            self.join()
41420
 
+
41421
 
         def start(self, flag=None):
41422
 
             self.flag = flag
41423
 
             threading.Thread.start(self)
41424
 
@@ -534,6 +562,7 @@
41425
 
                                          + str(connaddr) + '\n')
41426
 
                     handler = self.ConnectionHandler(self, newconn)
41427
 
                     handler.start()
41428
 
+                    handler.join()
41429
 
                 except socket.timeout:
41430
 
                     pass
41431
 
                 except KeyboardInterrupt:
41432
 
@@ -621,6 +650,21 @@
41433
 
         def __str__(self):
41434
 
             return "<%s %s>" % (self.__class__.__name__, self.server)
41435
 
 
41436
 
+        def __enter__(self):
41437
 
+            self.start(threading.Event())
41438
 
+            self.flag.wait()
41439
 
+            return self
41440
 
+
41441
 
+        def __exit__(self, *args):
41442
 
+            if test_support.verbose:
41443
 
+                sys.stdout.write(" cleanup: stopping server.\n")
41444
 
+            self.stop()
41445
 
+            if test_support.verbose:
41446
 
+                sys.stdout.write(" cleanup: joining server thread.\n")
41447
 
+            self.join()
41448
 
+            if test_support.verbose:
41449
 
+                sys.stdout.write(" cleanup: successfully joined.\n")
41450
 
+
41451
 
         def start(self, flag=None):
41452
 
             self.flag = flag
41453
 
             threading.Thread.start(self)
41454
 
@@ -735,12 +779,7 @@
41455
 
         server = ThreadedEchoServer(CERTFILE,
41456
 
                                     certreqs=ssl.CERT_REQUIRED,
41457
 
                                     cacerts=CERTFILE, chatty=False)
41458
 
-        flag = threading.Event()
41459
 
-        server.start(flag)
41460
 
-        # wait for it to start
41461
 
-        flag.wait()
41462
 
-        # try to connect
41463
 
-        try:
41464
 
+        with server:
41465
 
             try:
41466
 
                 s = ssl.wrap_socket(socket.socket(),
41467
 
                                     certfile=certfile,
41468
 
@@ -754,9 +793,6 @@
41469
 
                     sys.stdout.write("\nsocket.error is %s\n" % x[1])
41470
 
             else:
41471
 
                 raise AssertionError("Use of invalid cert should have failed!")
41472
 
-        finally:
41473
 
-            server.stop()
41474
 
-            server.join()
41475
 
 
41476
 
     def server_params_test(certfile, protocol, certreqs, cacertsfile,
41477
 
                            client_certfile, client_protocol=None, indata="FOO\n",
41478
 
@@ -774,14 +810,10 @@
41479
 
                                     chatty=chatty,
41480
 
                                     connectionchatty=connectionchatty,
41481
 
                                     wrap_accepting_socket=wrap_accepting_socket)
41482
 
-        flag = threading.Event()
41483
 
-        server.start(flag)
41484
 
-        # wait for it to start
41485
 
-        flag.wait()
41486
 
-        # try to connect
41487
 
-        if client_protocol is None:
41488
 
-            client_protocol = protocol
41489
 
-        try:
41490
 
+        with server:
41491
 
+            # try to connect
41492
 
+            if client_protocol is None:
41493
 
+                client_protocol = protocol
41494
 
             s = ssl.wrap_socket(socket.socket(),
41495
 
                                 certfile=client_certfile,
41496
 
                                 ca_certs=cacertsfile,
41497
 
@@ -809,9 +841,6 @@
41498
 
                 if test_support.verbose:
41499
 
                     sys.stdout.write(" client:  closing connection.\n")
41500
 
             s.close()
41501
 
-        finally:
41502
 
-            server.stop()
41503
 
-            server.join()
41504
 
 
41505
 
     def try_protocol_combo(server_protocol,
41506
 
                            client_protocol,
41507
 
@@ -913,12 +942,7 @@
41508
 
                                         ssl_version=ssl.PROTOCOL_SSLv23,
41509
 
                                         cacerts=CERTFILE,
41510
 
                                         chatty=False)
41511
 
-            flag = threading.Event()
41512
 
-            server.start(flag)
41513
 
-            # wait for it to start
41514
 
-            flag.wait()
41515
 
-            # try to connect
41516
 
-            try:
41517
 
+            with server:
41518
 
                 s = ssl.wrap_socket(socket.socket(),
41519
 
                                     certfile=CERTFILE,
41520
 
                                     ca_certs=CERTFILE,
41521
 
@@ -940,9 +964,6 @@
41522
 
                         "Missing or invalid 'organizationName' field in certificate subject; "
41523
 
                         "should be 'Python Software Foundation'.")
41524
 
                 s.close()
41525
 
-            finally:
41526
 
-                server.stop()
41527
 
-                server.join()
41528
 
 
41529
 
         def test_empty_cert(self):
41530
 
             """Connecting with an empty cert file"""
41531
 
@@ -966,6 +987,8 @@
41532
 
             """Connecting to an SSLv2 server with various client options"""
41533
 
             if test_support.verbose:
41534
 
                 sys.stdout.write("\n")
41535
 
+            if not hasattr(ssl, 'PROTOCOL_SSLv2'):
41536
 
+                self.skipTest("PROTOCOL_SSLv2 needed")
41537
 
             try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True)
41538
 
             try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_OPTIONAL)
41539
 
             try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_REQUIRED)
41540
 
@@ -978,14 +1001,6 @@
41541
 
             """Connecting to an SSLv23 server with various client options"""
41542
 
             if test_support.verbose:
41543
 
                 sys.stdout.write("\n")
41544
 
-            try:
41545
 
-                try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True)
41546
 
-            except (ssl.SSLError, socket.error), x:
41547
 
-                # this fails on some older versions of OpenSSL (0.9.7l, for instance)
41548
 
-                if test_support.verbose:
41549
 
-                    sys.stdout.write(
41550
 
-                        " SSL2 client to SSL23 server test unexpectedly failed:\n %s\n"
41551
 
-                        % str(x))
41552
 
             try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, True)
41553
 
             try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True)
41554
 
             try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True)
41555
 
@@ -1008,7 +1023,6 @@
41556
 
             try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_REQUIRED)
41557
 
             if hasattr(ssl, 'PROTOCOL_SSLv2'):
41558
 
                 try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv2, False)
41559
 
-            try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, False)
41560
 
             try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLSv1, False)
41561
 
 
41562
 
         @skip_if_broken_ubuntu_ssl
41563
 
@@ -1022,7 +1036,6 @@
41564
 
             if hasattr(ssl, 'PROTOCOL_SSLv2'):
41565
 
                 try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv2, False)
41566
 
             try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv3, False)
41567
 
-            try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv23, False)
41568
 
 
41569
 
         def test_starttls(self):
41570
 
             """Switching from clear text to encrypted and back again."""
41571
 
@@ -1033,13 +1046,8 @@
41572
 
                                         starttls_server=True,
41573
 
                                         chatty=True,
41574
 
                                         connectionchatty=True)
41575
 
-            flag = threading.Event()
41576
 
-            server.start(flag)
41577
 
-            # wait for it to start
41578
 
-            flag.wait()
41579
 
-            # try to connect
41580
 
             wrapped = False
41581
 
-            try:
41582
 
+            with server:
41583
 
                 s = socket.socket()
41584
 
                 s.setblocking(1)
41585
 
                 s.connect((HOST, server.port))
41586
 
@@ -1084,9 +1092,6 @@
41587
 
                 else:
41588
 
                     s.send("over\n")
41589
 
                 s.close()
41590
 
-            finally:
41591
 
-                server.stop()
41592
 
-                server.join()
41593
 
 
41594
 
         def test_socketserver(self):
41595
 
             """Using a SocketServer to create and manage SSL connections."""
41596
 
@@ -1136,12 +1141,7 @@
41597
 
             if test_support.verbose:
41598
 
                 sys.stdout.write("\n")
41599
 
             server = AsyncoreEchoServer(CERTFILE)
41600
 
-            flag = threading.Event()
41601
 
-            server.start(flag)
41602
 
-            # wait for it to start
41603
 
-            flag.wait()
41604
 
-            # try to connect
41605
 
-            try:
41606
 
+            with server:
41607
 
                 s = ssl.wrap_socket(socket.socket())
41608
 
                 s.connect(('127.0.0.1', server.port))
41609
 
                 if test_support.verbose:
41610
 
@@ -1160,10 +1160,6 @@
41611
 
                 if test_support.verbose:
41612
 
                     sys.stdout.write(" client:  closing connection.\n")
41613
 
                 s.close()
41614
 
-            finally:
41615
 
-                server.stop()
41616
 
-                # wait for server thread to end
41617
 
-                server.join()
41618
 
 
41619
 
         def test_recv_send(self):
41620
 
             """Test recv(), send() and friends."""
41621
 
@@ -1176,19 +1172,14 @@
41622
 
                                         cacerts=CERTFILE,
41623
 
                                         chatty=True,
41624
 
                                         connectionchatty=False)
41625
 
-            flag = threading.Event()
41626
 
-            server.start(flag)
41627
 
-            # wait for it to start
41628
 
-            flag.wait()
41629
 
-            # try to connect
41630
 
-            s = ssl.wrap_socket(socket.socket(),
41631
 
-                                server_side=False,
41632
 
-                                certfile=CERTFILE,
41633
 
-                                ca_certs=CERTFILE,
41634
 
-                                cert_reqs=ssl.CERT_NONE,
41635
 
-                                ssl_version=ssl.PROTOCOL_TLSv1)
41636
 
-            s.connect((HOST, server.port))
41637
 
-            try:
41638
 
+            with server:
41639
 
+                s = ssl.wrap_socket(socket.socket(),
41640
 
+                                    server_side=False,
41641
 
+                                    certfile=CERTFILE,
41642
 
+                                    ca_certs=CERTFILE,
41643
 
+                                    cert_reqs=ssl.CERT_NONE,
41644
 
+                                    ssl_version=ssl.PROTOCOL_TLSv1)
41645
 
+                s.connect((HOST, server.port))
41646
 
                 # helper methods for standardising recv* method signatures
41647
 
                 def _recv_into():
41648
 
                     b = bytearray("\0"*100)
41649
 
@@ -1276,9 +1267,6 @@
41650
 
 
41651
 
                 s.write("over\n".encode("ASCII", "strict"))
41652
 
                 s.close()
41653
 
-            finally:
41654
 
-                server.stop()
41655
 
-                server.join()
41656
 
 
41657
 
         def test_handshake_timeout(self):
41658
 
             # Issue #5103: SSL handshake must respect the socket timeout
41659
 
@@ -1327,17 +1315,39 @@
41660
 
                 t.join()
41661
 
                 server.close()
41662
 
 
41663
 
+        def test_default_ciphers(self):
41664
 
+            with ThreadedEchoServer(CERTFILE,
41665
 
+                                    ssl_version=ssl.PROTOCOL_SSLv23,
41666
 
+                                    chatty=False) as server:
41667
 
+                sock = socket.socket()
41668
 
+                try:
41669
 
+                    # Force a set of weak ciphers on our client socket
41670
 
+                    try:
41671
 
+                        s = ssl.wrap_socket(sock,
41672
 
+                                            ssl_version=ssl.PROTOCOL_SSLv23,
41673
 
+                                            ciphers="DES")
41674
 
+                    except ssl.SSLError:
41675
 
+                        self.skipTest("no DES cipher available")
41676
 
+                    with self.assertRaises((OSError, ssl.SSLError)):
41677
 
+                        s.connect((HOST, server.port))
41678
 
+                finally:
41679
 
+                    sock.close()
41680
 
+            self.assertIn("no shared cipher", str(server.conn_errors[0]))
41681
 
+
41682
 
 
41683
 
 def test_main(verbose=False):
41684
 
-    global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT
41685
 
+    global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, NOKIACERT
41686
 
     CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir,
41687
 
                             "keycert.pem")
41688
 
     SVN_PYTHON_ORG_ROOT_CERT = os.path.join(
41689
 
         os.path.dirname(__file__) or os.curdir,
41690
 
         "https_svn_python_org_root.pem")
41691
 
+    NOKIACERT = os.path.join(os.path.dirname(__file__) or os.curdir,
41692
 
+                             "nokia.pem")
41693
 
 
41694
 
     if (not os.path.exists(CERTFILE) or
41695
 
-        not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT)):
41696
 
+        not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT) or
41697
 
+        not os.path.exists(NOKIACERT)):
41698
 
         raise test_support.TestFailed("Can't read certificate files!")
41699
 
 
41700
 
     tests = [BasicTests, BasicSocketTests]
41701
 
diff -r 8527427914a2 Lib/test/test_subprocess.py
41702
 
--- a/Lib/test/test_subprocess.py
41703
 
+++ b/Lib/test/test_subprocess.py
41704
 
@@ -10,6 +10,11 @@
41705
 
 import re
41706
 
 import sysconfig
41707
 
 
41708
 
+try:
41709
 
+    import resource
41710
 
+except ImportError:
41711
 
+    resource = None
41712
 
+
41713
 
 mswindows = (sys.platform == "win32")
41714
 
 
41715
 
 #
41716
 
@@ -113,6 +118,16 @@
41717
 
                              env=newenv)
41718
 
         self.assertEqual(rc, 1)
41719
 
 
41720
 
+    def test_invalid_args(self):
41721
 
+        # Popen() called with invalid arguments should raise TypeError
41722
 
+        # but Popen.__del__ should not complain (issue #12085)
41723
 
+        with test_support.captured_stderr() as s:
41724
 
+            self.assertRaises(TypeError, subprocess.Popen, invalid_arg_name=1)
41725
 
+            argcount = subprocess.Popen.__init__.__code__.co_argcount
41726
 
+            too_many_args = [0] * (argcount + 1)
41727
 
+            self.assertRaises(TypeError, subprocess.Popen, *too_many_args)
41728
 
+        self.assertEqual(s.getvalue(), '')
41729
 
+
41730
 
     def test_stdin_none(self):
41731
 
         # .stdin is None when not redirected
41732
 
         p = subprocess.Popen([sys.executable, "-c", 'print "banana"'],
41733
 
@@ -623,12 +638,12 @@
41734
 
 
41735
 
     def __enter__(self):
41736
 
         """Try to save previous ulimit, then set it to (0, 0)."""
41737
 
-        try:
41738
 
-            import resource
41739
 
-            self.old_limit = resource.getrlimit(resource.RLIMIT_CORE)
41740
 
-            resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
41741
 
-        except (ImportError, ValueError, resource.error):
41742
 
-            pass
41743
 
+        if resource is not None:
41744
 
+            try:
41745
 
+                self.old_limit = resource.getrlimit(resource.RLIMIT_CORE)
41746
 
+                resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
41747
 
+            except (ValueError, resource.error):
41748
 
+                pass
41749
 
 
41750
 
         if sys.platform == 'darwin':
41751
 
             # Check if the 'Crash Reporter' on OSX was configured
41752
 
@@ -648,11 +663,29 @@
41753
 
         """Return core file behavior to default."""
41754
 
         if self.old_limit is None:
41755
 
             return
41756
 
-        try:
41757
 
-            import resource
41758
 
-            resource.setrlimit(resource.RLIMIT_CORE, self.old_limit)
41759
 
-        except (ImportError, ValueError, resource.error):
41760
 
+        if resource is not None:
41761
 
+            try:
41762
 
+                resource.setrlimit(resource.RLIMIT_CORE, self.old_limit)
41763
 
+            except (ValueError, resource.error):
41764
 
+                pass
41765
 
+
41766
 
+    @unittest.skipUnless(hasattr(signal, 'SIGALRM'),
41767
 
+                         "Requires signal.SIGALRM")
41768
 
+    def test_communicate_eintr(self):
41769
 
+        # Issue #12493: communicate() should handle EINTR
41770
 
+        def handler(signum, frame):
41771
 
             pass
41772
 
+        old_handler = signal.signal(signal.SIGALRM, handler)
41773
 
+        self.addCleanup(signal.signal, signal.SIGALRM, old_handler)
41774
 
+
41775
 
+        # the process is running for 2 seconds
41776
 
+        args = [sys.executable, "-c", 'import time; time.sleep(2)']
41777
 
+        for stream in ('stdout', 'stderr'):
41778
 
+            kw = {stream: subprocess.PIPE}
41779
 
+            with subprocess.Popen(args, **kw) as process:
41780
 
+                signal.alarm(1)
41781
 
+                # communicate() will be interrupted by SIGALRM
41782
 
+                process.communicate()
41783
 
 
41784
 
 
41785
 
 @unittest.skipIf(mswindows, "POSIX specific tests")
41786
 
@@ -849,6 +882,64 @@
41787
 
         # all standard fds closed.
41788
 
         self.check_close_std_fds([0, 1, 2])
41789
 
 
41790
 
+    def check_swap_fds(self, stdin_no, stdout_no, stderr_no):
41791
 
+        # open up some temporary files
41792
 
+        temps = [mkstemp() for i in range(3)]
41793
 
+        temp_fds = [fd for fd, fname in temps]
41794
 
+        try:
41795
 
+            # unlink the files -- we won't need to reopen them
41796
 
+            for fd, fname in temps:
41797
 
+                os.unlink(fname)
41798
 
+
41799
 
+            # save a copy of the standard file descriptors
41800
 
+            saved_fds = [os.dup(fd) for fd in range(3)]
41801
 
+            try:
41802
 
+                # duplicate the temp files over the standard fd's 0, 1, 2
41803
 
+                for fd, temp_fd in enumerate(temp_fds):
41804
 
+                    os.dup2(temp_fd, fd)
41805
 
+
41806
 
+                # write some data to what will become stdin, and rewind
41807
 
+                os.write(stdin_no, b"STDIN")
41808
 
+                os.lseek(stdin_no, 0, 0)
41809
 
+
41810
 
+                # now use those files in the given order, so that subprocess
41811
 
+                # has to rearrange them in the child
41812
 
+                p = subprocess.Popen([sys.executable, "-c",
41813
 
+                    'import sys; got = sys.stdin.read();'
41814
 
+                    'sys.stdout.write("got %s"%got); sys.stderr.write("err")'],
41815
 
+                    stdin=stdin_no,
41816
 
+                    stdout=stdout_no,
41817
 
+                    stderr=stderr_no)
41818
 
+                p.wait()
41819
 
+
41820
 
+                for fd in temp_fds:
41821
 
+                    os.lseek(fd, 0, 0)
41822
 
+
41823
 
+                out = os.read(stdout_no, 1024)
41824
 
+                err = test_support.strip_python_stderr(os.read(stderr_no, 1024))
41825
 
+            finally:
41826
 
+                for std, saved in enumerate(saved_fds):
41827
 
+                    os.dup2(saved, std)
41828
 
+                    os.close(saved)
41829
 
+
41830
 
+            self.assertEqual(out, b"got STDIN")
41831
 
+            self.assertEqual(err, b"err")
41832
 
+
41833
 
+        finally:
41834
 
+            for fd in temp_fds:
41835
 
+                os.close(fd)
41836
 
+
41837
 
+    # When duping fds, if there arises a situation where one of the fds is
41838
 
+    # either 0, 1 or 2, it is possible that it is overwritten (#12607).
41839
 
+    # This tests all combinations of this.
41840
 
+    def test_swap_fds(self):
41841
 
+        self.check_swap_fds(0, 1, 2)
41842
 
+        self.check_swap_fds(0, 2, 1)
41843
 
+        self.check_swap_fds(1, 0, 2)
41844
 
+        self.check_swap_fds(1, 2, 0)
41845
 
+        self.check_swap_fds(2, 0, 1)
41846
 
+        self.check_swap_fds(2, 1, 0)
41847
 
+
41848
 
     def test_wait_when_sigchild_ignored(self):
41849
 
         # NOTE: sigchild_ignore.py may not be an effective test on all OSes.
41850
 
         sigchild_ignore = test_support.findfile("sigchild_ignore.py",
41851
 
@@ -859,6 +950,87 @@
41852
 
         self.assertEqual(0, p.returncode, "sigchild_ignore.py exited"
41853
 
                          " non-zero with this error:\n%s" % stderr)
41854
 
 
41855
 
+    def test_zombie_fast_process_del(self):
41856
 
+        # Issue #12650: on Unix, if Popen.__del__() was called before the
41857
 
+        # process exited, it wouldn't be added to subprocess._active, and would
41858
 
+        # remain a zombie.
41859
 
+        # spawn a Popen, and delete its reference before it exits
41860
 
+        p = subprocess.Popen([sys.executable, "-c",
41861
 
+                              'import sys, time;'
41862
 
+                              'time.sleep(0.2)'],
41863
 
+                             stdout=subprocess.PIPE,
41864
 
+                             stderr=subprocess.PIPE)
41865
 
+        self.addCleanup(p.stdout.close)
41866
 
+        self.addCleanup(p.stderr.close)
41867
 
+        ident = id(p)
41868
 
+        pid = p.pid
41869
 
+        del p
41870
 
+        # check that p is in the active processes list
41871
 
+        self.assertIn(ident, [id(o) for o in subprocess._active])
41872
 
+
41873
 
+    def test_leak_fast_process_del_killed(self):
41874
 
+        # Issue #12650: on Unix, if Popen.__del__() was called before the
41875
 
+        # process exited, and the process got killed by a signal, it would never
41876
 
+        # be removed from subprocess._active, which triggered a FD and memory
41877
 
+        # leak.
41878
 
+        # spawn a Popen, delete its reference and kill it
41879
 
+        p = subprocess.Popen([sys.executable, "-c",
41880
 
+                              'import time;'
41881
 
+                              'time.sleep(3)'],
41882
 
+                             stdout=subprocess.PIPE,
41883
 
+                             stderr=subprocess.PIPE)
41884
 
+        self.addCleanup(p.stdout.close)
41885
 
+        self.addCleanup(p.stderr.close)
41886
 
+        ident = id(p)
41887
 
+        pid = p.pid
41888
 
+        del p
41889
 
+        os.kill(pid, signal.SIGKILL)
41890
 
+        # check that p is in the active processes list
41891
 
+        self.assertIn(ident, [id(o) for o in subprocess._active])
41892
 
+
41893
 
+        # let some time for the process to exit, and create a new Popen: this
41894
 
+        # should trigger the wait() of p
41895
 
+        time.sleep(0.2)
41896
 
+        with self.assertRaises(EnvironmentError) as c:
41897
 
+            with subprocess.Popen(['nonexisting_i_hope'],
41898
 
+                                  stdout=subprocess.PIPE,
41899
 
+                                  stderr=subprocess.PIPE) as proc:
41900
 
+                pass
41901
 
+        # p should have been wait()ed on, and removed from the _active list
41902
 
+        self.assertRaises(OSError, os.waitpid, pid, 0)
41903
 
+        self.assertNotIn(ident, [id(o) for o in subprocess._active])
41904
 
+
41905
 
+    def test_pipe_cloexec(self):
41906
 
+        # Issue 12786: check that the communication pipes' FDs are set CLOEXEC,
41907
 
+        # and are not inherited by another child process.
41908
 
+        p1 = subprocess.Popen([sys.executable, "-c",
41909
 
+                               'import os;'
41910
 
+                               'os.read(0, 1)'
41911
 
+                              ],
41912
 
+                              stdin=subprocess.PIPE, stdout=subprocess.PIPE,
41913
 
+                              stderr=subprocess.PIPE)
41914
 
+
41915
 
+        p2 = subprocess.Popen([sys.executable, "-c", """if True:
41916
 
+                               import os, errno, sys
41917
 
+                               for fd in %r:
41918
 
+                                   try:
41919
 
+                                       os.close(fd)
41920
 
+                                   except OSError as e:
41921
 
+                                       if e.errno != errno.EBADF:
41922
 
+                                           raise
41923
 
+                                   else:
41924
 
+                                       sys.exit(1)
41925
 
+                               sys.exit(0)
41926
 
+                               """ % [f.fileno() for f in (p1.stdin, p1.stdout,
41927
 
+                                                           p1.stderr)]
41928
 
+                              ],
41929
 
+                              stdin=subprocess.PIPE, stdout=subprocess.PIPE,
41930
 
+                              stderr=subprocess.PIPE, close_fds=False)
41931
 
+        p1.communicate('foo')
41932
 
+        _, stderr = p2.communicate()
41933
 
+
41934
 
+        self.assertEqual(p2.returncode, 0, "Unexpected error: " + repr(stderr))
41935
 
+
41936
 
 
41937
 
 @unittest.skipUnless(mswindows, "Windows specific tests")
41938
 
 class Win32ProcessTestCase(BaseTestCase):
41939
 
@@ -994,7 +1166,6 @@
41940
 
                          subprocess._eintr_retry_call(fake_os_func, 666))
41941
 
         self.assertEqual([(256, 999), (666,), (666,)], record_calls)
41942
 
 
41943
 
-
41944
 
 @unittest.skipUnless(mswindows, "mswindows only")
41945
 
 class CommandsWithSpaces (BaseTestCase):
41946
 
 
41947
 
diff -r 8527427914a2 Lib/test/test_support.py
41948
 
--- a/Lib/test/test_support.py
41949
 
+++ b/Lib/test/test_support.py
41950
 
@@ -763,6 +763,8 @@
41951
 
         ('ETIMEDOUT', 110),
41952
 
     ]
41953
 
     default_gai_errnos = [
41954
 
+        ('EAI_AGAIN', -3),
41955
 
+        ('EAI_FAIL', -4),
41956
 
         ('EAI_NONAME', -2),
41957
 
         ('EAI_NODATA', -5),
41958
 
     ]
41959
 
@@ -833,6 +835,9 @@
41960
 
     """
41961
 
     return captured_output("stdout")
41962
 
 
41963
 
+def captured_stderr():
41964
 
+    return captured_output("stderr")
41965
 
+
41966
 
 def captured_stdin():
41967
 
     return captured_output("stdin")
41968
 
 
41969
 
diff -r 8527427914a2 Lib/test/test_symtable.py
41970
 
--- a/Lib/test/test_symtable.py
41971
 
+++ b/Lib/test/test_symtable.py
41972
 
@@ -88,10 +88,10 @@
41973
 
 
41974
 
     def test_function_info(self):
41975
 
         func = self.spam
41976
 
-        self.assertEqual(func.get_parameters(), ("a", "b", "kw", "var"))
41977
 
-        self.assertEqual(func.get_locals(),
41978
 
-                         ("a", "b", "internal", "kw", "var", "x"))
41979
 
-        self.assertEqual(func.get_globals(), ("bar", "glob"))
41980
 
+        self.assertEqual(sorted(func.get_parameters()), ["a", "b", "kw", "var"])
41981
 
+        expected = ["a", "b", "internal", "kw", "var", "x"]
41982
 
+        self.assertEqual(sorted(func.get_locals()), expected)
41983
 
+        self.assertEqual(sorted(func.get_globals()), ["bar", "glob"])
41984
 
         self.assertEqual(self.internal.get_frees(), ("x",))
41985
 
 
41986
 
     def test_globals(self):
41987
 
diff -r 8527427914a2 Lib/test/test_sys.py
41988
 
--- a/Lib/test/test_sys.py
41989
 
+++ b/Lib/test/test_sys.py
41990
 
@@ -224,6 +224,18 @@
41991
 
         self.assertEqual(sys.getrecursionlimit(), 10000)
41992
 
         sys.setrecursionlimit(oldlimit)
41993
 
 
41994
 
+        self.assertRaises(OverflowError, sys.setrecursionlimit, 1 << 31)
41995
 
+        try:
41996
 
+            sys.setrecursionlimit((1 << 31) - 5)
41997
 
+            try:
41998
 
+                # issue13546: isinstance(e, ValueError) used to fail
41999
 
+                # when the recursion limit is close to 1<<31
42000
 
+                raise ValueError()
42001
 
+            except ValueError, e:
42002
 
+                pass
42003
 
+        finally:
42004
 
+            sys.setrecursionlimit(oldlimit)
42005
 
+
42006
 
     def test_getwindowsversion(self):
42007
 
         # Raise SkipTest if sys doesn't have getwindowsversion attribute
42008
 
         test.test_support.get_attribute(sys, "getwindowsversion")
42009
 
@@ -459,6 +471,9 @@
42010
 
         self.assertRaises(TypeError, sys.call_tracing, str, 2)
42011
 
 
42012
 
     def test_executable(self):
42013
 
+        # sys.executable should be absolute
42014
 
+        self.assertEqual(os.path.abspath(sys.executable), sys.executable)
42015
 
+
42016
 
         # Issue #7774: Ensure that sys.executable is an empty string if argv[0]
42017
 
         # has been set to an non existent program name and Python is unable to
42018
 
         # retrieve the real program name
42019
 
diff -r 8527427914a2 Lib/test/test_sys_settrace.py
42020
 
--- a/Lib/test/test_sys_settrace.py
42021
 
+++ b/Lib/test/test_sys_settrace.py
42022
 
@@ -282,11 +282,11 @@
42023
 
         self.compare_events(func.func_code.co_firstlineno,
42024
 
                             tracer.events, func.events)
42025
 
 
42026
 
-    def set_and_retrieve_none(self):
42027
 
+    def test_set_and_retrieve_none(self):
42028
 
         sys.settrace(None)
42029
 
         assert sys.gettrace() is None
42030
 
 
42031
 
-    def set_and_retrieve_func(self):
42032
 
+    def test_set_and_retrieve_func(self):
42033
 
         def fn(*args):
42034
 
             pass
42035
 
 
42036
 
diff -r 8527427914a2 Lib/test/test_sysconfig.py
42037
 
--- a/Lib/test/test_sysconfig.py
42038
 
+++ b/Lib/test/test_sysconfig.py
42039
 
@@ -1,9 +1,5 @@
42040
 
-"""Tests for 'site'.
42041
 
+"""Tests for sysconfig."""
42042
 
 
42043
 
-Tests assume the initial paths in sys.path once the interpreter has begun
42044
 
-executing have not been removed.
42045
 
-
42046
 
-"""
42047
 
 import unittest
42048
 
 import sys
42049
 
 import os
42050
 
@@ -255,14 +251,21 @@
42051
 
             unlink(link)
42052
 
 
42053
 
     def test_user_similar(self):
42054
 
-        # Issue 8759 : make sure the posix scheme for the users
42055
 
+        # Issue #8759: make sure the posix scheme for the users
42056
 
         # is similar to the global posix_prefix one
42057
 
         base = get_config_var('base')
42058
 
         user = get_config_var('userbase')
42059
 
+        # the global scheme mirrors the distinction between prefix and
42060
 
+        # exec-prefix but not the user scheme, so we have to adapt the paths
42061
 
+        # before comparing (issue #9100)
42062
 
+        adapt = sys.prefix != sys.exec_prefix
42063
 
         for name in ('stdlib', 'platstdlib', 'purelib', 'platlib'):
42064
 
             global_path = get_path(name, 'posix_prefix')
42065
 
+            if adapt:
42066
 
+                global_path = global_path.replace(sys.exec_prefix, sys.prefix)
42067
 
+                base = base.replace(sys.exec_prefix, sys.prefix)
42068
 
             user_path = get_path(name, 'posix_user')
42069
 
-            self.assertEqual(user_path, global_path.replace(base, user))
42070
 
+            self.assertEqual(user_path, global_path.replace(base, user, 1))
42071
 
 
42072
 
     @unittest.skipUnless(sys.platform == "darwin", "test only relevant on MacOSX")
42073
 
     def test_platform_in_subprocess(self):
42074
 
diff -r 8527427914a2 Lib/test/test_tarfile.py
42075
 
--- a/Lib/test/test_tarfile.py
42076
 
+++ b/Lib/test/test_tarfile.py
42077
 
@@ -440,6 +440,23 @@
42078
 
     def test_detect_fileobj(self):
42079
 
         self._test_modes(self._testfunc_fileobj)
42080
 
 
42081
 
+    def test_detect_stream_bz2(self):
42082
 
+        # Originally, tarfile's stream detection looked for the string
42083
 
+        # "BZh91" at the start of the file. This is incorrect because
42084
 
+        # the '9' represents the blocksize (900kB). If the file was
42085
 
+        # compressed using another blocksize autodetection fails.
42086
 
+        if not bz2:
42087
 
+            return
42088
 
+
42089
 
+        with open(tarname, "rb") as fobj:
42090
 
+            data = fobj.read()
42091
 
+
42092
 
+        # Compress with blocksize 100kB, the file starts with "BZh11".
42093
 
+        with bz2.BZ2File(tmpname, "wb", compresslevel=1) as fobj:
42094
 
+            fobj.write(data)
42095
 
+
42096
 
+        self._testfunc_file(tmpname, "r|*")
42097
 
+
42098
 
 
42099
 
 class MemberReadTest(ReadTest):
42100
 
 
42101
 
@@ -977,6 +994,13 @@
42102
 
         finally:
42103
 
             os.umask(original_umask)
42104
 
 
42105
 
+    def test_issue13639(self):
42106
 
+        try:
42107
 
+            with tarfile.open(unicode(tmpname, sys.getfilesystemencoding()), self.mode):
42108
 
+                pass
42109
 
+        except UnicodeDecodeError:
42110
 
+            self.fail("_Stream failed to write unicode filename")
42111
 
+
42112
 
 
42113
 
 class GNUWriteTest(unittest.TestCase):
42114
 
     # This testcase checks for correct creation of GNU Longname
42115
 
diff -r 8527427914a2 Lib/test/test_telnetlib.py
42116
 
--- a/Lib/test/test_telnetlib.py
42117
 
+++ b/Lib/test/test_telnetlib.py
42118
 
@@ -15,7 +15,6 @@
42119
 
         1) set evt to true to let the parent know we are ready
42120
 
         2) [optional] if is not False, write the list of data from dataq.get()
42121
 
            to the socket.
42122
 
-        3) set evt to true to let the parent know we're done
42123
 
     """
42124
 
     serv.listen(5)
42125
 
     evt.set()
42126
 
@@ -34,29 +33,25 @@
42127
 
                     data += item
42128
 
                 written = conn.send(data)
42129
 
                 data = data[written:]
42130
 
+        conn.close()
42131
 
     except socket.timeout:
42132
 
         pass
42133
 
-    else:
42134
 
-        conn.close()
42135
 
     finally:
42136
 
         serv.close()
42137
 
-        evt.set()
42138
 
 
42139
 
 class GeneralTests(TestCase):
42140
 
 
42141
 
     def setUp(self):
42142
 
         self.evt = threading.Event()
42143
 
         self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
42144
 
-        self.sock.settimeout(3)
42145
 
+        self.sock.settimeout(60)  # Safety net. Look issue 11812
42146
 
         self.port = test_support.bind_port(self.sock)
42147
 
         self.thread = threading.Thread(target=server, args=(self.evt,self.sock))
42148
 
+        self.thread.setDaemon(True)
42149
 
         self.thread.start()
42150
 
         self.evt.wait()
42151
 
-        self.evt.clear()
42152
 
-        time.sleep(.1)
42153
 
 
42154
 
     def tearDown(self):
42155
 
-        self.evt.wait()
42156
 
         self.thread.join()
42157
 
 
42158
 
     def testBasic(self):
42159
 
@@ -68,7 +63,7 @@
42160
 
         self.assertTrue(socket.getdefaulttimeout() is None)
42161
 
         socket.setdefaulttimeout(30)
42162
 
         try:
42163
 
-            telnet = telnetlib.Telnet("localhost", self.port)
42164
 
+            telnet = telnetlib.Telnet(HOST, self.port)
42165
 
         finally:
42166
 
             socket.setdefaulttimeout(None)
42167
 
         self.assertEqual(telnet.sock.gettimeout(), 30)
42168
 
@@ -86,13 +81,13 @@
42169
 
         telnet.sock.close()
42170
 
 
42171
 
     def testTimeoutValue(self):
42172
 
-        telnet = telnetlib.Telnet("localhost", self.port, timeout=30)
42173
 
+        telnet = telnetlib.Telnet(HOST, self.port, timeout=30)
42174
 
         self.assertEqual(telnet.sock.gettimeout(), 30)
42175
 
         telnet.sock.close()
42176
 
 
42177
 
     def testTimeoutOpen(self):
42178
 
         telnet = telnetlib.Telnet()
42179
 
-        telnet.open("localhost", self.port, timeout=30)
42180
 
+        telnet.open(HOST, self.port, timeout=30)
42181
 
         self.assertEqual(telnet.sock.gettimeout(), 30)
42182
 
         telnet.sock.close()
42183
 
 
42184
 
@@ -100,16 +95,13 @@
42185
 
     self.evt = threading.Event()
42186
 
     self.dataq = Queue.Queue()
42187
 
     self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
42188
 
-    self.sock.settimeout(3)
42189
 
+    self.sock.settimeout(10)
42190
 
     self.port = test_support.bind_port(self.sock)
42191
 
     self.thread = threading.Thread(target=server, args=(self.evt,self.sock, self.dataq))
42192
 
     self.thread.start()
42193
 
     self.evt.wait()
42194
 
-    self.evt.clear()
42195
 
-    time.sleep(.1)
42196
 
 
42197
 
 def _read_tearDown(self):
42198
 
-    self.evt.wait()
42199
 
     self.thread.join()
42200
 
 
42201
 
 class ReadTests(TestCase):
42202
 
diff -r 8527427914a2 Lib/test/test_tempfile.py
42203
 
--- a/Lib/test/test_tempfile.py
42204
 
+++ b/Lib/test/test_tempfile.py
42205
 
@@ -1,6 +1,7 @@
42206
 
 # tempfile.py unit tests.
42207
 
 import tempfile
42208
 
 import os
42209
 
+import signal
42210
 
 import sys
42211
 
 import re
42212
 
 import warnings
42213
 
@@ -126,6 +127,37 @@
42214
 
         except:
42215
 
             self.failOnException("iteration")
42216
 
 
42217
 
+    @unittest.skipUnless(hasattr(os, 'fork'),
42218
 
+        "os.fork is required for this test")
42219
 
+    def test_process_awareness(self):
42220
 
+        # ensure that the random source differs between
42221
 
+        # child and parent.
42222
 
+        read_fd, write_fd = os.pipe()
42223
 
+        pid = None
42224
 
+        try:
42225
 
+            pid = os.fork()
42226
 
+            if not pid:
42227
 
+                os.close(read_fd)
42228
 
+                os.write(write_fd, next(self.r).encode("ascii"))
42229
 
+                os.close(write_fd)
42230
 
+                # bypass the normal exit handlers- leave those to
42231
 
+                # the parent.
42232
 
+                os._exit(0)
42233
 
+            parent_value = next(self.r)
42234
 
+            child_value = os.read(read_fd, len(parent_value)).decode("ascii")
42235
 
+        finally:
42236
 
+            if pid:
42237
 
+                # best effort to ensure the process can't bleed out
42238
 
+                # via any bugs above
42239
 
+                try:
42240
 
+                    os.kill(pid, signal.SIGKILL)
42241
 
+                except EnvironmentError:
42242
 
+                    pass
42243
 
+            os.close(read_fd)
42244
 
+            os.close(write_fd)
42245
 
+        self.assertNotEqual(child_value, parent_value)
42246
 
+
42247
 
+
42248
 
 test_classes.append(test__RandomNameSequence)
42249
 
 
42250
 
 
42251
 
diff -r 8527427914a2 Lib/test/test_threading.py
42252
 
--- a/Lib/test/test_threading.py
42253
 
+++ b/Lib/test/test_threading.py
42254
 
@@ -417,6 +417,13 @@
42255
 
 
42256
 
 class ThreadJoinOnShutdown(BaseTestCase):
42257
 
 
42258
 
+    # Between fork() and exec(), only async-safe functions are allowed (issues
42259
 
+    # #12316 and #11870), and fork() from a worker thread is known to trigger
42260
 
+    # problems with some operating systems (issue #3863): skip problematic tests
42261
 
+    # on platforms known to behave badly.
42262
 
+    platforms_to_skip = ('freebsd4', 'freebsd5', 'freebsd6', 'netbsd5',
42263
 
+                         'os2emx')
42264
 
+
42265
 
     def _run_and_join(self, script):
42266
 
         script = """if 1:
42267
 
             import sys, os, time, threading
42268
 
@@ -448,11 +455,10 @@
42269
 
         self._run_and_join(script)
42270
 
 
42271
 
 
42272
 
+    @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()")
42273
 
+    @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug")
42274
 
     def test_2_join_in_forked_process(self):
42275
 
         # Like the test above, but from a forked interpreter
42276
 
-        import os
42277
 
-        if not hasattr(os, 'fork'):
42278
 
-            return
42279
 
         script = """if 1:
42280
 
             childpid = os.fork()
42281
 
             if childpid != 0:
42282
 
@@ -466,19 +472,11 @@
42283
 
             """
42284
 
         self._run_and_join(script)
42285
 
 
42286
 
+    @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()")
42287
 
+    @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug")
42288
 
     def test_3_join_in_forked_from_thread(self):
42289
 
         # Like the test above, but fork() was called from a worker thread
42290
 
         # In the forked process, the main Thread object must be marked as stopped.
42291
 
-        import os
42292
 
-        if not hasattr(os, 'fork'):
42293
 
-            return
42294
 
-        # Skip platforms with known problems forking from a worker thread.
42295
 
-        # See http://bugs.python.org/issue3863.
42296
 
-        if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'netbsd5',
42297
 
-                           'os2emx'):
42298
 
-            print >>sys.stderr, ('Skipping test_3_join_in_forked_from_thread'
42299
 
-                                 ' due to known OS bugs on'), sys.platform
42300
 
-            return
42301
 
         script = """if 1:
42302
 
             main_thread = threading.current_thread()
42303
 
             def worker():
42304
 
@@ -507,15 +505,11 @@
42305
 
         self.assertEqual(data, expected_output)
42306
 
 
42307
 
     @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()")
42308
 
+    @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug")
42309
 
     def test_4_joining_across_fork_in_worker_thread(self):
42310
 
         # There used to be a possible deadlock when forking from a child
42311
 
         # thread.  See http://bugs.python.org/issue6643.
42312
 
 
42313
 
-        # Skip platforms with known problems forking from a worker thread.
42314
 
-        # See http://bugs.python.org/issue3863.
42315
 
-        if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'os2emx'):
42316
 
-            raise unittest.SkipTest('due to known OS bugs on ' + sys.platform)
42317
 
-
42318
 
         # The script takes the following steps:
42319
 
         # - The main thread in the parent process starts a new thread and then
42320
 
         #   tries to join it.
42321
 
@@ -584,6 +578,7 @@
42322
 
         self.assertScriptHasOutput(script, "end of main\n")
42323
 
 
42324
 
     @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()")
42325
 
+    @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug")
42326
 
     def test_5_clear_waiter_locks_to_avoid_crash(self):
42327
 
         # Check that a spawned thread that forks doesn't segfault on certain
42328
 
         # platforms, namely OS X.  This used to happen if there was a waiter
42329
 
@@ -596,10 +591,6 @@
42330
 
         # lock will be acquired, we can't know if the internal mutex will be
42331
 
         # acquired at the time of the fork.
42332
 
 
42333
 
-        # Skip platforms with known problems forking from a worker thread.
42334
 
-        # See http://bugs.python.org/issue3863.
42335
 
-        if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'os2emx'):
42336
 
-            raise unittest.SkipTest('due to known OS bugs on ' + sys.platform)
42337
 
         script = """if True:
42338
 
             import os, time, threading
42339
 
 
42340
 
@@ -644,6 +635,30 @@
42341
 
         output = "end of worker thread\nend of main thread\n"
42342
 
         self.assertScriptHasOutput(script, output)
42343
 
 
42344
 
+    @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()")
42345
 
+    @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug")
42346
 
+    def test_reinit_tls_after_fork(self):
42347
 
+        # Issue #13817: fork() would deadlock in a multithreaded program with
42348
 
+        # the ad-hoc TLS implementation.
42349
 
+
42350
 
+        def do_fork_and_wait():
42351
 
+            # just fork a child process and wait it
42352
 
+            pid = os.fork()
42353
 
+            if pid > 0:
42354
 
+                os.waitpid(pid, 0)
42355
 
+            else:
42356
 
+                os._exit(0)
42357
 
+
42358
 
+        # start a bunch of threads that will fork() child processes
42359
 
+        threads = []
42360
 
+        for i in range(16):
42361
 
+            t = threading.Thread(target=do_fork_and_wait)
42362
 
+            threads.append(t)
42363
 
+            t.start()
42364
 
+
42365
 
+        for t in threads:
42366
 
+            t.join()
42367
 
+
42368
 
 
42369
 
 class ThreadingExceptionTests(BaseTestCase):
42370
 
     # A RuntimeError should be raised if Thread.start() is called
42371
 
diff -r 8527427914a2 Lib/test/test_time.py
42372
 
--- a/Lib/test/test_time.py
42373
 
+++ b/Lib/test/test_time.py
42374
 
@@ -184,7 +184,12 @@
42375
 
             environ['TZ'] = victoria
42376
 
             time.tzset()
42377
 
             self.assertNotEqual(time.gmtime(xmas2002), time.localtime(xmas2002))
42378
 
-            self.assertTrue(time.tzname[0] == 'AEST', str(time.tzname[0]))
42379
 
+
42380
 
+            # Issue #11886: Australian Eastern Standard Time (UTC+10) is called
42381
 
+            # "EST" (as Eastern Standard Time, UTC-5) instead of "AEST" on some
42382
 
+            # operating systems (e.g. FreeBSD), which is wrong. See for example
42383
 
+            # this bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=93810
42384
 
+            self.assertIn(time.tzname[0], ('AEST' 'EST'), time.tzname[0])
42385
 
             self.assertTrue(time.tzname[1] == 'AEDT', str(time.tzname[1]))
42386
 
             self.assertEqual(len(time.tzname), 2)
42387
 
             self.assertEqual(time.daylight, 1)
42388
 
diff -r 8527427914a2 Lib/test/test_tk.py
42389
 
--- a/Lib/test/test_tk.py
42390
 
+++ b/Lib/test/test_tk.py
42391
 
@@ -1,18 +1,9 @@
42392
 
 import os
42393
 
-import unittest
42394
 
 from test import test_support
42395
 
 
42396
 
 # Skip test if _tkinter wasn't built.
42397
 
 test_support.import_module('_tkinter')
42398
 
 
42399
 
-import Tkinter
42400
 
-
42401
 
-try:
42402
 
-    Tkinter.Button()
42403
 
-except Tkinter.TclError, msg:
42404
 
-    # assuming tk is not available
42405
 
-    raise unittest.SkipTest("tk not available: %s" % msg)
42406
 
-
42407
 
 this_dir = os.path.dirname(os.path.abspath(__file__))
42408
 
 lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir,
42409
 
     'lib-tk', 'test'))
42410
 
@@ -20,6 +11,9 @@
42411
 
 with test_support.DirsOnSysPath(lib_tk_test):
42412
 
     import runtktests
42413
 
 
42414
 
+# Skip test if tk cannot be initialized.
42415
 
+runtktests.check_tk_availability()
42416
 
+
42417
 
 def test_main(enable_gui=False):
42418
 
     if enable_gui:
42419
 
         if test_support.use_resources is None:
42420
 
diff -r 8527427914a2 Lib/test/test_ttk_guionly.py
42421
 
--- a/Lib/test/test_ttk_guionly.py
42422
 
+++ b/Lib/test/test_ttk_guionly.py
42423
 
@@ -5,6 +5,16 @@
42424
 
 # Skip this test if _tkinter wasn't built.
42425
 
 test_support.import_module('_tkinter')
42426
 
 
42427
 
+this_dir = os.path.dirname(os.path.abspath(__file__))
42428
 
+lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir,
42429
 
+    'lib-tk', 'test'))
42430
 
+
42431
 
+with test_support.DirsOnSysPath(lib_tk_test):
42432
 
+    import runtktests
42433
 
+
42434
 
+# Skip test if tk cannot be initialized.
42435
 
+runtktests.check_tk_availability()
42436
 
+
42437
 
 import ttk
42438
 
 from _tkinter import TclError
42439
 
 
42440
 
@@ -14,13 +24,6 @@
42441
 
     # assuming ttk is not available
42442
 
     raise unittest.SkipTest("ttk not available: %s" % msg)
42443
 
 
42444
 
-this_dir = os.path.dirname(os.path.abspath(__file__))
42445
 
-lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir,
42446
 
-    'lib-tk', 'test'))
42447
 
-
42448
 
-with test_support.DirsOnSysPath(lib_tk_test):
42449
 
-    import runtktests
42450
 
-
42451
 
 def test_main(enable_gui=False):
42452
 
     if enable_gui:
42453
 
         if test_support.use_resources is None:
42454
 
diff -r 8527427914a2 Lib/test/test_unicode.py
42455
 
--- a/Lib/test/test_unicode.py
42456
 
+++ b/Lib/test/test_unicode.py
42457
 
@@ -5,9 +5,16 @@
42458
 
 (c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
42459
 
 
42460
 
 """#"
42461
 
-import sys, struct, codecs
42462
 
+import sys
42463
 
+import struct
42464
 
+import codecs
42465
 
+import unittest
42466
 
 from test import test_support, string_tests
42467
 
 
42468
 
+# decorator to skip tests on narrow builds
42469
 
+requires_wide_build = unittest.skipIf(sys.maxunicode == 65535,
42470
 
+                                      'requires wide build')
42471
 
+
42472
 
 # Error handling (bad decoder return)
42473
 
 def search_function(encoding):
42474
 
     def decode1(input, errors="strict"):
42475
 
@@ -269,30 +276,106 @@
42476
 
         # Surrogates on both sides, no fixup required
42477
 
         self.assertTrue(u'\ud800\udc02' < u'\ud84d\udc56')
42478
 
 
42479
 
+    def test_capitalize(self):
42480
 
+        string_tests.CommonTest.test_capitalize(self)
42481
 
+        # check that titlecased chars are lowered correctly
42482
 
+        # \u1ffc is the titlecased char
42483
 
+        self.checkequal(u'\u1ffc\u1ff3\u1ff3\u1ff3',
42484
 
+                        u'\u1ff3\u1ff3\u1ffc\u1ffc', 'capitalize')
42485
 
+        # check with cased non-letter chars
42486
 
+        self.checkequal(u'\u24c5\u24e8\u24e3\u24d7\u24de\u24dd',
42487
 
+                        u'\u24c5\u24ce\u24c9\u24bd\u24c4\u24c3', 'capitalize')
42488
 
+        self.checkequal(u'\u24c5\u24e8\u24e3\u24d7\u24de\u24dd',
42489
 
+                        u'\u24df\u24e8\u24e3\u24d7\u24de\u24dd', 'capitalize')
42490
 
+        self.checkequal(u'\u2160\u2171\u2172',
42491
 
+                        u'\u2160\u2161\u2162', 'capitalize')
42492
 
+        self.checkequal(u'\u2160\u2171\u2172',
42493
 
+                        u'\u2170\u2171\u2172', 'capitalize')
42494
 
+        # check with Ll chars with no upper - nothing changes here
42495
 
+        self.checkequal(u'\u019b\u1d00\u1d86\u0221\u1fb7',
42496
 
+                        u'\u019b\u1d00\u1d86\u0221\u1fb7', 'capitalize')
42497
 
+
42498
 
     def test_islower(self):
42499
 
         string_tests.MixinStrUnicodeUserStringTest.test_islower(self)
42500
 
         self.checkequalnofix(False, u'\u1FFc', 'islower')
42501
 
 
42502
 
+    @requires_wide_build
42503
 
+    def test_islower_non_bmp(self):
42504
 
+        # non-BMP, uppercase
42505
 
+        self.assertFalse(u'\U00010401'.islower())
42506
 
+        self.assertFalse(u'\U00010427'.islower())
42507
 
+        # non-BMP, lowercase
42508
 
+        self.assertTrue(u'\U00010429'.islower())
42509
 
+        self.assertTrue(u'\U0001044E'.islower())
42510
 
+        # non-BMP, non-cased
42511
 
+        self.assertFalse(u'\U0001F40D'.islower())
42512
 
+        self.assertFalse(u'\U0001F46F'.islower())
42513
 
+
42514
 
     def test_isupper(self):
42515
 
         string_tests.MixinStrUnicodeUserStringTest.test_isupper(self)
42516
 
         if not sys.platform.startswith('java'):
42517
 
             self.checkequalnofix(False, u'\u1FFc', 'isupper')
42518
 
 
42519
 
+    @requires_wide_build
42520
 
+    def test_isupper_non_bmp(self):
42521
 
+        # non-BMP, uppercase
42522
 
+        self.assertTrue(u'\U00010401'.isupper())
42523
 
+        self.assertTrue(u'\U00010427'.isupper())
42524
 
+        # non-BMP, lowercase
42525
 
+        self.assertFalse(u'\U00010429'.isupper())
42526
 
+        self.assertFalse(u'\U0001044E'.isupper())
42527
 
+        # non-BMP, non-cased
42528
 
+        self.assertFalse(u'\U0001F40D'.isupper())
42529
 
+        self.assertFalse(u'\U0001F46F'.isupper())
42530
 
+
42531
 
     def test_istitle(self):
42532
 
-        string_tests.MixinStrUnicodeUserStringTest.test_title(self)
42533
 
+        string_tests.MixinStrUnicodeUserStringTest.test_istitle(self)
42534
 
         self.checkequalnofix(True, u'\u1FFc', 'istitle')
42535
 
         self.checkequalnofix(True, u'Greek \u1FFcitlecases ...', 'istitle')
42536
 
 
42537
 
+    @requires_wide_build
42538
 
+    def test_istitle_non_bmp(self):
42539
 
+        # non-BMP, uppercase + lowercase
42540
 
+        self.assertTrue(u'\U00010401\U00010429'.istitle())
42541
 
+        self.assertTrue(u'\U00010427\U0001044E'.istitle())
42542
 
+        # apparently there are no titlecased (Lt) non-BMP chars in Unicode 6
42543
 
+        for ch in [u'\U00010429', u'\U0001044E', u'\U0001F40D', u'\U0001F46F']:
42544
 
+            self.assertFalse(ch.istitle(), '{!r} is not title'.format(ch))
42545
 
+
42546
 
     def test_isspace(self):
42547
 
         string_tests.MixinStrUnicodeUserStringTest.test_isspace(self)
42548
 
         self.checkequalnofix(True, u'\u2000', 'isspace')
42549
 
         self.checkequalnofix(True, u'\u200a', 'isspace')
42550
 
         self.checkequalnofix(False, u'\u2014', 'isspace')
42551
 
 
42552
 
+    @requires_wide_build
42553
 
+    def test_isspace_non_bmp(self):
42554
 
+        # apparently there are no non-BMP spaces chars in Unicode 6
42555
 
+        for ch in [u'\U00010401', u'\U00010427', u'\U00010429', u'\U0001044E',
42556
 
+                   u'\U0001F40D', u'\U0001F46F']:
42557
 
+            self.assertFalse(ch.isspace(), '{!r} is not space.'.format(ch))
42558
 
+
42559
 
+    @requires_wide_build
42560
 
+    def test_isalnum_non_bmp(self):
42561
 
+        for ch in [u'\U00010401', u'\U00010427', u'\U00010429', u'\U0001044E',
42562
 
+                   u'\U0001D7F6', u'\U000104A0', u'\U000104A0', u'\U0001F107']:
42563
 
+            self.assertTrue(ch.isalnum(), '{!r} is alnum.'.format(ch))
42564
 
+
42565
 
     def test_isalpha(self):
42566
 
         string_tests.MixinStrUnicodeUserStringTest.test_isalpha(self)
42567
 
         self.checkequalnofix(True, u'\u1FFc', 'isalpha')
42568
 
 
42569
 
+    @requires_wide_build
42570
 
+    def test_isalpha_non_bmp(self):
42571
 
+        # non-BMP, cased
42572
 
+        self.assertTrue(u'\U00010401'.isalpha())
42573
 
+        self.assertTrue(u'\U00010427'.isalpha())
42574
 
+        self.assertTrue(u'\U00010429'.isalpha())
42575
 
+        self.assertTrue(u'\U0001044E'.isalpha())
42576
 
+        # non-BMP, non-cased
42577
 
+        self.assertFalse(u'\U0001F40D'.isalpha())
42578
 
+        self.assertFalse(u'\U0001F46F'.isalpha())
42579
 
+
42580
 
     def test_isdecimal(self):
42581
 
         self.checkequalnofix(False, u'', 'isdecimal')
42582
 
         self.checkequalnofix(False, u'a', 'isdecimal')
42583
 
@@ -305,12 +388,28 @@
42584
 
 
42585
 
         self.checkraises(TypeError, 'abc', 'isdecimal', 42)
42586
 
 
42587
 
+    @requires_wide_build
42588
 
+    def test_isdecimal_non_bmp(self):
42589
 
+        for ch in [u'\U00010401', u'\U00010427', u'\U00010429', u'\U0001044E',
42590
 
+                   u'\U0001F40D', u'\U0001F46F', u'\U00011065', u'\U0001F107']:
42591
 
+            self.assertFalse(ch.isdecimal(), '{!r} is not decimal.'.format(ch))
42592
 
+        for ch in [u'\U0001D7F6', u'\U000104A0', u'\U000104A0']:
42593
 
+            self.assertTrue(ch.isdecimal(), '{!r} is decimal.'.format(ch))
42594
 
+
42595
 
     def test_isdigit(self):
42596
 
         string_tests.MixinStrUnicodeUserStringTest.test_isdigit(self)
42597
 
         self.checkequalnofix(True, u'\u2460', 'isdigit')
42598
 
         self.checkequalnofix(False, u'\xbc', 'isdigit')
42599
 
         self.checkequalnofix(True, u'\u0660', 'isdigit')
42600
 
 
42601
 
+    @requires_wide_build
42602
 
+    def test_isdigit_non_bmp(self):
42603
 
+        for ch in [u'\U00010401', u'\U00010427', u'\U00010429', u'\U0001044E',
42604
 
+                   u'\U0001F40D', u'\U0001F46F', u'\U00011065']:
42605
 
+            self.assertFalse(ch.isdigit(), '{!r} is not a digit.'.format(ch))
42606
 
+        for ch in [u'\U0001D7F6', u'\U000104A0', u'\U000104A0', u'\U0001F107']:
42607
 
+            self.assertTrue(ch.isdigit(), '{!r} is a digit.'.format(ch))
42608
 
+
42609
 
     def test_isnumeric(self):
42610
 
         self.checkequalnofix(False, u'', 'isnumeric')
42611
 
         self.checkequalnofix(False, u'a', 'isnumeric')
42612
 
@@ -323,6 +422,109 @@
42613
 
 
42614
 
         self.assertRaises(TypeError, u"abc".isnumeric, 42)
42615
 
 
42616
 
+    @requires_wide_build
42617
 
+    def test_isnumeric_non_bmp(self):
42618
 
+        for ch in [u'\U00010401', u'\U00010427', u'\U00010429', u'\U0001044E',
42619
 
+                   u'\U0001F40D', u'\U0001F46F']:
42620
 
+            self.assertFalse(ch.isnumeric(), '{!r} is not numeric.'.format(ch))
42621
 
+        for ch in [u'\U00010107', u'\U0001D7F6', u'\U00023b1b',
42622
 
+                   u'\U000104A0', u'\U0001F107']:
42623
 
+            self.assertTrue(ch.isnumeric(), '{!r} is numeric.'.format(ch))
42624
 
+
42625
 
+    @requires_wide_build
42626
 
+    def test_surrogates(self):
42627
 
+        # this test actually passes on narrow too, but it's just by accident.
42628
 
+        # Surrogates are seen as non-cased chars, so u'X\uD800X' is as
42629
 
+        # uppercase as 'X X'
42630
 
+        for s in (u'a\uD800b\uDFFF', u'a\uDFFFb\uD800',
42631
 
+                  u'a\uD800b\uDFFFa', u'a\uDFFFb\uD800a'):
42632
 
+            self.assertTrue(s.islower())
42633
 
+            self.assertFalse(s.isupper())
42634
 
+            self.assertFalse(s.istitle())
42635
 
+        for s in (u'A\uD800B\uDFFF', u'A\uDFFFB\uD800',
42636
 
+                  u'A\uD800B\uDFFFA', u'A\uDFFFB\uD800A'):
42637
 
+            self.assertFalse(s.islower())
42638
 
+            self.assertTrue(s.isupper())
42639
 
+            self.assertTrue(s.istitle())
42640
 
+
42641
 
+        for meth_name in ('islower', 'isupper', 'istitle'):
42642
 
+            meth = getattr(unicode, meth_name)
42643
 
+            for s in (u'\uD800', u'\uDFFF', u'\uD800\uD800', u'\uDFFF\uDFFF'):
42644
 
+                self.assertFalse(meth(s), '%r.%s() is False' % (s, meth_name))
42645
 
+
42646
 
+        for meth_name in ('isalpha', 'isalnum', 'isdigit', 'isspace',
42647
 
+                          'isdecimal', 'isnumeric'):
42648
 
+            meth = getattr(unicode, meth_name)
42649
 
+            for s in (u'\uD800', u'\uDFFF', u'\uD800\uD800', u'\uDFFF\uDFFF',
42650
 
+                      u'a\uD800b\uDFFF', u'a\uDFFFb\uD800',
42651
 
+                      u'a\uD800b\uDFFFa', u'a\uDFFFb\uD800a'):
42652
 
+                self.assertFalse(meth(s), '%r.%s() is False' % (s, meth_name))
42653
 
+
42654
 
+
42655
 
+    @requires_wide_build
42656
 
+    def test_lower(self):
42657
 
+        string_tests.CommonTest.test_lower(self)
42658
 
+        self.assertEqual(u'\U00010427'.lower(), u'\U0001044F')
42659
 
+        self.assertEqual(u'\U00010427\U00010427'.lower(),
42660
 
+                         u'\U0001044F\U0001044F')
42661
 
+        self.assertEqual(u'\U00010427\U0001044F'.lower(),
42662
 
+                         u'\U0001044F\U0001044F')
42663
 
+        self.assertEqual(u'X\U00010427x\U0001044F'.lower(),
42664
 
+                         u'x\U0001044Fx\U0001044F')
42665
 
+
42666
 
+    @requires_wide_build
42667
 
+    def test_upper(self):
42668
 
+        string_tests.CommonTest.test_upper(self)
42669
 
+        self.assertEqual(u'\U0001044F'.upper(), u'\U00010427')
42670
 
+        self.assertEqual(u'\U0001044F\U0001044F'.upper(),
42671
 
+                         u'\U00010427\U00010427')
42672
 
+        self.assertEqual(u'\U00010427\U0001044F'.upper(),
42673
 
+                         u'\U00010427\U00010427')
42674
 
+        self.assertEqual(u'X\U00010427x\U0001044F'.upper(),
42675
 
+                         u'X\U00010427X\U00010427')
42676
 
+
42677
 
+    @requires_wide_build
42678
 
+    def test_capitalize(self):
42679
 
+        string_tests.CommonTest.test_capitalize(self)
42680
 
+        self.assertEqual(u'\U0001044F'.capitalize(), u'\U00010427')
42681
 
+        self.assertEqual(u'\U0001044F\U0001044F'.capitalize(),
42682
 
+                         u'\U00010427\U0001044F')
42683
 
+        self.assertEqual(u'\U00010427\U0001044F'.capitalize(),
42684
 
+                         u'\U00010427\U0001044F')
42685
 
+        self.assertEqual(u'\U0001044F\U00010427'.capitalize(),
42686
 
+                         u'\U00010427\U0001044F')
42687
 
+        self.assertEqual(u'X\U00010427x\U0001044F'.capitalize(),
42688
 
+                         u'X\U0001044Fx\U0001044F')
42689
 
+
42690
 
+    @requires_wide_build
42691
 
+    def test_title(self):
42692
 
+        string_tests.MixinStrUnicodeUserStringTest.test_title(self)
42693
 
+        self.assertEqual(u'\U0001044F'.title(), u'\U00010427')
42694
 
+        self.assertEqual(u'\U0001044F\U0001044F'.title(),
42695
 
+                         u'\U00010427\U0001044F')
42696
 
+        self.assertEqual(u'\U0001044F\U0001044F \U0001044F\U0001044F'.title(),
42697
 
+                         u'\U00010427\U0001044F \U00010427\U0001044F')
42698
 
+        self.assertEqual(u'\U00010427\U0001044F \U00010427\U0001044F'.title(),
42699
 
+                         u'\U00010427\U0001044F \U00010427\U0001044F')
42700
 
+        self.assertEqual(u'\U0001044F\U00010427 \U0001044F\U00010427'.title(),
42701
 
+                         u'\U00010427\U0001044F \U00010427\U0001044F')
42702
 
+        self.assertEqual(u'X\U00010427x\U0001044F X\U00010427x\U0001044F'.title(),
42703
 
+                         u'X\U0001044Fx\U0001044F X\U0001044Fx\U0001044F')
42704
 
+
42705
 
+    @requires_wide_build
42706
 
+    def test_swapcase(self):
42707
 
+        string_tests.CommonTest.test_swapcase(self)
42708
 
+        self.assertEqual(u'\U0001044F'.swapcase(), u'\U00010427')
42709
 
+        self.assertEqual(u'\U00010427'.swapcase(), u'\U0001044F')
42710
 
+        self.assertEqual(u'\U0001044F\U0001044F'.swapcase(),
42711
 
+                         u'\U00010427\U00010427')
42712
 
+        self.assertEqual(u'\U00010427\U0001044F'.swapcase(),
42713
 
+                         u'\U0001044F\U00010427')
42714
 
+        self.assertEqual(u'\U0001044F\U00010427'.swapcase(),
42715
 
+                         u'\U00010427\U0001044F')
42716
 
+        self.assertEqual(u'X\U00010427x\U0001044F'.swapcase(),
42717
 
+                         u'x\U0001044FX\U00010427')
42718
 
+
42719
 
     def test_contains(self):
42720
 
         # Testing Unicode contains method
42721
 
         self.assertIn('a', u'abdb')
42722
 
@@ -569,10 +771,18 @@
42723
 
         for (x, y) in utfTests:
42724
 
             self.assertEqual(x.encode('utf-7'), y)
42725
 
 
42726
 
-        # Unpaired surrogates not supported
42727
 
-        self.assertRaises(UnicodeError, unicode, '+3ADYAA-', 'utf-7')
42728
 
+        # Unpaired surrogates are passed through
42729
 
+        self.assertEqual(u'\uD801'.encode('utf-7'), '+2AE-')
42730
 
+        self.assertEqual(u'\uD801x'.encode('utf-7'), '+2AE-x')
42731
 
+        self.assertEqual(u'\uDC01'.encode('utf-7'), '+3AE-')
42732
 
+        self.assertEqual(u'\uDC01x'.encode('utf-7'), '+3AE-x')
42733
 
+        self.assertEqual('+2AE-'.decode('utf-7'), u'\uD801')
42734
 
+        self.assertEqual('+2AE-x'.decode('utf-7'), u'\uD801x')
42735
 
+        self.assertEqual('+3AE-'.decode('utf-7'), u'\uDC01')
42736
 
+        self.assertEqual('+3AE-x'.decode('utf-7'), u'\uDC01x')
42737
 
 
42738
 
-        self.assertEqual(unicode('+3ADYAA-', 'utf-7', 'replace'), u'\ufffd\ufffd')
42739
 
+        self.assertEqual(u'\uD801\U000abcde'.encode('utf-7'), '+2AHab9ze-')
42740
 
+        self.assertEqual('+2AHab9ze-'.decode('utf-7'), u'\uD801\U000abcde')
42741
 
 
42742
 
         # Direct encoded characters
42743
 
         set_d = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'(),-./:?"
42744
 
@@ -1396,6 +1606,31 @@
42745
 
         self.assertEqual("%s" % u, u'__unicode__ overridden')
42746
 
         self.assertEqual("{}".format(u), '__unicode__ overridden')
42747
 
 
42748
 
+    def test_encode_decimal(self):
42749
 
+        from _testcapi import unicode_encodedecimal
42750
 
+        self.assertEqual(unicode_encodedecimal(u'123'),
42751
 
+                         b'123')
42752
 
+        self.assertEqual(unicode_encodedecimal(u'\u0663.\u0661\u0664'),
42753
 
+                         b'3.14')
42754
 
+        self.assertEqual(unicode_encodedecimal(u"\N{EM SPACE}3.14\N{EN SPACE}"),
42755
 
+                         b' 3.14 ')
42756
 
+        self.assertRaises(UnicodeEncodeError,
42757
 
+                          unicode_encodedecimal, u"123\u20ac", "strict")
42758
 
+        self.assertEqual(unicode_encodedecimal(u"123\u20ac", "replace"),
42759
 
+                         b'123?')
42760
 
+        self.assertEqual(unicode_encodedecimal(u"123\u20ac", "ignore"),
42761
 
+                         b'123')
42762
 
+        self.assertEqual(unicode_encodedecimal(u"123\u20ac", "xmlcharrefreplace"),
42763
 
+                         b'123&#8364;')
42764
 
+        self.assertEqual(unicode_encodedecimal(u"123\u20ac", "backslashreplace"),
42765
 
+                         b'123\\u20ac')
42766
 
+        self.assertEqual(unicode_encodedecimal(u"123\u20ac\N{EM SPACE}", "replace"),
42767
 
+                         b'123? ')
42768
 
+        self.assertEqual(unicode_encodedecimal(u"123\u20ac\u20ac", "replace"),
42769
 
+                         b'123??')
42770
 
+        self.assertEqual(unicode_encodedecimal(u"123\u20ac\u0660", "replace"),
42771
 
+                         b'123?0')
42772
 
+
42773
 
 
42774
 
 def test_main():
42775
 
     test_support.run_unittest(__name__)
42776
 
diff -r 8527427914a2 Lib/test/test_urllib.py
42777
 
--- a/Lib/test/test_urllib.py
42778
 
+++ b/Lib/test/test_urllib.py
42779
 
@@ -3,13 +3,16 @@
42780
 
 import urllib
42781
 
 import httplib
42782
 
 import unittest
42783
 
-from test import test_support
42784
 
 import os
42785
 
 import sys
42786
 
 import mimetools
42787
 
 import tempfile
42788
 
 import StringIO
42789
 
 
42790
 
+from test import test_support
42791
 
+from base64 import b64encode
42792
 
+
42793
 
+
42794
 
 def hexescape(char):
42795
 
     """Escape char as RFC 2396 specifies"""
42796
 
     hex_repr = hex(ord(char))[2:].upper()
42797
 
@@ -17,6 +20,43 @@
42798
 
         hex_repr = "0%s" % hex_repr
42799
 
     return "%" + hex_repr
42800
 
 
42801
 
+
42802
 
+class FakeHTTPMixin(object):
42803
 
+    def fakehttp(self, fakedata):
42804
 
+        class FakeSocket(StringIO.StringIO):
42805
 
+
42806
 
+            def sendall(self, data):
42807
 
+                FakeHTTPConnection.buf = data
42808
 
+
42809
 
+            def makefile(self, *args, **kwds):
42810
 
+                return self
42811
 
+
42812
 
+            def read(self, amt=None):
42813
 
+                if self.closed:
42814
 
+                    return ""
42815
 
+                return StringIO.StringIO.read(self, amt)
42816
 
+
42817
 
+            def readline(self, length=None):
42818
 
+                if self.closed:
42819
 
+                    return ""
42820
 
+                return StringIO.StringIO.readline(self, length)
42821
 
+
42822
 
+        class FakeHTTPConnection(httplib.HTTPConnection):
42823
 
+
42824
 
+            # buffer to store data for verification in urlopen tests.
42825
 
+            buf = ""
42826
 
+
42827
 
+            def connect(self):
42828
 
+                self.sock = FakeSocket(fakedata)
42829
 
+
42830
 
+        assert httplib.HTTP._connection_class == httplib.HTTPConnection
42831
 
+
42832
 
+        httplib.HTTP._connection_class = FakeHTTPConnection
42833
 
+
42834
 
+    def unfakehttp(self):
42835
 
+        httplib.HTTP._connection_class = httplib.HTTPConnection
42836
 
+
42837
 
+
42838
 
 class urlopen_FileTests(unittest.TestCase):
42839
 
     """Test urlopen() opening a temporary file.
42840
 
 
42841
 
@@ -94,6 +134,9 @@
42842
 
         for line in self.returned_obj.__iter__():
42843
 
             self.assertEqual(line, self.text)
42844
 
 
42845
 
+    def test_relativelocalfile(self):
42846
 
+        self.assertRaises(ValueError,urllib.urlopen,'./' + self.pathname)
42847
 
+
42848
 
 class ProxyTests(unittest.TestCase):
42849
 
 
42850
 
     def setUp(self):
42851
 
@@ -114,30 +157,14 @@
42852
 
         proxies = urllib.getproxies_environment()
42853
 
         # getproxies_environment use lowered case truncated (no '_proxy') keys
42854
 
         self.assertEqual('localhost', proxies['no'])
42855
 
+        # List of no_proxies with space.
42856
 
+        self.env.set('NO_PROXY', 'localhost, anotherdomain.com, newdomain.com')
42857
 
+        self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com'))
42858
 
 
42859
 
 
42860
 
-class urlopen_HttpTests(unittest.TestCase):
42861
 
+class urlopen_HttpTests(unittest.TestCase, FakeHTTPMixin):
42862
 
     """Test urlopen() opening a fake http connection."""
42863
 
 
42864
 
-    def fakehttp(self, fakedata):
42865
 
-        class FakeSocket(StringIO.StringIO):
42866
 
-            def sendall(self, str): pass
42867
 
-            def makefile(self, mode, name): return self
42868
 
-            def read(self, amt=None):
42869
 
-                if self.closed: return ''
42870
 
-                return StringIO.StringIO.read(self, amt)
42871
 
-            def readline(self, length=None):
42872
 
-                if self.closed: return ''
42873
 
-                return StringIO.StringIO.readline(self, length)
42874
 
-        class FakeHTTPConnection(httplib.HTTPConnection):
42875
 
-            def connect(self):
42876
 
-                self.sock = FakeSocket(fakedata)
42877
 
-        assert httplib.HTTP._connection_class == httplib.HTTPConnection
42878
 
-        httplib.HTTP._connection_class = FakeHTTPConnection
42879
 
-
42880
 
-    def unfakehttp(self):
42881
 
-        httplib.HTTP._connection_class = httplib.HTTPConnection
42882
 
-
42883
 
     def test_read(self):
42884
 
         self.fakehttp('Hello!')
42885
 
         try:
42886
 
@@ -195,6 +222,41 @@
42887
 
         finally:
42888
 
             self.unfakehttp()
42889
 
 
42890
 
+    def test_userpass_inurl(self):
42891
 
+        self.fakehttp('Hello!')
42892
 
+        try:
42893
 
+            fakehttp_wrapper = httplib.HTTP._connection_class
42894
 
+            fp = urllib.urlopen("http://user:pass@python.org/")
42895
 
+            authorization = ("Authorization: Basic %s\r\n" %
42896
 
+                            b64encode('user:pass'))
42897
 
+            # The authorization header must be in place
42898
 
+            self.assertIn(authorization, fakehttp_wrapper.buf)
42899
 
+            self.assertEqual(fp.readline(), "Hello!")
42900
 
+            self.assertEqual(fp.readline(), "")
42901
 
+            self.assertEqual(fp.geturl(), 'http://user:pass@python.org/')
42902
 
+            self.assertEqual(fp.getcode(), 200)
42903
 
+        finally:
42904
 
+            self.unfakehttp()
42905
 
+
42906
 
+    def test_userpass_with_spaces_inurl(self):
42907
 
+        self.fakehttp('Hello!')
42908
 
+        try:
42909
 
+            url = "http://a b:c d@python.org/"
42910
 
+            fakehttp_wrapper = httplib.HTTP._connection_class
42911
 
+            authorization = ("Authorization: Basic %s\r\n" %
42912
 
+                             b64encode('a b:c d'))
42913
 
+            fp = urllib.urlopen(url)
42914
 
+            # The authorization header must be in place
42915
 
+            self.assertIn(authorization, fakehttp_wrapper.buf)
42916
 
+            self.assertEqual(fp.readline(), "Hello!")
42917
 
+            self.assertEqual(fp.readline(), "")
42918
 
+            # the spaces are quoted in URL so no match
42919
 
+            self.assertNotEqual(fp.geturl(), url)
42920
 
+            self.assertEqual(fp.getcode(), 200)
42921
 
+        finally:
42922
 
+            self.unfakehttp()
42923
 
+
42924
 
+
42925
 
 class urlretrieve_FileTests(unittest.TestCase):
42926
 
     """Test urllib.urlretrieve() on local files"""
42927
 
 
42928
 
@@ -327,6 +389,45 @@
42929
 
         self.assertEqual(report[0][1], 8192)
42930
 
         self.assertEqual(report[0][2], 8193)
42931
 
 
42932
 
+
42933
 
+class urlretrieve_HttpTests(unittest.TestCase, FakeHTTPMixin):
42934
 
+    """Test urllib.urlretrieve() using fake http connections"""
42935
 
+
42936
 
+    def test_short_content_raises_ContentTooShortError(self):
42937
 
+        self.fakehttp('''HTTP/1.1 200 OK
42938
 
+Date: Wed, 02 Jan 2008 03:03:54 GMT
42939
 
+Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e
42940
 
+Connection: close
42941
 
+Content-Length: 100
42942
 
+Content-Type: text/html; charset=iso-8859-1
42943
 
+
42944
 
+FF
42945
 
+''')
42946
 
+
42947
 
+        def _reporthook(par1, par2, par3):
42948
 
+            pass
42949
 
+
42950
 
+        try:
42951
 
+            self.assertRaises(urllib.ContentTooShortError, urllib.urlretrieve,
42952
 
+                    'http://example.com', reporthook=_reporthook)
42953
 
+        finally:
42954
 
+            self.unfakehttp()
42955
 
+
42956
 
+    def test_short_content_raises_ContentTooShortError_without_reporthook(self):
42957
 
+        self.fakehttp('''HTTP/1.1 200 OK
42958
 
+Date: Wed, 02 Jan 2008 03:03:54 GMT
42959
 
+Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e
42960
 
+Connection: close
42961
 
+Content-Length: 100
42962
 
+Content-Type: text/html; charset=iso-8859-1
42963
 
+
42964
 
+FF
42965
 
+''')
42966
 
+        try:
42967
 
+            self.assertRaises(urllib.ContentTooShortError, urllib.urlretrieve, 'http://example.com/')
42968
 
+        finally:
42969
 
+            self.unfakehttp()
42970
 
+
42971
 
 class QuotingTests(unittest.TestCase):
42972
 
     """Tests for urllib.quote() and urllib.quote_plus()
42973
 
 
42974
 
@@ -404,6 +505,7 @@
42975
 
         result = urllib.quote(partial_quote)
42976
 
         self.assertEqual(expected, result,
42977
 
                          "using quote(): %s != %s" % (expected, result))
42978
 
+        result = urllib.quote_plus(partial_quote)
42979
 
         self.assertEqual(expected, result,
42980
 
                          "using quote_plus(): %s != %s" % (expected, result))
42981
 
         self.assertRaises(TypeError, urllib.quote, None)
42982
 
@@ -662,6 +764,9 @@
42983
 
         self.assertEqual(('user', 'a\fb'),urllib.splitpasswd('user:a\fb'))
42984
 
         self.assertEqual(('user', 'a\vb'),urllib.splitpasswd('user:a\vb'))
42985
 
         self.assertEqual(('user', 'a:b'),urllib.splitpasswd('user:a:b'))
42986
 
+        self.assertEqual(('user', 'a b'),urllib.splitpasswd('user:a b'))
42987
 
+        self.assertEqual(('user 2', 'ab'),urllib.splitpasswd('user 2:ab'))
42988
 
+        self.assertEqual(('user+1', 'a+b'),urllib.splitpasswd('user+1:a+b'))
42989
 
 
42990
 
 
42991
 
 class URLopener_Tests(unittest.TestCase):
42992
 
@@ -770,6 +875,7 @@
42993
 
             urlopen_FileTests,
42994
 
             urlopen_HttpTests,
42995
 
             urlretrieve_FileTests,
42996
 
+            urlretrieve_HttpTests,
42997
 
             ProxyTests,
42998
 
             QuotingTests,
42999
 
             UnquotingTests,
43000
 
diff -r 8527427914a2 Lib/test/test_urllib2.py
43001
 
--- a/Lib/test/test_urllib2.py
43002
 
+++ b/Lib/test/test_urllib2.py
43003
 
@@ -293,6 +293,7 @@
43004
 
             self._tunnel_headers = headers
43005
 
         else:
43006
 
             self._tunnel_headers.clear()
43007
 
+
43008
 
     def request(self, method, url, body=None, headers=None):
43009
 
         self.method = method
43010
 
         self.selector = url
43011
 
@@ -304,9 +305,13 @@
43012
 
         if self.raise_on_endheaders:
43013
 
             import socket
43014
 
             raise socket.error()
43015
 
+
43016
 
     def getresponse(self):
43017
 
         return MockHTTPResponse(MockFile(), {}, 200, "OK")
43018
 
 
43019
 
+    def close(self):
43020
 
+        pass
43021
 
+
43022
 
 class MockHandler:
43023
 
     # useful for testing handler machinery
43024
 
     # see add_ordered_mock_handlers() docstring
43025
 
@@ -606,6 +611,7 @@
43026
 
             def retrfile(self, filename, filetype):
43027
 
                 self.filename, self.filetype = filename, filetype
43028
 
                 return StringIO.StringIO(self.data), len(self.data)
43029
 
+            def close(self): pass
43030
 
 
43031
 
         class NullFTPHandler(urllib2.FTPHandler):
43032
 
             def __init__(self, data): self.data = data
43033
 
@@ -1312,6 +1318,17 @@
43034
 
         req = Request(url)
43035
 
         self.assertEqual(req.get_full_url(), url)
43036
 
 
43037
 
+def test_HTTPError_interface():
43038
 
+    """
43039
 
+    Issue 13211 reveals that HTTPError didn't implement the URLError
43040
 
+    interface even though HTTPError is a subclass of URLError.
43041
 
+
43042
 
+    >>> err = urllib2.HTTPError(msg='something bad happened', url=None, code=None, hdrs=None, fp=None)
43043
 
+    >>> assert hasattr(err, 'reason')
43044
 
+    >>> err.reason
43045
 
+    'something bad happened'
43046
 
+    """
43047
 
+
43048
 
 def test_main(verbose=None):
43049
 
     from test import test_urllib2
43050
 
     test_support.run_doctest(test_urllib2, verbose)
43051
 
diff -r 8527427914a2 Lib/test/test_urllib2net.py
43052
 
--- a/Lib/test/test_urllib2net.py
43053
 
+++ b/Lib/test/test_urllib2net.py
43054
 
@@ -126,6 +126,8 @@
43055
 
         finally:
43056
 
             os.remove(TESTFN)
43057
 
 
43058
 
+        self.assertRaises(ValueError, urllib2.urlopen,'./relative_path/to/file')
43059
 
+
43060
 
     # XXX Following test depends on machine configurations that are internal
43061
 
     # to CNRI.  Need to set up a public server with the right authentication
43062
 
     # configuration for test purposes.
43063
 
@@ -186,6 +188,16 @@
43064
 
             opener.open(request)
43065
 
             self.assertEqual(request.get_header('User-agent'),'Test-Agent')
43066
 
 
43067
 
+    def test_sites_no_connection_close(self):
43068
 
+        # Some sites do not send Connection: close header.
43069
 
+        # Verify that those work properly. (#issue12576)
43070
 
+
43071
 
+        URL = 'http://www.imdb.com' # No Connection:close
43072
 
+        with test_support.transient_internet(URL):
43073
 
+            req = urllib2.urlopen(URL)
43074
 
+            res = req.read()
43075
 
+            self.assertTrue(res)
43076
 
+
43077
 
     def _test_urls(self, urls, handlers, retry=True):
43078
 
         import time
43079
 
         import logging
43080
 
@@ -231,6 +243,7 @@
43081
 
         handlers = []
43082
 
 
43083
 
         cfh = urllib2.CacheFTPHandler()
43084
 
+        self.addCleanup(cfh.clear_cache)
43085
 
         cfh.setTimeout(1)
43086
 
         handlers.append(cfh)
43087
 
 
43088
 
diff -r 8527427914a2 Lib/test/test_urllibnet.py
43089
 
--- a/Lib/test/test_urllibnet.py
43090
 
+++ b/Lib/test/test_urllibnet.py
43091
 
@@ -131,6 +131,14 @@
43092
 
     def test_bad_address(self):
43093
 
         # Make sure proper exception is raised when connecting to a bogus
43094
 
         # address.
43095
 
+        bogus_domain = "sadflkjsasf.i.nvali.d"
43096
 
+        try:
43097
 
+            socket.gethostbyname(bogus_domain)
43098
 
+        except socket.gaierror:
43099
 
+            pass
43100
 
+        else:
43101
 
+            # This happens with some overzealous DNS providers such as OpenDNS
43102
 
+            self.skipTest("%r should not resolve for test to work" % bogus_domain)
43103
 
         self.assertRaises(IOError,
43104
 
                           # SF patch 809915:  In Sep 2003, VeriSign started
43105
 
                           # highjacking invalid .com and .net addresses to
43106
 
diff -r 8527427914a2 Lib/test/test_urlparse.py
43107
 
--- a/Lib/test/test_urlparse.py
43108
 
+++ b/Lib/test/test_urlparse.py
43109
 
@@ -9,7 +9,7 @@
43110
 
 RFC3986_BASE = 'http://a/b/c/d;p?q'
43111
 
 SIMPLE_BASE  = 'http://a/b/c/d'
43112
 
 
43113
 
-# A list of test cases.  Each test case is a a two-tuple that contains
43114
 
+# A list of test cases.  Each test case is a two-tuple that contains
43115
 
 # a string with the query and a dictionary with the expected result.
43116
 
 
43117
 
 parse_qsl_test_cases = [
43118
 
@@ -82,7 +82,12 @@
43119
 
     def test_qsl(self):
43120
 
         for orig, expect in parse_qsl_test_cases:
43121
 
             result = urlparse.parse_qsl(orig, keep_blank_values=True)
43122
 
-            self.assertEqual(result, expect, "Error parsing %s" % repr(orig))
43123
 
+            self.assertEqual(result, expect, "Error parsing %r" % orig)
43124
 
+            expect_without_blanks = [v for v in expect if len(v[1])]
43125
 
+            result = urlparse.parse_qsl(orig, keep_blank_values=False)
43126
 
+            self.assertEqual(result, expect_without_blanks,
43127
 
+                    "Error parsing %r" % orig)
43128
 
+
43129
 
 
43130
 
     def test_roundtrips(self):
43131
 
         testcases = [
43132
 
@@ -331,6 +336,11 @@
43133
 
         self.checkJoin(SIMPLE_BASE, 'http:?y','http://a/b/c/d?y')
43134
 
         self.checkJoin(SIMPLE_BASE, 'http:g?y','http://a/b/c/g?y')
43135
 
         self.checkJoin(SIMPLE_BASE, 'http:g?y/./x','http://a/b/c/g?y/./x')
43136
 
+        self.checkJoin('http:///', '..','http:///')
43137
 
+        self.checkJoin('', 'http://a/b/c/g?y/./x','http://a/b/c/g?y/./x')
43138
 
+        self.checkJoin('', 'http://a/./g', 'http://a/./g')
43139
 
+        self.checkJoin('svn://pathtorepo/dir1','dir2','svn://pathtorepo/dir2')
43140
 
+        self.checkJoin('svn+ssh://pathtorepo/dir1','dir2','svn+ssh://pathtorepo/dir2')
43141
 
 
43142
 
     def test_RFC2732(self):
43143
 
         for url, hostname, port in [
43144
 
@@ -505,7 +515,6 @@
43145
 
         self.assertEqual(urlparse.urlparse("http://www.python.org:80"),
43146
 
                 ('http','www.python.org:80','','','',''))
43147
 
 
43148
 
-
43149
 
 def test_main():
43150
 
     test_support.run_unittest(UrlParseTestCase)
43151
 
 
43152
 
diff -r 8527427914a2 Lib/test/test_warnings.py
43153
 
--- a/Lib/test/test_warnings.py
43154
 
+++ b/Lib/test/test_warnings.py
43155
 
@@ -530,6 +530,18 @@
43156
 
         assert expected_line
43157
 
         self.assertEqual(second_line, expected_line)
43158
 
 
43159
 
+    def test_filename_none(self):
43160
 
+        # issue #12467: race condition if a warning is emitted at shutdown
43161
 
+        globals_dict = globals()
43162
 
+        oldfile = globals_dict['__file__']
43163
 
+        try:
43164
 
+            with original_warnings.catch_warnings(module=self.module) as w:
43165
 
+                self.module.filterwarnings("always", category=UserWarning)
43166
 
+                globals_dict['__file__'] = None
43167
 
+                self.module.warn('test', UserWarning)
43168
 
+        finally:
43169
 
+            globals_dict['__file__'] = oldfile
43170
 
+
43171
 
 
43172
 
 class WarningsDisplayTests(unittest.TestCase):
43173
 
 
43174
 
diff -r 8527427914a2 Lib/test/test_xml_etree.py
43175
 
--- a/Lib/test/test_xml_etree.py
43176
 
+++ b/Lib/test/test_xml_etree.py
43177
 
@@ -738,6 +738,7 @@
43178
 
     ...     print action, elem.tag
43179
 
     ... except ET.ParseError, v:
43180
 
     ...   print v
43181
 
+    end document
43182
 
     junk after document element: line 1, column 12
43183
 
     """
43184
 
 
43185
 
diff -r 8527427914a2 Lib/test/test_xmlrpc.py
43186
 
--- a/Lib/test/test_xmlrpc.py
43187
 
+++ b/Lib/test/test_xmlrpc.py
43188
 
@@ -308,7 +308,7 @@
43189
 
         global ADDR, PORT, URL
43190
 
         ADDR, PORT = serv.socket.getsockname()
43191
 
         #connect to IP address directly.  This avoids socket.create_connection()
43192
 
-        #trying to connect to to "localhost" using all address families, which
43193
 
+        #trying to connect to "localhost" using all address families, which
43194
 
         #causes slowdown e.g. on vista which supports AF_INET6.  The server listens
43195
 
         #on AF_INET only.
43196
 
         URL = "http://%s:%d"%(ADDR, PORT)
43197
 
@@ -367,7 +367,7 @@
43198
 
         global ADDR, PORT, URL
43199
 
         ADDR, PORT = serv.socket.getsockname()
43200
 
         #connect to IP address directly.  This avoids socket.create_connection()
43201
 
-        #trying to connect to to "localhost" using all address families, which
43202
 
+        #trying to connect to "localhost" using all address families, which
43203
 
         #causes slowdown e.g. on vista which supports AF_INET6.  The server listens
43204
 
         #on AF_INET only.
43205
 
         URL = "http://%s:%d"%(ADDR, PORT)
43206
 
@@ -472,6 +472,9 @@
43207
 
                 # protocol error; provide additional information in test output
43208
 
                 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
43209
 
 
43210
 
+    def test_unicode_host(self):
43211
 
+        server = xmlrpclib.ServerProxy(u"http://%s:%d/RPC2"%(ADDR, PORT))
43212
 
+        self.assertEqual(server.add("a", u"\xe9"), u"a\xe9")
43213
 
 
43214
 
     # [ch] The test 404 is causing lots of false alarms.
43215
 
     def XXXtest_404(self):
43216
 
diff -r 8527427914a2 Lib/test/test_xpickle.py
43217
 
--- a/Lib/test/test_xpickle.py
43218
 
+++ b/Lib/test/test_xpickle.py
43219
 
@@ -154,6 +154,10 @@
43220
 
     def test_unicode_high_plane(self):
43221
 
         pass
43222
 
 
43223
 
+    # This tests a fix that's in 2.7 only
43224
 
+    def test_dynamic_class(self):
43225
 
+        pass
43226
 
+
43227
 
     if test_support.have_unicode:
43228
 
         # This is a cut-down version of pickletester's test_unicode. Backwards
43229
 
         # compatibility was explicitly broken in r67934 to fix a bug.
43230
 
diff -r 8527427914a2 Lib/test/test_zipfile.py
43231
 
--- a/Lib/test/test_zipfile.py
43232
 
+++ b/Lib/test/test_zipfile.py
43233
 
@@ -335,6 +335,24 @@
43234
 
             with zipfile.ZipFile(f, "r") as zipfp:
43235
 
                 self.assertEqual(zipfp.namelist(), [TESTFN])
43236
 
 
43237
 
+    def test_ignores_newline_at_end(self):
43238
 
+        with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:
43239
 
+            zipfp.write(TESTFN, TESTFN)
43240
 
+        with open(TESTFN2, 'a') as f:
43241
 
+            f.write("\r\n\00\00\00")
43242
 
+        with zipfile.ZipFile(TESTFN2, "r") as zipfp:
43243
 
+            self.assertIsInstance(zipfp, zipfile.ZipFile)
43244
 
+
43245
 
+    def test_ignores_stuff_appended_past_comments(self):
43246
 
+        with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:
43247
 
+            zipfp.comment = b"this is a comment"
43248
 
+            zipfp.write(TESTFN, TESTFN)
43249
 
+        with open(TESTFN2, 'a') as f:
43250
 
+            f.write("abcdef\r\n")
43251
 
+        with zipfile.ZipFile(TESTFN2, "r") as zipfp:
43252
 
+            self.assertIsInstance(zipfp, zipfile.ZipFile)
43253
 
+            self.assertEqual(zipfp.comment, b"this is a comment")
43254
 
+
43255
 
     def test_write_default_name(self):
43256
 
         """Check that calling ZipFile.write without arcname specified
43257
 
         produces the expected result."""
43258
 
@@ -459,6 +477,12 @@
43259
 
         except zipfile.BadZipfile:
43260
 
             self.assertTrue(zipfp2.fp is None, 'zipfp is not closed')
43261
 
 
43262
 
+    def test_add_file_before_1980(self):
43263
 
+        # Set atime and mtime to 1970-01-01
43264
 
+        os.utime(TESTFN, (0, 0))
43265
 
+        with zipfile.ZipFile(TESTFN2, "w") as zipfp:
43266
 
+            self.assertRaises(ValueError, zipfp.write, TESTFN)
43267
 
+
43268
 
     def tearDown(self):
43269
 
         unlink(TESTFN)
43270
 
         unlink(TESTFN2)
43271
 
@@ -972,6 +996,10 @@
43272
 
             pass
43273
 
         self.assertRaises(zipfile.BadZipfile, zipfile.ZipFile, TESTFN, 'r')
43274
 
 
43275
 
+    def test_create_zipinfo_before_1980(self):
43276
 
+        self.assertRaises(ValueError,
43277
 
+                          zipfile.ZipInfo, 'seventies', (1979, 1, 1, 0, 0, 0))
43278
 
+
43279
 
     def tearDown(self):
43280
 
         unlink(TESTFN)
43281
 
         unlink(TESTFN2)
43282
 
diff -r 8527427914a2 Lib/threading.py
43283
 
--- a/Lib/threading.py
43284
 
+++ b/Lib/threading.py
43285
 
@@ -12,7 +12,6 @@
43286
 
 
43287
 
 from time import time as _time, sleep as _sleep
43288
 
 from traceback import format_exc as _format_exc
43289
 
-from collections import deque
43290
 
 
43291
 
 # Note regarding PEP 8 compliant aliases
43292
 
 #  This threading model was originally inspired by Java, and inherited
43293
 
@@ -878,22 +877,19 @@
43294
 
     current = current_thread()
43295
 
     with _active_limbo_lock:
43296
 
         for thread in _active.itervalues():
43297
 
+            # Any lock/condition variable may be currently locked or in an
43298
 
+            # invalid state, so we reinitialize them.
43299
 
+            if hasattr(thread, '_reset_internal_locks'):
43300
 
+                thread._reset_internal_locks()
43301
 
             if thread is current:
43302
 
                 # There is only one active thread. We reset the ident to
43303
 
                 # its new value since it can have changed.
43304
 
                 ident = _get_ident()
43305
 
                 thread._Thread__ident = ident
43306
 
-                # Any condition variables hanging off of the active thread may
43307
 
-                # be in an invalid state, so we reinitialize them.
43308
 
-                if hasattr(thread, '_reset_internal_locks'):
43309
 
-                    thread._reset_internal_locks()
43310
 
                 new_active[ident] = thread
43311
 
             else:
43312
 
                 # All the others are already stopped.
43313
 
-                # We don't call _Thread__stop() because it tries to acquire
43314
 
-                # thread._Thread__block which could also have been held while
43315
 
-                # we forked.
43316
 
-                thread._Thread__stopped = True
43317
 
+                thread._Thread__stop()
43318
 
 
43319
 
         _limbo.clear()
43320
 
         _active.clear()
43321
 
diff -r 8527427914a2 Lib/timeit.py
43322
 
--- a/Lib/timeit.py
43323
 
+++ b/Lib/timeit.py
43324
 
@@ -191,9 +191,11 @@
43325
 
             it = [None] * number
43326
 
         gcold = gc.isenabled()
43327
 
         gc.disable()
43328
 
-        timing = self.inner(it, self.timer)
43329
 
-        if gcold:
43330
 
-            gc.enable()
43331
 
+        try:
43332
 
+            timing = self.inner(it, self.timer)
43333
 
+        finally:
43334
 
+            if gcold:
43335
 
+                gc.enable()
43336
 
         return timing
43337
 
 
43338
 
     def repeat(self, repeat=default_repeat, number=default_number):
43339
 
diff -r 8527427914a2 Lib/trace.py
43340
 
--- a/Lib/trace.py
43341
 
+++ b/Lib/trace.py
43342
 
@@ -502,15 +502,7 @@
43343
 
     def run(self, cmd):
43344
 
         import __main__
43345
 
         dict = __main__.__dict__
43346
 
-        if not self.donothing:
43347
 
-            threading.settrace(self.globaltrace)
43348
 
-            sys.settrace(self.globaltrace)
43349
 
-        try:
43350
 
-            exec cmd in dict, dict
43351
 
-        finally:
43352
 
-            if not self.donothing:
43353
 
-                sys.settrace(None)
43354
 
-                threading.settrace(None)
43355
 
+        self.runctx(cmd, dict, dict)
43356
 
 
43357
 
     def runctx(self, cmd, globals=None, locals=None):
43358
 
         if globals is None: globals = {}
43359
 
diff -r 8527427914a2 Lib/unittest/case.py
43360
 
--- a/Lib/unittest/case.py
43361
 
+++ b/Lib/unittest/case.py
43362
 
@@ -196,12 +196,12 @@
43363
 
         # instances of said type in more detail to generate a more useful
43364
 
         # error message.
43365
 
         self._type_equality_funcs = {}
43366
 
-        self.addTypeEqualityFunc(dict, self.assertDictEqual)
43367
 
-        self.addTypeEqualityFunc(list, self.assertListEqual)
43368
 
-        self.addTypeEqualityFunc(tuple, self.assertTupleEqual)
43369
 
-        self.addTypeEqualityFunc(set, self.assertSetEqual)
43370
 
-        self.addTypeEqualityFunc(frozenset, self.assertSetEqual)
43371
 
-        self.addTypeEqualityFunc(unicode, self.assertMultiLineEqual)
43372
 
+        self.addTypeEqualityFunc(dict, 'assertDictEqual')
43373
 
+        self.addTypeEqualityFunc(list, 'assertListEqual')
43374
 
+        self.addTypeEqualityFunc(tuple, 'assertTupleEqual')
43375
 
+        self.addTypeEqualityFunc(set, 'assertSetEqual')
43376
 
+        self.addTypeEqualityFunc(frozenset, 'assertSetEqual')
43377
 
+        self.addTypeEqualityFunc(unicode, 'assertMultiLineEqual')
43378
 
 
43379
 
     def addTypeEqualityFunc(self, typeobj, function):
43380
 
         """Add a type specific assertEqual style function to compare a type.
43381
 
@@ -490,6 +490,8 @@
43382
 
         if type(first) is type(second):
43383
 
             asserter = self._type_equality_funcs.get(type(first))
43384
 
             if asserter is not None:
43385
 
+                if isinstance(asserter, basestring):
43386
 
+                    asserter = getattr(self, asserter)
43387
 
                 return asserter
43388
 
 
43389
 
         return self._baseAssertEqual
43390
 
diff -r 8527427914a2 Lib/unittest/test/test_case.py
43391
 
--- a/Lib/unittest/test/test_case.py
43392
 
+++ b/Lib/unittest/test/test_case.py
43393
 
@@ -1,5 +1,6 @@
43394
 
 import difflib
43395
 
 import pprint
43396
 
+import pickle
43397
 
 import re
43398
 
 import sys
43399
 
 
43400
 
@@ -1104,6 +1105,20 @@
43401
 
             self.assertEqual(len(result.errors), 1)
43402
 
             self.assertEqual(result.testsRun, 1)
43403
 
 
43404
 
+    def testPickle(self):
43405
 
+        # Issue 10326
43406
 
+
43407
 
+        # Can't use TestCase classes defined in Test class as
43408
 
+        # pickle does not work with inner classes
43409
 
+        test = unittest.TestCase('run')
43410
 
+        for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
43411
 
+
43412
 
+            # blew up prior to fix
43413
 
+            pickled_test = pickle.dumps(test, protocol=protocol)
43414
 
+
43415
 
+            unpickled_test = pickle.loads(pickled_test)
43416
 
+            self.assertEqual(test, unpickled_test)
43417
 
+
43418
 
 
43419
 
 if __name__ == '__main__':
43420
 
     unittest.main()
43421
 
diff -r 8527427914a2 Lib/urllib.py
43422
 
--- a/Lib/urllib.py
43423
 
+++ b/Lib/urllib.py
43424
 
@@ -27,6 +27,8 @@
43425
 
 import os
43426
 
 import time
43427
 
 import sys
43428
 
+import base64
43429
 
+
43430
 
 from urlparse import urljoin as basejoin
43431
 
 
43432
 
 __all__ = ["urlopen", "URLopener", "FancyURLopener", "urlretrieve",
43433
 
@@ -257,9 +259,9 @@
43434
 
                 size = -1
43435
 
                 read = 0
43436
 
                 blocknum = 0
43437
 
+                if "content-length" in headers:
43438
 
+                    size = int(headers["Content-Length"])
43439
 
                 if reporthook:
43440
 
-                    if "content-length" in headers:
43441
 
-                        size = int(headers["Content-Length"])
43442
 
                     reporthook(blocknum, bs, size)
43443
 
                 while 1:
43444
 
                     block = fp.read(bs)
43445
 
@@ -318,13 +320,13 @@
43446
 
         if not host: raise IOError, ('http error', 'no host given')
43447
 
 
43448
 
         if proxy_passwd:
43449
 
-            import base64
43450
 
+            proxy_passwd = unquote(proxy_passwd)
43451
 
             proxy_auth = base64.b64encode(proxy_passwd).strip()
43452
 
         else:
43453
 
             proxy_auth = None
43454
 
 
43455
 
         if user_passwd:
43456
 
-            import base64
43457
 
+            user_passwd = unquote(user_passwd)
43458
 
             auth = base64.b64encode(user_passwd).strip()
43459
 
         else:
43460
 
             auth = None
43461
 
@@ -374,7 +376,6 @@
43462
 
 
43463
 
     def http_error_default(self, url, fp, errcode, errmsg, headers):
43464
 
         """Default error handler: close the connection and raise IOError."""
43465
 
-        void = fp.read()
43466
 
         fp.close()
43467
 
         raise IOError, ('http error', errcode, errmsg, headers)
43468
 
 
43469
 
@@ -409,12 +410,12 @@
43470
 
                 #print "proxy via https:", host, selector
43471
 
             if not host: raise IOError, ('https error', 'no host given')
43472
 
             if proxy_passwd:
43473
 
-                import base64
43474
 
+                proxy_passwd = unquote(proxy_passwd)
43475
 
                 proxy_auth = base64.b64encode(proxy_passwd).strip()
43476
 
             else:
43477
 
                 proxy_auth = None
43478
 
             if user_passwd:
43479
 
-                import base64
43480
 
+                user_passwd = unquote(user_passwd)
43481
 
                 auth = base64.b64encode(user_passwd).strip()
43482
 
             else:
43483
 
                 auth = None
43484
 
@@ -483,6 +484,8 @@
43485
 
             urlfile = file
43486
 
             if file[:1] == '/':
43487
 
                 urlfile = 'file://' + file
43488
 
+            elif file[:2] == './':
43489
 
+                raise ValueError("local file url may start with / or file:. Unknown url of type: %s" % url)
43490
 
             return addinfourl(open(localname, 'rb'),
43491
 
                               headers, urlfile)
43492
 
         host, port = splitport(host)
43493
 
@@ -590,7 +593,6 @@
43494
 
                                             time.gmtime(time.time())))
43495
 
         msg.append('Content-type: %s' % type)
43496
 
         if encoding == 'base64':
43497
 
-            import base64
43498
 
             data = base64.decodestring(data)
43499
 
         else:
43500
 
             data = unquote(data)
43501
 
@@ -640,7 +642,6 @@
43502
 
             newurl = headers['uri']
43503
 
         else:
43504
 
             return
43505
 
-        void = fp.read()
43506
 
         fp.close()
43507
 
         # In case the server sent a relative URL, join with original:
43508
 
         newurl = basejoin(self.type + ":" + url, newurl)
43509
 
@@ -850,13 +851,16 @@
43510
 
     """Class used by open_ftp() for cache of open FTP connections."""
43511
 
 
43512
 
     def __init__(self, user, passwd, host, port, dirs,
43513
 
-                 timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
43514
 
+                 timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
43515
 
+                 persistent=True):
43516
 
         self.user = user
43517
 
         self.passwd = passwd
43518
 
         self.host = host
43519
 
         self.port = port
43520
 
         self.dirs = dirs
43521
 
         self.timeout = timeout
43522
 
+        self.refcount = 0
43523
 
+        self.keepalive = persistent
43524
 
         self.init()
43525
 
 
43526
 
     def init(self):
43527
 
@@ -883,7 +887,7 @@
43528
 
             # Try to retrieve as a file
43529
 
             try:
43530
 
                 cmd = 'RETR ' + file
43531
 
-                conn = self.ftp.ntransfercmd(cmd)
43532
 
+                conn, retrlen = self.ftp.ntransfercmd(cmd)
43533
 
             except ftplib.error_perm, reason:
43534
 
                 if str(reason)[:3] != '550':
43535
 
                     raise IOError, ('ftp error', reason), sys.exc_info()[2]
43536
 
@@ -903,11 +907,14 @@
43537
 
                 cmd = 'LIST ' + file
43538
 
             else:
43539
 
                 cmd = 'LIST'
43540
 
-            conn = self.ftp.ntransfercmd(cmd)
43541
 
+            conn, retrlen = self.ftp.ntransfercmd(cmd)
43542
 
         self.busy = 1
43543
 
+        ftpobj = addclosehook(conn.makefile('rb'), self.file_close)
43544
 
+        self.refcount += 1
43545
 
+        conn.close()
43546
 
         # Pass back both a suitably decorated object and a retrieval length
43547
 
-        return (addclosehook(conn[0].makefile('rb'),
43548
 
-                             self.endtransfer), conn[1])
43549
 
+        return (ftpobj, retrlen)
43550
 
+
43551
 
     def endtransfer(self):
43552
 
         if not self.busy:
43553
 
             return
43554
 
@@ -918,6 +925,17 @@
43555
 
             pass
43556
 
 
43557
 
     def close(self):
43558
 
+        self.keepalive = False
43559
 
+        if self.refcount <= 0:
43560
 
+            self.real_close()
43561
 
+
43562
 
+    def file_close(self):
43563
 
+        self.endtransfer()
43564
 
+        self.refcount -= 1
43565
 
+        if self.refcount <= 0 and not self.keepalive:
43566
 
+            self.real_close()
43567
 
+
43568
 
+    def real_close(self):
43569
 
         self.endtransfer()
43570
 
         try:
43571
 
             self.ftp.close()
43572
 
@@ -1349,7 +1367,8 @@
43573
 
     # strip port off host
43574
 
     hostonly, port = splitport(host)
43575
 
     # check if the host ends with any of the DNS suffixes
43576
 
-    for name in no_proxy.split(','):
43577
 
+    no_proxy_list = [proxy.strip() for proxy in no_proxy.split(',')]
43578
 
+    for name in no_proxy_list:
43579
 
         if name and (hostonly.endswith(name) or host.endswith(name)):
43580
 
             return 1
43581
 
     # otherwise, don't bypass
43582
 
@@ -1581,66 +1600,3 @@
43583
 
     # Report during remote transfers
43584
 
     print "Block number: %d, Block size: %d, Total size: %d" % (
43585
 
         blocknum, blocksize, totalsize)
43586
 
-
43587
 
-# Test program
43588
 
-def test(args=[]):
43589
 
-    if not args:
43590
 
-        args = [
43591
 
-            '/etc/passwd',
43592
 
-            'file:/etc/passwd',
43593
 
-            'file://localhost/etc/passwd',
43594
 
-            'ftp://ftp.gnu.org/pub/README',
43595
 
-            'http://www.python.org/index.html',
43596
 
-            ]
43597
 
-        if hasattr(URLopener, "open_https"):
43598
 
-            args.append('https://synergy.as.cmu.edu/~geek/')
43599
 
-    try:
43600
 
-        for url in args:
43601
 
-            print '-'*10, url, '-'*10
43602
 
-            fn, h = urlretrieve(url, None, reporthook)
43603
 
-            print fn
43604
 
-            if h:
43605
 
-                print '======'
43606
 
-                for k in h.keys(): print k + ':', h[k]
43607
 
-                print '======'
43608
 
-            with open(fn, 'rb') as fp:
43609
 
-                data = fp.read()
43610
 
-            if '\r' in data:
43611
 
-                table = string.maketrans("", "")
43612
 
-                data = data.translate(table, "\r")
43613
 
-            print data
43614
 
-            fn, h = None, None
43615
 
-        print '-'*40
43616
 
-    finally:
43617
 
-        urlcleanup()
43618
 
-
43619
 
-def main():
43620
 
-    import getopt, sys
43621
 
-    try:
43622
 
-        opts, args = getopt.getopt(sys.argv[1:], "th")
43623
 
-    except getopt.error, msg:
43624
 
-        print msg
43625
 
-        print "Use -h for help"
43626
 
-        return
43627
 
-    t = 0
43628
 
-    for o, a in opts:
43629
 
-        if o == '-t':
43630
 
-            t = t + 1
43631
 
-        if o == '-h':
43632
 
-            print "Usage: python urllib.py [-t] [url ...]"
43633
 
-            print "-t runs self-test;",
43634
 
-            print "otherwise, contents of urls are printed"
43635
 
-            return
43636
 
-    if t:
43637
 
-        if t > 1:
43638
 
-            test1()
43639
 
-        test(args)
43640
 
-    else:
43641
 
-        if not args:
43642
 
-            print "Use -h for help"
43643
 
-        for url in args:
43644
 
-            print urlopen(url).read(),
43645
 
-
43646
 
-# Run test program when run as a script
43647
 
-if __name__ == '__main__':
43648
 
-    main()
43649
 
diff -r 8527427914a2 Lib/urllib2.py
43650
 
--- a/Lib/urllib2.py
43651
 
+++ b/Lib/urllib2.py
43652
 
@@ -166,6 +166,12 @@
43653
 
     def __str__(self):
43654
 
         return 'HTTP Error %s: %s' % (self.code, self.msg)
43655
 
 
43656
 
+    # since URLError specifies a .reason attribute, HTTPError should also
43657
 
+    #  provide this attribute. See issue13211 fo discussion.
43658
 
+    @property
43659
 
+    def reason(self):
43660
 
+        return self.msg
43661
 
+
43662
 
 # copied from cookielib.py
43663
 
 _cut_port_re = re.compile(r":\d+$")
43664
 
 def request_host(request):
43665
 
@@ -1166,12 +1172,14 @@
43666
 
 
43667
 
         try:
43668
 
             h.request(req.get_method(), req.get_selector(), req.data, headers)
43669
 
+        except socket.error, err: # XXX what error?
43670
 
+            h.close()
43671
 
+            raise URLError(err)
43672
 
+        else:
43673
 
             try:
43674
 
                 r = h.getresponse(buffering=True)
43675
 
-            except TypeError: #buffering kw not supported
43676
 
+            except TypeError: # buffering kw not supported
43677
 
                 r = h.getresponse()
43678
 
-        except socket.error, err: # XXX what error?
43679
 
-            raise URLError(err)
43680
 
 
43681
 
         # Pick apart the HTTPResponse object to get the addinfourl
43682
 
         # object initialized properly.
43683
 
@@ -1397,7 +1405,8 @@
43684
 
             raise URLError, ('ftp error: %s' % msg), sys.exc_info()[2]
43685
 
 
43686
 
     def connect_ftp(self, user, passwd, host, port, dirs, timeout):
43687
 
-        fw = ftpwrapper(user, passwd, host, port, dirs, timeout)
43688
 
+        fw = ftpwrapper(user, passwd, host, port, dirs, timeout,
43689
 
+                        persistent=False)
43690
 
 ##        fw.ftp.set_debuglevel(1)
43691
 
         return fw
43692
 
 
43693
 
@@ -1446,3 +1455,9 @@
43694
 
                     del self.timeout[k]
43695
 
                     break
43696
 
             self.soonest = min(self.timeout.values())
43697
 
+
43698
 
+    def clear_cache(self):
43699
 
+        for conn in self.cache.values():
43700
 
+            conn.close()
43701
 
+        self.cache.clear()
43702
 
+        self.timeout.clear()
43703
 
diff -r 8527427914a2 Lib/urlparse.py
43704
 
--- a/Lib/urlparse.py
43705
 
+++ b/Lib/urlparse.py
43706
 
@@ -34,7 +34,8 @@
43707
 
 # A classification of schemes ('' means apply by default)
43708
 
 uses_relative = ['ftp', 'http', 'gopher', 'nntp', 'imap',
43709
 
                  'wais', 'file', 'https', 'shttp', 'mms',
43710
 
-                 'prospero', 'rtsp', 'rtspu', '', 'sftp']
43711
 
+                 'prospero', 'rtsp', 'rtspu', '', 'sftp',
43712
 
+                 'svn', 'svn+ssh']
43713
 
 uses_netloc = ['ftp', 'http', 'gopher', 'nntp', 'telnet',
43714
 
                'imap', 'wais', 'file', 'mms', 'https', 'shttp',
43715
 
                'snews', 'prospero', 'rtsp', 'rtspu', 'rsync', '',
43716
 
diff -r 8527427914a2 Lib/webbrowser.py
43717
 
--- a/Lib/webbrowser.py
43718
 
+++ b/Lib/webbrowser.py
43719
 
@@ -237,7 +237,7 @@
43720
 
                              stdout=(self.redirect_stdout and inout or None),
43721
 
                              stderr=inout, preexec_fn=setsid)
43722
 
         if remote:
43723
 
-            # wait five secons. If the subprocess is not finished, the
43724
 
+            # wait five seconds. If the subprocess is not finished, the
43725
 
             # remote invocation has (hopefully) started a new instance.
43726
 
             time.sleep(1)
43727
 
             rc = p.poll()
43728
 
diff -r 8527427914a2 Lib/whichdb.py
43729
 
--- a/Lib/whichdb.py
43730
 
+++ b/Lib/whichdb.py
43731
 
@@ -91,7 +91,7 @@
43732
 
         return ""
43733
 
 
43734
 
     # Check for GNU dbm
43735
 
-    if magic == 0x13579ace:
43736
 
+    if magic in (0x13579ace, 0x13579acd, 0x13579acf):
43737
 
         return "gdbm"
43738
 
 
43739
 
     # Check for old Berkeley db hash file format v2
43740
 
diff -r 8527427914a2 Lib/xml/dom/minidom.py
43741
 
--- a/Lib/xml/dom/minidom.py
43742
 
+++ b/Lib/xml/dom/minidom.py
43743
 
@@ -806,10 +806,16 @@
43744
 
             _write_data(writer, attrs[a_name].value)
43745
 
             writer.write("\"")
43746
 
         if self.childNodes:
43747
 
-            writer.write(">%s"%(newl))
43748
 
-            for node in self.childNodes:
43749
 
-                node.writexml(writer,indent+addindent,addindent,newl)
43750
 
-            writer.write("%s</%s>%s" % (indent,self.tagName,newl))
43751
 
+            writer.write(">")
43752
 
+            if (len(self.childNodes) == 1 and
43753
 
+                self.childNodes[0].nodeType == Node.TEXT_NODE):
43754
 
+                self.childNodes[0].writexml(writer, '', '', '')
43755
 
+            else:
43756
 
+                writer.write(newl)
43757
 
+                for node in self.childNodes:
43758
 
+                    node.writexml(writer, indent+addindent, addindent, newl)
43759
 
+                writer.write(indent)
43760
 
+            writer.write("</%s>%s" % (self.tagName, newl))
43761
 
         else:
43762
 
             writer.write("/>%s"%(newl))
43763
 
 
43764
 
@@ -1031,7 +1037,7 @@
43765
 
         return newText
43766
 
 
43767
 
     def writexml(self, writer, indent="", addindent="", newl=""):
43768
 
-        _write_data(writer, "%s%s%s"%(indent, self.data, newl))
43769
 
+        _write_data(writer, "%s%s%s" % (indent, self.data, newl))
43770
 
 
43771
 
     # DOM Level 3 (WD 9 April 2002)
43772
 
 
43773
 
diff -r 8527427914a2 Lib/xml/etree/ElementTree.py
43774
 
--- a/Lib/xml/etree/ElementTree.py
43775
 
+++ b/Lib/xml/etree/ElementTree.py
43776
 
@@ -642,17 +642,23 @@
43777
 
     # @exception ParseError If the parser fails to parse the document.
43778
 
 
43779
 
     def parse(self, source, parser=None):
43780
 
+        close_source = False
43781
 
         if not hasattr(source, "read"):
43782
 
             source = open(source, "rb")
43783
 
-        if not parser:
43784
 
-            parser = XMLParser(target=TreeBuilder())
43785
 
-        while 1:
43786
 
-            data = source.read(65536)
43787
 
-            if not data:
43788
 
-                break
43789
 
-            parser.feed(data)
43790
 
-        self._root = parser.close()
43791
 
-        return self._root
43792
 
+            close_source = True
43793
 
+        try:
43794
 
+            if not parser:
43795
 
+                parser = XMLParser(target=TreeBuilder())
43796
 
+            while 1:
43797
 
+                data = source.read(65536)
43798
 
+                if not data:
43799
 
+                    break
43800
 
+                parser.feed(data)
43801
 
+            self._root = parser.close()
43802
 
+            return self._root
43803
 
+        finally:
43804
 
+            if close_source:
43805
 
+                source.close()
43806
 
 
43807
 
     ##
43808
 
     # Creates a tree iterator for the root element.  The iterator loops
43809
 
@@ -1189,18 +1195,22 @@
43810
 
 # @return A (event, elem) iterator.
43811
 
 
43812
 
 def iterparse(source, events=None, parser=None):
43813
 
+    close_source = False
43814
 
     if not hasattr(source, "read"):
43815
 
         source = open(source, "rb")
43816
 
+        close_source = True
43817
 
     if not parser:
43818
 
         parser = XMLParser(target=TreeBuilder())
43819
 
-    return _IterParseIterator(source, events, parser)
43820
 
+    return _IterParseIterator(source, events, parser, close_source)
43821
 
 
43822
 
 class _IterParseIterator(object):
43823
 
 
43824
 
-    def __init__(self, source, events, parser):
43825
 
+    def __init__(self, source, events, parser, close_source=False):
43826
 
         self._file = source
43827
 
+        self._close_file = close_source
43828
 
         self._events = []
43829
 
         self._index = 0
43830
 
+        self._error = None
43831
 
         self.root = self._root = None
43832
 
         self._parser = parser
43833
 
         # wire up the parser for event reporting
43834
 
@@ -1246,22 +1256,31 @@
43835
 
         while 1:
43836
 
             try:
43837
 
                 item = self._events[self._index]
43838
 
+                self._index += 1
43839
 
+                return item
43840
 
             except IndexError:
43841
 
-                if self._parser is None:
43842
 
-                    self.root = self._root
43843
 
-                    raise StopIteration
43844
 
-                # load event buffer
43845
 
-                del self._events[:]
43846
 
-                self._index = 0
43847
 
-                data = self._file.read(16384)
43848
 
-                if data:
43849
 
+                pass
43850
 
+            if self._error:
43851
 
+                e = self._error
43852
 
+                self._error = None
43853
 
+                raise e
43854
 
+            if self._parser is None:
43855
 
+                self.root = self._root
43856
 
+                if self._close_file:
43857
 
+                    self._file.close()
43858
 
+                raise StopIteration
43859
 
+            # load event buffer
43860
 
+            del self._events[:]
43861
 
+            self._index = 0
43862
 
+            data = self._file.read(16384)
43863
 
+            if data:
43864
 
+                try:
43865
 
                     self._parser.feed(data)
43866
 
-                else:
43867
 
-                    self._root = self._parser.close()
43868
 
-                    self._parser = None
43869
 
+                except SyntaxError as exc:
43870
 
+                    self._error = exc
43871
 
             else:
43872
 
-                self._index = self._index + 1
43873
 
-                return item
43874
 
+                self._root = self._parser.close()
43875
 
+                self._parser = None
43876
 
 
43877
 
     def __iter__(self):
43878
 
         return self
43879
 
diff -r 8527427914a2 Lib/xml/parsers/expat.py
43880
 
--- a/Lib/xml/parsers/expat.py
43881
 
+++ b/Lib/xml/parsers/expat.py
43882
 
@@ -1,4 +1,4 @@
43883
 
 """Interface to the Expat non-validating XML parser."""
43884
 
-__version__ = '$Revision$'
43885
 
+__version__ = '$Revision: 17640 $'
43886
 
 
43887
 
 from pyexpat import *
43888
 
diff -r 8527427914a2 Lib/xmlrpclib.py
43889
 
--- a/Lib/xmlrpclib.py
43890
 
+++ b/Lib/xmlrpclib.py
43891
 
@@ -1539,6 +1539,9 @@
43892
 
                  allow_none=0, use_datetime=0):
43893
 
         # establish a "logical" server connection
43894
 
 
43895
 
+        if isinstance(uri, unicode):
43896
 
+            uri = uri.encode('ISO-8859-1')
43897
 
+
43898
 
         # get the url
43899
 
         import urllib
43900
 
         type, uri = urllib.splittype(uri)
43901
 
diff -r 8527427914a2 Lib/zipfile.py
43902
 
--- a/Lib/zipfile.py
43903
 
+++ b/Lib/zipfile.py
43904
 
@@ -236,16 +236,14 @@
43905
 
         # found the magic number; attempt to unpack and interpret
43906
 
         recData = data[start:start+sizeEndCentDir]
43907
 
         endrec = list(struct.unpack(structEndArchive, recData))
43908
 
-        comment = data[start+sizeEndCentDir:]
43909
 
-        # check that comment length is correct
43910
 
-        if endrec[_ECD_COMMENT_SIZE] == len(comment):
43911
 
-            # Append the archive comment and start offset
43912
 
-            endrec.append(comment)
43913
 
-            endrec.append(maxCommentStart + start)
43914
 
+        commentSize = endrec[_ECD_COMMENT_SIZE] #as claimed by the zip file
43915
 
+        comment = data[start+sizeEndCentDir:start+sizeEndCentDir+commentSize]
43916
 
+        endrec.append(comment)
43917
 
+        endrec.append(maxCommentStart + start)
43918
 
 
43919
 
-            # Try to read the "Zip64 end of central directory" structure
43920
 
-            return _EndRecData64(fpin, maxCommentStart + start - filesize,
43921
 
-                                 endrec)
43922
 
+        # Try to read the "Zip64 end of central directory" structure
43923
 
+        return _EndRecData64(fpin, maxCommentStart + start - filesize,
43924
 
+                             endrec)
43925
 
 
43926
 
     # Unable to find a valid end of central directory structure
43927
 
     return
43928
 
@@ -292,6 +290,10 @@
43929
 
 
43930
 
         self.filename = filename        # Normalized file name
43931
 
         self.date_time = date_time      # year, month, day, hour, min, sec
43932
 
+
43933
 
+        if date_time[0] < 1980:
43934
 
+            raise ValueError('ZIP does not support timestamps before 1980')
43935
 
+
43936
 
         # Standard values:
43937
 
         self.compress_type = ZIP_STORED # Type of compression for the file
43938
 
         self.comment = ""               # Comment for each file
43939
 
diff -r 8527427914a2 Mac/IDLE/Info.plist.in
43940
 
--- a/Mac/IDLE/Info.plist.in
43941
 
+++ b/Mac/IDLE/Info.plist.in
43942
 
@@ -36,7 +36,7 @@
43943
 
        <key>CFBundleExecutable</key>
43944
 
        <string>IDLE</string>
43945
 
        <key>CFBundleGetInfoString</key>
43946
 
-       <string>%VERSION%, © 2001-2011 Python Software Foundation</string>
43947
 
+       <string>%VERSION%, © 2001-2012 Python Software Foundation</string>
43948
 
        <key>CFBundleIconFile</key>
43949
 
        <string>IDLE.icns</string>
43950
 
        <key>CFBundleIdentifier</key>
43951
 
diff -r 8527427914a2 Mac/PythonLauncher/Info.plist.in
43952
 
--- a/Mac/PythonLauncher/Info.plist.in
43953
 
+++ b/Mac/PythonLauncher/Info.plist.in
43954
 
@@ -40,7 +40,7 @@
43955
 
        <key>CFBundleExecutable</key>
43956
 
        <string>PythonLauncher</string>
43957
 
        <key>CFBundleGetInfoString</key>
43958
 
-       <string>%VERSION%, © 2001-2011 Python Software Foundation</string>
43959
 
+       <string>%VERSION%, © 2001-2012 Python Software Foundation</string>
43960
 
        <key>CFBundleIconFile</key>
43961
 
        <string>PythonLauncher.icns</string>
43962
 
        <key>CFBundleIdentifier</key>
43963
 
diff -r 8527427914a2 Mac/Resources/app/Info.plist.in
43964
 
--- a/Mac/Resources/app/Info.plist.in
43965
 
+++ b/Mac/Resources/app/Info.plist.in
43966
 
@@ -20,7 +20,7 @@
43967
 
        <key>CFBundleExecutable</key>
43968
 
        <string>Python</string>
43969
 
        <key>CFBundleGetInfoString</key>
43970
 
-       <string>%version%, (c) 2004-2011 Python Software Foundation.</string>
43971
 
+       <string>%version%, (c) 2004-2012 Python Software Foundation.</string>
43972
 
        <key>CFBundleHelpBookFolder</key>
43973
 
        <array>
43974
 
                <string>Documentation</string>
43975
 
@@ -37,7 +37,7 @@
43976
 
        <key>CFBundleInfoDictionaryVersion</key>
43977
 
        <string>6.0</string>
43978
 
        <key>CFBundleLongVersionString</key>
43979
 
-       <string>%version%, (c) 2004-2011 Python Software Foundation.</string>
43980
 
+       <string>%version%, (c) 2004-2012 Python Software Foundation.</string>
43981
 
        <key>CFBundleName</key>
43982
 
        <string>Python</string>
43983
 
        <key>CFBundlePackageType</key>
43984
 
@@ -55,6 +55,6 @@
43985
 
        <key>NSAppleScriptEnabled</key>
43986
 
        <true/>
43987
 
        <key>NSHumanReadableCopyright</key>
43988
 
-       <string>(c) 2011 Python Software Foundation.</string>
43989
 
+       <string>(c) 2012 Python Software Foundation.</string>
43990
 
 </dict>
43991
 
 </plist>
43992
 
diff -r 8527427914a2 Mac/Resources/framework/Info.plist.in
43993
 
--- a/Mac/Resources/framework/Info.plist.in
43994
 
+++ b/Mac/Resources/framework/Info.plist.in
43995
 
@@ -17,9 +17,9 @@
43996
 
        <key>CFBundlePackageType</key>
43997
 
        <string>FMWK</string>
43998
 
        <key>CFBundleShortVersionString</key>
43999
 
-       <string>%VERSION%, (c) 2004-2011 Python Software Foundation.</string>
44000
 
+       <string>%VERSION%, (c) 2004-2012 Python Software Foundation.</string>
44001
 
        <key>CFBundleLongVersionString</key>
44002
 
-       <string>%VERSION%, (c) 2004-2011 Python Software Foundation.</string>
44003
 
+       <string>%VERSION%, (c) 2004-2012 Python Software Foundation.</string>
44004
 
        <key>CFBundleSignature</key>
44005
 
        <string>????</string>
44006
 
        <key>CFBundleVersion</key>
44007
 
diff -r 8527427914a2 Makefile.pre.in
44008
 
--- a/Makefile.pre.in
44009
 
+++ b/Makefile.pre.in
44010
 
@@ -869,7 +869,7 @@
44011
 
                unittest unittest/test \
44012
 
                lib-old \
44013
 
                curses pydoc_data $(MACHDEPS)
44014
 
-libinstall:    build_all $(srcdir)/Lib/$(PLATDIR)
44015
 
+libinstall:    build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
44016
 
        @for i in $(SCRIPTDIR) $(LIBDEST); \
44017
 
        do \
44018
 
                if test ! -d $(DESTDIR)$$i; then \
44019
 
@@ -925,6 +925,10 @@
44020
 
                done; \
44021
 
        done
44022
 
        $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
44023
 
+       if test -d $(DESTDIR)$(LIBDEST)/distutils/tests; then \
44024
 
+               $(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \
44025
 
+                       $(DESTDIR)$(LIBDEST)/distutils/tests ; \
44026
 
+       fi
44027
 
        PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
44028
 
                ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
44029
 
                -d $(LIBDEST) -f \
44030
 
@@ -1218,7 +1222,7 @@
44031
 
 
44032
 
 # Find files with funny names
44033
 
 funny:
44034
 
-       find $(DISTDIRS) -type d \
44035
 
+       find $(SUBDIRS) $(SUBDIRSTOO) -type d \
44036
 
                -o -name '*.[chs]' \
44037
 
                -o -name '*.py' \
44038
 
                -o -name '*.doc' \
44039
 
diff -r 8527427914a2 Misc/ACKS
44040
 
--- a/Misc/ACKS
44041
 
+++ b/Misc/ACKS
44042
 
@@ -120,6 +120,7 @@
44043
 
 Lee Busby
44044
 
 Ralph Butler
44045
 
 Jp Calderone
44046
 
+Arnaud Calmettes
44047
 
 Daniel Calvelo
44048
 
 Tony Campbell
44049
 
 Brett Cannon
44050
 
@@ -147,6 +148,7 @@
44051
 
 Tom Christiansen
44052
 
 Vadim Chugunov
44053
 
 David Cinege
44054
 
+Craig Citro
44055
 
 Mike Clarkson
44056
 
 Andrew Clegg
44057
 
 Brad Clements
44058
 
@@ -162,6 +164,7 @@
44059
 
 Juan José Conti
44060
 
 Matt Conway
44061
 
 David M. Cooke
44062
 
+Garrett Cooper
44063
 
 Greg Copeland
44064
 
 Aldo Cortesi
44065
 
 David Costanzo
44066
 
@@ -193,6 +196,7 @@
44067
 
 Vincent Delft
44068
 
 Arnaud Delobelle
44069
 
 Erik Demaine
44070
 
+John Dennis
44071
 
 Roger Dev
44072
 
 Raghuram Devarakonda
44073
 
 Catherine Devlin
44074
 
@@ -307,6 +311,7 @@
44075
 
 Eddy De Greef
44076
 
 Duncan Grisby
44077
 
 Fabian Groffen
44078
 
+John S. Gruber
44079
 
 Dag Gruneau
44080
 
 Filip Gruszczyński
44081
 
 Michael Guravage
44082
 
@@ -399,6 +404,7 @@
44083
 
 Geert Jansen
44084
 
 Jack Jansen
44085
 
 Bill Janssen
44086
 
+Thomas Jarosch
44087
 
 Drew Jenkins
44088
 
 Flemming Kjær Jensen
44089
 
 Jiba
44090
 
@@ -431,6 +437,7 @@
44091
 
 Randall Kern
44092
 
 Magnus Kessler
44093
 
 Lawrence Kesteloot
44094
 
+Rafe Kettler
44095
 
 Vivek Khera
44096
 
 Akira Kitada
44097
 
 Mads Kiilerich
44098
 
@@ -443,11 +450,14 @@
44099
 
 Bastian Kleineidam
44100
 
 Bob Kline
44101
 
 Matthias Klose
44102
 
+Jeremy Kloth
44103
 
+Thomas Kluyver
44104
 
 Kim Knapp
44105
 
 Lenny Kneler
44106
 
 Pat Knight
44107
 
 Greg Kochanski
44108
 
 Damon Kohler
44109
 
+Marko Kohtala
44110
 
 Joseph Koshy
44111
 
 Maksim Kozyarchuk
44112
 
 Stefan Krah
44113
 
@@ -455,12 +465,14 @@
44114
 
 Holger Krekel
44115
 
 Michael Kremer
44116
 
 Fabian Kreutz
44117
 
+Cédric Krier
44118
 
 Hannu Krosing
44119
 
 Andrej Krpic
44120
 
 Ivan Krstić
44121
 
 Andrew Kuchling
44122
 
 Ralf W. Grosse-Kunstleve
44123
 
 Vladimir Kushnir
44124
 
+Kirill Kuzminykh (Кирилл Кузьминых)
44125
 
 Ross Lagerwall
44126
 
 Cameron Laird
44127
 
 Łukasz Langa
44128
 
@@ -482,6 +494,7 @@
44129
 
 Kip Lehman
44130
 
 Joerg Lehmann
44131
 
 Robert Lehmann
44132
 
+Petri Lehtinen
44133
 
 Luke Kenneth Casson Leighton
44134
 
 Marc-Andre Lemburg
44135
 
 John Lenton
44136
 
@@ -502,6 +515,7 @@
44137
 
 Stephanie Lockwood
44138
 
 Anne Lord
44139
 
 Tom Loredo
44140
 
+Justin Love
44141
 
 Jason Lowe
44142
 
 Tony Lownds
44143
 
 Ray Loyzaga
44144
 
@@ -546,6 +560,7 @@
44145
 
 Ezio Melotti
44146
 
 Brian Merrell
44147
 
 Luke Mewburn
44148
 
+Carl Meyer
44149
 
 Mike Meyer
44150
 
 Steven Miale
44151
 
 Trent Mick
44152
 
@@ -577,6 +592,7 @@
44153
 
 Takahiro Nakayama
44154
 
 Travers Naran
44155
 
 Charles-François Natali
44156
 
+Vilmos Nebehaj
44157
 
 Fredrik Nehr
44158
 
 Trent Nelson
44159
 
 Tony Nelson
44160
 
@@ -608,6 +624,7 @@
44161
 
 Jason Orendorff
44162
 
 Douglas Orr
44163
 
 Michele Orrù
44164
 
+Oleg Oshmyan
44165
 
 Denis S. Otkidach
44166
 
 Michael Otteneder
44167
 
 R. M. Oudkerk
44168
 
@@ -647,6 +664,7 @@
44169
 
 Michael Piotrowski
44170
 
 Antoine Pitrou
44171
 
 Jean-François Piéronne
44172
 
+Oleg Plakhotnyuk
44173
 
 Guilherme Polo
44174
 
 Michael Pomraning
44175
 
 Iustin Pop
44176
 
@@ -669,6 +687,7 @@
44177
 
 Marc Recht
44178
 
 John Redford
44179
 
 Terry Reedy
44180
 
+Gareth Rees
44181
 
 Steve Reeves
44182
 
 Lennart Regebro
44183
 
 Ofir Reichenberg
44184
 
@@ -683,7 +702,9 @@
44185
 
 Armin Rigo
44186
 
 Nicholas Riley
44187
 
 Jean-Claude Rimbault
44188
 
+Vlad Riscutia
44189
 
 Juan M. Bello Rivas
44190
 
+Davide Rizzo
44191
 
 Anthony Roach
44192
 
 Mark Roberts
44193
 
 Jim Robinson
44194
 
@@ -711,6 +732,7 @@
44195
 
 Mark Russell
44196
 
 Nick Russo
44197
 
 Sébastien Sablé
44198
 
+Suman Saha
44199
 
 Hajime Saitou
44200
 
 George Sakkis
44201
 
 Rich Salz
44202
 
@@ -719,6 +741,8 @@
44203
 
 Mark Sapiro
44204
 
 Ty Sarna
44205
 
 Ben Sayer
44206
 
+sbt
44207
 
+Marco Scataglini
44208
 
 Michael Scharf
44209
 
 Neil Schemenauer
44210
 
 David Scherer
44211
 
@@ -738,6 +762,7 @@
44212
 
 Žiga Seilnach
44213
 
 Fred Sells
44214
 
 Jiwon Seo
44215
 
+Roger Serwy
44216
 
 Jerry Seutter
44217
 
 Denis Severson
44218
 
 Ian Seyer
44219
 
@@ -766,6 +791,7 @@
44220
 
 Paul Sokolovsky
44221
 
 Cody Somerville
44222
 
 Clay Spence
44223
 
+Stefan Sperling
44224
 
 Per Spilling
44225
 
 Joshua Spoerri
44226
 
 Noah Spurrier
44227
 
@@ -803,9 +829,12 @@
44228
 
 Amy Taylor
44229
 
 Anatoly Techtonik
44230
 
 Mikhail Terekhov
44231
 
+Richard M. Tew
44232
 
 Tobias Thelen
44233
 
+Nicolas M. Thiéry
44234
 
 James Thomas
44235
 
 Robin Thomas
44236
 
+Stephen Thorne
44237
 
 Eric Tiedemann
44238
 
 Tracy Tims
44239
 
 Oren Tirosh
44240
 
@@ -904,6 +933,7 @@
44241
 
 Danny Yoo
44242
 
 George Yoshida
44243
 
 Masazumi Yoshikawa
44244
 
+Arnaud Ysmal
44245
 
 Bernard Yue
44246
 
 Moshe Zadka
44247
 
 Milan Zamazal
44248
 
diff -r 8527427914a2 Misc/NEWS
44249
 
--- a/Misc/NEWS
44250
 
+++ b/Misc/NEWS
44251
 
@@ -1,6 +1,595 @@
44252
 
 Python News
44253
 
 +++++++++++
44254
 
 
44255
 
+What's New in Python 2.7.3?
44256
 
+===========================
44257
 
+
44258
 
+*Release date: XXXX-XX-XX*
44259
 
+
44260
 
+Core and Builtins
44261
 
+-----------------
44262
 
+
44263
 
+- Issue #13020: Fix a reference leak when allocating a structsequence object
44264
 
+  fails.  Patch by Suman Saha.
44265
 
+
44266
 
+- Issue #11235: Fix OverflowError when trying to import a source file whose
44267
 
+  modification time doesn't fit in a 32-bit timestamp.
44268
 
+
44269
 
+- Issue #11638: Unicode strings in 'name' and 'version' no longer cause
44270
 
+  UnicodeDecodeErrors.
44271
 
+
44272
 
+- Fix the fix for issue #12149: it was incorrect, although it had the side
44273
 
+  effect of appearing to resolve the issue.  Thanks to Mark Shannon for
44274
 
+  noticing.
44275
 
+
44276
 
+- Issue #13546: Fixed an overflow issue that could crash the intepreter when
44277
 
+  calling sys.setrecursionlimit((1<<31)-1).
44278
 
+
44279
 
+- Issue #13333: The UTF-7 decoder now accepts lone surrogates (the encoder
44280
 
+  already accepts them).
44281
 
+
44282
 
+- Issue #10519: Avoid unnecessary recursive function calls in
44283
 
+  setobject.c.
44284
 
+
44285
 
+- Issue #13268: Fix the assert statement when a tuple is passed as the message.
44286
 
+
44287
 
+- Issue #13018: Fix reference leaks in error paths in dictobject.c.
44288
 
+  Patch by Suman Saha.
44289
 
+
44290
 
+- Issue #12604: VTRACE macro expanded to no-op in _sre.c to avoid compiler
44291
 
+  warnings. Patch by Josh Triplett and Petri Lehtinen.
44292
 
+
44293
 
+- Issue #7833: Extension modules built using distutils on Windows will no
44294
 
+  longer include a "manifest" to prevent them failing at import time in some
44295
 
+  embedded situations.
44296
 
+
44297
 
+- Issue #13186: Fix __delitem__ on old-style instances when invoked through
44298
 
+  PySequence_DelItem.
44299
 
+
44300
 
+- Issue #13156: Revert the patch for issue #10517 (reset TLS upon fork()),
44301
 
+  which was only relevant for the native pthread TLS implementation.
44302
 
+
44303
 
+- Issue #7732: Fix a crash on importing a module if a directory has the same
44304
 
+  name than a Python module (e.g. "__init__.py"): don't close the file twice.
44305
 
+
44306
 
+- Issue #12973: Fix overflow checks that invoked undefined behaviour in
44307
 
+  int.__pow__.  These overflow checks were causing int.__pow__ to produce
44308
 
+  incorrect results with recent versions of Clang, as a result of the
44309
 
+  compiler optimizing the check away.  Also fix similar overflow checks
44310
 
+  in list_repeat (listobject.c) and islice_next (itertoolsmodule.c).  These
44311
 
+  bugs caused test failures with recent versions of Clang.
44312
 
+
44313
 
+- Issue #12266: Fix str.capitalize() to correctly uppercase/lowercase
44314
 
+  titlecased and cased non-letter characters.
44315
 
+
44316
 
+- Issues #12610 and #12609: Verify that user generated AST has correct string
44317
 
+  and identifier types before compiling.
44318
 
+
44319
 
+- Issue #11627: Fix segfault when __new__ on a exception returns a
44320
 
+  non-exception class.
44321
 
+
44322
 
+- Issue #12149: Update the method cache after a type's dictionnary gets
44323
 
+  cleared by the garbage collector.  This fixes a segfault when an instance
44324
 
+  and its type get caught in a reference cycle, and the instance's
44325
 
+  deallocator calls one of the methods on the type (e.g. when subclassing
44326
 
+  IOBase).  Diagnosis and patch by Davide Rizzo.
44327
 
+
44328
 
+- Issue #12501: Remove Py3k warning for callable. callable() is supported
44329
 
+  again in Python 3.2.
44330
 
+
44331
 
+- Issue #9611, #9015: FileIO.read(), FileIO.readinto(), FileIO.write() and
44332
 
+  os.write() clamp the length to INT_MAX on Windows.
44333
 
+
44334
 
+- Issue #1195: my_fgets() now always clears errors before calling fgets(). Fix
44335
 
+  the following case: sys.stdin.read() stopped with CTRL+d (end of file),
44336
 
+  raw_input() interrupted by CTRL+c.
44337
 
+
44338
 
+- Issue #10860: httplib now correctly handles an empty port after port
44339
 
+  delimiter in URLs.
44340
 
+
44341
 
+- dict_proxy objects now display their contents rather than just the class
44342
 
+  name.
44343
 
+
44344
 
+Library
44345
 
+-------
44346
 
+
44347
 
+- Issue #2489: pty.spawn could consume 100% cpu when it encountered an EOF.
44348
 
+
44349
 
+- Issue #13014: Fix a possible reference leak in SSLSocket.getpeercert().
44350
 
+
44351
 
+- Issue #13987: HTMLParser is now able to handle EOFs in the middle of a
44352
 
+  construct and malformed start tags.
44353
 
+
44354
 
+- Issue #13015: Fix a possible reference leak in defaultdict.__repr__.
44355
 
+  Patch by Suman Saha.
44356
 
+
44357
 
+- Issue #13979: A bug in ctypes.util.find_library that caused
44358
 
+  the wrong library name to be returned has been fixed.
44359
 
+
44360
 
+- Issue #1326113: distutils' build_ext command --libraries option now
44361
 
+  correctly parses multiple values separated by whitespace or commas.
44362
 
+
44363
 
+- Issue #13993: HTMLParser is now able to handle broken end tags.
44364
 
+
44365
 
+- Issue #13960: HTMLParser is now able to handle broken comments.
44366
 
+
44367
 
+- Issue #9750: Fix sqlite3.Connection.iterdump on tables and fields
44368
 
+  with a name that is a keyword or contains quotes. Patch by Marko
44369
 
+  Kohtala.
44370
 
+
44371
 
+- Issue #13994: Earlier partial revert of Distutils enhancements in 2.7
44372
 
+  has left two versions of customize_compiler, the original in
44373
 
+  distutils.sysconfig and another copy in distutils.ccompiler, with some
44374
 
+  parts of distutils calling one and others using the other.
44375
 
+  Complete the revert back to only having one in distutils.sysconfig as
44376
 
+  is the case in 3.x.
44377
 
+
44378
 
+- Issue #13590: On OS X 10.7 and 10.6 with Xcode 4.2, building
44379
 
+  Distutils-based packages with C extension modules may fail because
44380
 
+  Apple has removed gcc-4.2, the version used to build python.org
44381
 
+  64-bit/32-bit Pythons.  If the user does not explicitly override
44382
 
+  the default C compiler by setting the CC environment variable,
44383
 
+  Distutils will now attempt to compile extension modules with clang
44384
 
+  if gcc-4.2 is required but not found. Also as a convenience, if
44385
 
+  the user does explicitly set CC, substitute its value as the default
44386
 
+  compiler in the Distutils LDSHARED configuration variable for OS X.
44387
 
+  (Note, the python.org 32-bit-only Pythons use gcc-4.0 and the 10.4u
44388
 
+  SDK, neither of which are available in Xcode 4.  This change does not
44389
 
+  attempt to override settings to support their use with Xcode 4.)
44390
 
+
44391
 
+- Issue #9021: Add an introduction to the copy module documentation.
44392
 
+
44393
 
+- Issue #6005: Examples in the socket library documentation use sendall, where
44394
 
+  relevant, instead send method.
44395
 
+
44396
 
+- Issue #10811: Fix recursive usage of cursors. Instead of crashing,
44397
 
+  raise a ProgrammingError now.
44398
 
+
44399
 
+- Issue #10881: Fix test_site failures with OS X framework builds.
44400
 
+
44401
 
+- Issue #964437 Make IDLE help window non-modal.
44402
 
+  Patch by Guilherme Polo and Roger Serwy.
44403
 
+
44404
 
+- Issue #13933: IDLE auto-complete did not work with some imported
44405
 
+  module, like hashlib.  (Patch by Roger Serwy)
44406
 
+
44407
 
+- Issue #13901: Prevent test_distutils failures on OS X with --enable-shared.
44408
 
+
44409
 
+- Issue #13676: Handle strings with embedded zeros correctly in sqlite3.
44410
 
+
44411
 
+- Issue #13506: Add '' to path for IDLE Shell when started and restarted with Restart Shell.
44412
 
+  Original patches by Marco Scataglini and Roger Serwy.
44413
 
+
44414
 
+- Issue #13806: The size check in audioop decompression functions was too
44415
 
+  strict and could reject valid compressed data.  Patch by Oleg Plakhotnyuk.
44416
 
+
44417
 
+- Issue #13885: CVE-2011-3389: the _ssl module would always disable the CBC
44418
 
+  IV attack countermeasure.
44419
 
+
44420
 
+- Issue #6631: Disallow relative file paths in urllib urlopen methods.
44421
 
+
44422
 
+- Issue #13781: Prevent gzip.GzipFile from using the dummy filename provided by
44423
 
+  file objects opened with os.fdopen().
44424
 
+
44425
 
+- Issue #13589: Fix some serialization primitives in the aifc module.
44426
 
+  Patch by Oleg Plakhotnyuk.
44427
 
+
44428
 
+- Issue #13803: Under Solaris, distutils doesn't include bitness
44429
 
+  in the directory name.
44430
 
+
44431
 
+- Issue #13642: Unquote before b64encoding user:password during Basic
44432
 
+  Authentication. Patch contributed by Joonas Kuorilehto and Michele Orrù.
44433
 
+
44434
 
+- Issue #13636: Weak ciphers are now disabled by default in the ssl module
44435
 
+  (except when SSLv2 is explicitly asked for).
44436
 
+
44437
 
+- Issue #12798: Updated the mimetypes documentation.
44438
 
+
44439
 
+- Issue #13639: Accept unicode filenames in tarfile.open(mode="w|gz").
44440
 
+
44441
 
+- Issue #1785: Fix inspect and pydoc with misbehaving descriptors.
44442
 
+
44443
 
+- Issue #7502: Fix equality comparison for DocTestCase instances.  Patch by
44444
 
+  Cédric Krier.
44445
 
+
44446
 
+- Issue #11870: threading: Properly reinitialize threads internal locks and
44447
 
+  condition variables to avoid deadlocks in child processes.
44448
 
+
44449
 
+- Issue #8035: urllib: Fix a bug where the client could remain stuck after a
44450
 
+  redirection or an error.
44451
 
+
44452
 
+- Issue #4625: If IDLE cannot write to its recent file or breakpoint
44453
 
+  files, display a message popup and continue rather than crash.
44454
 
+  (original patch by Roger Serwy)
44455
 
+
44456
 
+- tarfile.py: Correctly detect bzip2 compressed streams with blocksizes
44457
 
+  other than 900k.
44458
 
+
44459
 
+- Issue #13573: The csv.writer now uses the repr() for floats rather than str().
44460
 
+  This allows floats to round-trip without loss of precision.
44461
 
+
44462
 
+- Issue #13439: Fix many errors in turtle docstrings.
44463
 
+
44464
 
+- Issue #12856: Ensure child processes do not inherit the parent's random
44465
 
+  seed for filename generation in the tempfile module.  Patch by Brian
44466
 
+  Harring.
44467
 
+
44468
 
+- Issue #13458: Fix a memory leak in the ssl module when decoding a
44469
 
+  certificate with a subjectAltName.  Patch by Robert Xiao.
44470
 
+
44471
 
+- Issue #13415: os.unsetenv() doesn't ignore errors anymore.
44472
 
+
44473
 
+- Issue #13322: Fix BufferedWriter.write() to ensure that BlockingIOError is
44474
 
+  raised when the wrapped raw file is non-blocking and the write would block.
44475
 
+  Previous code assumed that the raw write() would raise BlockingIOError, but
44476
 
+  RawIOBase.write() is defined to returned None when the call would block.
44477
 
+  Patch by sbt.
44478
 
+
44479
 
+- Issue #13358: HTMLParser now calls handle_data only once for each CDATA.
44480
 
+
44481
 
+- Issue #4147: minidom's toprettyxml no longer adds whitespace around a text
44482
 
+  node when it is the only child of an element.  Initial patch by Dan
44483
 
+  Kenigsberg.
44484
 
+
44485
 
+- Issue #8793: Prevent IDLE crash when given strings with invalid hex escape
44486
 
+  sequences.
44487
 
+
44488
 
+- Issues #1745761, #755670, #13357, #12629, #1200313: HTMLParser now correctly
44489
 
+  handles non-valid attributes, including adjacent and unquoted attributes.
44490
 
+
44491
 
+- Issue #13193: Fix distutils.filelist.FileList under Windows.
44492
 
+
44493
 
+- Issue #13373: multiprocessing.Queue.get() could sometimes block indefinitely
44494
 
+  when called with a timeout.  Patch by Arnaud Ysmal.
44495
 
+
44496
 
+- Issue #3067: Enhance the documentation and docstring of
44497
 
+  locale.setlocale().
44498
 
+
44499
 
+- Issue #13254: Fix Maildir initialization so that maildir contents
44500
 
+  are read correctly.
44501
 
+
44502
 
+- Issue #13140: Fix the daemon_threads attribute of ThreadingMixIn.
44503
 
+
44504
 
+- Issue #2892: preserve iterparse events in case of SyntaxError.
44505
 
+
44506
 
+- Issue #670664: Fix HTMLParser to correctly handle the content of
44507
 
+  ``<script>...</script>`` and ``<style>...</style>``.
44508
 
+
44509
 
+- Issue #10817: Fix urlretrieve function to raise ContentTooShortError even
44510
 
+  when reporthook is None. Patch by Jyrki Pulliainen.
44511
 
+
44512
 
+- Issue #13296: Fix IDLE to clear compile __future__ flags on shell restart.
44513
 
+  (Patch by Roger Serwy)
44514
 
+
44515
 
+- Issue #7334: close source files on ElementTree.parse and iterparse.
44516
 
+
44517
 
+- Issue #13232: logging: Improved logging of exceptions in the presence of
44518
 
+  multiple encodings.
44519
 
+
44520
 
+- Issue #10332: multiprocessing: fix a race condition when a Pool is closed
44521
 
+  before all tasks have completed.
44522
 
+
44523
 
+- Issue #1548891: The cStringIO.StringIO() constructor now encodes unicode
44524
 
+  arguments with the system default encoding just like the write() method
44525
 
+  does, instead of converting it to a raw buffer.  This also fixes handling of
44526
 
+  unicode input in the shlex module (#6988, #1170).
44527
 
+
44528
 
+- Issue #9168: now smtpd is able to bind privileged port.
44529
 
+
44530
 
+- Issue #12529: fix cgi.parse_header issue on strings with double-quotes and
44531
 
+  semicolons together. Patch by Ben Darnell and Petri Lehtinen.
44532
 
+
44533
 
+- Issue #6090: zipfile raises a ValueError when a document with a timestamp
44534
 
+  earlier than 1980 is provided. Patch contributed by Petri Lehtinen.
44535
 
+
44536
 
+- Issue #13194: zlib.compressobj().copy() and zlib.decompressobj().copy() are
44537
 
+  now available on Windows.
44538
 
+
44539
 
+- Issue #13114: Fix the distutils commands check and register when the
44540
 
+  long description is a Unicode string with non-ASCII characters.
44541
 
+
44542
 
+- Issue #7367: Fix pkgutil.walk_paths to skip directories whose
44543
 
+  contents cannot be read.
44544
 
+
44545
 
+- Issue #7425: Prevent pydoc -k failures due to module import errors.
44546
 
+  (Backport to 2.7 of existing 3.x fix)
44547
 
+
44548
 
+- Issue #13099: Fix sqlite3.Cursor.lastrowid under a Turkish locale.
44549
 
+  Reported and diagnosed by Thomas Kluyver.
44550
 
+
44551
 
+- Issue #7689: Allow pickling of dynamically created classes when their
44552
 
+  metaclass is registered with copy_reg.  Patch by Nicolas M. Thiéry and
44553
 
+  Craig Citro.
44554
 
+
44555
 
+- Issue #13058: ossaudiodev: fix a file descriptor leak on error. Patch by
44556
 
+  Thomas Jarosch.
44557
 
+
44558
 
+- Issue #12931: xmlrpclib now encodes Unicode URI to ISO-8859-1, instead of
44559
 
+  failing with a UnicodeDecodeError.
44560
 
+
44561
 
+- Issue #8933: distutils' PKG-INFO files will now correctly report
44562
 
+  Metadata-Version: 1.1 instead of 1.0 if a Classifier or Download-URL field is
44563
 
+  present.
44564
 
+
44565
 
+- Issue #8286: The distutils command sdist will print a warning message instead
44566
 
+  of crashing when an invalid path is given in the manifest template.
44567
 
+
44568
 
+- Issue #12841: tarfile unnecessarily checked the existence of numerical user
44569
 
+  and group ids on extraction. If one of them did not exist the respective id
44570
 
+  of the current user (i.e. root) was used for the file and ownership
44571
 
+  information was lost.
44572
 
+
44573
 
+- Issue #10946: The distutils commands bdist_dumb, bdist_wininst and bdist_msi
44574
 
+  now respect a --skip-build option given to bdist.
44575
 
+
44576
 
+- Issue #12287: Fix a stack corruption in ossaudiodev module when the FD is
44577
 
+  greater than FD_SETSIZE.
44578
 
+
44579
 
+- Issue #12839: Fix crash in zlib module due to version mismatch.
44580
 
+  Fix by Richard M. Tew.
44581
 
+
44582
 
+- Issue #12786: Set communication pipes used by subprocess.Popen CLOEXEC to
44583
 
+  avoid them being inherited by other subprocesses.
44584
 
+
44585
 
+- Issue #4106: Fix occasional exceptions printed out by multiprocessing on
44586
 
+  interpreter shutdown.
44587
 
+
44588
 
+- Issue #11657: Fix sending file descriptors over 255 over a multiprocessing
44589
 
+  Pipe.
44590
 
+
44591
 
+- Issue #12213: Fix a buffering bug with interleaved reads and writes that
44592
 
+  could appear on io.BufferedRandom streams.
44593
 
+
44594
 
+- Issue #12326: sys.platform is now always 'linux2' on Linux, even if Python
44595
 
+  is compiled on Linux 3.
44596
 
+
44597
 
+- Issue #13007: whichdb should recognize gdbm 1.9 magic numbers.
44598
 
+
44599
 
+- Issue #9173: Let shutil._make_archive work if the logger argument is None.
44600
 
+
44601
 
+- Issue #12650: Fix a race condition where a subprocess.Popen could leak
44602
 
+  resources (FD/zombie) when killed at the wrong time.
44603
 
+
44604
 
+- Issue #12752: Fix regression which prevented locale.normalize() from
44605
 
+  accepting unicode strings.
44606
 
+
44607
 
+- Issue #12683: urlparse updated to include svn as schemes that uses relative
44608
 
+  paths. (svn from 1.5 onwards support relative path).
44609
 
+
44610
 
+- Issue #11933: Fix incorrect mtime comparison in distutils.
44611
 
+
44612
 
+- Issues #11104, #8688: Fix the behavior of distutils' sdist command with
44613
 
+  manually-maintained MANIFEST files.
44614
 
+
44615
 
+- Issue #8887: "pydoc somebuiltin.somemethod" (or help('somebuiltin.somemethod')
44616
 
+  in Python code) now finds the doc of the method.
44617
 
+
44618
 
+- Issue #12603: Fix pydoc.synopsis() on files with non-negative st_mtime.
44619
 
+
44620
 
+- Issue #12514: Use try/finally to assure the timeit module restores garbage
44621
 
+  collections when it is done.
44622
 
+
44623
 
+- Issue #12607: In subprocess, fix issue where if stdin, stdout or stderr is
44624
 
+  given as a low fd, it gets overwritten.
44625
 
+
44626
 
+- Issue #12102: Document that buffered files must be flushed before being used
44627
 
+  with mmap. Patch by Steffen Daode Nurpmeso.
44628
 
+
44629
 
+- Issue #12560: Build libpython.so on OpenBSD. Patch by Stefan Sperling.
44630
 
+
44631
 
+- Issue #1813: Fix codec lookup and setting/getting locales under Turkish
44632
 
+  locales.
44633
 
+
44634
 
+- Issue #10883: Fix socket leaks in urllib when using FTP.
44635
 
+
44636
 
+- Issue #12592: Make Python build on OpenBSD 5 (and future major releases).
44637
 
+
44638
 
+- Issue #12372: POSIX semaphores are broken on AIX: don't use them.
44639
 
+
44640
 
+- Issue #12571: Add a plat-linux3 directory mirroring the plat-linux2
44641
 
+  directory, so that "import DLFCN" and other similar imports work on
44642
 
+  Linux 3.0.
44643
 
+
44644
 
+- Issue #7484: smtplib no longer puts <> around addresses in VRFY and EXPN
44645
 
+  commands; they aren't required and in fact postfix doesn't support that form.
44646
 
+
44647
 
+- Issue #11603: Fix a crash when __str__ is rebound as __repr__.  Patch by
44648
 
+  Andreas Stührk.
44649
 
+
44650
 
+- Issue #12502: asyncore: fix polling loop with AF_UNIX sockets.
44651
 
+
44652
 
+- Issue #4376: ctypes now supports nested structures in a endian different than
44653
 
+  the parent structure. Patch by Vlad Riscutia.
44654
 
+
44655
 
+- Issue #12493: subprocess: Popen.communicate() now also handles EINTR errors
44656
 
+  if the process has only one pipe.
44657
 
+
44658
 
+- Issue #12467: warnings: fix a race condition if a warning is emitted at
44659
 
+  shutdown, if globals()['__file__'] is None.
44660
 
+
44661
 
+- Issue #12352: Fix a deadlock in multiprocessing.Heap when a block is freed by
44662
 
+  the garbage collector while the Heap lock is held.
44663
 
+
44664
 
+- Issue #9516: On Mac OS X, change Distutils to no longer globally attempt to
44665
 
+  check or set the MACOSX_DEPLOYMENT_TARGET environment variable for the
44666
 
+  interpreter process.  This could cause failures in non-Distutils subprocesses
44667
 
+  and was unreliable since tests or user programs could modify the interpreter
44668
 
+  environment after Distutils set it.  Instead, have Distutils set the the
44669
 
+  deployment target only in the environment of each build subprocess.  It is
44670
 
+  still possible to globally override the default by setting
44671
 
+  MACOSX_DEPLOYMENT_TARGET before launching the interpreter; its value must be
44672
 
+  greater or equal to the default value, the value with which the interpreter
44673
 
+  was built.
44674
 
+
44675
 
+- Issue #11802:  The cache in filecmp now has a maximum size of 100 so that
44676
 
+  it won't grow without bound.
44677
 
+
44678
 
+- Issue #12404: Remove C89 incompatible code from mmap module. Patch by Akira
44679
 
+  Kitada.
44680
 
+
44681
 
+- Issue #11700: mailbox proxy object close methods can now be called multiple
44682
 
+  times without error, and _ProxyFile now closes the wrapped file.
44683
 
+
44684
 
+- Issue #12133: AbstractHTTPHandler.do_open() of urllib.request closes the HTTP
44685
 
+  connection if its getresponse() method fails with a socket error. Patch
44686
 
+  written by Ezio Melotti.
44687
 
+
44688
 
+- Issue #9284: Allow inspect.findsource() to find the source of doctest
44689
 
+  functions.
44690
 
+
44691
 
+- Issue #10694: zipfile now ignores garbage at the end of a zipfile.
44692
 
+
44693
 
+- Issue #11583: Speed up os.path.isdir on Windows by using GetFileAttributes
44694
 
+  instead of os.stat.
44695
 
+
44696
 
+- Issue #12080: Fix a performance issue in Decimal._power_exact that caused
44697
 
+  some corner-case Decimal.__pow__ calls to take an unreasonably long time.
44698
 
+
44699
 
+- Named tuples now work correctly with vars().
44700
 
+
44701
 
+- sys.setcheckinterval() now updates the current ticker count as well as
44702
 
+  updating the check interval, so if the user decreases the check interval,
44703
 
+  the ticker doesn't have to wind down to zero from the old starting point
44704
 
+  before the new interval takes effect.  And if the user increases the
44705
 
+  interval, it makes sure the new limit takes effect right away rather have an
44706
 
+  early task switch before recognizing the new interval.
44707
 
+
44708
 
+- Issue #12085: Fix an attribute error in subprocess.Popen destructor if the
44709
 
+  constructor has failed, e.g. because of an undeclared keyword argument. Patch
44710
 
+  written by Oleg Oshmyan.
44711
 
+
44712
 
+Extension Modules
44713
 
+-----------------
44714
 
+
44715
 
+- bsddb module: Erratic behaviour of "DBEnv->rep_elect()" because a typo.
44716
 
+  Possible crash.
44717
 
+
44718
 
+- Issue #13774: json: Fix a SystemError when a bogus encoding is passed to
44719
 
+  json.loads().
44720
 
+
44721
 
+- Issue #9975: socket: Fix incorrect use of flowinfo and scope_id. Patch by
44722
 
+  Vilmos Nebehaj.
44723
 
+
44724
 
+- Issue #13159: FileIO, BZ2File, and the built-in file class now use a
44725
 
+  linear-time buffer growth strategy instead of a quadratic one.
44726
 
+
44727
 
+- Issue #13070: Fix a crash when a TextIOWrapper caught in a reference cycle
44728
 
+  would be finalized after the reference to its underlying BufferedRWPair's
44729
 
+  writer got cleared by the GC.
44730
 
+
44731
 
+- Issue #12881: ctypes: Fix segfault with large structure field names.
44732
 
+
44733
 
+- Issue #13013: ctypes: Fix a reference leak in PyCArrayType_from_ctype.
44734
 
+  Thanks to Suman Saha for finding the bug and providing a patch.
44735
 
+
44736
 
+- Issue #13022: Fix: _multiprocessing.recvfd() doesn't check that
44737
 
+  file descriptor was actually received.
44738
 
+
44739
 
+- Issue #12483: ctypes: Fix a crash when the destruction of a callback
44740
 
+  object triggers the garbage collector.
44741
 
+
44742
 
+- Issue #12950: Fix passing file descriptors in multiprocessing, under
44743
 
+  OpenIndiana/Illumos.
44744
 
+
44745
 
+- Issue #12764: Fix a crash in ctypes when the name of a Structure field is not
44746
 
+  a string.
44747
 
+
44748
 
+- Issue #9651: Fix a crash when ctypes.create_string_buffer(0) was passed to
44749
 
+  some functions like file.write().
44750
 
+
44751
 
+- Issue #10309: Define _GNU_SOURCE so that mremap() gets the proper
44752
 
+  signature.  Without this, architectures where sizeof void* != sizeof int are
44753
 
+  broken.  Patch given by Hallvard B Furuseth.
44754
 
+
44755
 
+Build
44756
 
+-----
44757
 
+
44758
 
+- Issue #8746: Correct faulty configure checks so that os.chflags() and
44759
 
+  os.lchflags() are once again built on systems that support these
44760
 
+  functions (*BSD and OS X).  Also add new stat file flags for OS X
44761
 
+  (UF_HIDDEN and UF_COMPRESSED).
44762
 
+
44763
 
+Tools/Demos
44764
 
+-----------
44765
 
+
44766
 
+- Issue #13930: 2to3 is now able to write its converted output files to another
44767
 
+  directory tree as well as copying unchanged files and altering the file
44768
 
+  suffix.  See its new -o, -W and --add-suffix options.  This makes it more
44769
 
+  useful in many automated code translation workflows.
44770
 
+
44771
 
+- Issue #10639: reindent.py no longer converts newlines and will raise
44772
 
+  an error if attempting to convert a file with mixed newlines.
44773
 
+
44774
 
+- Issue #13628: python-gdb.py is now able to retrieve more frames in the Python
44775
 
+  traceback if Python is optimized.
44776
 
+
44777
 
+Tests
44778
 
+-----
44779
 
+
44780
 
+- Issue #13304: Skip test case if user site-packages disabled (-s or
44781
 
+  PYTHONNOUSERSITE).  (Patch by Carl Meyer)
44782
 
+
44783
 
+- Issue #13218: Fix test_ssl failures on Debian/Ubuntu.
44784
 
+
44785
 
+- Issue #12821: Fix test_fcntl failures on OpenBSD 5.
44786
 
+
44787
 
+- Issue #12331: The test suite for lib2to3 can now run from an installed
44788
 
+  Python.
44789
 
+
44790
 
+- Issue #12549: Correct test_platform to not fail when OS X returns 'x86_64'
44791
 
+  as the processor type on some Mac systems.
44792
 
+
44793
 
+- Skip network tests when getaddrinfo() returns EAI_AGAIN, meaning a temporary
44794
 
+  failure in name resolution.
44795
 
+
44796
 
+- Issue #11812: Solve transient socket failure to connect to 'localhost'
44797
 
+  in test_telnetlib.py.
44798
 
+
44799
 
+- Solved a potential deadlock in test_telnetlib.py. Related to issue #11812.
44800
 
+
44801
 
+- Avoid failing in test_robotparser when mueblesmoraleda.com is flaky and
44802
 
+  an overzealous DNS service (e.g. OpenDNS) redirects to a placeholder
44803
 
+  Web site.
44804
 
+
44805
 
+- Avoid failing in test_urllibnet.test_bad_address when some overzealous
44806
 
+  DNS service (e.g. OpenDNS) resolves a non-existent domain name.  The test
44807
 
+  is now skipped instead.
44808
 
+
44809
 
+- Issue #8716: Avoid crashes caused by Aqua Tk on OSX when attempting to run
44810
 
+  test_tk or test_ttk_guionly under a username that is not currently logged
44811
 
+  in to the console windowserver (as may be the case under buildbot or ssh).
44812
 
+
44813
 
+- Issue #12141: Install a copy of template C module file so that
44814
 
+  test_build_ext of test_distutils is no longer silently skipped when
44815
 
+  run outside of a build directory.
44816
 
+
44817
 
+- Issue #8746: Add additional tests for os.chflags() and os.lchflags().
44818
 
+  Patch by Garrett Cooper.
44819
 
+
44820
 
+- Issue #10736: Fix test_ttk test_widgets failures with Cocoa Tk 8.5.9
44821
 
+  on Mac OS X.  (Patch by Ronald Oussoren)
44822
 
+
44823
 
+- Issue #12057: Add tests for ISO 2022 codecs (iso2022_jp, iso2022_jp_2,
44824
 
+  iso2022_kr).
44825
 
+
44826
 
+Documentation
44827
 
+-------------
44828
 
+
44829
 
+- Issue #13402: Document absoluteness of sys.executable.
44830
 
+
44831
 
+- Issue #13883: PYTHONCASEOK also works on OS X, OS/2, and RiscOS.
44832
 
+
44833
 
+- Issue #2134: The tokenize documentation has been clarified to explain why
44834
 
+  all operator and delimiter tokens are treated as token.OP tokens.
44835
 
+
44836
 
+- Issue #13513: Fix io.IOBase documentation to correctly link to the
44837
 
+  io.IOBase.readline method instead of the readline module.
44838
 
+
44839
 
+- Issue #13237: Reorganise subprocess documentation to emphasise convenience
44840
 
+  functions and the most commonly needed arguments to Popen.
44841
 
+
44842
 
+- Issue #13141: Demonstrate recommended style for SocketServer examples.
44843
 
+
44844
 
 
44845
 
 What's New in Python 2.7.2?
44846
 
 ===========================
44847
 
@@ -106,6 +695,9 @@
44848
 
 Library
44849
 
 -------
44850
 
 
44851
 
+- Issue #12590: IDLE editor window now always displays the first line
44852
 
+  when opening a long file.  With Tk 8.5, the first line was hidden.
44853
 
+
44854
 
 - Issue #12161: Cause StringIO.getvalue() to raise a ValueError when used on a
44855
 
   closed StringIO instance.
44856
 
 
44857
 
diff -r 8527427914a2 Misc/build.sh
44858
 
--- a/Misc/build.sh
44859
 
+++ /dev/null
44860
 
@@ -1,279 +0,0 @@
44861
 
-#!/bin/sh
44862
 
-
44863
 
-## Script to build and test the latest python from svn.  It basically
44864
 
-## does this:
44865
 
-##   svn up ; ./configure ; make ; make test ; make install ; cd Doc ; make
44866
 
-##
44867
 
-## Logs are kept and rsync'ed to the webhost.  If there are test failure(s),
44868
 
-## information about the failure(s) is mailed.
44869
 
-##
44870
 
-## The user must be a member of the webmaster group locally and on webhost.
44871
 
-##
44872
 
-## This script is run on the PSF's machine as user neal via crontab.
44873
 
-##
44874
 
-## Yes, this script would probably be easier in python, but then
44875
 
-## there's a bootstrap problem.  What if Python doesn't build?
44876
 
-##
44877
 
-## This script should be fairly clean Bourne shell, ie not too many
44878
 
-## bash-isms.  We should try to keep it portable to other Unixes.
44879
 
-## Even though it will probably only run on Linux.  I'm sure there are
44880
 
-## several GNU-isms currently (date +%s and readlink).
44881
 
-##
44882
 
-## Perhaps this script should be broken up into 2 (or more) components.
44883
 
-## Building doc is orthogonal to the rest of the python build/test.
44884
 
-##
44885
 
-
44886
 
-## FIXME: we should detect test hangs (eg, if they take more than 45 minutes)
44887
 
-
44888
 
-## FIXME: we should run valgrind
44889
 
-## FIXME: we should run code coverage
44890
 
-
44891
 
-## Utilities invoked in this script include:
44892
 
-##    basename, date, dirname, expr, grep, readlink, uname
44893
 
-##    cksum, make, mutt, rsync, svn
44894
 
-
44895
 
-## remember where did we started from
44896
 
-DIR=`dirname $0`
44897
 
-if [ "$DIR" = "" ]; then
44898
 
-   DIR="."
44899
 
-fi
44900
 
-
44901
 
-## make directory absolute
44902
 
-DIR=`readlink -f $DIR`
44903
 
-FULLPATHNAME="$DIR/`basename $0`"
44904
 
-## we want Misc/..
44905
 
-DIR=`dirname $DIR`
44906
 
-
44907
 
-## Configurable options
44908
 
-
44909
 
-FAILURE_SUBJECT="Python Regression Test Failures"
44910
 
-#FAILURE_MAILTO="YOUR_ACCOUNT@gmail.com"
44911
 
-FAILURE_MAILTO="python-checkins@python.org"
44912
 
-#FAILURE_CC="optional--uncomment and set to desired address"
44913
 
-
44914
 
-REMOTE_SYSTEM="neal@dinsdale.python.org"
44915
 
-REMOTE_DIR="/data/ftp.python.org/pub/docs.python.org/dev/"
44916
 
-RESULT_FILE="$DIR/build/index.html"
44917
 
-INSTALL_DIR="/tmp/python-test/local"
44918
 
-RSYNC_OPTS="-C -e ssh -rlogD"
44919
 
-
44920
 
-# Always run the installed version of Python.
44921
 
-PYTHON=$INSTALL_DIR/bin/python
44922
 
-
44923
 
-# Python options and regression test program that should always be run.
44924
 
-REGRTEST_ARGS="-E -tt $INSTALL_DIR/lib/python2.7/test/regrtest.py"
44925
 
-
44926
 
-REFLOG="build/reflog.txt.out"
44927
 
-# These tests are not stable and falsely report leaks sometimes.
44928
 
-# The entire leak report will be mailed if any test not in this list leaks.
44929
 
-# Note: test_XXX (none currently) really leak, but are disabled
44930
 
-# so we don't send spam.  Any test which really leaks should only 
44931
 
-# be listed here if there are also test cases under Lib/test/leakers.
44932
 
-LEAKY_TESTS="test_(asynchat|cmd_line|docxmlrpc|dumbdbm|file|ftplib|httpservers|imaplib|popen2|socket|smtplib|sys|telnetlib|threadedtempfile|threading|threadsignals|xmlrpc)"
44933
 
-
44934
 
-# Skip these tests altogether when looking for leaks.  These tests
44935
 
-# do not need to be stored above in LEAKY_TESTS too.
44936
 
-# test_compiler almost never finishes with the same number of refs
44937
 
-# since it depends on other modules, skip it.
44938
 
-# test_logging causes hangs, skip it.
44939
 
-# KBK 21Apr09: test_httpservers causes hangs, skip for now.
44940
 
-LEAKY_SKIPS="-x test_compiler test_logging test_httpservers"
44941
 
-
44942
 
-# Change this flag to "yes" for old releases to only update/build the docs.
44943
 
-BUILD_DISABLED="no"
44944
 
-
44945
 
-## utility functions
44946
 
-current_time() {
44947
 
-    date +%s
44948
 
-}
44949
 
-
44950
 
-update_status() {
44951
 
-    now=`current_time`
44952
 
-    time=`expr $now - $3`
44953
 
-    echo "<li><a href=\"$2\">$1</a> <font size=\"-1\">($time seconds)</font></li>" >> $RESULT_FILE
44954
 
-}
44955
 
-
44956
 
-place_summary_first() {
44957
 
-    testf=$1
44958
 
-    sed -n '/^[0-9][0-9]* tests OK\./,$p' < $testf \
44959
 
-        | egrep -v '\[[0-9]+ refs\]' > $testf.tmp
44960
 
-    echo "" >> $testf.tmp
44961
 
-    cat $testf >> $testf.tmp
44962
 
-    mv $testf.tmp $testf
44963
 
-}
44964
 
-
44965
 
-count_failures () {
44966
 
-    testf=$1
44967
 
-    n=`grep -ic " failed:" $testf`
44968
 
-    if [ $n -eq 1 ] ; then
44969
 
-        n=`grep " failed:" $testf | sed -e 's/ .*//'`
44970
 
-    fi
44971
 
-    echo $n
44972
 
-}
44973
 
-
44974
 
-mail_on_failure() {
44975
 
-    if [ "$NUM_FAILURES" != "0" ]; then
44976
 
-        dest=$FAILURE_MAILTO
44977
 
-        # FAILURE_CC is optional.
44978
 
-        if [ "$FAILURE_CC" != "" ]; then
44979
 
-            dest="$dest -c $FAILURE_CC"
44980
 
-        fi
44981
 
-        if [ "x$3" != "x" ] ; then
44982
 
-            (echo "More important issues:"
44983
 
-             echo "----------------------"
44984
 
-             egrep -v "$3" < $2
44985
 
-             echo ""
44986
 
-             echo "Less important issues:"
44987
 
-             echo "----------------------"
44988
 
-             egrep "$3" < $2)
44989
 
-        else
44990
 
-            cat $2
44991
 
-        fi | mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $dest
44992
 
-    fi
44993
 
-}
44994
 
-
44995
 
-## setup
44996
 
-cd $DIR
44997
 
-make clobber > /dev/null 2>&1
44998
 
-cp -p Modules/Setup.dist Modules/Setup
44999
 
-# But maybe there was no Makefile - we are only building docs. Clear build:
45000
 
-rm -rf build/
45001
 
-mkdir -p build
45002
 
-rm -rf $INSTALL_DIR
45003
 
-## get the path we are building
45004
 
-repo_path=$(grep "url=" .svn/entries | sed -e s/\\W*url=// -e s/\"//g)
45005
 
-
45006
 
-## create results file
45007
 
-TITLE="Automated Python Build Results"
45008
 
-echo "<html>" >> $RESULT_FILE
45009
 
-echo "  <head>" >> $RESULT_FILE
45010
 
-echo "    <title>$TITLE</title>" >> $RESULT_FILE
45011
 
-echo "    <meta http-equiv=\"refresh\" content=\"43200\">" >> $RESULT_FILE
45012
 
-echo "  </head>" >> $RESULT_FILE
45013
 
-echo "<body>" >> $RESULT_FILE
45014
 
-echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE
45015
 
-echo "<table>" >> $RESULT_FILE
45016
 
-echo "  <tr>" >> $RESULT_FILE
45017
 
-echo "    <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE
45018
 
-echo "  </tr><tr>" >> $RESULT_FILE
45019
 
-echo "    <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE
45020
 
-echo "  </tr><tr>" >> $RESULT_FILE
45021
 
-echo "    <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE
45022
 
-echo "  </tr><tr>" >> $RESULT_FILE
45023
 
-echo "    <td>URL:</td><td>$repo_path</td>" >> $RESULT_FILE
45024
 
-echo "  </tr>" >> $RESULT_FILE
45025
 
-echo "</table>" >> $RESULT_FILE
45026
 
-echo "<ul>" >> $RESULT_FILE
45027
 
-
45028
 
-## update, build, and test
45029
 
-ORIG_CHECKSUM=`cksum $FULLPATHNAME`
45030
 
-F=svn-update.out
45031
 
-start=`current_time`
45032
 
-svn update >& build/$F
45033
 
-err=$?
45034
 
-update_status "Updating" "$F" $start
45035
 
-if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then
45036
 
-    ## FIXME: we should check if this file has changed.
45037
 
-    ##  If it has changed, we should re-run the script to pick up changes.
45038
 
-    if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then
45039
 
-        exec $FULLPATHNAME $@
45040
 
-    fi
45041
 
-
45042
 
-    F=svn-stat.out
45043
 
-    start=`current_time`
45044
 
-    svn stat >& build/$F
45045
 
-    ## ignore some of the diffs
45046
 
-    NUM_DIFFS=`egrep -vc '^.      (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F`
45047
 
-    update_status "svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start
45048
 
-
45049
 
-    F=configure.out
45050
 
-    start=`current_time`
45051
 
-    ./configure --prefix=$INSTALL_DIR --with-pydebug >& build/$F
45052
 
-    err=$?
45053
 
-    update_status "Configuring" "$F" $start
45054
 
-    if [ $err = 0 ]; then
45055
 
-        F=make.out
45056
 
-        start=`current_time`
45057
 
-        make >& build/$F
45058
 
-        err=$?
45059
 
-        warnings=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"`
45060
 
-        update_status "Building ($warnings warnings)" "$F" $start
45061
 
-        if [ $err = 0 ]; then
45062
 
-            ## make install
45063
 
-            F=make-install.out
45064
 
-            start=`current_time`
45065
 
-            make install >& build/$F
45066
 
-            update_status "Installing" "$F" $start
45067
 
-
45068
 
-            if [ ! -x $PYTHON ]; then
45069
 
-                ln -s ${PYTHON}2.* $PYTHON
45070
 
-            fi
45071
 
-
45072
 
-            ## make and run basic tests
45073
 
-            F=make-test.out
45074
 
-            start=`current_time`
45075
 
-            $PYTHON $REGRTEST_ARGS -W -u urlfetch >& build/$F
45076
 
-            NUM_FAILURES=`count_failures build/$F`
45077
 
-            place_summary_first build/$F
45078
 
-            update_status "Testing basics ($NUM_FAILURES failures)" "$F" $start
45079
 
-            mail_on_failure "basics" build/$F
45080
 
-
45081
 
-            F=make-test-opt.out
45082
 
-            start=`current_time`
45083
 
-            $PYTHON -O $REGRTEST_ARGS -W -u urlfetch >& build/$F
45084
 
-            NUM_FAILURES=`count_failures build/$F`
45085
 
-            place_summary_first build/$F
45086
 
-            update_status "Testing opt ($NUM_FAILURES failures)" "$F" $start
45087
 
-            mail_on_failure "opt" build/$F
45088
 
-
45089
 
-            ## run the tests looking for leaks
45090
 
-            F=make-test-refleak.out
45091
 
-            start=`current_time`
45092
 
-            ## ensure that the reflog exists so the grep doesn't fail
45093
 
-            touch $REFLOG
45094
 
-            $PYTHON $REGRTEST_ARGS -R 4:3:$REFLOG -u network $LEAKY_SKIPS >& build/$F
45095
 
-            LEAK_PAT="($LEAKY_TESTS|sum=0)"
45096
 
-            NUM_FAILURES=`egrep -vc "$LEAK_PAT" $REFLOG`
45097
 
-            place_summary_first build/$F
45098
 
-            update_status "Testing refleaks ($NUM_FAILURES failures)" "$F" $start
45099
 
-            mail_on_failure "refleak" $REFLOG "$LEAK_PAT"
45100
 
-
45101
 
-            ## now try to run all the tests
45102
 
-            F=make-testall.out
45103
 
-            start=`current_time`
45104
 
-            ## skip curses when running from cron since there's no terminal
45105
 
-            ## skip sound since it's not setup on the PSF box (/dev/dsp)
45106
 
-            $PYTHON $REGRTEST_ARGS -W -uall -x test_curses test_linuxaudiodev test_ossaudiodev >& build/$F
45107
 
-            NUM_FAILURES=`count_failures build/$F`
45108
 
-            place_summary_first build/$F
45109
 
-            update_status "Testing all except curses and sound ($NUM_FAILURES failures)" "$F" $start
45110
 
-            mail_on_failure "all" build/$F
45111
 
-        fi
45112
 
-    fi
45113
 
-fi
45114
 
-
45115
 
-
45116
 
-## make doc
45117
 
-cd $DIR/Doc
45118
 
-F="make-doc.out"
45119
 
-start=`current_time`
45120
 
-make clean > ../build/$F 2>&1
45121
 
-make checkout html >> ../build/$F 2>&1
45122
 
-err=$?
45123
 
-update_status "Making doc" "$F" $start
45124
 
-if [ $err != 0 ]; then
45125
 
-    NUM_FAILURES=1
45126
 
-    mail_on_failure "doc" ../build/$F
45127
 
-fi
45128
 
-
45129
 
-echo "</ul>" >> $RESULT_FILE
45130
 
-echo "</body>" >> $RESULT_FILE
45131
 
-echo "</html>" >> $RESULT_FILE
45132
 
-
45133
 
-## copy results
45134
 
-## (not used anymore, the daily build is now done directly on the server)
45135
 
-#chgrp -R webmaster build/html
45136
 
-#chmod -R g+w build/html
45137
 
-#rsync $RSYNC_OPTS build/html/* $REMOTE_SYSTEM:$REMOTE_DIR
45138
 
-#cd ../build
45139
 
-#rsync $RSYNC_OPTS index.html *.out $REMOTE_SYSTEM:$REMOTE_DIR/results/
45140
 
diff -r 8527427914a2 Modules/_bsddb.c
45141
 
--- a/Modules/_bsddb.c
45142
 
+++ b/Modules/_bsddb.c
45143
 
@@ -7257,7 +7257,7 @@
45144
 
     }
45145
 
     CHECK_ENV_NOT_CLOSED(self);
45146
 
     MYDB_BEGIN_ALLOW_THREADS;
45147
 
-    err = self->db_env->rep_elect(self->db_env, nvotes, nvotes, 0);
45148
 
+    err = self->db_env->rep_elect(self->db_env, nsites, nvotes, 0);
45149
 
     MYDB_END_ALLOW_THREADS;
45150
 
     RETURN_IF_ERR();
45151
 
     RETURN_NONE();
45152
 
@@ -8795,7 +8795,7 @@
45153
 
     {"txn_recover",     (PyCFunction)DBEnv_txn_recover,     METH_NOARGS},
45154
 
 #if (DBVER < 48)
45155
 
     {"set_rpc_server",  (PyCFunction)DBEnv_set_rpc_server,
45156
 
-        METH_VARARGS||METH_KEYWORDS},
45157
 
+        METH_VARARGS|METH_KEYWORDS},
45158
 
 #endif
45159
 
 #if (DBVER >= 43)
45160
 
     {"set_mp_max_openfd", (PyCFunction)DBEnv_set_mp_max_openfd, METH_VARARGS},
45161
 
diff -r 8527427914a2 Modules/_collectionsmodule.c
45162
 
--- a/Modules/_collectionsmodule.c
45163
 
+++ b/Modules/_collectionsmodule.c
45164
 
@@ -1475,8 +1475,10 @@
45165
 
     {
45166
 
         int status = Py_ReprEnter(dd->default_factory);
45167
 
         if (status != 0) {
45168
 
-            if (status < 0)
45169
 
+            if (status < 0) {
45170
 
+                Py_DECREF(baserepr);
45171
 
                 return NULL;
45172
 
+            }
45173
 
             defrepr = PyString_FromString("...");
45174
 
         }
45175
 
         else
45176
 
diff -r 8527427914a2 Modules/_csv.c
45177
 
--- a/Modules/_csv.c
45178
 
+++ b/Modules/_csv.c
45179
 
@@ -1184,7 +1184,11 @@
45180
 
         else {
45181
 
             PyObject *str;
45182
 
 
45183
 
-            str = PyObject_Str(field);
45184
 
+            if (PyFloat_Check(field)) {
45185
 
+                str = PyObject_Repr(field);
45186
 
+            } else {
45187
 
+                str = PyObject_Str(field);
45188
 
+            }
45189
 
             Py_DECREF(field);
45190
 
             if (str == NULL)
45191
 
                 return NULL;
45192
 
diff -r 8527427914a2 Modules/_ctypes/_ctypes.c
45193
 
--- a/Modules/_ctypes/_ctypes.c
45194
 
+++ b/Modules/_ctypes/_ctypes.c
45195
 
@@ -2576,8 +2576,10 @@
45196
 
     view->ndim = dict->ndim;
45197
 
     view->shape = dict->shape;
45198
 
     view->itemsize = self->b_size;
45199
 
-    for (i = 0; i < view->ndim; ++i) {
45200
 
-        view->itemsize /= dict->shape[i];
45201
 
+    if (view->itemsize) {
45202
 
+        for (i = 0; i < view->ndim; ++i) {
45203
 
+            view->itemsize /= dict->shape[i];
45204
 
+        }
45205
 
     }
45206
 
     view->strides = NULL;
45207
 
     view->suboffsets = NULL;
45208
 
@@ -4676,6 +4678,7 @@
45209
 
     if (!PyType_Check(itemtype)) {
45210
 
         PyErr_SetString(PyExc_TypeError,
45211
 
                         "Expected a type object");
45212
 
+        Py_DECREF(key);
45213
 
         return NULL;
45214
 
     }
45215
 
 #ifdef MS_WIN64
45216
 
diff -r 8527427914a2 Modules/_ctypes/callbacks.c
45217
 
--- a/Modules/_ctypes/callbacks.c
45218
 
+++ b/Modules/_ctypes/callbacks.c
45219
 
@@ -18,6 +18,7 @@
45220
 
 CThunkObject_dealloc(PyObject *_self)
45221
 
 {
45222
 
     CThunkObject *self = (CThunkObject *)_self;
45223
 
+    PyObject_GC_UnTrack(self);
45224
 
     Py_XDECREF(self->converters);
45225
 
     Py_XDECREF(self->callable);
45226
 
     Py_XDECREF(self->restype);
45227
 
diff -r 8527427914a2 Modules/_ctypes/libffi/src/dlmalloc.c
45228
 
--- a/Modules/_ctypes/libffi/src/dlmalloc.c
45229
 
+++ b/Modules/_ctypes/libffi/src/dlmalloc.c
45230
 
@@ -457,6 +457,11 @@
45231
 
 #define LACKS_ERRNO_H
45232
 
 #define MALLOC_FAILURE_ACTION
45233
 
 #define MMAP_CLEARS 0 /* WINCE and some others apparently don't clear */
45234
 
+#elif !defined _GNU_SOURCE
45235
 
+/* mremap() on Linux requires this via sys/mman.h
45236
 
+ * See roundup issue 10309
45237
 
+ */
45238
 
+#define _GNU_SOURCE 1
45239
 
 #endif  /* WIN32 */
45240
 
 
45241
 
 #if defined(DARWIN) || defined(_DARWIN)
45242
 
diff -r 8527427914a2 Modules/_ctypes/stgdict.c
45243
 
--- a/Modules/_ctypes/stgdict.c
45244
 
+++ b/Modules/_ctypes/stgdict.c
45245
 
@@ -494,14 +494,33 @@
45246
 
             char *fieldfmt = dict->format ? dict->format : "B";
45247
 
             char *fieldname = PyString_AsString(name);
45248
 
             char *ptr;
45249
 
-            Py_ssize_t len = strlen(fieldname) + strlen(fieldfmt);
45250
 
-            char *buf = alloca(len + 2 + 1);
45251
 
+            Py_ssize_t len; 
45252
 
+            char *buf;
45253
 
 
45254
 
+            if (fieldname == NULL)
45255
 
+            {
45256
 
+                PyErr_Format(PyExc_TypeError,
45257
 
+                             "structure field name must be string not %s",
45258
 
+                             name->ob_type->tp_name);
45259
 
+                                
45260
 
+                Py_DECREF(pair);
45261
 
+                return -1;
45262
 
+            }
45263
 
+
45264
 
+            len = strlen(fieldname) + strlen(fieldfmt);
45265
 
+
45266
 
+            buf = PyMem_Malloc(len + 2 + 1);
45267
 
+            if (buf == NULL) {
45268
 
+                Py_DECREF(pair);
45269
 
+                PyErr_NoMemory();
45270
 
+                return -1;
45271
 
+            }
45272
 
             sprintf(buf, "%s:%s:", fieldfmt, fieldname);
45273
 
 
45274
 
             ptr = stgdict->format;
45275
 
             stgdict->format = _ctypes_alloc_format_string(stgdict->format, buf);
45276
 
             PyMem_Free(ptr);
45277
 
+            PyMem_Free(buf);
45278
 
 
45279
 
             if (stgdict->format == NULL) {
45280
 
                 Py_DECREF(pair);
45281
 
diff -r 8527427914a2 Modules/_elementtree.c
45282
 
--- a/Modules/_elementtree.c
45283
 
+++ b/Modules/_elementtree.c
45284
 
@@ -2915,19 +2915,25 @@
45285
 
 
45286
 
         "class ElementTree(ET.ElementTree):\n" /* public */
45287
 
         "  def parse(self, source, parser=None):\n"
45288
 
+        "    close_source = False\n"
45289
 
         "    if not hasattr(source, 'read'):\n"
45290
 
         "      source = open(source, 'rb')\n"
45291
 
-        "    if parser is not None:\n"
45292
 
-        "      while 1:\n"
45293
 
-        "        data = source.read(65536)\n"
45294
 
-        "        if not data:\n"
45295
 
-        "          break\n"
45296
 
-        "        parser.feed(data)\n"
45297
 
-        "      self._root = parser.close()\n"
45298
 
-        "    else:\n" 
45299
 
-        "      parser = cElementTree.XMLParser()\n"
45300
 
-        "      self._root = parser._parse(source)\n"
45301
 
-        "    return self._root\n"
45302
 
+        "      close_source = False\n"
45303
 
+        "    try:\n"
45304
 
+        "      if parser is not None:\n"
45305
 
+        "        while 1:\n"
45306
 
+        "          data = source.read(65536)\n"
45307
 
+        "          if not data:\n"
45308
 
+        "            break\n"
45309
 
+        "          parser.feed(data)\n"
45310
 
+        "        self._root = parser.close()\n"
45311
 
+        "      else:\n" 
45312
 
+        "        parser = cElementTree.XMLParser()\n"
45313
 
+        "        self._root = parser._parse(source)\n"
45314
 
+        "      return self._root\n"
45315
 
+        "    finally:\n"
45316
 
+        "      if close_source:\n"
45317
 
+        "        source.close()\n"
45318
 
         "cElementTree.ElementTree = ElementTree\n"
45319
 
 
45320
 
         "def iter(node, tag=None):\n" /* helper */
45321
 
@@ -2957,11 +2963,14 @@
45322
 
         "class iterparse(object):\n"
45323
 
         " root = None\n"
45324
 
         " def __init__(self, file, events=None):\n"
45325
 
+        "  self._close_file = False\n"
45326
 
         "  if not hasattr(file, 'read'):\n"
45327
 
         "    file = open(file, 'rb')\n"
45328
 
+        "    self._close_file = True\n"
45329
 
         "  self._file = file\n"
45330
 
         "  self._events = []\n"
45331
 
         "  self._index = 0\n"
45332
 
+        "  self._error = None\n"
45333
 
         "  self.root = self._root = None\n"
45334
 
         "  b = cElementTree.TreeBuilder()\n"
45335
 
         "  self._parser = cElementTree.XMLParser(b)\n"
45336
 
@@ -2970,22 +2979,31 @@
45337
 
         "  while 1:\n"
45338
 
         "    try:\n"
45339
 
         "      item = self._events[self._index]\n"
45340
 
+        "      self._index += 1\n"
45341
 
+        "      return item\n"
45342
 
         "    except IndexError:\n"
45343
 
-        "      if self._parser is None:\n"
45344
 
-        "        self.root = self._root\n"
45345
 
-        "        raise StopIteration\n"
45346
 
-        "      # load event buffer\n"
45347
 
-        "      del self._events[:]\n"
45348
 
-        "      self._index = 0\n"
45349
 
-        "      data = self._file.read(16384)\n"
45350
 
-        "      if data:\n"
45351
 
+        "      pass\n"
45352
 
+        "    if self._error:\n"
45353
 
+        "      e = self._error\n"
45354
 
+        "      self._error = None\n"
45355
 
+        "      raise e\n"
45356
 
+        "    if self._parser is None:\n"
45357
 
+        "      self.root = self._root\n"
45358
 
+        "      if self._close_file:\n"
45359
 
+        "        self._file.close()\n"
45360
 
+        "      raise StopIteration\n"
45361
 
+        "    # load event buffer\n"
45362
 
+        "    del self._events[:]\n"
45363
 
+        "    self._index = 0\n"
45364
 
+        "    data = self._file.read(16384)\n"
45365
 
+        "    if data:\n"
45366
 
+        "      try:\n"
45367
 
         "        self._parser.feed(data)\n"
45368
 
-        "      else:\n"
45369
 
-        "        self._root = self._parser.close()\n"
45370
 
-        "        self._parser = None\n"
45371
 
+        "      except SyntaxError as exc:\n"
45372
 
+        "        self._error = exc\n"
45373
 
         "    else:\n"
45374
 
-        "      self._index = self._index + 1\n"
45375
 
-        "      return item\n"
45376
 
+        "      self._root = self._parser.close()\n"
45377
 
+        "      self._parser = None\n"
45378
 
         " def __iter__(self):\n"
45379
 
         "  return self\n"
45380
 
         "cElementTree.iterparse = iterparse\n"
45381
 
diff -r 8527427914a2 Modules/_io/bufferedio.c
45382
 
--- a/Modules/_io/bufferedio.c
45383
 
+++ b/Modules/_io/bufferedio.c
45384
 
@@ -550,7 +550,7 @@
45385
 
 
45386
 
 /* Forward decls */
45387
 
 static PyObject *
45388
 
-_bufferedwriter_flush_unlocked(buffered *, int);
45389
 
+_bufferedwriter_flush_unlocked(buffered *);
45390
 
 static Py_ssize_t
45391
 
 _bufferedreader_fill_buffer(buffered *self);
45392
 
 static void
45393
 
@@ -571,6 +571,18 @@
45394
 
  * Helpers
45395
 
  */
45396
 
 
45397
 
+/* Sets the current error to BlockingIOError */
45398
 
+static void
45399
 
+_set_BlockingIOError(char *msg, Py_ssize_t written)
45400
 
+{
45401
 
+    PyObject *err;
45402
 
+    err = PyObject_CallFunction(PyExc_BlockingIOError, "isn",
45403
 
+                                errno, msg, written);
45404
 
+    if (err)
45405
 
+        PyErr_SetObject(PyExc_BlockingIOError, err);
45406
 
+    Py_XDECREF(err);
45407
 
+}
45408
 
+
45409
 
 /* Returns the address of the `written` member if a BlockingIOError was
45410
 
    raised, NULL otherwise. The error is always re-raised. */
45411
 
 static Py_ssize_t *
45412
 
@@ -721,6 +733,28 @@
45413
 
  */
45414
 
 
45415
 
 static PyObject *
45416
 
+buffered_flush_and_rewind_unlocked(buffered *self)
45417
 
+{
45418
 
+    PyObject *res;
45419
 
+
45420
 
+    res = _bufferedwriter_flush_unlocked(self);
45421
 
+    if (res == NULL)
45422
 
+        return NULL;
45423
 
+    Py_DECREF(res);
45424
 
+
45425
 
+    if (self->readable) {
45426
 
+        /* Rewind the raw stream so that its position corresponds to
45427
 
+           the current logical position. */
45428
 
+        Py_off_t n;
45429
 
+        n = _buffered_raw_seek(self, -RAW_OFFSET(self), 1);
45430
 
+        _bufferedreader_reset_buf(self);
45431
 
+        if (n == -1)
45432
 
+            return NULL;
45433
 
+    }
45434
 
+    Py_RETURN_NONE;
45435
 
+}
45436
 
+
45437
 
+static PyObject *
45438
 
 buffered_flush(buffered *self, PyObject *args)
45439
 
 {
45440
 
     PyObject *res;
45441
 
@@ -730,16 +764,7 @@
45442
 
 
45443
 
     if (!ENTER_BUFFERED(self))
45444
 
         return NULL;
45445
 
-    res = _bufferedwriter_flush_unlocked(self, 0);
45446
 
-    if (res != NULL && self->readable) {
45447
 
-        /* Rewind the raw stream so that its position corresponds to
45448
 
-           the current logical position. */
45449
 
-        Py_off_t n;
45450
 
-        n = _buffered_raw_seek(self, -RAW_OFFSET(self), 1);
45451
 
-        if (n == -1)
45452
 
-            Py_CLEAR(res);
45453
 
-        _bufferedreader_reset_buf(self);
45454
 
-    }
45455
 
+    res = buffered_flush_and_rewind_unlocked(self);
45456
 
     LEAVE_BUFFERED(self)
45457
 
 
45458
 
     return res;
45459
 
@@ -760,7 +785,7 @@
45460
 
         return NULL;
45461
 
 
45462
 
     if (self->writable) {
45463
 
-        res = _bufferedwriter_flush_unlocked(self, 1);
45464
 
+        res = buffered_flush_and_rewind_unlocked(self);
45465
 
         if (res == NULL)
45466
 
             goto end;
45467
 
         Py_CLEAR(res);
45468
 
@@ -795,19 +820,18 @@
45469
 
         if (!ENTER_BUFFERED(self))
45470
 
             return NULL;
45471
 
         res = _bufferedreader_read_all(self);
45472
 
-        LEAVE_BUFFERED(self)
45473
 
     }
45474
 
     else {
45475
 
         res = _bufferedreader_read_fast(self, n);
45476
 
-        if (res == Py_None) {
45477
 
-            Py_DECREF(res);
45478
 
-            if (!ENTER_BUFFERED(self))
45479
 
-                return NULL;
45480
 
-            res = _bufferedreader_read_generic(self, n);
45481
 
-            LEAVE_BUFFERED(self)
45482
 
-        }
45483
 
+        if (res != Py_None)
45484
 
+            return res;
45485
 
+        Py_DECREF(res);
45486
 
+        if (!ENTER_BUFFERED(self))
45487
 
+            return NULL;
45488
 
+        res = _bufferedreader_read_generic(self, n);
45489
 
     }
45490
 
 
45491
 
+    LEAVE_BUFFERED(self)
45492
 
     return res;
45493
 
 }
45494
 
 
45495
 
@@ -833,13 +857,6 @@
45496
 
     if (!ENTER_BUFFERED(self))
45497
 
         return NULL;
45498
 
     
45499
 
-    if (self->writable) {
45500
 
-        res = _bufferedwriter_flush_unlocked(self, 1);
45501
 
-        if (res == NULL)
45502
 
-            goto end;
45503
 
-        Py_CLEAR(res);
45504
 
-    }
45505
 
-
45506
 
     /* Return up to n bytes.  If at least one byte is buffered, we
45507
 
        only return buffered bytes.  Otherwise, we do one raw read. */
45508
 
 
45509
 
@@ -859,6 +876,13 @@
45510
 
         goto end;
45511
 
     }
45512
 
 
45513
 
+    if (self->writable) {
45514
 
+        res = buffered_flush_and_rewind_unlocked(self);
45515
 
+        if (res == NULL)
45516
 
+            goto end;
45517
 
+        Py_DECREF(res);
45518
 
+    }
45519
 
+
45520
 
     /* Fill the buffer from the raw stream, and copy it to the result. */
45521
 
     _bufferedreader_reset_buf(self);
45522
 
     r = _bufferedreader_fill_buffer(self);
45523
 
@@ -881,24 +905,10 @@
45524
 
 static PyObject *
45525
 
 buffered_readinto(buffered *self, PyObject *args)
45526
 
 {
45527
 
-    PyObject *res = NULL;
45528
 
-
45529
 
     CHECK_INITIALIZED(self)
45530
 
     
45531
 
-    /* TODO: use raw.readinto() instead! */
45532
 
-    if (self->writable) {
45533
 
-        if (!ENTER_BUFFERED(self))
45534
 
-            return NULL;
45535
 
-        res = _bufferedwriter_flush_unlocked(self, 0);
45536
 
-        LEAVE_BUFFERED(self)
45537
 
-        if (res == NULL)
45538
 
-            goto end;
45539
 
-        Py_DECREF(res);
45540
 
-    }
45541
 
-    res = bufferediobase_readinto((PyObject *)self, args);
45542
 
-
45543
 
-end:
45544
 
-    return res;
45545
 
+    /* TODO: use raw.readinto() (or a direct copy from our buffer) instead! */
45546
 
+    return bufferediobase_readinto((PyObject *)self, args);
45547
 
 }
45548
 
 
45549
 
 static PyObject *
45550
 
@@ -936,12 +946,6 @@
45551
 
         goto end_unlocked;
45552
 
 
45553
 
     /* Now we try to get some more from the raw stream */
45554
 
-    if (self->writable) {
45555
 
-        res = _bufferedwriter_flush_unlocked(self, 1);
45556
 
-        if (res == NULL)
45557
 
-            goto end;
45558
 
-        Py_CLEAR(res);
45559
 
-    }
45560
 
     chunks = PyList_New(0);
45561
 
     if (chunks == NULL)
45562
 
         goto end;
45563
 
@@ -955,9 +959,16 @@
45564
 
         }
45565
 
         Py_CLEAR(res);
45566
 
         written += n;
45567
 
+        self->pos += n;
45568
 
         if (limit >= 0)
45569
 
             limit -= n;
45570
 
     }
45571
 
+    if (self->writable) {
45572
 
+        PyObject *r = buffered_flush_and_rewind_unlocked(self);
45573
 
+        if (r == NULL)
45574
 
+            goto end;
45575
 
+        Py_DECREF(r);
45576
 
+    }
45577
 
 
45578
 
     for (;;) {
45579
 
         _bufferedreader_reset_buf(self);
45580
 
@@ -1088,7 +1099,7 @@
45581
 
 
45582
 
     /* Fallback: invoke raw seek() method and clear buffer */
45583
 
     if (self->writable) {
45584
 
-        res = _bufferedwriter_flush_unlocked(self, 0);
45585
 
+        res = _bufferedwriter_flush_unlocked(self);
45586
 
         if (res == NULL)
45587
 
             goto end;
45588
 
         Py_CLEAR(res);
45589
 
@@ -1126,20 +1137,11 @@
45590
 
         return NULL;
45591
 
 
45592
 
     if (self->writable) {
45593
 
-        res = _bufferedwriter_flush_unlocked(self, 0);
45594
 
+        res = buffered_flush_and_rewind_unlocked(self);
45595
 
         if (res == NULL)
45596
 
             goto end;
45597
 
         Py_CLEAR(res);
45598
 
     }
45599
 
-    if (self->readable) {
45600
 
-        if (pos == Py_None) {
45601
 
-            /* Rewind the raw stream so that its position corresponds to
45602
 
-               the current logical position. */
45603
 
-            if (_buffered_raw_seek(self, -RAW_OFFSET(self), 1) == -1)
45604
 
-                goto end;
45605
 
-        }
45606
 
-        _bufferedreader_reset_buf(self);
45607
 
-    }
45608
 
     res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_truncate, pos, NULL);
45609
 
     if (res == NULL)
45610
 
         goto end;
45611
 
@@ -1341,17 +1343,18 @@
45612
 
             Py_DECREF(chunks);
45613
 
             return NULL;
45614
 
         }
45615
 
+        self->pos += current_size;
45616
 
     }
45617
 
-    _bufferedreader_reset_buf(self);
45618
 
     /* We're going past the buffer's bounds, flush it */
45619
 
     if (self->writable) {
45620
 
-        res = _bufferedwriter_flush_unlocked(self, 1);
45621
 
+        res = buffered_flush_and_rewind_unlocked(self);
45622
 
         if (res == NULL) {
45623
 
             Py_DECREF(chunks);
45624
 
             return NULL;
45625
 
         }
45626
 
         Py_CLEAR(res);
45627
 
     }
45628
 
+    _bufferedreader_reset_buf(self);
45629
 
     while (1) {
45630
 
         if (data) {
45631
 
             if (PyList_Append(chunks, data) < 0) {
45632
 
@@ -1434,6 +1437,14 @@
45633
 
         memcpy(out, self->buffer + self->pos, current_size);
45634
 
         remaining -= current_size;
45635
 
         written += current_size;
45636
 
+        self->pos += current_size;
45637
 
+    }
45638
 
+    /* Flush the write buffer if necessary */
45639
 
+    if (self->writable) {
45640
 
+        PyObject *r = buffered_flush_and_rewind_unlocked(self);
45641
 
+        if (r == NULL)
45642
 
+            goto error;
45643
 
+        Py_DECREF(r);
45644
 
     }
45645
 
     _bufferedreader_reset_buf(self);
45646
 
     while (remaining > 0) {
45647
 
@@ -1684,6 +1695,7 @@
45648
 
     Py_buffer buf;
45649
 
     PyObject *memobj, *res;
45650
 
     Py_ssize_t n;
45651
 
+    int errnum;
45652
 
     /* NOTE: the buffer needn't be released as its object is NULL. */
45653
 
     if (PyBuffer_FillInfo(&buf, NULL, start, len, 1, PyBUF_CONTIG_RO) == -1)
45654
 
         return -1;
45655
 
@@ -1696,11 +1708,21 @@
45656
 
        raised (see issue #10956).
45657
 
     */
45658
 
     do {
45659
 
+        errno = 0;
45660
 
         res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_write, memobj, NULL);
45661
 
+        errnum = errno;
45662
 
     } while (res == NULL && _trap_eintr());
45663
 
     Py_DECREF(memobj);
45664
 
     if (res == NULL)
45665
 
         return -1;
45666
 
+    if (res == Py_None) {
45667
 
+        /* Non-blocking stream would have blocked. Special return code!
45668
 
+           Being paranoid we reset errno in case it is changed by code
45669
 
+           triggered by a decref.  errno is used by _set_BlockingIOError(). */
45670
 
+        Py_DECREF(res);
45671
 
+        errno = errnum;
45672
 
+        return -2;
45673
 
+    }
45674
 
     n = PyNumber_AsSsize_t(res, PyExc_ValueError);
45675
 
     Py_DECREF(res);
45676
 
     if (n < 0 || n > len) {
45677
 
@@ -1717,7 +1739,7 @@
45678
 
 /* `restore_pos` is 1 if we need to restore the raw stream position at
45679
 
    the end, 0 otherwise. */
45680
 
 static PyObject *
45681
 
-_bufferedwriter_flush_unlocked(buffered *self, int restore_pos)
45682
 
+_bufferedwriter_flush_unlocked(buffered *self)
45683
 
 {
45684
 
     Py_ssize_t written = 0;
45685
 
     Py_off_t n, rewind;
45686
 
@@ -1739,14 +1761,11 @@
45687
 
             Py_SAFE_DOWNCAST(self->write_end - self->write_pos,
45688
 
                              Py_off_t, Py_ssize_t));
45689
 
         if (n == -1) {
45690
 
-            Py_ssize_t *w = _buffered_check_blocking_error();
45691
 
-            if (w == NULL)
45692
 
-                goto error;
45693
 
-            self->write_pos += *w;
45694
 
-            self->raw_pos = self->write_pos;
45695
 
-            written += *w;
45696
 
-            *w = written;
45697
 
-            /* Already re-raised */
45698
 
+            goto error;
45699
 
+        }
45700
 
+        else if (n == -2) {
45701
 
+            _set_BlockingIOError("write could not complete without blocking",
45702
 
+                                 0);
45703
 
             goto error;
45704
 
         }
45705
 
         self->write_pos += n;
45706
 
@@ -1759,16 +1778,6 @@
45707
 
             goto error;
45708
 
     }
45709
 
 
45710
 
-    if (restore_pos) {
45711
 
-        Py_off_t forward = rewind - written;
45712
 
-        if (forward != 0) {
45713
 
-            n = _buffered_raw_seek(self, forward, 1);
45714
 
-            if (n < 0) {
45715
 
-                goto error;
45716
 
-            }
45717
 
-            self->raw_pos += forward;
45718
 
-        }
45719
 
-    }
45720
 
     _bufferedwriter_reset_buf(self);
45721
 
 
45722
 
 end:
45723
 
@@ -1821,7 +1830,7 @@
45724
 
     }
45725
 
 
45726
 
     /* First write the current buffer */
45727
 
-    res = _bufferedwriter_flush_unlocked(self, 0);
45728
 
+    res = _bufferedwriter_flush_unlocked(self);
45729
 
     if (res == NULL) {
45730
 
         Py_ssize_t *w = _buffered_check_blocking_error();
45731
 
         if (w == NULL)
45732
 
@@ -1844,14 +1853,19 @@
45733
 
             PyErr_Clear();
45734
 
             memcpy(self->buffer + self->write_end, buf.buf, buf.len);
45735
 
             self->write_end += buf.len;
45736
 
+            self->pos += buf.len;
45737
 
             written = buf.len;
45738
 
             goto end;
45739
 
         }
45740
 
         /* Buffer as much as possible. */
45741
 
         memcpy(self->buffer + self->write_end, buf.buf, avail);
45742
 
         self->write_end += avail;
45743
 
-        /* Already re-raised */
45744
 
-        *w = avail;
45745
 
+        self->pos += avail;
45746
 
+        /* XXX Modifying the existing exception e using the pointer w
45747
 
+           will change e.characters_written but not e.args[2].
45748
 
+           Therefore we just replace with a new error. */
45749
 
+        _set_BlockingIOError("write could not complete without blocking",
45750
 
+                             avail);
45751
 
         goto error;
45752
 
     }
45753
 
     Py_CLEAR(res);
45754
 
@@ -1876,11 +1890,9 @@
45755
 
         Py_ssize_t n = _bufferedwriter_raw_write(
45756
 
             self, (char *) buf.buf + written, buf.len - written);
45757
 
         if (n == -1) {
45758
 
-            Py_ssize_t *w = _buffered_check_blocking_error();
45759
 
-            if (w == NULL)
45760
 
-                goto error;
45761
 
-            written += *w;
45762
 
-            remaining -= *w;
45763
 
+            goto error;
45764
 
+        } else if (n == -2) {
45765
 
+            /* Write failed because raw file is non-blocking */
45766
 
             if (remaining > self->buffer_size) {
45767
 
                 /* Can't buffer everything, still buffer as much as possible */
45768
 
                 memcpy(self->buffer,
45769
 
@@ -1888,8 +1900,9 @@
45770
 
                 self->raw_pos = 0;
45771
 
                 ADJUST_POSITION(self, self->buffer_size);
45772
 
                 self->write_end = self->buffer_size;
45773
 
-                *w = written + self->buffer_size;
45774
 
-                /* Already re-raised */
45775
 
+                written += self->buffer_size;
45776
 
+                _set_BlockingIOError("write could not complete without "
45777
 
+                                     "blocking", written);
45778
 
                 goto error;
45779
 
             }
45780
 
             PyErr_Clear();
45781
 
@@ -2180,6 +2193,11 @@
45782
 
 static PyObject *
45783
 
 bufferedrwpair_closed_get(rwpair *self, void *context)
45784
 
 {
45785
 
+    if (self->writer == NULL) {
45786
 
+        PyErr_SetString(PyExc_RuntimeError,
45787
 
+                "the BufferedRWPair object is being garbage-collected");
45788
 
+        return NULL;
45789
 
+    }
45790
 
     return PyObject_GetAttr((PyObject *) self->writer, _PyIO_str_closed);
45791
 
 }
45792
 
 
45793
 
diff -r 8527427914a2 Modules/_io/fileio.c
45794
 
--- a/Modules/_io/fileio.c
45795
 
+++ b/Modules/_io/fileio.c
45796
 
@@ -42,12 +42,6 @@
45797
 
 #define SMALLCHUNK BUFSIZ
45798
 
 #endif
45799
 
 
45800
 
-#if SIZEOF_INT < 4
45801
 
-#define BIGCHUNK  (512 * 32)
45802
 
-#else
45803
 
-#define BIGCHUNK  (512 * 1024)
45804
 
-#endif
45805
 
-
45806
 
 typedef struct {
45807
 
     PyObject_HEAD
45808
 
     int fd;
45809
 
@@ -474,7 +468,7 @@
45810
 
 fileio_readinto(fileio *self, PyObject *args)
45811
 
 {
45812
 
     Py_buffer pbuf;
45813
 
-    Py_ssize_t n;
45814
 
+    Py_ssize_t n, len;
45815
 
 
45816
 
     if (self->fd < 0)
45817
 
         return err_closed();
45818
 
@@ -485,9 +479,16 @@
45819
 
         return NULL;
45820
 
 
45821
 
     if (_PyVerify_fd(self->fd)) {
45822
 
+        len = pbuf.len;
45823
 
         Py_BEGIN_ALLOW_THREADS
45824
 
         errno = 0;
45825
 
-        n = read(self->fd, pbuf.buf, pbuf.len);
45826
 
+#if defined(MS_WIN64) || defined(MS_WINDOWS)
45827
 
+        if (len > INT_MAX)
45828
 
+            len = INT_MAX;
45829
 
+        n = read(self->fd, pbuf.buf, (int)len);
45830
 
+#else
45831
 
+        n = read(self->fd, pbuf.buf, len);
45832
 
+#endif
45833
 
         Py_END_ALLOW_THREADS
45834
 
     } else
45835
 
         n = -1;
45836
 
@@ -521,15 +522,10 @@
45837
 
         }
45838
 
     }
45839
 
 #endif
45840
 
-    if (currentsize > SMALLCHUNK) {
45841
 
-        /* Keep doubling until we reach BIGCHUNK;
45842
 
-           then keep adding BIGCHUNK. */
45843
 
-        if (currentsize <= BIGCHUNK)
45844
 
-            return currentsize + currentsize;
45845
 
-        else
45846
 
-            return currentsize + BIGCHUNK;
45847
 
-    }
45848
 
-    return currentsize + SMALLCHUNK;
45849
 
+    /* Expand the buffer by an amount proportional to the current size,
45850
 
+       giving us amortized linear-time behavior. Use a less-than-double
45851
 
+       growth factor to avoid excessive allocation. */
45852
 
+    return currentsize + (currentsize >> 3) + 6;
45853
 
 }
45854
 
 
45855
 
 static PyObject *
45856
 
@@ -620,6 +616,10 @@
45857
 
         return fileio_readall(self);
45858
 
     }
45859
 
 
45860
 
+#if defined(MS_WIN64) || defined(MS_WINDOWS)
45861
 
+    if (size > INT_MAX)
45862
 
+        size = INT_MAX;
45863
 
+#endif
45864
 
     bytes = PyBytes_FromStringAndSize(NULL, size);
45865
 
     if (bytes == NULL)
45866
 
         return NULL;
45867
 
@@ -628,7 +628,11 @@
45868
 
     if (_PyVerify_fd(self->fd)) {
45869
 
         Py_BEGIN_ALLOW_THREADS
45870
 
         errno = 0;
45871
 
+#if defined(MS_WIN64) || defined(MS_WINDOWS)
45872
 
+        n = read(self->fd, ptr, (int)size);
45873
 
+#else
45874
 
         n = read(self->fd, ptr, size);
45875
 
+#endif
45876
 
         Py_END_ALLOW_THREADS
45877
 
     } else
45878
 
         n = -1;
45879
 
@@ -655,7 +659,7 @@
45880
 
 fileio_write(fileio *self, PyObject *args)
45881
 
 {
45882
 
     Py_buffer pbuf;
45883
 
-    Py_ssize_t n;
45884
 
+    Py_ssize_t n, len;
45885
 
 
45886
 
     if (self->fd < 0)
45887
 
         return err_closed();
45888
 
@@ -668,7 +672,14 @@
45889
 
     if (_PyVerify_fd(self->fd)) {
45890
 
         Py_BEGIN_ALLOW_THREADS
45891
 
         errno = 0;
45892
 
-        n = write(self->fd, pbuf.buf, pbuf.len);
45893
 
+        len = pbuf.len;
45894
 
+#if defined(MS_WIN64) || defined(MS_WINDOWS)
45895
 
+        if (len > INT_MAX)
45896
 
+            len = INT_MAX;
45897
 
+        n = write(self->fd, pbuf.buf, (int)len);
45898
 
+#else
45899
 
+        n = write(self->fd, pbuf.buf, len);
45900
 
+#endif
45901
 
         Py_END_ALLOW_THREADS
45902
 
     } else
45903
 
         n = -1;
45904
 
diff -r 8527427914a2 Modules/_io/stringio.c
45905
 
--- a/Modules/_io/stringio.c
45906
 
+++ b/Modules/_io/stringio.c
45907
 
@@ -464,7 +464,7 @@
45908
 
 
45909
 
     CHECK_INITIALIZED(self);
45910
 
     if (!PyUnicode_Check(obj)) {
45911
 
-        PyErr_Format(PyExc_TypeError, "string argument expected, got '%s'",
45912
 
+        PyErr_Format(PyExc_TypeError, "unicode argument expected, got '%s'",
45913
 
                      Py_TYPE(obj)->tp_name);
45914
 
         return NULL;
45915
 
     }
45916
 
diff -r 8527427914a2 Modules/_json.c
45917
 
--- a/Modules/_json.c
45918
 
+++ b/Modules/_json.c
45919
 
@@ -1725,8 +1725,15 @@
45920
 
         Py_DECREF(s->encoding);
45921
 
         s->encoding = tmp;
45922
 
     }
45923
 
-    if (s->encoding == NULL || !PyString_Check(s->encoding))
45924
 
+    if (s->encoding == NULL)
45925
 
         goto bail;
45926
 
+    if (!PyString_Check(s->encoding)) {
45927
 
+       PyErr_Format(PyExc_TypeError,
45928
 
+                    "encoding must be a string, not %.80s",
45929
 
+                    Py_TYPE(s->encoding)->tp_name);
45930
 
+       goto bail;
45931
 
+    }
45932
 
+       
45933
 
 
45934
 
     /* All of these will fail "gracefully" so we don't need to verify them */
45935
 
     s->strict = PyObject_GetAttrString(ctx, "strict");
45936
 
diff -r 8527427914a2 Modules/_multiprocessing/multiprocessing.c
45937
 
--- a/Modules/_multiprocessing/multiprocessing.c
45938
 
+++ b/Modules/_multiprocessing/multiprocessing.c
45939
 
@@ -8,7 +8,7 @@
45940
 
 
45941
 
 #include "multiprocessing.h"
45942
 
 
45943
 
-#ifdef SCM_RIGHTS
45944
 
+#if (defined(CMSG_LEN) && defined(SCM_RIGHTS))
45945
 
     #define HAVE_FD_TRANSFER 1
45946
 
 #else
45947
 
     #define HAVE_FD_TRANSFER 0
45948
 
@@ -97,32 +97,38 @@
45949
 
 /* Functions for transferring file descriptors between processes.
45950
 
    Reimplements some of the functionality of the fdcred
45951
 
    module at http://www.mca-ltd.com/resources/fdcred_1.tgz. */
45952
 
+/* Based in http://resin.csoft.net/cgi-bin/man.cgi?section=3&topic=CMSG_DATA */
45953
 
 
45954
 
 static PyObject *
45955
 
 multiprocessing_sendfd(PyObject *self, PyObject *args)
45956
 
 {
45957
 
     int conn, fd, res;
45958
 
+    struct iovec dummy_iov;
45959
 
     char dummy_char;
45960
 
-    char buf[CMSG_SPACE(sizeof(int))];
45961
 
-    struct msghdr msg = {0};
45962
 
-    struct iovec dummy_iov;
45963
 
+    struct msghdr msg;
45964
 
     struct cmsghdr *cmsg;
45965
 
+    union {
45966
 
+        struct cmsghdr hdr;
45967
 
+        unsigned char buf[CMSG_SPACE(sizeof(int))];
45968
 
+    } cmsgbuf;
45969
 
 
45970
 
     if (!PyArg_ParseTuple(args, "ii", &conn, &fd))
45971
 
         return NULL;
45972
 
 
45973
 
     dummy_iov.iov_base = &dummy_char;
45974
 
     dummy_iov.iov_len = 1;
45975
 
-    msg.msg_control = buf;
45976
 
-    msg.msg_controllen = sizeof(buf);
45977
 
+
45978
 
+    memset(&msg, 0, sizeof(msg));
45979
 
+    msg.msg_control = &cmsgbuf.buf;
45980
 
+    msg.msg_controllen = sizeof(cmsgbuf.buf);
45981
 
     msg.msg_iov = &dummy_iov;
45982
 
     msg.msg_iovlen = 1;
45983
 
+
45984
 
     cmsg = CMSG_FIRSTHDR(&msg);
45985
 
+    cmsg->cmsg_len = CMSG_LEN(sizeof(int));
45986
 
     cmsg->cmsg_level = SOL_SOCKET;
45987
 
     cmsg->cmsg_type = SCM_RIGHTS;
45988
 
-    cmsg->cmsg_len = CMSG_LEN(sizeof(int));
45989
 
-    msg.msg_controllen = cmsg->cmsg_len;
45990
 
-    *CMSG_DATA(cmsg) = fd;
45991
 
+    * (int *) CMSG_DATA(cmsg) = fd;
45992
 
 
45993
 
     Py_BEGIN_ALLOW_THREADS
45994
 
     res = sendmsg(conn, &msg, 0);
45995
 
@@ -138,20 +144,26 @@
45996
 
 {
45997
 
     int conn, fd, res;
45998
 
     char dummy_char;
45999
 
-    char buf[CMSG_SPACE(sizeof(int))];
46000
 
+    struct iovec dummy_iov;
46001
 
     struct msghdr msg = {0};
46002
 
-    struct iovec dummy_iov;
46003
 
     struct cmsghdr *cmsg;
46004
 
+    union {
46005
 
+        struct cmsghdr hdr;
46006
 
+        unsigned char buf[CMSG_SPACE(sizeof(int))];
46007
 
+    } cmsgbuf;
46008
 
 
46009
 
     if (!PyArg_ParseTuple(args, "i", &conn))
46010
 
         return NULL;
46011
 
 
46012
 
     dummy_iov.iov_base = &dummy_char;
46013
 
     dummy_iov.iov_len = 1;
46014
 
-    msg.msg_control = buf;
46015
 
-    msg.msg_controllen = sizeof(buf);
46016
 
+
46017
 
+    memset(&msg, 0, sizeof(msg));
46018
 
+    msg.msg_control = &cmsgbuf.buf;
46019
 
+    msg.msg_controllen = sizeof(cmsgbuf.buf);
46020
 
     msg.msg_iov = &dummy_iov;
46021
 
     msg.msg_iovlen = 1;
46022
 
+
46023
 
     cmsg = CMSG_FIRSTHDR(&msg);
46024
 
     cmsg->cmsg_level = SOL_SOCKET;
46025
 
     cmsg->cmsg_type = SCM_RIGHTS;
46026
 
@@ -165,7 +177,18 @@
46027
 
     if (res < 0)
46028
 
         return PyErr_SetFromErrno(PyExc_OSError);
46029
 
 
46030
 
-    fd = *CMSG_DATA(cmsg);
46031
 
+    if (msg.msg_controllen < CMSG_LEN(sizeof(int)) ||
46032
 
+        (cmsg = CMSG_FIRSTHDR(&msg)) == NULL ||
46033
 
+        cmsg->cmsg_level != SOL_SOCKET ||
46034
 
+        cmsg->cmsg_type != SCM_RIGHTS ||
46035
 
+        cmsg->cmsg_len < CMSG_LEN(sizeof(int))) {
46036
 
+        /* If at least one control message is present, there should be
46037
 
+           no room for any further data in the buffer. */
46038
 
+        PyErr_SetString(PyExc_RuntimeError, "No file descriptor received");
46039
 
+        return NULL;
46040
 
+    }
46041
 
+
46042
 
+    fd = * (int *) CMSG_DATA(cmsg);
46043
 
     return Py_BuildValue("i", fd);
46044
 
 }
46045
 
 
46046
 
diff -r 8527427914a2 Modules/_sqlite/cursor.c
46047
 
--- a/Modules/_sqlite/cursor.c
46048
 
+++ b/Modules/_sqlite/cursor.c
46049
 
@@ -55,8 +55,8 @@
46050
 
 
46051
 
     dst = buf;
46052
 
     *dst = 0;
46053
 
-    while (isalpha(*src) && dst - buf < sizeof(buf) - 2) {
46054
 
-        *dst++ = tolower(*src++);
46055
 
+    while (Py_ISALPHA(*src) && dst - buf < sizeof(buf) - 2) {
46056
 
+        *dst++ = Py_TOLOWER(*src++);
46057
 
     }
46058
 
 
46059
 
     *dst = 0;
46060
 
@@ -268,16 +268,17 @@
46061
 
     }
46062
 
 }
46063
 
 
46064
 
-PyObject* pysqlite_unicode_from_string(const char* val_str, int optimize)
46065
 
+PyObject* pysqlite_unicode_from_string(const char* val_str, Py_ssize_t size, int optimize)
46066
 
 {
46067
 
     const char* check;
46068
 
+    Py_ssize_t pos;
46069
 
     int is_ascii = 0;
46070
 
 
46071
 
     if (optimize) {
46072
 
         is_ascii = 1;
46073
 
 
46074
 
         check = val_str;
46075
 
-        while (*check) {
46076
 
+        for (pos = 0; pos < size; pos++) {
46077
 
             if (*check & 0x80) {
46078
 
                 is_ascii = 0;
46079
 
                 break;
46080
 
@@ -288,9 +289,9 @@
46081
 
     }
46082
 
 
46083
 
     if (is_ascii) {
46084
 
-        return PyString_FromString(val_str);
46085
 
+        return PyString_FromStringAndSize(val_str, size);
46086
 
     } else {
46087
 
-        return PyUnicode_DecodeUTF8(val_str, strlen(val_str), NULL);
46088
 
+        return PyUnicode_DecodeUTF8(val_str, size, NULL);
46089
 
     }
46090
 
 }
46091
 
 
46092
 
@@ -375,10 +376,11 @@
46093
 
                 converted = PyFloat_FromDouble(sqlite3_column_double(self->statement->st, i));
46094
 
             } else if (coltype == SQLITE_TEXT) {
46095
 
                 val_str = (const char*)sqlite3_column_text(self->statement->st, i);
46096
 
+                nbytes = sqlite3_column_bytes(self->statement->st, i);
46097
 
                 if ((self->connection->text_factory == (PyObject*)&PyUnicode_Type)
46098
 
                     || (self->connection->text_factory == pysqlite_OptimizedUnicode)) {
46099
 
 
46100
 
-                    converted = pysqlite_unicode_from_string(val_str,
46101
 
+                    converted = pysqlite_unicode_from_string(val_str, nbytes,
46102
 
                         self->connection->text_factory == pysqlite_OptimizedUnicode ? 1 : 0);
46103
 
 
46104
 
                     if (!converted) {
46105
 
@@ -391,9 +393,9 @@
46106
 
                         PyErr_SetString(pysqlite_OperationalError, buf);
46107
 
                     }
46108
 
                 } else if (self->connection->text_factory == (PyObject*)&PyString_Type) {
46109
 
-                    converted = PyString_FromString(val_str);
46110
 
+                    converted = PyString_FromStringAndSize(val_str, nbytes);
46111
 
                 } else {
46112
 
-                    converted = PyObject_CallFunction(self->connection->text_factory, "s", val_str);
46113
 
+                    converted = PyObject_CallFunction(self->connection->text_factory, "s#", val_str, nbytes);
46114
 
                 }
46115
 
             } else {
46116
 
                 /* coltype == SQLITE_BLOB */
46117
 
@@ -441,9 +443,14 @@
46118
 
     if (cur->closed) {
46119
 
         PyErr_SetString(pysqlite_ProgrammingError, "Cannot operate on a closed cursor.");
46120
 
         return 0;
46121
 
-    } else {
46122
 
-        return pysqlite_check_thread(cur->connection) && pysqlite_check_connection(cur->connection);
46123
 
     }
46124
 
+
46125
 
+    if (cur->locked) {
46126
 
+        PyErr_SetString(pysqlite_ProgrammingError, "Recursive use of cursors not allowed.");
46127
 
+        return 0;
46128
 
+    }
46129
 
+
46130
 
+    return pysqlite_check_thread(cur->connection) && pysqlite_check_connection(cur->connection);
46131
 
 }
46132
 
 
46133
 
 PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* args)
46134
 
@@ -466,9 +473,10 @@
46135
 
     int allow_8bit_chars;
46136
 
 
46137
 
     if (!check_cursor(self)) {
46138
 
-        return NULL;
46139
 
+        goto error;
46140
 
     }
46141
 
 
46142
 
+    self->locked = 1;
46143
 
     self->reset = 0;
46144
 
 
46145
 
     /* Make shooting yourself in the foot with not utf-8 decodable 8-bit-strings harder */
46146
 
@@ -481,12 +489,12 @@
46147
 
     if (multiple) {
46148
 
         /* executemany() */
46149
 
         if (!PyArg_ParseTuple(args, "OO", &operation, &second_argument)) {
46150
 
-            return NULL;
46151
 
+            goto error;
46152
 
         }
46153
 
 
46154
 
         if (!PyString_Check(operation) && !PyUnicode_Check(operation)) {
46155
 
             PyErr_SetString(PyExc_ValueError, "operation parameter must be str or unicode");
46156
 
-            return NULL;
46157
 
+            goto error;
46158
 
         }
46159
 
 
46160
 
         if (PyIter_Check(second_argument)) {
46161
 
@@ -497,23 +505,23 @@
46162
 
             /* sequence */
46163
 
             parameters_iter = PyObject_GetIter(second_argument);
46164
 
             if (!parameters_iter) {
46165
 
-                return NULL;
46166
 
+                goto error;
46167
 
             }
46168
 
         }
46169
 
     } else {
46170
 
         /* execute() */
46171
 
         if (!PyArg_ParseTuple(args, "O|O", &operation, &second_argument)) {
46172
 
-            return NULL;
46173
 
+            goto error;
46174
 
         }
46175
 
 
46176
 
         if (!PyString_Check(operation) && !PyUnicode_Check(operation)) {
46177
 
             PyErr_SetString(PyExc_ValueError, "operation parameter must be str or unicode");
46178
 
-            return NULL;
46179
 
+            goto error;
46180
 
         }
46181
 
 
46182
 
         parameters_list = PyList_New(0);
46183
 
         if (!parameters_list) {
46184
 
-            return NULL;
46185
 
+            goto error;
46186
 
         }
46187
 
 
46188
 
         if (second_argument == NULL) {
46189
 
@@ -759,7 +767,8 @@
46190
 
      * ROLLBACK could have happened */
46191
 
     #ifdef SQLITE_VERSION_NUMBER
46192
 
     #if SQLITE_VERSION_NUMBER >= 3002002
46193
 
-    self->connection->inTransaction = !sqlite3_get_autocommit(self->connection->db);
46194
 
+    if (self->connection && self->connection->db)
46195
 
+        self->connection->inTransaction = !sqlite3_get_autocommit(self->connection->db);
46196
 
     #endif
46197
 
     #endif
46198
 
 
46199
 
@@ -768,6 +777,8 @@
46200
 
     Py_XDECREF(parameters_iter);
46201
 
     Py_XDECREF(parameters_list);
46202
 
 
46203
 
+    self->locked = 0;
46204
 
+
46205
 
     if (PyErr_Occurred()) {
46206
 
         self->rowcount = -1L;
46207
 
         return NULL;
46208
 
diff -r 8527427914a2 Modules/_sqlite/cursor.h
46209
 
--- a/Modules/_sqlite/cursor.h
46210
 
+++ b/Modules/_sqlite/cursor.h
46211
 
@@ -42,6 +42,7 @@
46212
 
     pysqlite_Statement* statement;
46213
 
     int closed;
46214
 
     int reset;
46215
 
+    int locked;
46216
 
     int initialized;
46217
 
 
46218
 
     /* the next row to be returned, NULL if no next row available */
46219
 
diff -r 8527427914a2 Modules/_sqlite/statement.c
46220
 
--- a/Modules/_sqlite/statement.c
46221
 
+++ b/Modules/_sqlite/statement.c
46222
 
@@ -166,13 +166,13 @@
46223
 
             rc = sqlite3_bind_double(self->st, pos, PyFloat_AsDouble(parameter));
46224
 
             break;
46225
 
         case TYPE_STRING:
46226
 
-            string = PyString_AS_STRING(parameter);
46227
 
-            rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);
46228
 
+            PyString_AsStringAndSize(parameter, &string, &buflen);
46229
 
+            rc = sqlite3_bind_text(self->st, pos, string, buflen, SQLITE_TRANSIENT);
46230
 
             break;
46231
 
         case TYPE_UNICODE:
46232
 
             stringval = PyUnicode_AsUTF8String(parameter);
46233
 
-            string = PyString_AsString(stringval);
46234
 
-            rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);
46235
 
+            PyString_AsStringAndSize(stringval, &string, &buflen);
46236
 
+            rc = sqlite3_bind_text(self->st, pos, string, buflen, SQLITE_TRANSIENT);
46237
 
             Py_DECREF(stringval);
46238
 
             break;
46239
 
         case TYPE_BUFFER:
46240
 
diff -r 8527427914a2 Modules/_sre.c
46241
 
--- a/Modules/_sre.c
46242
 
+++ b/Modules/_sre.c
46243
 
@@ -2744,7 +2744,7 @@
46244
 
 #if defined(VVERBOSE)
46245
 
 #define VTRACE(v) printf v
46246
 
 #else
46247
 
-#define VTRACE(v)
46248
 
+#define VTRACE(v) do {} while(0)  /* do nothing */
46249
 
 #endif
46250
 
 
46251
 
 /* Report failure */
46252
 
diff -r 8527427914a2 Modules/_ssl.c
46253
 
--- a/Modules/_ssl.c
46254
 
+++ b/Modules/_ssl.c
46255
 
@@ -369,7 +369,8 @@
46256
 
     }
46257
 
 
46258
 
     /* ssl compatibility */
46259
 
-    SSL_CTX_set_options(self->ctx, SSL_OP_ALL);
46260
 
+    SSL_CTX_set_options(self->ctx,
46261
 
+                        SSL_OP_ALL & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS);
46262
 
 
46263
 
     verification_mode = SSL_VERIFY_NONE;
46264
 
     if (certreq == PY_SSL_CERT_OPTIONAL)
46265
 
@@ -643,15 +644,20 @@
46266
 
             goto fail1;
46267
 
     }
46268
 
     /* now, there's typically a dangling RDN */
46269
 
-    if ((rdn != NULL) && (PyList_Size(rdn) > 0)) {
46270
 
-        rdnt = PyList_AsTuple(rdn);
46271
 
-        Py_DECREF(rdn);
46272
 
-        if (rdnt == NULL)
46273
 
-            goto fail0;
46274
 
-        retcode = PyList_Append(dn, rdnt);
46275
 
-        Py_DECREF(rdnt);
46276
 
-        if (retcode < 0)
46277
 
-            goto fail0;
46278
 
+    if (rdn != NULL) {
46279
 
+        if (PyList_GET_SIZE(rdn) > 0) {
46280
 
+            rdnt = PyList_AsTuple(rdn);
46281
 
+            Py_DECREF(rdn);
46282
 
+            if (rdnt == NULL)
46283
 
+                goto fail0;
46284
 
+            retcode = PyList_Append(dn, rdnt);
46285
 
+            Py_DECREF(rdnt);
46286
 
+            if (retcode < 0)
46287
 
+                goto fail0;
46288
 
+        }
46289
 
+        else {
46290
 
+            Py_DECREF(rdn);
46291
 
+        }
46292
 
     }
46293
 
 
46294
 
     /* convert list to tuple */
46295
 
@@ -702,7 +708,7 @@
46296
 
     /* get a memory buffer */
46297
 
     biobuf = BIO_new(BIO_s_mem());
46298
 
 
46299
 
-    i = 0;
46300
 
+    i = -1;
46301
 
     while ((i = X509_get_ext_by_NID(
46302
 
                     certificate, NID_subject_alt_name, i)) >= 0) {
46303
 
 
46304
 
@@ -798,6 +804,7 @@
46305
 
             }
46306
 
             Py_DECREF(t);
46307
 
         }
46308
 
+        sk_GENERAL_NAME_pop_free(names, GENERAL_NAME_free);
46309
 
     }
46310
 
     BIO_free(biobuf);
46311
 
     if (peer_alt_names != Py_None) {
46312
 
@@ -1145,10 +1152,8 @@
46313
 
 #endif
46314
 
 
46315
 
     /* Guard against socket too large for select*/
46316
 
-#ifndef Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
46317
 
-    if (s->sock_fd >= FD_SETSIZE)
46318
 
+    if (!_PyIsSelectable_fd(s->sock_fd))
46319
 
         return SOCKET_TOO_LARGE_FOR_SELECT;
46320
 
-#endif
46321
 
 
46322
 
     /* Construct the arguments to select */
46323
 
     tv.tv_sec = (int)s->sock_timeout;
46324
 
diff -r 8527427914a2 Modules/_testcapimodule.c
46325
 
--- a/Modules/_testcapimodule.c
46326
 
+++ b/Modules/_testcapimodule.c
46327
 
@@ -1106,6 +1106,41 @@
46328
 
 }
46329
 
 
46330
 
 static PyObject *
46331
 
+unicode_encodedecimal(PyObject *self, PyObject *args)
46332
 
+{
46333
 
+    Py_UNICODE *unicode;
46334
 
+    int length;
46335
 
+    char *errors = NULL;
46336
 
+    PyObject *decimal;
46337
 
+    Py_ssize_t decimal_length, new_length;
46338
 
+    int res;
46339
 
+
46340
 
+    if (!PyArg_ParseTuple(args, "u#|s", &unicode, &length, &errors))
46341
 
+        return NULL;
46342
 
+
46343
 
+    decimal_length = length * 7; /* len('&#8364;') */
46344
 
+    decimal = PyBytes_FromStringAndSize(NULL, decimal_length);
46345
 
+    if (decimal == NULL)
46346
 
+        return NULL;
46347
 
+
46348
 
+    res = PyUnicode_EncodeDecimal(unicode, length,
46349
 
+                                  PyBytes_AS_STRING(decimal),
46350
 
+                                  errors);
46351
 
+    if (res < 0) {
46352
 
+        Py_DECREF(decimal);
46353
 
+        return NULL;
46354
 
+    }
46355
 
+
46356
 
+    new_length = strlen(PyBytes_AS_STRING(decimal));
46357
 
+    assert(new_length <= decimal_length);
46358
 
+    res = _PyBytes_Resize(&decimal, new_length);
46359
 
+    if (res < 0)
46360
 
+        return NULL;
46361
 
+
46362
 
+    return decimal;
46363
 
+}
46364
 
+
46365
 
+static PyObject *
46366
 
 test_empty_argparse(PyObject *self)
46367
 
 {
46368
 
     /* Test that formats can begin with '|'. See issue #4720. */
46369
 
@@ -1639,6 +1674,19 @@
46370
 
     return PyErr_NewExceptionWithDoc(name, doc, base, dict);
46371
 
 }
46372
 
 
46373
 
+static PyObject *
46374
 
+sequence_delitem(PyObject *self, PyObject *args)
46375
 
+{
46376
 
+    PyObject *seq;
46377
 
+    Py_ssize_t i;
46378
 
+
46379
 
+    if (!PyArg_ParseTuple(args, "On", &seq, &i))
46380
 
+        return NULL;
46381
 
+    if (PySequence_DelItem(seq, i) < 0)
46382
 
+        return NULL;
46383
 
+    Py_RETURN_NONE;
46384
 
+}
46385
 
+
46386
 
 static PyMethodDef TestMethods[] = {
46387
 
     {"raise_exception",         raise_exception,                 METH_VARARGS},
46388
 
     {"test_config",             (PyCFunction)test_config,        METH_NOARGS},
46389
 
@@ -1685,6 +1733,7 @@
46390
 
 #ifdef Py_USING_UNICODE
46391
 
     {"test_u_code",             (PyCFunction)test_u_code,        METH_NOARGS},
46392
 
     {"test_widechar",           (PyCFunction)test_widechar,      METH_NOARGS},
46393
 
+    {"unicode_encodedecimal",   unicode_encodedecimal,           METH_VARARGS},
46394
 
 #endif
46395
 
 #ifdef WITH_THREAD
46396
 
     {"_test_thread_state",  test_thread_state,                   METH_VARARGS},
46397
 
@@ -1695,6 +1744,7 @@
46398
 
     {"code_newempty", code_newempty,                     METH_VARARGS},
46399
 
     {"make_exception_with_doc", (PyCFunction)make_exception_with_doc,
46400
 
      METH_VARARGS | METH_KEYWORDS},
46401
 
+    {"sequence_delitem", (PyCFunction)sequence_delitem, METH_VARARGS},
46402
 
     {NULL, NULL} /* sentinel */
46403
 
 };
46404
 
 
46405
 
diff -r 8527427914a2 Modules/_tkinter.c
46406
 
--- a/Modules/_tkinter.c
46407
 
+++ b/Modules/_tkinter.c
46408
 
@@ -663,8 +663,8 @@
46409
 
     }
46410
 
 
46411
 
     strcpy(argv0, className);
46412
 
-    if (isupper(Py_CHARMASK(argv0[0])))
46413
 
-        argv0[0] = tolower(Py_CHARMASK(argv0[0]));
46414
 
+    if (Py_ISUPPER(Py_CHARMASK(argv0[0])))
46415
 
+        argv0[0] = Py_TOLOWER(Py_CHARMASK(argv0[0]));
46416
 
     Tcl_SetVar(v->interp, "argv0", argv0, TCL_GLOBAL_ONLY);
46417
 
     ckfree(argv0);
46418
 
 
46419
 
diff -r 8527427914a2 Modules/arraymodule.c
46420
 
--- a/Modules/arraymodule.c
46421
 
+++ b/Modules/arraymodule.c
46422
 
@@ -2050,7 +2050,7 @@
46423
 
 \n\
46424
 
 Return a new array whose items are restricted by typecode, and\n\
46425
 
 initialized from the optional initializer value, which must be a list,\n\
46426
 
-string. or iterable over elements of the appropriate type.\n\
46427
 
+string or iterable over elements of the appropriate type.\n\
46428
 
 \n\
46429
 
 Arrays represent basic values and behave very much like lists, except\n\
46430
 
 the type of objects stored in them is constrained.\n\
46431
 
diff -r 8527427914a2 Modules/audioop.c
46432
 
--- a/Modules/audioop.c
46433
 
+++ b/Modules/audioop.c
46434
 
@@ -1298,7 +1298,7 @@
46435
 
                            &cp, &len, &size) )
46436
 
         return 0;
46437
 
 
46438
 
-    if (!audioop_check_parameters(len, size))
46439
 
+    if (!audioop_check_size(size))
46440
 
         return NULL;
46441
 
 
46442
 
     if (len > INT_MAX/size) {
46443
 
@@ -1367,7 +1367,7 @@
46444
 
                            &cp, &len, &size) )
46445
 
         return 0;
46446
 
 
46447
 
-    if (!audioop_check_parameters(len, size))
46448
 
+    if (!audioop_check_size(size))
46449
 
         return NULL;
46450
 
 
46451
 
     if (len > INT_MAX/size) {
46452
 
@@ -1509,7 +1509,7 @@
46453
 
                            &cp, &len, &size, &state) )
46454
 
         return 0;
46455
 
 
46456
 
-    if (!audioop_check_parameters(len, size))
46457
 
+    if (!audioop_check_size(size))
46458
 
         return NULL;
46459
 
 
46460
 
     /* Decode state, should have (value, step) */
46461
 
diff -r 8527427914a2 Modules/binascii.c
46462
 
--- a/Modules/binascii.c
46463
 
+++ b/Modules/binascii.c
46464
 
@@ -1105,8 +1105,8 @@
46465
 
     if (isdigit(c))
46466
 
         return c - '0';
46467
 
     else {
46468
 
-        if (isupper(c))
46469
 
-            c = tolower(c);
46470
 
+        if (Py_ISUPPER(c))
46471
 
+            c = Py_TOLOWER(c);
46472
 
         if (c >= 'a' && c <= 'f')
46473
 
             return c - 'a' + 10;
46474
 
     }
46475
 
diff -r 8527427914a2 Modules/bsddb.h
46476
 
--- a/Modules/bsddb.h
46477
 
+++ b/Modules/bsddb.h
46478
 
@@ -109,7 +109,7 @@
46479
 
 #error "eek! DBVER can't handle minor versions > 9"
46480
 
 #endif
46481
 
 
46482
 
-#define PY_BSDDB_VERSION "4.8.4.1"
46483
 
+#define PY_BSDDB_VERSION "4.8.4.2"
46484
 
 
46485
 
 /* Python object definitions */
46486
 
 
46487
 
diff -r 8527427914a2 Modules/bz2module.c
46488
 
--- a/Modules/bz2module.c
46489
 
+++ b/Modules/bz2module.c
46490
 
@@ -224,25 +224,14 @@
46491
 
 #define SMALLCHUNK BUFSIZ
46492
 
 #endif
46493
 
 
46494
 
-#if SIZEOF_INT < 4
46495
 
-#define BIGCHUNK  (512 * 32)
46496
 
-#else
46497
 
-#define BIGCHUNK  (512 * 1024)
46498
 
-#endif
46499
 
-
46500
 
 /* This is a hacked version of Python's fileobject.c:new_buffersize(). */
46501
 
 static size_t
46502
 
 Util_NewBufferSize(size_t currentsize)
46503
 
 {
46504
 
-    if (currentsize > SMALLCHUNK) {
46505
 
-        /* Keep doubling until we reach BIGCHUNK;
46506
 
-           then keep adding BIGCHUNK. */
46507
 
-        if (currentsize <= BIGCHUNK)
46508
 
-            return currentsize + currentsize;
46509
 
-        else
46510
 
-            return currentsize + BIGCHUNK;
46511
 
-    }
46512
 
-    return currentsize + SMALLCHUNK;
46513
 
+    /* Expand the buffer by an amount proportional to the current size,
46514
 
+       giving us amortized linear-time behavior. Use a less-than-double
46515
 
+       growth factor to avoid excessive allocation. */
46516
 
+    return currentsize + (currentsize >> 3) + 6;
46517
 
 }
46518
 
 
46519
 
 /* This is a hacked version of Python's fileobject.c:get_line(). */
46520
 
diff -r 8527427914a2 Modules/cPickle.c
46521
 
--- a/Modules/cPickle.c
46522
 
+++ b/Modules/cPickle.c
46523
 
@@ -2697,11 +2697,6 @@
46524
 
         }
46525
 
     }
46526
 
 
46527
 
-    if (PyType_IsSubtype(type, &PyType_Type)) {
46528
 
-        res = save_global(self, args, NULL);
46529
 
-        goto finally;
46530
 
-    }
46531
 
-
46532
 
     /* Get a reduction callable, and call it.  This may come from
46533
 
      * copy_reg.dispatch_table, the object's __reduce_ex__ method,
46534
 
      * or the object's __reduce__ method.
46535
 
@@ -2717,6 +2712,11 @@
46536
 
         }
46537
 
     }
46538
 
     else {
46539
 
+        if (PyType_IsSubtype(type, &PyType_Type)) {
46540
 
+            res = save_global(self, args, NULL);
46541
 
+            goto finally;
46542
 
+        }
46543
 
+
46544
 
         /* Check for a __reduce_ex__ method. */
46545
 
         __reduce__ = PyObject_GetAttr(args, __reduce_ex___str);
46546
 
         if (__reduce__ != NULL) {
46547
 
diff -r 8527427914a2 Modules/cStringIO.c
46548
 
--- a/Modules/cStringIO.c
46549
 
+++ b/Modules/cStringIO.c
46550
 
@@ -661,7 +661,11 @@
46551
 
   char *buf;
46552
 
   Py_ssize_t size;
46553
 
 
46554
 
-  if (PyObject_AsReadBuffer(s, (const void **)&buf, &size)) {
46555
 
+  if (PyUnicode_Check(s)) {
46556
 
+    if (PyObject_AsCharBuffer(s, (const char **)&buf, &size) != 0)
46557
 
+      return NULL;
46558
 
+  }
46559
 
+  else if (PyObject_AsReadBuffer(s, (const void **)&buf, &size)) {
46560
 
     PyErr_Format(PyExc_TypeError, "expected read buffer, %.200s found",
46561
 
                  s->ob_type->tp_name);
46562
 
     return NULL;
46563
 
diff -r 8527427914a2 Modules/cjkcodecs/_codecs_hk.c
46564
 
--- a/Modules/cjkcodecs/_codecs_hk.c
46565
 
+++ b/Modules/cjkcodecs/_codecs_hk.c
46566
 
@@ -115,55 +115,56 @@
46567
 
 
46568
 
         REQUIRE_INBUF(2)
46569
 
 
46570
 
-        if (0xc6 <= c && c <= 0xc8 && (c >= 0xc7 || IN2 >= 0xa1))
46571
 
-            goto hkscsdec;
46572
 
+        if (0xc6 > c || c > 0xc8 || (c < 0xc7 && IN2 < 0xa1)) {
46573
 
+            TRYMAP_DEC(big5, **outbuf, c, IN2) {
46574
 
+                NEXT(2, 1)
46575
 
+                continue;
46576
 
+            }
46577
 
+        }
46578
 
 
46579
 
-        TRYMAP_DEC(big5, **outbuf, c, IN2) {
46580
 
-            NEXT(2, 1)
46581
 
+        TRYMAP_DEC(big5hkscs, decoded, c, IN2)
46582
 
+        {
46583
 
+            int s = BH2S(c, IN2);
46584
 
+            const unsigned char *hintbase;
46585
 
+
46586
 
+            assert(0x87 <= c && c <= 0xfe);
46587
 
+            assert(0x40 <= IN2 && IN2 <= 0xfe);
46588
 
+
46589
 
+            if (BH2S(0x87, 0x40) <= s && s <= BH2S(0xa0, 0xfe)) {
46590
 
+                    hintbase = big5hkscs_phint_0;
46591
 
+                    s -= BH2S(0x87, 0x40);
46592
 
+            }
46593
 
+            else if (BH2S(0xc6,0xa1) <= s && s <= BH2S(0xc8,0xfe)){
46594
 
+                    hintbase = big5hkscs_phint_12130;
46595
 
+                    s -= BH2S(0xc6, 0xa1);
46596
 
+            }
46597
 
+            else if (BH2S(0xf9,0xd6) <= s && s <= BH2S(0xfe,0xfe)){
46598
 
+                    hintbase = big5hkscs_phint_21924;
46599
 
+                    s -= BH2S(0xf9, 0xd6);
46600
 
+            }
46601
 
+            else
46602
 
+                    return MBERR_INTERNAL;
46603
 
+
46604
 
+            if (hintbase[s >> 3] & (1 << (s & 7))) {
46605
 
+                    WRITEUCS4(decoded | 0x20000)
46606
 
+                    NEXT_IN(2)
46607
 
+            }
46608
 
+            else {
46609
 
+                    OUT1(decoded)
46610
 
+                    NEXT(2, 1)
46611
 
+            }
46612
 
+            continue;
46613
 
         }
46614
 
-        else
46615
 
-hkscsdec:       TRYMAP_DEC(big5hkscs, decoded, c, IN2) {
46616
 
-                        int s = BH2S(c, IN2);
46617
 
-                        const unsigned char *hintbase;
46618
 
 
46619
 
-                        assert(0x87 <= c && c <= 0xfe);
46620
 
-                        assert(0x40 <= IN2 && IN2 <= 0xfe);
46621
 
+        switch ((c << 8) | IN2) {
46622
 
+        case 0x8862: WRITE2(0x00ca, 0x0304); break;
46623
 
+        case 0x8864: WRITE2(0x00ca, 0x030c); break;
46624
 
+        case 0x88a3: WRITE2(0x00ea, 0x0304); break;
46625
 
+        case 0x88a5: WRITE2(0x00ea, 0x030c); break;
46626
 
+        default: return 2;
46627
 
+        }
46628
 
 
46629
 
-                        if (BH2S(0x87, 0x40) <= s && s <= BH2S(0xa0, 0xfe)) {
46630
 
-                                hintbase = big5hkscs_phint_0;
46631
 
-                                s -= BH2S(0x87, 0x40);
46632
 
-                        }
46633
 
-                        else if (BH2S(0xc6,0xa1) <= s && s <= BH2S(0xc8,0xfe)){
46634
 
-                                hintbase = big5hkscs_phint_12130;
46635
 
-                                s -= BH2S(0xc6, 0xa1);
46636
 
-                        }
46637
 
-                        else if (BH2S(0xf9,0xd6) <= s && s <= BH2S(0xfe,0xfe)){
46638
 
-                                hintbase = big5hkscs_phint_21924;
46639
 
-                                s -= BH2S(0xf9, 0xd6);
46640
 
-                        }
46641
 
-                        else
46642
 
-                                return MBERR_INTERNAL;
46643
 
-
46644
 
-                        if (hintbase[s >> 3] & (1 << (s & 7))) {
46645
 
-                                WRITEUCS4(decoded | 0x20000)
46646
 
-                                NEXT_IN(2)
46647
 
-                        }
46648
 
-                        else {
46649
 
-                                OUT1(decoded)
46650
 
-                                NEXT(2, 1)
46651
 
-                        }
46652
 
-                }
46653
 
-                else {
46654
 
-                        switch ((c << 8) | IN2) {
46655
 
-                        case 0x8862: WRITE2(0x00ca, 0x0304); break;
46656
 
-                        case 0x8864: WRITE2(0x00ca, 0x030c); break;
46657
 
-                        case 0x88a3: WRITE2(0x00ea, 0x0304); break;
46658
 
-                        case 0x88a5: WRITE2(0x00ea, 0x030c); break;
46659
 
-                        default: return 2;
46660
 
-                        }
46661
 
-
46662
 
-                        NEXT(2, 2) /* all decoded codepoints are pairs, above. */
46663
 
-        }
46664
 
+        NEXT(2, 2) /* all decoded codepoints are pairs, above. */
46665
 
     }
46666
 
 
46667
 
     return 0;
46668
 
diff -r 8527427914a2 Modules/cjkcodecs/_codecs_jp.c
46669
 
--- a/Modules/cjkcodecs/_codecs_jp.c
46670
 
+++ b/Modules/cjkcodecs/_codecs_jp.c
46671
 
@@ -371,11 +371,11 @@
46672
 
 
46673
 
         REQUIRE_OUTBUF(1)
46674
 
 
46675
 
-            if (c < 0x80) {
46676
 
-                OUT1(c)
46677
 
-                NEXT(1, 1)
46678
 
-                continue;
46679
 
-            }
46680
 
+        if (c < 0x80) {
46681
 
+            OUT1(c)
46682
 
+            NEXT(1, 1)
46683
 
+            continue;
46684
 
+        }
46685
 
 
46686
 
         if (c == 0x8e) {
46687
 
             /* JIS X 0201 half-width katakana */
46688
 
diff -r 8527427914a2 Modules/itertoolsmodule.c
46689
 
--- a/Modules/itertoolsmodule.c
46690
 
+++ b/Modules/itertoolsmodule.c
46691
 
@@ -1234,7 +1234,9 @@
46692
 
         return NULL;
46693
 
     lz->cnt++;
46694
 
     oldnext = lz->next;
46695
 
-    lz->next += lz->step;
46696
 
+    /* The (size_t) cast below avoids the danger of undefined
46697
 
+       behaviour from signed integer overflow. */
46698
 
+    lz->next += (size_t)lz->step;
46699
 
     if (lz->next < oldnext || (stop != -1 && lz->next > stop))
46700
 
         lz->next = stop;
46701
 
     return item;
46702
 
diff -r 8527427914a2 Modules/mmapmodule.c
46703
 
--- a/Modules/mmapmodule.c
46704
 
+++ b/Modules/mmapmodule.c
46705
 
@@ -1188,12 +1188,13 @@
46706
 
 #  endif
46707
 
     if (fd != -1 && fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) {
46708
 
         if (map_size == 0) {
46709
 
+            off_t calc_size;
46710
 
             if (offset >= st.st_size) {
46711
 
                 PyErr_SetString(PyExc_ValueError,
46712
 
                                 "mmap offset is greater than file size");
46713
 
                 return NULL;
46714
 
             }
46715
 
-            off_t calc_size = st.st_size - offset;
46716
 
+            calc_size = st.st_size - offset;
46717
 
             map_size = calc_size;
46718
 
             if (map_size != calc_size) {
46719
 
                 PyErr_SetString(PyExc_ValueError,
46720
 
diff -r 8527427914a2 Modules/ossaudiodev.c
46721
 
--- a/Modules/ossaudiodev.c
46722
 
+++ b/Modules/ossaudiodev.c
46723
 
@@ -129,6 +129,7 @@
46724
 
     }
46725
 
 
46726
 
     if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) {
46727
 
+        close(fd);
46728
 
         PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename);
46729
 
         return NULL;
46730
 
     }
46731
 
@@ -425,6 +426,11 @@
46732
 
     if (!PyArg_ParseTuple(args, "s#:write", &cp, &size))
46733
 
         return NULL;
46734
 
 
46735
 
+    if (!_PyIsSelectable_fd(self->fd)) {
46736
 
+        PyErr_SetString(PyExc_ValueError,
46737
 
+                        "file descriptor out of range for select");
46738
 
+        return NULL;
46739
 
+    }
46740
 
     /* use select to wait for audio device to be available */
46741
 
     FD_ZERO(&write_set_fds);
46742
 
     FD_SET(self->fd, &write_set_fds);
46743
 
diff -r 8527427914a2 Modules/posixmodule.c
46744
 
--- a/Modules/posixmodule.c
46745
 
+++ b/Modules/posixmodule.c
46746
 
@@ -11,8 +11,6 @@
46747
 
    compiler is assumed to be IBM's VisualAge C++ (VACPP).  PYCC_GCC is used
46748
 
    as the compiler specific macro for the EMX port of gcc to OS/2. */
46749
 
 
46750
 
-/* See also ../Dos/dosmodule.c */
46751
 
-
46752
 
 #ifdef __APPLE__
46753
 
    /*
46754
 
     * Step 1 of support for weak-linking a number of symbols existing on
46755
 
@@ -338,20 +336,6 @@
46756
 
 #define USE_TMPNAM_R
46757
 
 #endif
46758
 
 
46759
 
-/* choose the appropriate stat and fstat functions and return structs */
46760
 
-#undef STAT
46761
 
-#undef FSTAT
46762
 
-#undef STRUCT_STAT
46763
 
-#if defined(MS_WIN64) || defined(MS_WINDOWS)
46764
 
-#       define STAT win32_stat
46765
 
-#       define FSTAT win32_fstat
46766
 
-#       define STRUCT_STAT struct win32_stat
46767
 
-#else
46768
 
-#       define STAT stat
46769
 
-#       define FSTAT fstat
46770
 
-#       define STRUCT_STAT struct stat
46771
 
-#endif
46772
 
-
46773
 
 #if defined(MAJOR_IN_MKDEV)
46774
 
 #include <sys/mkdev.h>
46775
 
 #else
46776
 
@@ -842,6 +826,20 @@
46777
 
 }
46778
 
 #endif
46779
 
 
46780
 
+/* choose the appropriate stat and fstat functions and return structs */
46781
 
+#undef STAT
46782
 
+#undef FSTAT
46783
 
+#undef STRUCT_STAT
46784
 
+#if defined(MS_WIN64) || defined(MS_WINDOWS)
46785
 
+#       define STAT win32_stat
46786
 
+#       define FSTAT win32_fstat
46787
 
+#       define STRUCT_STAT struct win32_stat
46788
 
+#else
46789
 
+#       define STAT stat
46790
 
+#       define FSTAT fstat
46791
 
+#       define STRUCT_STAT struct stat
46792
 
+#endif
46793
 
+
46794
 
 #ifdef MS_WINDOWS
46795
 
 /* The CRT of Windows has a number of flaws wrt. its stat() implementation:
46796
 
    - time stamps are restricted to second resolution
46797
 
@@ -3903,7 +3901,7 @@
46798
 
 #endif
46799
 
     gid_t grouplist[MAX_GROUPS];
46800
 
 
46801
 
-    /* On MacOSX getgroups(2) can return more than MAX_GROUPS results 
46802
 
+    /* On MacOSX getgroups(2) can return more than MAX_GROUPS results
46803
 
      * This is a helper variable to store the intermediate result when
46804
 
      * that happens.
46805
 
      *
46806
 
@@ -4199,6 +4197,44 @@
46807
 
     CloseHandle(handle);
46808
 
     return result;
46809
 
 }
46810
 
+
46811
 
+PyDoc_STRVAR(posix__isdir__doc__,
46812
 
+"Return true if the pathname refers to an existing directory.");
46813
 
+
46814
 
+static PyObject *
46815
 
+posix__isdir(PyObject *self, PyObject *args)
46816
 
+{
46817
 
+    PyObject *opath;
46818
 
+    char *path;
46819
 
+    PyUnicodeObject *po;
46820
 
+    DWORD attributes;
46821
 
+
46822
 
+    if (PyArg_ParseTuple(args, "U|:_isdir", &po)) {
46823
 
+        Py_UNICODE *wpath = PyUnicode_AS_UNICODE(po);
46824
 
+
46825
 
+        attributes = GetFileAttributesW(wpath);
46826
 
+        if (attributes == INVALID_FILE_ATTRIBUTES)
46827
 
+            Py_RETURN_FALSE;
46828
 
+        goto check;
46829
 
+    }
46830
 
+    /* Drop the argument parsing error as narrow strings
46831
 
+       are also valid. */
46832
 
+    PyErr_Clear();
46833
 
+
46834
 
+    if (!PyArg_ParseTuple(args, "et:_isdir",
46835
 
+                          Py_FileSystemDefaultEncoding, &path))
46836
 
+        return NULL;
46837
 
+
46838
 
+    attributes = GetFileAttributesA(path);
46839
 
+    if (attributes == INVALID_FILE_ATTRIBUTES)
46840
 
+        Py_RETURN_FALSE;
46841
 
+
46842
 
+check:
46843
 
+    if (attributes & FILE_ATTRIBUTE_DIRECTORY)
46844
 
+        Py_RETURN_TRUE;
46845
 
+    else
46846
 
+        Py_RETURN_FALSE;
46847
 
+}
46848
 
 #endif /* MS_WINDOWS */
46849
 
 
46850
 
 #ifdef HAVE_PLOCK
46851
 
@@ -6610,7 +6646,7 @@
46852
 
 {
46853
 
     Py_buffer pbuf;
46854
 
     int fd;
46855
 
-    Py_ssize_t size;
46856
 
+    Py_ssize_t size, len;
46857
 
 
46858
 
     if (!PyArg_ParseTuple(args, "is*:write", &fd, &pbuf))
46859
 
         return NULL;
46860
 
@@ -6618,8 +6654,15 @@
46861
 
         PyBuffer_Release(&pbuf);
46862
 
         return posix_error();
46863
 
     }
46864
 
+    len = pbuf.len;
46865
 
     Py_BEGIN_ALLOW_THREADS
46866
 
-    size = write(fd, pbuf.buf, (size_t)pbuf.len);
46867
 
+#if defined(MS_WIN64) || defined(MS_WINDOWS)
46868
 
+    if (len > INT_MAX)
46869
 
+        len = INT_MAX;
46870
 
+    size = write(fd, pbuf.buf, (int)len);
46871
 
+#else
46872
 
+    size = write(fd, pbuf.buf, len);
46873
 
+#endif
46874
 
     Py_END_ALLOW_THREADS
46875
 
     PyBuffer_Release(&pbuf);
46876
 
     if (size < 0)
46877
 
@@ -6712,6 +6755,8 @@
46878
 
     PyMem_FREE(mode);
46879
 
     if (fp == NULL)
46880
 
         return posix_error();
46881
 
+    /* The dummy filename used here must be kept in sync with the value
46882
 
+       tested against in gzip.GzipFile.__init__() - see issue #13781. */
46883
 
     f = PyFile_FromFile(fp, "<fdopen>", orgmode, fclose);
46884
 
     if (f != NULL)
46885
 
         PyFile_SetBufSize(f, bufsize);
46886
 
@@ -6951,6 +6996,14 @@
46887
 
 
46888
 
     /* XXX This can leak memory -- not easy to fix :-( */
46889
 
     len = strlen(s1) + strlen(s2) + 2;
46890
 
+#ifdef MS_WINDOWS
46891
 
+    if (_MAX_ENV < (len - 1)) {
46892
 
+        PyErr_Format(PyExc_ValueError,
46893
 
+                     "the environment variable is longer than %u bytes",
46894
 
+                     _MAX_ENV);
46895
 
+        return NULL;
46896
 
+    }
46897
 
+#endif
46898
 
     /* len includes space for a trailing \0; the size arg to
46899
 
        PyString_FromStringAndSize does not count that */
46900
 
     newstr = PyString_FromStringAndSize(NULL, (int)len - 1);
46901
 
@@ -6993,11 +7046,20 @@
46902
 
 posix_unsetenv(PyObject *self, PyObject *args)
46903
 
 {
46904
 
     char *s1;
46905
 
+#ifndef HAVE_BROKEN_UNSETENV
46906
 
+    int err;
46907
 
+#endif
46908
 
 
46909
 
     if (!PyArg_ParseTuple(args, "s:unsetenv", &s1))
46910
 
         return NULL;
46911
 
 
46912
 
+#ifdef HAVE_BROKEN_UNSETENV
46913
 
     unsetenv(s1);
46914
 
+#else
46915
 
+    err = unsetenv(s1);
46916
 
+    if (err)
46917
 
+        return posix_error();
46918
 
+#endif
46919
 
 
46920
 
     /* Remove the key from posix_putenv_garbage;
46921
 
      * this will cause it to be collected.  This has to
46922
 
@@ -8968,6 +9030,7 @@
46923
 
     {"abort",           posix_abort, METH_NOARGS, posix_abort__doc__},
46924
 
 #ifdef MS_WINDOWS
46925
 
     {"_getfullpathname",        posix__getfullpathname, METH_VARARGS, NULL},
46926
 
+    {"_isdir",                  posix__isdir, METH_VARARGS, posix__isdir__doc__},
46927
 
 #endif
46928
 
 #ifdef HAVE_GETLOADAVG
46929
 
     {"getloadavg",      posix_getloadavg, METH_NOARGS, posix_getloadavg__doc__},
46930
 
diff -r 8527427914a2 Modules/selectmodule.c
46931
 
--- a/Modules/selectmodule.c
46932
 
+++ b/Modules/selectmodule.c
46933
 
@@ -114,7 +114,7 @@
46934
 
 #if defined(_MSC_VER)
46935
 
         max = 0;                             /* not used for Win32 */
46936
 
 #else  /* !_MSC_VER */
46937
 
-        if (v < 0 || v >= FD_SETSIZE) {
46938
 
+        if (!_PyIsSelectable_fd(v)) {
46939
 
             PyErr_SetString(PyExc_ValueError,
46940
 
                         "filedescriptor out of range in select()");
46941
 
             goto finally;
46942
 
@@ -164,13 +164,6 @@
46943
 
     for (j = 0; fd2obj[j].sentinel >= 0; j++) {
46944
 
         fd = fd2obj[j].fd;
46945
 
         if (FD_ISSET(fd, set)) {
46946
 
-#ifndef _MSC_VER
46947
 
-            if (fd > FD_SETSIZE) {
46948
 
-                PyErr_SetString(PyExc_SystemError,
46949
 
-               "filedescriptor out of range returned in select()");
46950
 
-                goto finally;
46951
 
-            }
46952
 
-#endif
46953
 
             o = fd2obj[j].obj;
46954
 
             fd2obj[j].obj = NULL;
46955
 
             /* transfer ownership */
46956
 
@@ -912,7 +905,7 @@
46957
 
 PyDoc_STRVAR(pyepoll_register_doc,
46958
 
 "register(fd[, eventmask]) -> None\n\
46959
 
 \n\
46960
 
-Registers a new fd or modifies an already registered fd.\n\
46961
 
+Registers a new fd or raises an IOError if the fd is already registered.\n\
46962
 
 fd is the target file descriptor of the operation.\n\
46963
 
 events is a bit set composed of the various EPOLL constants; the default\n\
46964
 
 is EPOLL_IN | EPOLL_OUT | EPOLL_PRI.\n\
46965
 
diff -r 8527427914a2 Modules/signalmodule.c
46966
 
--- a/Modules/signalmodule.c
46967
 
+++ b/Modules/signalmodule.c
46968
 
@@ -976,11 +976,12 @@
46969
 
 PyOS_AfterFork(void)
46970
 
 {
46971
 
 #ifdef WITH_THREAD
46972
 
-    _PyGILState_Reinit();
46973
 
+    /* PyThread_ReInitTLS() must be called early, to make sure that the TLS API
46974
 
+     * can be called safely. */
46975
 
+    PyThread_ReInitTLS();
46976
 
     PyEval_ReInitThreads();
46977
 
     main_thread = PyThread_get_thread_ident();
46978
 
     main_pid = getpid();
46979
 
     _PyImport_ReInitLock();
46980
 
-    PyThread_ReInitTLS();
46981
 
 #endif
46982
 
 }
46983
 
diff -r 8527427914a2 Modules/socketmodule.c
46984
 
--- a/Modules/socketmodule.c
46985
 
+++ b/Modules/socketmodule.c
46986
 
@@ -456,18 +456,14 @@
46987
 
 #include <sys/poll.h>
46988
 
 #endif
46989
 
 
46990
 
-#ifdef Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
46991
 
-/* Platform can select file descriptors beyond FD_SETSIZE */
46992
 
-#define IS_SELECTABLE(s) 1
46993
 
-#elif defined(HAVE_POLL)
46994
 
+#ifdef HAVE_POLL
46995
 
 /* Instead of select(), we'll use poll() since poll() works on any fd. */
46996
 
 #define IS_SELECTABLE(s) 1
46997
 
 /* Can we call select() with this socket without a buffer overrun? */
46998
 
 #else
46999
 
-/* POSIX says selecting file descriptors beyond FD_SETSIZE
47000
 
-   has undefined behaviour.  If there's no timeout left, we don't have to
47001
 
-   call select, so it's a safe, little white lie. */
47002
 
-#define IS_SELECTABLE(s) ((s)->sock_fd < FD_SETSIZE || s->sock_timeout <= 0.0)
47003
 
+/* If there's no timeout left, we don't have to call select, so it's a safe,
47004
 
+ * little white lie. */
47005
 
+#define IS_SELECTABLE(s) (_PyIsSelectable_fd((s)->sock_fd) || (s)->sock_timeout <= 0.0)
47006
 
 #endif
47007
 
 
47008
 
 static PyObject*
47009
 
@@ -1032,10 +1028,10 @@
47010
 
         PyObject *ret = NULL;
47011
 
         if (addrobj) {
47012
 
             a = (struct sockaddr_in6 *)addr;
47013
 
-            ret = Py_BuildValue("Oiii",
47014
 
+            ret = Py_BuildValue("OiII",
47015
 
                                 addrobj,
47016
 
                                 ntohs(a->sin6_port),
47017
 
-                                a->sin6_flowinfo,
47018
 
+                                ntohl(a->sin6_flowinfo),
47019
 
                                 a->sin6_scope_id);
47020
 
             Py_DECREF(addrobj);
47021
 
         }
47022
 
@@ -1286,7 +1282,8 @@
47023
 
     {
47024
 
         struct sockaddr_in6* addr;
47025
 
         char *host;
47026
 
-        int port, flowinfo, scope_id, result;
47027
 
+        int port, result;
47028
 
+        unsigned int flowinfo, scope_id;
47029
 
         flowinfo = scope_id = 0;
47030
 
         if (!PyTuple_Check(args)) {
47031
 
             PyErr_Format(
47032
 
@@ -1296,7 +1293,7 @@
47033
 
                 Py_TYPE(args)->tp_name);
47034
 
             return 0;
47035
 
         }
47036
 
-        if (!PyArg_ParseTuple(args, "eti|ii",
47037
 
+        if (!PyArg_ParseTuple(args, "eti|II",
47038
 
                               "idna", &host, &port, &flowinfo,
47039
 
                               &scope_id)) {
47040
 
             return 0;
47041
 
@@ -1313,9 +1310,15 @@
47042
 
                 "getsockaddrarg: port must be 0-65535.");
47043
 
             return 0;
47044
 
         }
47045
 
+        if (flowinfo < 0 || flowinfo > 0xfffff) {
47046
 
+            PyErr_SetString(
47047
 
+                PyExc_OverflowError,
47048
 
+                "getsockaddrarg: flowinfo must be 0-1048575.");
47049
 
+            return 0;
47050
 
+        }
47051
 
         addr->sin6_family = s->sock_family;
47052
 
         addr->sin6_port = htons((short)port);
47053
 
-        addr->sin6_flowinfo = flowinfo;
47054
 
+        addr->sin6_flowinfo = htonl(flowinfo);
47055
 
         addr->sin6_scope_id = scope_id;
47056
 
         *len_ret = sizeof *addr;
47057
 
         return 1;
47058
 
@@ -1784,7 +1787,7 @@
47059
 
 PyDoc_STRVAR(gettimeout_doc,
47060
 
 "gettimeout() -> timeout\n\
47061
 
 \n\
47062
 
-Returns the timeout in floating seconds associated with socket \n\
47063
 
+Returns the timeout in seconds (float) associated with socket \n\
47064
 
 operations. A timeout of None indicates that timeouts on socket \n\
47065
 
 operations are disabled.");
47066
 
 
47067
 
@@ -4160,7 +4163,8 @@
47068
 
     PyObject *sa = (PyObject *)NULL;
47069
 
     int flags;
47070
 
     char *hostp;
47071
 
-    int port, flowinfo, scope_id;
47072
 
+    int port;
47073
 
+    unsigned int flowinfo, scope_id;
47074
 
     char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
47075
 
     struct addrinfo hints, *res = NULL;
47076
 
     int error;
47077
 
@@ -4174,9 +4178,14 @@
47078
 
                         "getnameinfo() argument 1 must be a tuple");
47079
 
         return NULL;
47080
 
     }
47081
 
-    if (!PyArg_ParseTuple(sa, "si|ii",
47082
 
+    if (!PyArg_ParseTuple(sa, "si|II",
47083
 
                           &hostp, &port, &flowinfo, &scope_id))
47084
 
         return NULL;
47085
 
+    if (flowinfo < 0 || flowinfo > 0xfffff) {
47086
 
+        PyErr_SetString(PyExc_OverflowError,
47087
 
+                        "getsockaddrarg: flowinfo must be 0-1048575.");
47088
 
+        return NULL;
47089
 
+    }
47090
 
     PyOS_snprintf(pbuf, sizeof(pbuf), "%d", port);
47091
 
     memset(&hints, 0, sizeof(hints));
47092
 
     hints.ai_family = AF_UNSPEC;
47093
 
@@ -4210,7 +4219,7 @@
47094
 
         {
47095
 
         struct sockaddr_in6 *sin6;
47096
 
         sin6 = (struct sockaddr_in6 *)res->ai_addr;
47097
 
-        sin6->sin6_flowinfo = flowinfo;
47098
 
+        sin6->sin6_flowinfo = htonl(flowinfo);
47099
 
         sin6->sin6_scope_id = scope_id;
47100
 
         break;
47101
 
         }
47102
 
@@ -4252,7 +4261,7 @@
47103
 
 PyDoc_STRVAR(getdefaulttimeout_doc,
47104
 
 "getdefaulttimeout() -> timeout\n\
47105
 
 \n\
47106
 
-Returns the default timeout in floating seconds for new socket objects.\n\
47107
 
+Returns the default timeout in seconds (float) for new socket objects.\n\
47108
 
 A value of None indicates that new socket objects have no timeout.\n\
47109
 
 When the socket module is first imported, the default is None.");
47110
 
 
47111
 
@@ -4282,7 +4291,7 @@
47112
 
 PyDoc_STRVAR(setdefaulttimeout_doc,
47113
 
 "setdefaulttimeout(timeout)\n\
47114
 
 \n\
47115
 
-Set the default timeout in floating seconds for new socket objects.\n\
47116
 
+Set the default timeout in seconds (float) for new socket objects.\n\
47117
 
 A value of None indicates that new socket objects have no timeout.\n\
47118
 
 When the socket module is first imported, the default is None.");
47119
 
 
47120
 
diff -r 8527427914a2 Modules/threadmodule.c
47121
 
--- a/Modules/threadmodule.c
47122
 
+++ b/Modules/threadmodule.c
47123
 
@@ -715,7 +715,7 @@
47124
 
 
47125
 
 PyDoc_STRVAR(exit_doc,
47126
 
 "exit()\n\
47127
 
-(PyThread_exit_thread() is an obsolete synonym)\n\
47128
 
+(exit_thread() is an obsolete synonym)\n\
47129
 
 \n\
47130
 
 This is synonymous to ``raise SystemExit''.  It will cause the current\n\
47131
 
 thread to exit silently unless the exception is caught.");
47132
 
diff -r 8527427914a2 Modules/unicodedata.c
47133
 
--- a/Modules/unicodedata.c
47134
 
+++ b/Modules/unicodedata.c
47135
 
@@ -830,7 +830,7 @@
47136
 
     unsigned long h = 0;
47137
 
     unsigned long ix;
47138
 
     for (i = 0; i < len; i++) {
47139
 
-        h = (h * scale) + (unsigned char) toupper(Py_CHARMASK(s[i]));
47140
 
+        h = (h * scale) + (unsigned char) Py_TOUPPER(Py_CHARMASK(s[i]));
47141
 
         ix = h & 0xff000000;
47142
 
         if (ix)
47143
 
             h = (h ^ ((ix>>24) & 0xff)) & 0x00ffffff;
47144
 
@@ -978,7 +978,7 @@
47145
 
     if (!_getucname(self, code, buffer, sizeof(buffer)))
47146
 
         return 0;
47147
 
     for (i = 0; i < namelen; i++) {
47148
 
-        if (toupper(Py_CHARMASK(name[i])) != buffer[i])
47149
 
+        if (Py_TOUPPER(Py_CHARMASK(name[i])) != buffer[i])
47150
 
             return 0;
47151
 
     }
47152
 
     return buffer[namelen] == '\0';
47153
 
diff -r 8527427914a2 Modules/zlibmodule.c
47154
 
--- a/Modules/zlibmodule.c
47155
 
+++ b/Modules/zlibmodule.c
47156
 
@@ -72,7 +72,13 @@
47157
 
 static void
47158
 
 zlib_error(z_stream zst, int err, char *msg)
47159
 
 {
47160
 
-    const char *zmsg = zst.msg;
47161
 
+    const char *zmsg = Z_NULL;
47162
 
+    /* In case of a version mismatch, zst.msg won't be initialized.
47163
 
+       Check for this case first, before looking at zst.msg. */
47164
 
+    if (err == Z_VERSION_ERROR)
47165
 
+        zmsg = "library version mismatch";
47166
 
+    if (zmsg == Z_NULL)
47167
 
+        zmsg = zst.msg;
47168
 
     if (zmsg == Z_NULL) {
47169
 
         switch (err) {
47170
 
         case Z_BUF_ERROR:
47171
 
diff -r 8527427914a2 Objects/abstract.c
47172
 
--- a/Objects/abstract.c
47173
 
+++ b/Objects/abstract.c
47174
 
@@ -156,7 +156,7 @@
47175
 
                               "be integer, not '%.200s'", key);
47176
 
     }
47177
 
 
47178
 
-    return type_error("'%.200s' object is not subscriptable", o);
47179
 
+    return type_error("'%.200s' object has no attribute '__getitem__'", o);
47180
 
 }
47181
 
 
47182
 
 int
47183
 
diff -r 8527427914a2 Objects/bytearrayobject.c
47184
 
--- a/Objects/bytearrayobject.c
47185
 
+++ b/Objects/bytearrayobject.c
47186
 
@@ -1170,7 +1170,7 @@
47187
 
 "B.find(sub [,start [,end]]) -> int\n\
47188
 
 \n\
47189
 
 Return the lowest index in B where subsection sub is found,\n\
47190
 
-such that sub is contained within s[start,end].  Optional\n\
47191
 
+such that sub is contained within B[start,end].  Optional\n\
47192
 
 arguments start and end are interpreted as in slice notation.\n\
47193
 
 \n\
47194
 
 Return -1 on failure.");
47195
 
@@ -1240,7 +1240,7 @@
47196
 
 "B.rfind(sub [,start [,end]]) -> int\n\
47197
 
 \n\
47198
 
 Return the highest index in B where subsection sub is found,\n\
47199
 
-such that sub is contained within s[start,end].  Optional\n\
47200
 
+such that sub is contained within B[start,end].  Optional\n\
47201
 
 arguments start and end are interpreted as in slice notation.\n\
47202
 
 \n\
47203
 
 Return -1 on failure.");
47204
 
diff -r 8527427914a2 Objects/classobject.c
47205
 
--- a/Objects/classobject.c
47206
 
+++ b/Objects/classobject.c
47207
 
@@ -1221,7 +1221,7 @@
47208
 
     if (func == NULL)
47209
 
         return -1;
47210
 
     if (item == NULL)
47211
 
-        arg = PyInt_FromSsize_t(i);
47212
 
+        arg = Py_BuildValue("(n)", i);
47213
 
     else
47214
 
         arg = Py_BuildValue("(nO)", i, item);
47215
 
     if (arg == NULL) {
47216
 
diff -r 8527427914a2 Objects/descrobject.c
47217
 
--- a/Objects/descrobject.c
47218
 
+++ b/Objects/descrobject.c
47219
 
@@ -801,6 +801,20 @@
47220
 
     return PyObject_Str(pp->dict);
47221
 
 }
47222
 
 
47223
 
+static PyObject *
47224
 
+proxy_repr(proxyobject *pp)
47225
 
+{
47226
 
+    PyObject *dictrepr;
47227
 
+    PyObject *result;
47228
 
+
47229
 
+    dictrepr = PyObject_Repr(pp->dict);
47230
 
+    if (dictrepr == NULL)
47231
 
+        return NULL;
47232
 
+    result = PyString_FromFormat("dict_proxy(%s)", PyString_AS_STRING(dictrepr));
47233
 
+    Py_DECREF(dictrepr);
47234
 
+    return result;
47235
 
+}
47236
 
+
47237
 
 static int
47238
 
 proxy_traverse(PyObject *self, visitproc visit, void *arg)
47239
 
 {
47240
 
@@ -832,7 +846,7 @@
47241
 
     0,                                          /* tp_getattr */
47242
 
     0,                                          /* tp_setattr */
47243
 
     (cmpfunc)proxy_compare,                     /* tp_compare */
47244
 
-    0,                                          /* tp_repr */
47245
 
+    (reprfunc)proxy_repr,                       /* tp_repr */
47246
 
     0,                                          /* tp_as_number */
47247
 
     &proxy_as_sequence,                         /* tp_as_sequence */
47248
 
     &proxy_as_mapping,                          /* tp_as_mapping */
47249
 
diff -r 8527427914a2 Objects/dictobject.c
47250
 
--- a/Objects/dictobject.c
47251
 
+++ b/Objects/dictobject.c
47252
 
@@ -1335,14 +1335,18 @@
47253
 
         PyObject *key;
47254
 
         long hash;
47255
 
 
47256
 
-        if (dictresize(mp, Py_SIZE(seq)))
47257
 
+        if (dictresize(mp, Py_SIZE(seq))) {
47258
 
+            Py_DECREF(d);
47259
 
             return NULL;
47260
 
+        }
47261
 
 
47262
 
         while (_PyDict_Next(seq, &pos, &key, &oldvalue, &hash)) {
47263
 
             Py_INCREF(key);
47264
 
             Py_INCREF(value);
47265
 
-            if (insertdict(mp, key, hash, value))
47266
 
+            if (insertdict(mp, key, hash, value)) {
47267
 
+                Py_DECREF(d);
47268
 
                 return NULL;
47269
 
+            }
47270
 
         }
47271
 
         return d;
47272
 
     }
47273
 
@@ -1353,14 +1357,18 @@
47274
 
         PyObject *key;
47275
 
         long hash;
47276
 
 
47277
 
-        if (dictresize(mp, PySet_GET_SIZE(seq)))
47278
 
+        if (dictresize(mp, PySet_GET_SIZE(seq))) {
47279
 
+            Py_DECREF(d);
47280
 
             return NULL;
47281
 
+        }
47282
 
 
47283
 
         while (_PySet_NextEntry(seq, &pos, &key, &hash)) {
47284
 
             Py_INCREF(key);
47285
 
             Py_INCREF(value);
47286
 
-            if (insertdict(mp, key, hash, value))
47287
 
+            if (insertdict(mp, key, hash, value)) {
47288
 
+                Py_DECREF(d);
47289
 
                 return NULL;
47290
 
+            }
47291
 
         }
47292
 
         return d;
47293
 
     }
47294
 
@@ -2159,9 +2167,9 @@
47295
 
 "D.values() -> list of D's values");
47296
 
 
47297
 
 PyDoc_STRVAR(update__doc__,
47298
 
-"D.update(E, **F) -> None.  Update D from dict/iterable E and F.\n"
47299
 
-"If E has a .keys() method, does:     for k in E: D[k] = E[k]\n\
47300
 
-If E lacks .keys() method, does:     for (k, v) in E: D[k] = v\n\
47301
 
+"D.update([E, ]**F) -> None.  Update D from dict/iterable E and F.\n"
47302
 
+"If E present and has a .keys() method, does:     for k in E: D[k] = E[k]\n\
47303
 
+If E present and lacks .keys() method, does:     for (k, v) in E: D[k] = v\n\
47304
 
 In either case, this is followed by: for k in F: D[k] = F[k]");
47305
 
 
47306
 
 PyDoc_STRVAR(fromkeys__doc__,
47307
 
diff -r 8527427914a2 Objects/exceptions.c
47308
 
--- a/Objects/exceptions.c
47309
 
+++ b/Objects/exceptions.c
47310
 
@@ -306,7 +306,8 @@
47311
 
         return -1;
47312
 
     }
47313
 
     seq = PySequence_Tuple(val);
47314
 
-    if (!seq) return -1;
47315
 
+    if (!seq)
47316
 
+        return -1;
47317
 
     Py_CLEAR(self->args);
47318
 
     self->args = seq;
47319
 
     return 0;
47320
 
@@ -773,7 +774,8 @@
47321
 
      * file name given to EnvironmentError. */
47322
 
     if (PyTuple_GET_SIZE(args) == 2 && self->filename) {
47323
 
         args = PyTuple_New(3);
47324
 
-        if (!args) return NULL;
47325
 
+        if (!args)
47326
 
+            return NULL;
47327
 
 
47328
 
         tmp = PyTuple_GET_ITEM(self->args, 0);
47329
 
         Py_INCREF(tmp);
47330
 
@@ -1071,7 +1073,8 @@
47331
 
     if (lenargs == 2) {
47332
 
         info = PyTuple_GET_ITEM(args, 1);
47333
 
         info = PySequence_Tuple(info);
47334
 
-        if (!info) return -1;
47335
 
+        if (!info)
47336
 
+            return -1;
47337
 
 
47338
 
         if (PyTuple_GET_SIZE(info) != 4) {
47339
 
             /* not a very good error message, but it's what Python 2.4 gives */
47340
 
@@ -1167,9 +1170,11 @@
47341
 
         str = PyObject_Str(self->msg);
47342
 
     else
47343
 
         str = PyObject_Str(Py_None);
47344
 
-    if (!str) return NULL;
47345
 
+    if (!str)
47346
 
+        return NULL;
47347
 
     /* Don't fiddle with non-string return (shouldn't happen anyway) */
47348
 
-    if (!PyString_Check(str)) return str;
47349
 
+    if (!PyString_Check(str))
47350
 
+        return str;
47351
 
 
47352
 
     /* XXX -- do all the additional formatting with filename and
47353
 
        lineno here */
47354
 
@@ -2111,7 +2116,8 @@
47355
 
 
47356
 
     m = Py_InitModule4("exceptions", functions, exceptions_doc,
47357
 
         (PyObject *)NULL, PYTHON_API_VERSION);
47358
 
-    if (m == NULL) return;
47359
 
+    if (m == NULL)
47360
 
+        return;
47361
 
 
47362
 
     bltinmod = PyImport_ImportModule("__builtin__");
47363
 
     if (bltinmod == NULL)
47364
 
@@ -2203,7 +2209,6 @@
47365
 
             Py_FatalError("init of pre-allocated RuntimeError failed");
47366
 
         Py_DECREF(args_tuple);
47367
 
     }
47368
 
-
47369
 
     Py_DECREF(bltinmod);
47370
 
 }
47371
 
 
47372
 
diff -r 8527427914a2 Objects/fileobject.c
47373
 
--- a/Objects/fileobject.c
47374
 
+++ b/Objects/fileobject.c
47375
 
@@ -468,28 +468,34 @@
47376
 
 PyObject *
47377
 
 PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE *))
47378
 
 {
47379
 
-    PyFileObject *f = (PyFileObject *)PyFile_Type.tp_new(&PyFile_Type,
47380
 
-                                                         NULL, NULL);
47381
 
-    if (f != NULL) {
47382
 
-        PyObject *o_name = PyString_FromString(name);
47383
 
-        if (o_name == NULL)
47384
 
-            return NULL;
47385
 
-        if (fill_file_fields(f, fp, o_name, mode, close) == NULL) {
47386
 
-            Py_DECREF(f);
47387
 
-            f = NULL;
47388
 
-        }
47389
 
+    PyFileObject *f;
47390
 
+    PyObject *o_name;
47391
 
+
47392
 
+    f = (PyFileObject *)PyFile_Type.tp_new(&PyFile_Type, NULL, NULL);
47393
 
+    if (f == NULL)
47394
 
+        return NULL;
47395
 
+    o_name = PyString_FromString(name);
47396
 
+    if (o_name == NULL) {
47397
 
+        if (close != NULL && fp != NULL)
47398
 
+            close(fp);
47399
 
+        Py_DECREF(f);
47400
 
+        return NULL;
47401
 
+    }
47402
 
+    if (fill_file_fields(f, fp, o_name, mode, close) == NULL) {
47403
 
+        Py_DECREF(f);
47404
 
         Py_DECREF(o_name);
47405
 
+        return NULL;
47406
 
     }
47407
 
-    return (PyObject *) f;
47408
 
+    Py_DECREF(o_name);
47409
 
+    return (PyObject *)f;
47410
 
 }
47411
 
 
47412
 
 PyObject *
47413
 
 PyFile_FromString(char *name, char *mode)
47414
 
 {
47415
 
-    extern int fclose(FILE *);
47416
 
     PyFileObject *f;
47417
 
 
47418
 
-    f = (PyFileObject *)PyFile_FromFile((FILE *)NULL, name, mode, fclose);
47419
 
+    f = (PyFileObject *)PyFile_FromFile((FILE *)NULL, name, mode, NULL);
47420
 
     if (f != NULL) {
47421
 
         if (open_the_file(f, name, mode) == NULL) {
47422
 
             Py_DECREF(f);
47423
 
@@ -986,12 +992,6 @@
47424
 
 #define SMALLCHUNK BUFSIZ
47425
 
 #endif
47426
 
 
47427
 
-#if SIZEOF_INT < 4
47428
 
-#define BIGCHUNK  (512 * 32)
47429
 
-#else
47430
 
-#define BIGCHUNK  (512 * 1024)
47431
 
-#endif
47432
 
-
47433
 
 static size_t
47434
 
 new_buffersize(PyFileObject *f, size_t currentsize)
47435
 
 {
47436
 
@@ -1020,15 +1020,10 @@
47437
 
         /* Add 1 so if the file were to grow we'd notice. */
47438
 
     }
47439
 
 #endif
47440
 
-    if (currentsize > SMALLCHUNK) {
47441
 
-        /* Keep doubling until we reach BIGCHUNK;
47442
 
-           then keep adding BIGCHUNK. */
47443
 
-        if (currentsize <= BIGCHUNK)
47444
 
-            return currentsize + currentsize;
47445
 
-        else
47446
 
-            return currentsize + BIGCHUNK;
47447
 
-    }
47448
 
-    return currentsize + SMALLCHUNK;
47449
 
+    /* Expand the buffer by an amount proportional to the current size,
47450
 
+       giving us amortized linear-time behavior. Use a less-than-double
47451
 
+       growth factor to avoid excessive allocation. */
47452
 
+    return currentsize + (currentsize >> 3) + 6;
47453
 
 }
47454
 
 
47455
 
 #if defined(EWOULDBLOCK) && defined(EAGAIN) && EWOULDBLOCK != EAGAIN
47456
 
diff -r 8527427914a2 Objects/floatobject.c
47457
 
--- a/Objects/floatobject.c
47458
 
+++ b/Objects/floatobject.c
47459
 
@@ -1086,6 +1086,7 @@
47460
 
     char *buf, *buf_end, shortbuf[100], *mybuf=shortbuf;
47461
 
     int decpt, sign, val, halfway_case;
47462
 
     PyObject *result = NULL;
47463
 
+    _Py_SET_53BIT_PRECISION_HEADER;
47464
 
 
47465
 
     /* The basic idea is very simple: convert and round the double to a
47466
 
        decimal string using _Py_dg_dtoa, then convert that decimal string
47467
 
@@ -1142,7 +1143,9 @@
47468
 
         halfway_case = 0;
47469
 
 
47470
 
     /* round to a decimal string; use an extra place for halfway case */
47471
 
+    _Py_SET_53BIT_PRECISION_START;
47472
 
     buf = _Py_dg_dtoa(x, 3, ndigits+halfway_case, &decpt, &sign, &buf_end);
47473
 
+    _Py_SET_53BIT_PRECISION_END;
47474
 
     if (buf == NULL) {
47475
 
         PyErr_NoMemory();
47476
 
         return NULL;
47477
 
@@ -1186,7 +1189,9 @@
47478
 
 
47479
 
     /* and convert the resulting string back to a double */
47480
 
     errno = 0;
47481
 
+    _Py_SET_53BIT_PRECISION_START;
47482
 
     rounded = _Py_dg_strtod(mybuf, NULL);
47483
 
+    _Py_SET_53BIT_PRECISION_END;
47484
 
     if (errno == ERANGE && fabs(rounded) >= 1.)
47485
 
         PyErr_SetString(PyExc_OverflowError,
47486
 
                         "rounded value too large to represent");
47487
 
diff -r 8527427914a2 Objects/intobject.c
47488
 
--- a/Objects/intobject.c
47489
 
+++ b/Objects/intobject.c
47490
 
@@ -751,7 +751,13 @@
47491
 
     while (iw > 0) {
47492
 
         prev = ix;              /* Save value for overflow check */
47493
 
         if (iw & 1) {
47494
 
-            ix = ix*temp;
47495
 
+            /*
47496
 
+             * The (unsigned long) cast below ensures that the multiplication
47497
 
+             * is interpreted as an unsigned operation rather than a signed one
47498
 
+             * (C99 6.3.1.8p1), thus avoiding the perils of undefined behaviour
47499
 
+             * from signed arithmetic overflow (C99 6.5p5).  See issue #12973.
47500
 
+             */
47501
 
+            ix = (unsigned long)ix * temp;
47502
 
             if (temp == 0)
47503
 
                 break; /* Avoid ix / 0 */
47504
 
             if (ix / temp != prev) {
47505
 
@@ -764,7 +770,7 @@
47506
 
         iw >>= 1;               /* Shift exponent down by 1 bit */
47507
 
         if (iw==0) break;
47508
 
         prev = temp;
47509
 
-        temp *= temp;           /* Square the value of temp */
47510
 
+        temp = (unsigned long)temp * temp;  /* Square the value of temp */
47511
 
         if (prev != 0 && temp / prev != prev) {
47512
 
             return PyLong_Type.tp_as_number->nb_power(
47513
 
                 (PyObject *)v, (PyObject *)w, (PyObject *)z);
47514
 
diff -r 8527427914a2 Objects/listobject.c
47515
 
--- a/Objects/listobject.c
47516
 
+++ b/Objects/listobject.c
47517
 
@@ -58,7 +58,7 @@
47518
 
     if (newsize == 0)
47519
 
         new_allocated = 0;
47520
 
     items = self->ob_item;
47521
 
-    if (new_allocated <= ((~(size_t)0) / sizeof(PyObject *)))
47522
 
+    if (new_allocated <= (PY_SIZE_MAX / sizeof(PyObject *)))
47523
 
         PyMem_RESIZE(items, PyObject *, new_allocated);
47524
 
     else
47525
 
         items = NULL;
47526
 
@@ -551,9 +551,9 @@
47527
 
     PyObject *elem;
47528
 
     if (n < 0)
47529
 
         n = 0;
47530
 
+    if (n > 0 && Py_SIZE(a) > PY_SSIZE_T_MAX / n)
47531
 
+        return PyErr_NoMemory();
47532
 
     size = Py_SIZE(a) * n;
47533
 
-    if (n && size/n != Py_SIZE(a))
47534
 
-        return PyErr_NoMemory();
47535
 
     if (size == 0)
47536
 
         return PyList_New(0);
47537
 
     np = (PyListObject *) PyList_New(size);
47538
 
diff -r 8527427914a2 Objects/setobject.c
47539
 
--- a/Objects/setobject.c
47540
 
+++ b/Objects/setobject.c
47541
 
@@ -1871,7 +1871,7 @@
47542
 
         tmpkey = make_new_set(&PyFrozenSet_Type, key);
47543
 
         if (tmpkey == NULL)
47544
 
             return -1;
47545
 
-        rv = set_contains(so, tmpkey);
47546
 
+        rv = set_contains_key(so, tmpkey);
47547
 
         Py_DECREF(tmpkey);
47548
 
     }
47549
 
     return rv;
47550
 
@@ -1925,7 +1925,7 @@
47551
 
 static PyObject *
47552
 
 set_discard(PySetObject *so, PyObject *key)
47553
 
 {
47554
 
-    PyObject *tmpkey, *result;
47555
 
+    PyObject *tmpkey;
47556
 
     int rv;
47557
 
 
47558
 
     rv = set_discard_key(so, key);
47559
 
@@ -1936,9 +1936,10 @@
47560
 
         tmpkey = make_new_set(&PyFrozenSet_Type, key);
47561
 
         if (tmpkey == NULL)
47562
 
             return NULL;
47563
 
-        result = set_discard(so, tmpkey);
47564
 
+        rv = set_discard_key(so, tmpkey);
47565
 
         Py_DECREF(tmpkey);
47566
 
-        return result;
47567
 
+        if (rv == -1)
47568
 
+            return NULL;
47569
 
     }
47570
 
     Py_RETURN_NONE;
47571
 
 }
47572
 
diff -r 8527427914a2 Objects/stringobject.c
47573
 
--- a/Objects/stringobject.c
47574
 
+++ b/Objects/stringobject.c
47575
 
@@ -1727,7 +1727,7 @@
47576
 
 "S.find(sub [,start [,end]]) -> int\n\
47577
 
 \n\
47578
 
 Return the lowest index in S where substring sub is found,\n\
47579
 
-such that sub is contained within s[start:end].  Optional\n\
47580
 
+such that sub is contained within S[start:end].  Optional\n\
47581
 
 arguments start and end are interpreted as in slice notation.\n\
47582
 
 \n\
47583
 
 Return -1 on failure.");
47584
 
@@ -1766,7 +1766,7 @@
47585
 
 "S.rfind(sub [,start [,end]]) -> int\n\
47586
 
 \n\
47587
 
 Return the highest index in S where substring sub is found,\n\
47588
 
-such that sub is contained within s[start:end].  Optional\n\
47589
 
+such that sub is contained within S[start:end].  Optional\n\
47590
 
 arguments start and end are interpreted as in slice notation.\n\
47591
 
 \n\
47592
 
 Return -1 on failure.");
47593
 
@@ -2173,7 +2173,9 @@
47594
 
 Return a copy of the string S, where all characters occurring\n\
47595
 
 in the optional argument deletechars are removed, and the\n\
47596
 
 remaining characters have been mapped through the given\n\
47597
 
-translation table, which must be a string of length 256.");
47598
 
+translation table, which must be a string of length 256 or None.\n\
47599
 
+If the table argument is None, no translation is applied and\n\
47600
 
+the operation simply removes the characters in deletechars.");
47601
 
 
47602
 
 static PyObject *
47603
 
 string_translate(PyStringObject *self, PyObject *args)
47604
 
diff -r 8527427914a2 Objects/structseq.c
47605
 
--- a/Objects/structseq.c
47606
 
+++ b/Objects/structseq.c
47607
 
@@ -175,32 +175,33 @@
47608
 
     if (min_len != max_len) {
47609
 
         if (len < min_len) {
47610
 
             PyErr_Format(PyExc_TypeError,
47611
 
-           "%.500s() takes an at least %zd-sequence (%zd-sequence given)",
47612
 
-                                 type->tp_name, min_len, len);
47613
 
-                    Py_DECREF(arg);
47614
 
-                    return NULL;
47615
 
+                "%.500s() takes an at least %zd-sequence (%zd-sequence given)",
47616
 
+                type->tp_name, min_len, len);
47617
 
+            Py_DECREF(arg);
47618
 
+            return NULL;
47619
 
         }
47620
 
 
47621
 
         if (len > max_len) {
47622
 
             PyErr_Format(PyExc_TypeError,
47623
 
-           "%.500s() takes an at most %zd-sequence (%zd-sequence given)",
47624
 
-                                 type->tp_name, max_len, len);
47625
 
-                    Py_DECREF(arg);
47626
 
-                    return NULL;
47627
 
+                         "%.500s() takes an at most %zd-sequence (%zd-sequence given)",
47628
 
+                         type->tp_name, max_len, len);
47629
 
+            Py_DECREF(arg);
47630
 
+            return NULL;
47631
 
         }
47632
 
     }
47633
 
     else {
47634
 
         if (len != min_len) {
47635
 
             PyErr_Format(PyExc_TypeError,
47636
 
-           "%.500s() takes a %zd-sequence (%zd-sequence given)",
47637
 
-                                 type->tp_name, min_len, len);
47638
 
-                    Py_DECREF(arg);
47639
 
-                    return NULL;
47640
 
+                         "%.500s() takes a %zd-sequence (%zd-sequence given)",
47641
 
+                         type->tp_name, min_len, len);
47642
 
+            Py_DECREF(arg);
47643
 
+            return NULL;
47644
 
         }
47645
 
     }
47646
 
 
47647
 
     res = (PyStructSequence*) PyStructSequence_New(type);
47648
 
     if (res == NULL) {
47649
 
+        Py_DECREF(arg);
47650
 
         return NULL;
47651
 
     }
47652
 
     for (i = 0; i < len; ++i) {
47653
 
diff -r 8527427914a2 Objects/typeobject.c
47654
 
--- a/Objects/typeobject.c
47655
 
+++ b/Objects/typeobject.c
47656
 
@@ -2233,8 +2233,10 @@
47657
 
                 (add_weak && strcmp(s, "__weakref__") == 0))
47658
 
                 continue;
47659
 
             tmp =_Py_Mangle(name, tmp);
47660
 
-            if (!tmp)
47661
 
+            if (!tmp) {
47662
 
+                Py_DECREF(newslots);
47663
 
                 goto bad_slots;
47664
 
+            }
47665
 
             PyList_SET_ITEM(newslots, j, tmp);
47666
 
             j++;
47667
 
         }
47668
 
@@ -2703,15 +2705,16 @@
47669
 
        for heaptypes. */
47670
 
     assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE);
47671
 
 
47672
 
-    /* The only field we need to clear is tp_mro, which is part of a
47673
 
-       hard cycle (its first element is the class itself) that won't
47674
 
-       be broken otherwise (it's a tuple and tuples don't have a
47675
 
+    /* We need to invalidate the method cache carefully before clearing
47676
 
+       the dict, so that other objects caught in a reference cycle
47677
 
+       don't start calling destroyed methods.
47678
 
+
47679
 
+       Otherwise, the only field we need to clear is tp_mro, which is
47680
 
+       part of a hard cycle (its first element is the class itself) that
47681
 
+       won't be broken otherwise (it's a tuple and tuples don't have a
47682
 
        tp_clear handler).  None of the other fields need to be
47683
 
        cleared, and here's why:
47684
 
 
47685
 
-       tp_dict:
47686
 
-           It is a dict, so the collector will call its tp_clear.
47687
 
-
47688
 
        tp_cache:
47689
 
            Not used; if it were, it would be a dict.
47690
 
 
47691
 
@@ -2728,6 +2731,9 @@
47692
 
            A tuple of strings can't be part of a cycle.
47693
 
     */
47694
 
 
47695
 
+    PyType_Modified(type);
47696
 
+    if (type->tp_dict)
47697
 
+        PyDict_Clear(type->tp_dict);
47698
 
     Py_CLEAR(type->tp_mro);
47699
 
 
47700
 
     return 0;
47701
 
@@ -2978,7 +2984,7 @@
47702
 
     unaryfunc f;
47703
 
 
47704
 
     f = Py_TYPE(self)->tp_repr;
47705
 
-    if (f == NULL)
47706
 
+    if (f == NULL || f == object_str)
47707
 
         f = object_repr;
47708
 
     return f(self);
47709
 
 }
47710
 
@@ -5933,27 +5939,27 @@
47711
 
     NBSLOT("__index__", nb_index, slot_nb_index, wrap_unaryfunc,
47712
 
            "x[y:z] <==> x[y.__index__():z.__index__()]"),
47713
 
     IBSLOT("__iadd__", nb_inplace_add, slot_nb_inplace_add,
47714
 
-           wrap_binaryfunc, "+"),
47715
 
+           wrap_binaryfunc, "+="),
47716
 
     IBSLOT("__isub__", nb_inplace_subtract, slot_nb_inplace_subtract,
47717
 
-           wrap_binaryfunc, "-"),
47718
 
+           wrap_binaryfunc, "-="),
47719
 
     IBSLOT("__imul__", nb_inplace_multiply, slot_nb_inplace_multiply,
47720
 
-           wrap_binaryfunc, "*"),
47721
 
+           wrap_binaryfunc, "*="),
47722
 
     IBSLOT("__idiv__", nb_inplace_divide, slot_nb_inplace_divide,
47723
 
-           wrap_binaryfunc, "/"),
47724
 
+           wrap_binaryfunc, "/="),
47725
 
     IBSLOT("__imod__", nb_inplace_remainder, slot_nb_inplace_remainder,
47726
 
-           wrap_binaryfunc, "%"),
47727
 
+           wrap_binaryfunc, "%="),
47728
 
     IBSLOT("__ipow__", nb_inplace_power, slot_nb_inplace_power,
47729
 
-           wrap_binaryfunc, "**"),
47730
 
+           wrap_binaryfunc, "**="),
47731
 
     IBSLOT("__ilshift__", nb_inplace_lshift, slot_nb_inplace_lshift,
47732
 
-           wrap_binaryfunc, "<<"),
47733
 
+           wrap_binaryfunc, "<<="),
47734
 
     IBSLOT("__irshift__", nb_inplace_rshift, slot_nb_inplace_rshift,
47735
 
-           wrap_binaryfunc, ">>"),
47736
 
+           wrap_binaryfunc, ">>="),
47737
 
     IBSLOT("__iand__", nb_inplace_and, slot_nb_inplace_and,
47738
 
-           wrap_binaryfunc, "&"),
47739
 
+           wrap_binaryfunc, "&="),
47740
 
     IBSLOT("__ixor__", nb_inplace_xor, slot_nb_inplace_xor,
47741
 
-           wrap_binaryfunc, "^"),
47742
 
+           wrap_binaryfunc, "^="),
47743
 
     IBSLOT("__ior__", nb_inplace_or, slot_nb_inplace_or,
47744
 
-           wrap_binaryfunc, "|"),
47745
 
+           wrap_binaryfunc, "|="),
47746
 
     BINSLOT("__floordiv__", nb_floor_divide, slot_nb_floor_divide, "//"),
47747
 
     RBINSLOT("__rfloordiv__", nb_floor_divide, slot_nb_floor_divide, "//"),
47748
 
     BINSLOT("__truediv__", nb_true_divide, slot_nb_true_divide, "/"),
47749
 
diff -r 8527427914a2 Objects/unicodeobject.c
47750
 
--- a/Objects/unicodeobject.c
47751
 
+++ b/Objects/unicodeobject.c
47752
 
@@ -1628,21 +1628,17 @@
47753
 
                             *p++ = outCh;
47754
 
 #endif
47755
 
                             surrogate = 0;
47756
 
+                            continue;
47757
 
                         }
47758
 
                         else {
47759
 
+                            *p++ = surrogate;
47760
 
                             surrogate = 0;
47761
 
-                            errmsg = "second surrogate missing";
47762
 
-                            goto utf7Error;
47763
 
                         }
47764
 
                     }
47765
 
-                    else if (outCh >= 0xD800 && outCh <= 0xDBFF) {
47766
 
+                    if (outCh >= 0xD800 && outCh <= 0xDBFF) {
47767
 
                         /* first surrogate */
47768
 
                         surrogate = outCh;
47769
 
                     }
47770
 
-                    else if (outCh >= 0xDC00 && outCh <= 0xDFFF) {
47771
 
-                        errmsg = "unexpected second surrogate";
47772
 
-                        goto utf7Error;
47773
 
-                    }
47774
 
                     else {
47775
 
                         *p++ = outCh;
47776
 
                     }
47777
 
@@ -1652,8 +1648,8 @@
47778
 
                 inShift = 0;
47779
 
                 s++;
47780
 
                 if (surrogate) {
47781
 
-                    errmsg = "second surrogate missing at end of shift sequence";
47782
 
-                    goto utf7Error;
47783
 
+                    *p++ = surrogate;
47784
 
+                    surrogate = 0;
47785
 
                 }
47786
 
                 if (base64bits > 0) { /* left-over bits */
47787
 
                     if (base64bits >= 6) {
47788
 
@@ -5164,11 +5160,10 @@
47789
 
         }
47790
 
         /* All other characters are considered unencodable */
47791
 
         collstart = p;
47792
 
-        collend = p+1;
47793
 
-        while (collend < end) {
47794
 
+        for (collend = p+1; collend < end; collend++) {
47795
 
             if ((0 < *collend && *collend < 256) ||
47796
 
-                !Py_UNICODE_ISSPACE(*collend) ||
47797
 
-                Py_UNICODE_TODECIMAL(*collend))
47798
 
+                Py_UNICODE_ISSPACE(*collend) ||
47799
 
+                0 <= Py_UNICODE_TODECIMAL(*collend))
47800
 
                 break;
47801
 
         }
47802
 
         /* cache callback name lookup
47803
 
@@ -5485,13 +5480,13 @@
47804
 
 
47805
 
     if (len == 0)
47806
 
         return 0;
47807
 
-    if (Py_UNICODE_ISLOWER(*s)) {
47808
 
+    if (!Py_UNICODE_ISUPPER(*s)) {
47809
 
         *s = Py_UNICODE_TOUPPER(*s);
47810
 
         status = 1;
47811
 
     }
47812
 
     s++;
47813
 
     while (--len > 0) {
47814
 
-        if (Py_UNICODE_ISUPPER(*s)) {
47815
 
+        if (!Py_UNICODE_ISLOWER(*s)) {
47816
 
             *s = Py_UNICODE_TOLOWER(*s);
47817
 
             status = 1;
47818
 
         }
47819
 
@@ -6491,7 +6486,7 @@
47820
 
              "S.find(sub [,start [,end]]) -> int\n\
47821
 
 \n\
47822
 
 Return the lowest index in S where substring sub is found,\n\
47823
 
-such that sub is contained within s[start:end].  Optional\n\
47824
 
+such that sub is contained within S[start:end].  Optional\n\
47825
 
 arguments start and end are interpreted as in slice notation.\n\
47826
 
 \n\
47827
 
 Return -1 on failure.");
47828
 
@@ -7226,7 +7221,7 @@
47829
 
              "S.rfind(sub [,start [,end]]) -> int\n\
47830
 
 \n\
47831
 
 Return the highest index in S where substring sub is found,\n\
47832
 
-such that sub is contained within s[start:end].  Optional\n\
47833
 
+such that sub is contained within S[start:end].  Optional\n\
47834
 
 arguments start and end are interpreted as in slice notation.\n\
47835
 
 \n\
47836
 
 Return -1 on failure.");
47837
 
diff -r 8527427914a2 PC/pyconfig.h
47838
 
--- a/PC/pyconfig.h
47839
 
+++ b/PC/pyconfig.h
47840
 
@@ -643,6 +643,9 @@
47841
 
 #define HAVE_WCSCOLL 1
47842
 
 #endif
47843
 
 
47844
 
+/* Define if the zlib library has inflateCopy */
47845
 
+#define HAVE_ZLIB_COPY 1
47846
 
+
47847
 
 /* Define if you have the <dlfcn.h> header file.  */
47848
 
 /* #undef HAVE_DLFCN_H */
47849
 
 
47850
 
diff -r 8527427914a2 Parser/asdl_c.py
47851
 
--- a/Parser/asdl_c.py
47852
 
+++ b/Parser/asdl_c.py
47853
 
@@ -800,8 +800,25 @@
47854
 
     return 0;
47855
 
 }
47856
 
 
47857
 
-#define obj2ast_identifier obj2ast_object
47858
 
-#define obj2ast_string obj2ast_object
47859
 
+static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena)
47860
 
+{
47861
 
+    if (!PyString_CheckExact(obj) && obj != Py_None) {
47862
 
+        PyErr_Format(PyExc_TypeError,
47863
 
+                    "AST identifier must be of type str");
47864
 
+        return 1;
47865
 
+    }
47866
 
+    return obj2ast_object(obj, out, arena);
47867
 
+}
47868
 
+
47869
 
+static int obj2ast_string(PyObject* obj, PyObject** out, PyArena* arena)
47870
 
+{
47871
 
+    if (!PyString_CheckExact(obj) && !PyUnicode_CheckExact(obj)) {
47872
 
+        PyErr_SetString(PyExc_TypeError,
47873
 
+                       "AST string must be of type str or unicode");
47874
 
+        return 1;
47875
 
+    }
47876
 
+    return obj2ast_object(obj, out, arena);
47877
 
+}
47878
 
 
47879
 
 static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
47880
 
 {
47881
 
@@ -903,9 +920,6 @@
47882
 
             self.emit("if (!%s_singleton) return 0;" % cons.name, 1)
47883
 
 
47884
 
 
47885
 
-def parse_version(mod):
47886
 
-    return mod.version.value[12:-3]
47887
 
-
47888
 
 class ASTModuleVisitor(PickleVisitor):
47889
 
 
47890
 
     def visitModule(self, mod):
47891
 
@@ -922,7 +936,7 @@
47892
 
         self.emit("return;", 2)
47893
 
         # Value of version: "$Revision$"
47894
 
         self.emit('if (PyModule_AddStringConstant(m, "__version__", "%s") < 0)'
47895
 
-                % parse_version(mod), 1)
47896
 
+                % mod.version, 1)
47897
 
         self.emit("return;", 2)
47898
 
         for dfn in mod.dfns:
47899
 
             self.visit(dfn)
47900
 
@@ -1160,6 +1174,7 @@
47901
 
     argv0 = os.sep.join(components[-2:])
47902
 
     auto_gen_msg = common_msg % argv0
47903
 
     mod = asdl.parse(srcfile)
47904
 
+    mod.version = "82160"
47905
 
     if not asdl.check(mod):
47906
 
         sys.exit(1)
47907
 
     if INC_DIR:
47908
 
@@ -1181,7 +1196,7 @@
47909
 
         p = os.path.join(SRC_DIR, str(mod.name) + "-ast.c")
47910
 
         f = open(p, "wb")
47911
 
         f.write(auto_gen_msg)
47912
 
-        f.write(c_file_msg % parse_version(mod))
47913
 
+        f.write(c_file_msg % mod.version)
47914
 
         f.write('#include "Python.h"\n')
47915
 
         f.write('#include "%s-ast.h"\n' % mod.name)
47916
 
         f.write('\n')
47917
 
diff -r 8527427914a2 Parser/myreadline.c
47918
 
--- a/Parser/myreadline.c
47919
 
+++ b/Parser/myreadline.c
47920
 
@@ -44,6 +44,7 @@
47921
 
         if (PyOS_InputHook != NULL)
47922
 
             (void)(PyOS_InputHook)();
47923
 
         errno = 0;
47924
 
+        clearerr(fp);
47925
 
         p = fgets(buf, len, fp);
47926
 
         if (p != NULL)
47927
 
             return 0; /* No error */
47928
 
diff -r 8527427914a2 Python/Python-ast.c
47929
 
--- a/Python/Python-ast.c
47930
 
+++ b/Python/Python-ast.c
47931
 
@@ -594,8 +594,25 @@
47932
 
     return 0;
47933
 
 }
47934
 
 
47935
 
-#define obj2ast_identifier obj2ast_object
47936
 
-#define obj2ast_string obj2ast_object
47937
 
+static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena)
47938
 
+{
47939
 
+    if (!PyString_CheckExact(obj) && obj != Py_None) {
47940
 
+        PyErr_Format(PyExc_TypeError,
47941
 
+                    "AST identifier must be of type str");
47942
 
+        return 1;
47943
 
+    }
47944
 
+    return obj2ast_object(obj, out, arena);
47945
 
+}
47946
 
+
47947
 
+static int obj2ast_string(PyObject* obj, PyObject** out, PyArena* arena)
47948
 
+{
47949
 
+    if (!PyString_CheckExact(obj) && !PyUnicode_CheckExact(obj)) {
47950
 
+        PyErr_SetString(PyExc_TypeError,
47951
 
+                       "AST string must be of type str or unicode");
47952
 
+        return 1;
47953
 
+    }
47954
 
+    return obj2ast_object(obj, out, arena);
47955
 
+}
47956
 
 
47957
 
 static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
47958
 
 {
47959
 
diff -r 8527427914a2 Python/_warnings.c
47960
 
--- a/Python/_warnings.c
47961
 
+++ b/Python/_warnings.c
47962
 
@@ -491,7 +491,7 @@
47963
 
 
47964
 
     /* Setup filename. */
47965
 
     *filename = PyDict_GetItemString(globals, "__file__");
47966
 
-    if (*filename != NULL) {
47967
 
+    if (*filename != NULL && PyString_Check(*filename)) {
47968
 
             Py_ssize_t len = PyString_Size(*filename);
47969
 
         const char *file_str = PyString_AsString(*filename);
47970
 
             if (file_str == NULL || (len < 0 && PyErr_Occurred()))
47971
 
@@ -514,6 +514,7 @@
47972
 
     }
47973
 
     else {
47974
 
         const char *module_str = PyString_AsString(*module);
47975
 
+        *filename = NULL;
47976
 
         if (module_str && strcmp(module_str, "__main__") == 0) {
47977
 
             PyObject *argv = PySys_GetObject("argv");
47978
 
             if (argv != NULL && PyList_Size(argv) > 0) {
47979
 
diff -r 8527427914a2 Python/bltinmodule.c
47980
 
--- a/Python/bltinmodule.c
47981
 
+++ b/Python/bltinmodule.c
47982
 
@@ -224,9 +224,6 @@
47983
 
 static PyObject *
47984
 
 builtin_callable(PyObject *self, PyObject *v)
47985
 
 {
47986
 
-    if (PyErr_WarnPy3k("callable() not supported in 3.x; "
47987
 
-                       "use isinstance(x, collections.Callable)", 1) < 0)
47988
 
-        return NULL;
47989
 
     return PyBool_FromLong((long)PyCallable_Check(v));
47990
 
 }
47991
 
 
47992
 
@@ -604,7 +601,7 @@
47993
 
 }
47994
 
 
47995
 
 PyDoc_STRVAR(divmod_doc,
47996
 
-"divmod(x, y) -> (div, mod)\n\
47997
 
+"divmod(x, y) -> (quotient, remainder)\n\
47998
 
 \n\
47999
 
 Return the tuple ((x-x%y)/y, x%y).  Invariant: div*y + mod == x.");
48000
 
 
48001
 
diff -r 8527427914a2 Python/ceval.c
48002
 
--- a/Python/ceval.c
48003
 
+++ b/Python/ceval.c
48004
 
@@ -3515,9 +3515,17 @@
48005
 
         Py_DECREF(tmp);
48006
 
     }
48007
 
 
48008
 
-    if (PyExceptionClass_Check(type))
48009
 
+    if (PyExceptionClass_Check(type)) {
48010
 
         PyErr_NormalizeException(&type, &value, &tb);
48011
 
-
48012
 
+        if (!PyExceptionInstance_Check(value)) {
48013
 
+            PyErr_Format(PyExc_TypeError,
48014
 
+                         "calling %s() should have returned an instance of "
48015
 
+                         "BaseException, not '%s'",
48016
 
+                         ((PyTypeObject *)type)->tp_name,
48017
 
+                         Py_TYPE(value)->tp_name);
48018
 
+            goto raise_error;
48019
 
+        }
48020
 
+    }
48021
 
     else if (PyExceptionInstance_Check(type)) {
48022
 
         /* Raising an instance.  The value should be a dummy. */
48023
 
         if (value != Py_None) {
48024
 
diff -r 8527427914a2 Python/codecs.c
48025
 
--- a/Python/codecs.c
48026
 
+++ b/Python/codecs.c
48027
 
@@ -70,7 +70,7 @@
48028
 
         if (ch == ' ')
48029
 
             ch = '-';
48030
 
         else
48031
 
-            ch = tolower(Py_CHARMASK(ch));
48032
 
+            ch = Py_TOLOWER(Py_CHARMASK(ch));
48033
 
         p[i] = ch;
48034
 
     }
48035
 
     return v;
48036
 
diff -r 8527427914a2 Python/compile.c
48037
 
--- a/Python/compile.c
48038
 
+++ b/Python/compile.c
48039
 
@@ -2079,11 +2079,9 @@
48040
 
     ADDOP_O(c, LOAD_GLOBAL, assertion_error, names);
48041
 
     if (s->v.Assert.msg) {
48042
 
         VISIT(c, expr, s->v.Assert.msg);
48043
 
-        ADDOP_I(c, RAISE_VARARGS, 2);
48044
 
+        ADDOP_I(c, CALL_FUNCTION, 1);
48045
 
     }
48046
 
-    else {
48047
 
-        ADDOP_I(c, RAISE_VARARGS, 1);
48048
 
-    }
48049
 
+    ADDOP_I(c, RAISE_VARARGS, 1);
48050
 
     compiler_use_next_block(c, end);
48051
 
     return 1;
48052
 
 }
48053
 
diff -r 8527427914a2 Python/errors.c
48054
 
--- a/Python/errors.c
48055
 
+++ b/Python/errors.c
48056
 
@@ -111,9 +111,11 @@
48057
 
         PyErr_Fetch(&exception, &value, &tb);
48058
 
         /* Temporarily bump the recursion limit, so that in the most
48059
 
            common case PyObject_IsSubclass will not raise a recursion
48060
 
-           error we have to ignore anyway. */
48061
 
+           error we have to ignore anyway.  Don't do it when the limit
48062
 
+           is already insanely high, to avoid overflow */
48063
 
         reclimit = Py_GetRecursionLimit();
48064
 
-        Py_SetRecursionLimit(reclimit + 5);
48065
 
+        if (reclimit < (1 << 30))
48066
 
+            Py_SetRecursionLimit(reclimit + 5);
48067
 
         res = PyObject_IsSubclass(err, exc);
48068
 
         Py_SetRecursionLimit(reclimit);
48069
 
         /* This function must not fail, so print the error here */
48070
 
diff -r 8527427914a2 Python/getcopyright.c
48071
 
--- a/Python/getcopyright.c
48072
 
+++ b/Python/getcopyright.c
48073
 
@@ -4,7 +4,7 @@
48074
 
 
48075
 
 static char cprt[] = 
48076
 
 "\
48077
 
-Copyright (c) 2001-2011 Python Software Foundation.\n\
48078
 
+Copyright (c) 2001-2012 Python Software Foundation.\n\
48079
 
 All Rights Reserved.\n\
48080
 
 \n\
48081
 
 Copyright (c) 2000 BeOpen.com.\n\
48082
 
diff -r 8527427914a2 Python/import.c
48083
 
--- a/Python/import.c
48084
 
+++ b/Python/import.c
48085
 
@@ -905,9 +905,9 @@
48086
 
         (void) unlink(cpathname);
48087
 
         return;
48088
 
     }
48089
 
-    /* Now write the true mtime */
48090
 
+    /* Now write the true mtime (as a 32-bit field) */
48091
 
     fseek(fp, 4L, 0);
48092
 
-    assert(mtime < LONG_MAX);
48093
 
+    assert(mtime <= 0xFFFFFFFF);
48094
 
     PyMarshal_WriteLongToFile((long)mtime, fp, Py_MARSHAL_VERSION);
48095
 
     fflush(fp);
48096
 
     fclose(fp);
48097
 
@@ -979,17 +979,14 @@
48098
 
                      pathname);
48099
 
         return NULL;
48100
 
     }
48101
 
-#if SIZEOF_TIME_T > 4
48102
 
-    /* Python's .pyc timestamp handling presumes that the timestamp fits
48103
 
-       in 4 bytes. This will be fine until sometime in the year 2038,
48104
 
-       when a 4-byte signed time_t will overflow.
48105
 
-     */
48106
 
-    if (st.st_mtime >> 32) {
48107
 
-        PyErr_SetString(PyExc_OverflowError,
48108
 
-            "modification time overflows a 4 byte field");
48109
 
-        return NULL;
48110
 
+    if (sizeof st.st_mtime > 4) {
48111
 
+        /* Python's .pyc timestamp handling presumes that the timestamp fits
48112
 
+           in 4 bytes. Since the code only does an equality comparison,
48113
 
+           ordering is not important and we can safely ignore the higher bits
48114
 
+           (collisions are extremely unlikely).
48115
 
+         */
48116
 
+        st.st_mtime &= 0xFFFFFFFF;
48117
 
     }
48118
 
-#endif
48119
 
     cpathname = make_compiled_pathname(pathname, buf,
48120
 
                                        (size_t)MAXPATHLEN + 1);
48121
 
     if (cpathname != NULL &&
48122
 
@@ -1235,7 +1232,7 @@
48123
 
 
48124
 
         meta_path = PySys_GetObject("meta_path");
48125
 
         if (meta_path == NULL || !PyList_Check(meta_path)) {
48126
 
-            PyErr_SetString(PyExc_ImportError,
48127
 
+            PyErr_SetString(PyExc_RuntimeError,
48128
 
                             "sys.meta_path must be a list of "
48129
 
                             "import hooks");
48130
 
             return NULL;
48131
 
@@ -1304,14 +1301,14 @@
48132
 
         path = PySys_GetObject("path");
48133
 
     }
48134
 
     if (path == NULL || !PyList_Check(path)) {
48135
 
-        PyErr_SetString(PyExc_ImportError,
48136
 
+        PyErr_SetString(PyExc_RuntimeError,
48137
 
                         "sys.path must be a list of directory names");
48138
 
         return NULL;
48139
 
     }
48140
 
 
48141
 
     path_hooks = PySys_GetObject("path_hooks");
48142
 
     if (path_hooks == NULL || !PyList_Check(path_hooks)) {
48143
 
-        PyErr_SetString(PyExc_ImportError,
48144
 
+        PyErr_SetString(PyExc_RuntimeError,
48145
 
                         "sys.path_hooks must be a list of "
48146
 
                         "import hooks");
48147
 
         return NULL;
48148
 
@@ -1319,7 +1316,7 @@
48149
 
     path_importer_cache = PySys_GetObject("path_importer_cache");
48150
 
     if (path_importer_cache == NULL ||
48151
 
         !PyDict_Check(path_importer_cache)) {
48152
 
-        PyErr_SetString(PyExc_ImportError,
48153
 
+        PyErr_SetString(PyExc_RuntimeError,
48154
 
                         "sys.path_importer_cache must be a dict");
48155
 
         return NULL;
48156
 
     }
48157
 
@@ -2064,7 +2061,9 @@
48158
 
 {
48159
 
     PyObject *result;
48160
 
     PyObject *modules;
48161
 
+#ifdef WITH_THREAD
48162
 
     long me;
48163
 
+#endif
48164
 
 
48165
 
     /* Try to get the module from sys.modules[name] */
48166
 
     modules = PyImport_GetModuleDict();
48167
 
@@ -2843,10 +2842,8 @@
48168
 
         return NULL;
48169
 
     if (fp != NULL) {
48170
 
         fob = PyFile_FromFile(fp, pathname, fdp->mode, fclose);
48171
 
-        if (fob == NULL) {
48172
 
-            fclose(fp);
48173
 
+        if (fob == NULL)
48174
 
             return NULL;
48175
 
-        }
48176
 
     }
48177
 
     else {
48178
 
         fob = Py_None;
48179
 
diff -r 8527427914a2 Python/pystate.c
48180
 
--- a/Python/pystate.c
48181
 
+++ b/Python/pystate.c
48182
 
@@ -537,23 +537,6 @@
48183
 
     autoInterpreterState = NULL;
48184
 
 }
48185
 
 
48186
 
-/* Reset the TLS key - called by PyOS_AfterFork.
48187
 
- * This should not be necessary, but some - buggy - pthread implementations
48188
 
- * don't flush TLS on fork, see issue #10517.
48189
 
- */
48190
 
-void
48191
 
-_PyGILState_Reinit(void)
48192
 
-{
48193
 
-    PyThreadState *tstate = PyGILState_GetThisThreadState();
48194
 
-    PyThread_delete_key(autoTLSkey);
48195
 
-    if ((autoTLSkey = PyThread_create_key()) == -1)
48196
 
-        Py_FatalError("Could not allocate TLS entry");
48197
 
-
48198
 
-    /* re-associate the current thread state with the new key */
48199
 
-    if (PyThread_set_key_value(autoTLSkey, (void *)tstate) < 0)
48200
 
-        Py_FatalError("Couldn't create autoTLSkey mapping");
48201
 
-}
48202
 
-
48203
 
 /* When a thread state is created for a thread by some mechanism other than
48204
 
    PyGILState_Ensure, it's important that the GILState machinery knows about
48205
 
    it so it doesn't try to create another thread state for the thread (this is
48206
 
diff -r 8527427914a2 Python/sysmodule.c
48207
 
--- a/Python/sysmodule.c
48208
 
+++ b/Python/sysmodule.c
48209
 
@@ -466,6 +466,7 @@
48210
 
 {
48211
 
     if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_Py_CheckInterval))
48212
 
         return NULL;
48213
 
+    _Py_Ticker = _Py_CheckInterval;
48214
 
     Py_INCREF(Py_None);
48215
 
     return Py_None;
48216
 
 }
48217
 
@@ -1092,7 +1093,7 @@
48218
 
 hexversion -- version information encoded as a single integer\n\
48219
 
 copyright -- copyright notice pertaining to this interpreter\n\
48220
 
 platform -- platform identifier\n\
48221
 
-executable -- pathname of this Python interpreter\n\
48222
 
+executable -- absolute path of the executable binary of the Python interpreter\n\
48223
 
 prefix -- prefix used to find the Python library\n\
48224
 
 exec_prefix -- prefix used to find the machine-specific Python library\n\
48225
 
 float_repr_style -- string indicating the style of repr() output for floats\n\
48226
 
diff -r 8527427914a2 README
48227
 
--- a/README
48228
 
+++ b/README
48229
 
@@ -1,8 +1,8 @@
48230
 
 This is Python version 2.7.2
48231
 
 ============================
48232
 
 
48233
 
-Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
48234
 
-Python Software Foundation.  All rights reserved.
48235
 
+Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
48236
 
+2012 Python Software Foundation.  All rights reserved.
48237
 
 
48238
 
 Copyright (c) 2000 BeOpen.com.
48239
 
 All rights reserved.
48240
 
diff -r 8527427914a2 Tools/gdb/libpython.py
48241
 
--- a/Tools/gdb/libpython.py
48242
 
+++ b/Tools/gdb/libpython.py
48243
 
@@ -47,7 +47,6 @@
48244
 
 _type_char_ptr = gdb.lookup_type('char').pointer() # char*
48245
 
 _type_unsigned_char_ptr = gdb.lookup_type('unsigned char').pointer() # unsigned char*
48246
 
 _type_void_ptr = gdb.lookup_type('void').pointer() # void*
48247
 
-_type_size_t = gdb.lookup_type('size_t')
48248
 
 
48249
 
 SIZEOF_VOID_P = _type_void_ptr.sizeof
48250
 
 
48251
 
@@ -410,11 +409,15 @@
48252
 
                                             self.address)
48253
 
 
48254
 
 def _PyObject_VAR_SIZE(typeobj, nitems):
48255
 
+    if _PyObject_VAR_SIZE._type_size_t is None:
48256
 
+        _PyObject_VAR_SIZE._type_size_t = gdb.lookup_type('size_t')
48257
 
+
48258
 
     return ( ( typeobj.field('tp_basicsize') +
48259
 
                nitems * typeobj.field('tp_itemsize') +
48260
 
                (SIZEOF_VOID_P - 1)
48261
 
              ) & ~(SIZEOF_VOID_P - 1)
48262
 
-           ).cast(_type_size_t)
48263
 
+           ).cast(_PyObject_VAR_SIZE._type_size_t)
48264
 
+_PyObject_VAR_SIZE._type_size_t = None
48265
 
 
48266
 
 class HeapTypeObjectPtr(PyObjectPtr):
48267
 
     _typename = 'PyObject'
48268
 
@@ -786,7 +789,7 @@
48269
 
 class PyFrameObjectPtr(PyObjectPtr):
48270
 
     _typename = 'PyFrameObject'
48271
 
 
48272
 
-    def __init__(self, gdbval, cast_to):
48273
 
+    def __init__(self, gdbval, cast_to=None):
48274
 
         PyObjectPtr.__init__(self, gdbval, cast_to)
48275
 
 
48276
 
         if not self.is_optimized_out():
48277
 
@@ -820,7 +823,7 @@
48278
 
         the global variables of this frame
48279
 
         '''
48280
 
         if self.is_optimized_out():
48281
 
-            return
48282
 
+            return ()
48283
 
 
48284
 
         pyop_globals = self.pyop_field('f_globals')
48285
 
         return pyop_globals.iteritems()
48286
 
@@ -831,7 +834,7 @@
48287
 
         the builtin variables
48288
 
         '''
48289
 
         if self.is_optimized_out():
48290
 
-            return
48291
 
+            return ()
48292
 
 
48293
 
         pyop_builtins = self.pyop_field('f_builtins')
48294
 
         return pyop_builtins.iteritems()
48295
 
@@ -1205,7 +1208,20 @@
48296
 
     def get_pyop(self):
48297
 
         try:
48298
 
             f = self._gdbframe.read_var('f')
48299
 
-            return PyFrameObjectPtr.from_pyobject_ptr(f)
48300
 
+            frame = PyFrameObjectPtr.from_pyobject_ptr(f)
48301
 
+            if not frame.is_optimized_out():
48302
 
+                return frame
48303
 
+            # gdb is unable to get the "f" argument of PyEval_EvalFrameEx()
48304
 
+            # because it was "optimized out". Try to get "f" from the frame
48305
 
+            # of the caller, PyEval_EvalCodeEx().
48306
 
+            orig_frame = frame
48307
 
+            caller = self._gdbframe.older()
48308
 
+            if caller:
48309
 
+                f = caller.read_var('f')
48310
 
+                frame = PyFrameObjectPtr.from_pyobject_ptr(f)
48311
 
+                if not frame.is_optimized_out():
48312
 
+                    return frame
48313
 
+            return orig_frame
48314
 
         except ValueError:
48315
 
             return None
48316
 
 
48317
 
@@ -1235,7 +1251,9 @@
48318
 
             pyop = self.get_pyop()
48319
 
             if pyop:
48320
 
                 sys.stdout.write('#%i %s\n' % (self.get_index(), pyop.get_truncated_repr(MAX_OUTPUT_LEN)))
48321
 
-                sys.stdout.write(pyop.current_line())
48322
 
+                if not pyop.is_optimized_out():
48323
 
+                    line = pyop.current_line()
48324
 
+                    sys.stdout.write('    %s\n' % line.strip())
48325
 
             else:
48326
 
                 sys.stdout.write('#%i (unable to read python frame information)\n' % self.get_index())
48327
 
         else:
48328
 
@@ -1281,7 +1299,7 @@
48329
 
             return
48330
 
 
48331
 
         pyop = frame.get_pyop()
48332
 
-        if not pyop:
48333
 
+        if not pyop or pyop.is_optimized_out():
48334
 
             print 'Unable to read information on python frame'
48335
 
             return
48336
 
 
48337
 
diff -r 8527427914a2 Tools/iobench/iobench.py
48338
 
--- a/Tools/iobench/iobench.py
48339
 
+++ b/Tools/iobench/iobench.py
48340
 
@@ -358,7 +358,7 @@
48341
 
             with text_open(name, "r") as f:
48342
 
                 return f.read()
48343
 
         run_test_family(modify_tests, "b", text_files,
48344
 
-            lambda fn: open(fn, "r+"), make_test_source)
48345
 
+            lambda fn: text_open(fn, "r+"), make_test_source)
48346
 
 
48347
 
 
48348
 
 def prepare_files():
48349
 
diff -r 8527427914a2 Tools/scripts/analyze_dxp.py
48350
 
--- a/Tools/scripts/analyze_dxp.py
48351
 
+++ b/Tools/scripts/analyze_dxp.py
48352
 
@@ -1,3 +1,4 @@
48353
 
+#!/usr/bin/env python
48354
 
 """
48355
 
 Some helper functions to analyze the output of sys.getdxp() (which is
48356
 
 only available if Python was built with -DDYNAMIC_EXECUTION_PROFILE).
48357
 
diff -r 8527427914a2 Tools/scripts/byext.py
48358
 
--- a/Tools/scripts/byext.py
48359
 
+++ b/Tools/scripts/byext.py
48360
 
@@ -23,12 +23,11 @@
48361
 
     def statdir(self, dir):
48362
 
         self.addstats("<dir>", "dirs", 1)
48363
 
         try:
48364
 
-            names = os.listdir(dir)
48365
 
-        except os.error, err:
48366
 
+            names = sorted(os.listdir(dir))
48367
 
+        except os.error as err:
48368
 
             sys.stderr.write("Can't list %s: %s\n" % (dir, err))
48369
 
             self.addstats("<dir>", "unlistable", 1)
48370
 
             return
48371
 
-        names.sort()
48372
 
         for name in names:
48373
 
             if name.startswith(".#"):
48374
 
                 continue # Skip CVS temp files
48375
 
@@ -53,14 +52,14 @@
48376
 
         self.addstats(ext, "files", 1)
48377
 
         try:
48378
 
             f = open(filename, "rb")
48379
 
-        except IOError, err:
48380
 
+        except IOError as err:
48381
 
             sys.stderr.write("Can't open %s: %s\n" % (filename, err))
48382
 
             self.addstats(ext, "unopenable", 1)
48383
 
             return
48384
 
         data = f.read()
48385
 
         f.close()
48386
 
         self.addstats(ext, "bytes", len(data))
48387
 
-        if '\0' in data:
48388
 
+        if b'\0' in data:
48389
 
             self.addstats(ext, "binary", 1)
48390
 
             return
48391
 
         if not data:
48392
 
@@ -77,14 +76,12 @@
48393
 
         d[key] = d.get(key, 0) + n
48394
 
 
48395
 
     def report(self):
48396
 
-        exts = self.stats.keys()
48397
 
-        exts.sort()
48398
 
+        exts = sorted(self.stats.keys())
48399
 
         # Get the column keys
48400
 
         columns = {}
48401
 
         for ext in exts:
48402
 
             columns.update(self.stats[ext])
48403
 
-        cols = columns.keys()
48404
 
-        cols.sort()
48405
 
+        cols = sorted(columns.keys())
48406
 
         colwidth = {}
48407
 
         colwidth["ext"] = max([len(ext) for ext in exts])
48408
 
         minwidth = 6
48409
 
@@ -109,14 +106,14 @@
48410
 
         cols.insert(0, "ext")
48411
 
         def printheader():
48412
 
             for col in cols:
48413
 
-                print "%*s" % (colwidth[col], col),
48414
 
-            print
48415
 
+                print("%*s" % (colwidth[col], col), end=" ")
48416
 
+            print()
48417
 
         printheader()
48418
 
         for ext in exts:
48419
 
             for col in cols:
48420
 
                 value = self.stats[ext].get(col, "")
48421
 
-                print "%*s" % (colwidth[col], value),
48422
 
-            print
48423
 
+                print("%*s" % (colwidth[col], value), end=" ")
48424
 
+            print()
48425
 
         printheader() # Another header at the bottom
48426
 
 
48427
 
 def main():
48428
 
diff -r 8527427914a2 Tools/scripts/diff.py
48429
 
--- a/Tools/scripts/diff.py
48430
 
+++ b/Tools/scripts/diff.py
48431
 
@@ -1,3 +1,4 @@
48432
 
+#!/usr/bin/env python
48433
 
 """ Command line interface to difflib.py providing diffs in four formats:
48434
 
 
48435
 
 * ndiff:    lists every line and highlights interline changes.
48436
 
diff -r 8527427914a2 Tools/scripts/mailerdaemon.py
48437
 
--- a/Tools/scripts/mailerdaemon.py
48438
 
+++ b/Tools/scripts/mailerdaemon.py
48439
 
@@ -1,3 +1,4 @@
48440
 
+#!/usr/bin/env python
48441
 
 """mailerdaemon - classes to parse mailer-daemon messages"""
48442
 
 
48443
 
 import rfc822
48444
 
diff -r 8527427914a2 Tools/scripts/patchcheck.py
48445
 
--- a/Tools/scripts/patchcheck.py
48446
 
+++ b/Tools/scripts/patchcheck.py
48447
 
@@ -1,13 +1,18 @@
48448
 
+#!/usr/bin/env python
48449
 
 import re
48450
 
 import sys
48451
 
 import shutil
48452
 
 import os.path
48453
 
 import subprocess
48454
 
+import sysconfig
48455
 
 
48456
 
 import reindent
48457
 
 import untabify
48458
 
 
48459
 
 
48460
 
+SRCDIR = sysconfig.get_config_var('srcdir')
48461
 
+
48462
 
+
48463
 
 def n_files_str(count):
48464
 
     """Return 'N file(s)' with the proper plurality on 'file'."""
48465
 
     return "{} file{}".format(count, "s" if count != 1 else "")
48466
 
@@ -35,7 +40,7 @@
48467
 
         info=lambda x: n_files_str(len(x)))
48468
 
 def changed_files():
48469
 
     """Get the list of changed or added files from the VCS."""
48470
 
-    if os.path.isdir('.hg'):
48471
 
+    if os.path.isdir(os.path.join(SRCDIR, '.hg')):
48472
 
         vcs = 'hg'
48473
 
         cmd = 'hg status --added --modified --no-status'
48474
 
     elif os.path.isdir('.svn'):
48475
 
@@ -74,7 +79,7 @@
48476
 
     reindent.makebackup = False  # No need to create backups.
48477
 
     fixed = []
48478
 
     for path in (x for x in file_paths if x.endswith('.py')):
48479
 
-        if reindent.check(path):
48480
 
+        if reindent.check(os.path.join(SRCDIR, path)):
48481
 
             fixed.append(path)
48482
 
     return fixed
48483
 
 
48484
 
@@ -84,10 +89,11 @@
48485
 
     """Report if any C files """
48486
 
     fixed = []
48487
 
     for path in file_paths:
48488
 
-        with open(path, 'r') as f:
48489
 
+        abspath = os.path.join(SRCDIR, path)
48490
 
+        with open(abspath, 'r') as f:
48491
 
             if '\t' not in f.read():
48492
 
                 continue
48493
 
-        untabify.process(path, 8, verbose=False)
48494
 
+        untabify.process(abspath, 8, verbose=False)
48495
 
         fixed.append(path)
48496
 
     return fixed
48497
 
 
48498
 
@@ -98,13 +104,14 @@
48499
 
 def normalize_docs_whitespace(file_paths):
48500
 
     fixed = []
48501
 
     for path in file_paths:
48502
 
+        abspath = os.path.join(SRCDIR, path)
48503
 
         try:
48504
 
-            with open(path, 'rb') as f:
48505
 
+            with open(abspath, 'rb') as f:
48506
 
                 lines = f.readlines()
48507
 
             new_lines = [ws_re.sub(br'\1', line) for line in lines]
48508
 
             if new_lines != lines:
48509
 
-                shutil.copyfile(path, path + '.bak')
48510
 
-                with open(path, 'wb') as f:
48511
 
+                shutil.copyfile(abspath, abspath + '.bak')
48512
 
+                with open(abspath, 'wb') as f:
48513
 
                     f.writelines(new_lines)
48514
 
                 fixed.append(path)
48515
 
         except Exception as err:
48516
 
@@ -150,8 +157,9 @@
48517
 
     reported_news(special_files)
48518
 
 
48519
 
     # Test suite run and passed.
48520
 
-    print
48521
 
-    print "Did you run the test suite?"
48522
 
+    if python_files or c_files:
48523
 
+        print
48524
 
+        print "Did you run the test suite?"
48525
 
 
48526
 
 
48527
 
 if __name__ == '__main__':
48528
 
diff -r 8527427914a2 Tools/scripts/redemo.py
48529
 
--- a/Tools/scripts/redemo.py
48530
 
+++ b/Tools/scripts/redemo.py
48531
 
@@ -1,3 +1,4 @@
48532
 
+#!/usr/bin/env python
48533
 
 """Basic regular expression demostration facility (Perl style syntax)."""
48534
 
 
48535
 
 from Tkinter import *
48536
 
diff -r 8527427914a2 Tools/scripts/reindent.py
48537
 
--- a/Tools/scripts/reindent.py
48538
 
+++ b/Tools/scripts/reindent.py
48539
 
@@ -35,7 +35,7 @@
48540
 
 
48541
 
 The backup file is a copy of the one that is being reindented. The ".bak"
48542
 
 file is generated with shutil.copy(), but some corner cases regarding
48543
 
-user/group and permissions could leave the backup file more readable that
48544
 
+user/group and permissions could leave the backup file more readable than
48545
 
 you'd prefer. You can always use the --nobackup option to prevent this.
48546
 
 """
48547
 
 
48548
 
@@ -44,6 +44,7 @@
48549
 
 import tokenize
48550
 
 import os, shutil
48551
 
 import sys
48552
 
+import io
48553
 
 
48554
 
 verbose    = 0
48555
 
 recurse    = 0
48556
 
@@ -108,13 +109,19 @@
48557
 
     if verbose:
48558
 
         print "checking", file, "...",
48559
 
     try:
48560
 
-        f = open(file)
48561
 
+        f = io.open(file)
48562
 
     except IOError, msg:
48563
 
         errprint("%s: I/O Error: %s" % (file, str(msg)))
48564
 
         return
48565
 
 
48566
 
     r = Reindenter(f)
48567
 
     f.close()
48568
 
+
48569
 
+    newline = r.newlines
48570
 
+    if isinstance(newline, tuple):
48571
 
+        errprint("%s: mixed newlines detected; cannot process file" % file)
48572
 
+        return
48573
 
+
48574
 
     if r.run():
48575
 
         if verbose:
48576
 
             print "changed."
48577
 
@@ -126,7 +133,7 @@
48578
 
                 shutil.copyfile(file, bak)
48579
 
                 if verbose:
48580
 
                     print "backed up", file, "to", bak
48581
 
-            f = open(file, "w")
48582
 
+            f = io.open(file, "w", newline=newline)
48583
 
             r.write(f)
48584
 
             f.close()
48585
 
             if verbose:
48586
 
@@ -173,6 +180,10 @@
48587
 
         # indeed, they're our headache!
48588
 
         self.stats = []
48589
 
 
48590
 
+        # Save the newlines found in the file so they can be used to
48591
 
+        #  create output without mutating the newlines.
48592
 
+        self.newlines = f.newlines
48593
 
+
48594
 
     def run(self):
48595
 
         tokenize.tokenize(self.getline, self.tokeneater)
48596
 
         # Remove trailing empty lines.
48597
 
diff -r 8527427914a2 configure.in
48598
 
--- a/configure.in
48599
 
+++ b/configure.in
48600
 
@@ -293,6 +293,7 @@
48601
 
        MACHDEP="$ac_md_system$ac_md_release"
48602
 
 
48603
 
        case $MACHDEP in
48604
 
+       linux*) MACHDEP="linux2";;
48605
 
        cygwin*) MACHDEP="cygwin";;
48606
 
        darwin*) MACHDEP="darwin";;
48607
 
        atheos*) MACHDEP="atheos";;
48608
 
@@ -317,14 +318,14 @@
48609
 
   # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
48610
 
   # In addition, Stefan Krah confirms that issue #1244610 exists through
48611
 
   # OpenBSD 4.6, but is fixed in 4.7.
48612
 
-  OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0123456@:>@) 
48613
 
+  OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@) 
48614
 
     define_xopen_source=no
48615
 
     # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
48616
 
     # also defined. This can be overridden by defining _BSD_SOURCE
48617
 
     # As this has a different meaning on Linux, only define it on OpenBSD
48618
 
     AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
48619
 
     ;;
48620
 
-  OpenBSD/4.@<:@789@:>@)
48621
 
+  OpenBSD/*)
48622
 
     # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
48623
 
     # also defined. This can be overridden by defining _BSD_SOURCE
48624
 
     # As this has a different meaning on Linux, only define it on OpenBSD
48625
 
@@ -778,7 +779,7 @@
48626
 
          RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
48627
 
          INSTSONAME="$LDLIBRARY".$SOVERSION
48628
 
           ;;
48629
 
-    Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
48630
 
+    Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
48631
 
          LDLIBRARY='libpython$(VERSION).so'
48632
 
          BLDLIBRARY='-L. -lpython$(VERSION)'
48633
 
          RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
48634
 
@@ -931,6 +932,13 @@
48635
 
         if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
48636
 
            WRAP="-fwrapv"
48637
 
         fi
48638
 
+
48639
 
+        # Clang also needs -fwrapv
48640
 
+        case $CC in
48641
 
+            *clang*) WRAP="-fwrapv"
48642
 
+            ;;
48643
 
+        esac
48644
 
+
48645
 
        case $ac_cv_prog_cc_g in
48646
 
        yes)
48647
 
            if test "$Py_DEBUG" = 'true' ; then
48648
 
@@ -2359,18 +2367,15 @@
48649
 
 
48650
 
       # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
48651
 
       case  $ac_sys_system/$ac_sys_release in
48652
 
-  SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
48653
 
+      SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
48654
 
                        [Defined for Solaris 2.6 bug in pthread header.])
48655
 
                       ;;
48656
 
       SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
48657
 
                       [Define if the Posix semaphores do not work on your system])
48658
 
                       ;;
48659
 
-      AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
48660
 
+      AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
48661
 
                       [Define if the Posix semaphores do not work on your system])
48662
 
                       ;;
48663
 
-      AIX/6) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
48664
 
-                      Define if the Posix semaphores do not work on your system)
48665
 
-                      ;;
48666
 
       esac
48667
 
 
48668
 
       AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
48669
 
@@ -2827,6 +2832,15 @@
48670
 
   [AC_MSG_RESULT(no)
48671
 
 ])
48672
 
 
48673
 
+AC_MSG_CHECKING(for broken unsetenv)
48674
 
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
48675
 
+#include <stdlib.h>
48676
 
+]], [[int res = unsetenv("DUMMY")]])],
48677
 
+  [AC_MSG_RESULT(no)],
48678
 
+  [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
48679
 
+   AC_MSG_RESULT(yes)
48680
 
+])
48681
 
+
48682
 
 dnl check for true
48683
 
 AC_CHECK_PROGS(TRUE, true, /bin/true)
48684
 
 
48685
 
@@ -2839,7 +2853,7 @@
48686
 
 # On Tru64, chflags seems to be present, but calling it will
48687
 
 # exit Python
48688
 
 AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
48689
 
-AC_RUN_IFELSE([AC_LANG_SOURCE([[[
48690
 
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
48691
 
 #include <sys/stat.h>
48692
 
 #include <unistd.h>
48693
 
 int main(int argc, char*argv[])
48694
 
@@ -2848,7 +2862,7 @@
48695
 
     return 1;
48696
 
   return 0;
48697
 
 }
48698
 
-]]])],
48699
 
+]])],
48700
 
 [ac_cv_have_chflags=yes],
48701
 
 [ac_cv_have_chflags=no],
48702
 
 [ac_cv_have_chflags=cross])
48703
 
@@ -2857,11 +2871,11 @@
48704
 
   AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
48705
 
 fi
48706
 
 if test "$ac_cv_have_chflags" = yes ; then
48707
 
-  AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the `chflags' function.])
48708
 
+  AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
48709
 
 fi
48710
 
 
48711
 
 AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
48712
 
-AC_RUN_IFELSE([AC_LANG_SOURCE([[[
48713
 
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
48714
 
 #include <sys/stat.h>
48715
 
 #include <unistd.h>
48716
 
 int main(int argc, char*argv[])
48717
 
@@ -2870,13 +2884,13 @@
48718
 
     return 1;
48719
 
   return 0;
48720
 
 }
48721
 
-]]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
48722
 
+]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
48723
 
 ])
48724
 
 if test "$ac_cv_have_lchflags" = cross ; then
48725
 
   AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
48726
 
 fi
48727
 
 if test "$ac_cv_have_lchflags" = yes ; then
48728
 
-  AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the `lchflags' function.])
48729
 
+  AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
48730
 
 fi
48731
 
 
48732
 
 dnl Check if system zlib has *Copy() functions
48733
 
diff -r 8527427914a2 pyconfig.h.in
48734
 
--- a/pyconfig.h.in
48735
 
+++ b/pyconfig.h.in
48736
 
@@ -97,10 +97,13 @@
48737
 
 /* define to 1 if your sem_getvalue is broken. */
48738
 
 #undef HAVE_BROKEN_SEM_GETVALUE
48739
 
 
48740
 
+/* Define if `unsetenv` does not return an int. */
48741
 
+#undef HAVE_BROKEN_UNSETENV
48742
 
+
48743
 
 /* Define this if you have the type _Bool. */
48744
 
 #undef HAVE_C99_BOOL
48745
 
 
48746
 
-/* Define to 1 if you have the `chflags' function. */
48747
 
+/* Define to 1 if you have the 'chflags' function. */
48748
 
 #undef HAVE_CHFLAGS
48749
 
 
48750
 
 /* Define to 1 if you have the `chown' function. */
48751
 
@@ -391,7 +394,7 @@
48752
 
    Solaris and Linux, the necessary defines are already defined.) */
48753
 
 #undef HAVE_LARGEFILE_SUPPORT
48754
 
 
48755
 
-/* Define to 1 if you have the `lchflags' function. */
48756
 
+/* Define to 1 if you have the 'lchflags' function. */
48757
 
 #undef HAVE_LCHFLAGS
48758
 
 
48759
 
 /* Define to 1 if you have the `lchmod' function. */
48760
 
@@ -1137,6 +1140,9 @@
48761
 
 /* This must be defined on some systems to enable large file support. */
48762
 
 #undef _LARGEFILE_SOURCE
48763
 
 
48764
 
+/* This must be defined on AIX systems to enable large file support. */
48765
 
+#undef _LARGE_FILES
48766
 
+
48767
 
 /* Define to 1 if on MINIX. */
48768
 
 #undef _MINIX
48769
 
 
 
1
# DP: hg updates of the 2.7 release branch (until 2012-03-09).
 
2
 
 
3
# hg diff -r v2.7.2 | filterdiff --exclude=.*ignore --exclude=.hg* --remove-timestamps
 
4