Merge lp:~mitya57/ubuntu/saucy/python3.3/3.3.2-5ubuntu1 into lp:ubuntu/saucy/python3.3

Proposed by Dmitry Shachnev
Status: Merged
Merge reported by: Dmitry Shachnev
Merged at revision: not available
Proposed branch: lp:~mitya57/ubuntu/saucy/python3.3/3.3.2-5ubuntu1
Merge into: lp:ubuntu/saucy/python3.3
Diff against target: 42201 lines (+40575/-225)
42 files modified
debian/PVER-minimal.postinst.in (+7/-3)
debian/changelog (+29/-0)
debian/control (+7/-6)
debian/control.in (+7/-6)
debian/multiarch.h.in (+8/-8)
debian/patches/add-python-config-sh.diff (+2/-8)
debian/patches/atomic-pyc-rename.diff (+2/-3)
debian/patches/avoid-rpath.diff (+4/-5)
debian/patches/bdist-wininst-notfound.diff (+0/-2)
debian/patches/ctypes-arm.diff (+1/-3)
debian/patches/deb-locations.diff (+0/-4)
debian/patches/deb-setup.diff (+3/-5)
debian/patches/disable-sem-check.diff (+2/-4)
debian/patches/distutils-init.diff (+1/-3)
debian/patches/distutils-install-layout.diff (+0/-16)
debian/patches/distutils-link.diff (+1/-3)
debian/patches/distutils-sysconfig.diff (+2/-4)
debian/patches/enable-fpectl.diff (+1/-3)
debian/patches/ext-no-libpython-link.diff (+2/-2)
debian/patches/hg-updates.diff (+40409/-43)
debian/patches/hurd-disable-nonworking-constants.diff (+2/-6)
debian/patches/installed-testsuite.diff (+0/-13)
debian/patches/kfreebsd-testsuite.diff (+47/-0)
debian/patches/kfreebsd-xattrs.diff (+1/-1)
debian/patches/lib-argparse.diff (+0/-2)
debian/patches/libffi-shared.diff (+1/-3)
debian/patches/link-opt.diff (+2/-4)
debian/patches/link-timemodule.diff (+0/-2)
debian/patches/locale-module.diff (+0/-2)
debian/patches/lto-link-flags.diff (+5/-7)
debian/patches/multiarch.diff (+5/-17)
debian/patches/ncurses-configure.diff (+7/-7)
debian/patches/no-zip-on-sys.path.diff (+4/-6)
debian/patches/platform-lsbrelease.diff (+2/-4)
debian/patches/profiled-build.diff (+0/-4)
debian/patches/series.in (+1/-0)
debian/patches/setup-modules.diff (+0/-2)
debian/patches/site-locations.diff (+0/-2)
debian/patches/statvfs-f_flag-constants.diff (+1/-3)
debian/patches/test-sundry.diff (+1/-1)
debian/patches/tkinter-import.diff (+1/-3)
debian/rules (+7/-5)
To merge this branch: bzr merge lp:~mitya57/ubuntu/saucy/python3.3/3.3.2-5ubuntu1
Reviewer Review Type Date Requested Status
Matthias Klose Pending
Barry Warsaw Pending
Ubuntu branches Pending
Review via email: mp+186118@code.launchpad.net

Description of the change

* Merge with Debian unstable, remaining change:
  - Regenerate the control file.
* debian/patches/platform-lsbrelease.diff: fix indentaion, which
  caused this patch to not work properly. LP: #1220508.

To post a comment you must log in.
37. By Dmitry Shachnev

d/control: Revert Multi-Arch headers change

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/PVER-minimal.postinst.in'
--- debian/PVER-minimal.postinst.in 2013-06-05 12:28:37 +0000
+++ debian/PVER-minimal.postinst.in 2013-09-17 18:06:34 +0000
@@ -35,9 +35,13 @@
35 # only available before removal of the packaging package35 # only available before removal of the packaging package
36 rm -f /etc/@PVER@/sysconfig.cfg36 rm -f /etc/@PVER@/sysconfig.cfg
3737
38 ls -L /usr/lib/@PVER@/sitecustomize.py >/dev/null 2>&1 \38 if ls -L /usr/lib/@PVER@/sitecustomize.py >/dev/null 2>&1; then
39 || filt='| fgrep -v sitecustomize.py'39 filt='cat'
40 files=$(dpkg -L lib@PVER@-minimal | sed -n '/^\/usr\/lib\/@PVER@\/.*\.py$/p' $filt)40 else
41 filt='fgrep -v sitecustomize.py'
42 fi
43 files=$(dpkg -L lib@PVER@-minimal \
44 | sed -n '/^\/usr\/lib\/@PVER@\/.*\.py$/p' | $filt)
41 if [ -n "$files" ]; then45 if [ -n "$files" ]; then
42 @PVER@ -E -S /usr/lib/@PVER@/py_compile.py $files46 @PVER@ -E -S /usr/lib/@PVER@/py_compile.py $files
43 if grep -sq '^byte-compile[^#]*optimize' /etc/python/debian_config; then47 if grep -sq '^byte-compile[^#]*optimize' /etc/python/debian_config; then
4448
=== modified file 'debian/changelog'
--- debian/changelog 2013-06-05 12:28:37 +0000
+++ debian/changelog 2013-09-17 18:06:34 +0000
@@ -1,3 +1,32 @@
1python3.3 (3.3.2-5ubuntu1) UNRELEASED; urgency=low
2
3 * Merge with Debian unstable, remaining change:
4 - Regenerate the control file.
5 * debian/patches/platform-lsbrelease.diff: fix indentaion, which
6 caused this patch to not work properly. LP: #1220508.
7
8 -- Dmitry Shachnev <mitya57@ubuntu.com> Tue, 17 Sep 2013 21:00:31 +0400
9
10python3.3 (3.3.2-5) unstable; urgency=low
11
12 * Update to 20130803 from the 3.3 branch.
13 - Fix fcntl test case on KFreeBSD (Petr Salinger).
14 * Disable some socket tests on KFreeBSD (Petr Salinger).
15 * Fix multiarch include header for sparc64. Closes: #714802.
16 * Update package descriptions (Filipus Klutiero). Closes: #715801.
17
18 -- Matthias Klose <doko@debian.org> Sun, 04 Aug 2013 17:38:35 +0200
19
20python3.3 (3.3.2-4) unstable; urgency=low
21
22 * Update to 20130612 from the 3.3 branch.
23 * Refresh patches.
24 * Don't run consistency check for cross builds.
25 * Really skip byte compile of non-existing sitecustomize.py.
26 * Fix the multiarch header file for mips64 (YunQiang Su). Closes: #710374.
27
28 -- Matthias Klose <doko@debian.org> Wed, 12 Jun 2013 22:55:02 +0200
29
1python3.3 (3.3.2-3ubuntu1) saucy; urgency=low30python3.3 (3.3.2-3ubuntu1) saucy; urgency=low
231
3 * Merge with Debian; remaining changes:32 * Merge with Debian; remaining changes:
433
=== modified file 'debian/control'
--- debian/control 2013-06-05 12:28:37 +0000
+++ debian/control 2013-09-17 18:06:34 +0000
@@ -14,6 +14,7 @@
14 libsqlite3-dev, libffi-dev (>= 3.0.5),14 libsqlite3-dev, libffi-dev (>= 3.0.5),
15 libgpm2 [!hurd-i386 !kfreebsd-i386 !kfreebsd-amd64],15 libgpm2 [!hurd-i386 !kfreebsd-i386 !kfreebsd-amd64],
16 mime-support, netbase, bzip2, python3:any,16 mime-support, netbase, bzip2, python3:any,
17 gcc (>= 4:4.8) [amd64 armel armhf i386 x32 kfreebsd-any hurd-any],
17 xvfb, xauth18 xvfb, xauth
18Build-Depends-Indep: python-sphinx19Build-Depends-Indep: python-sphinx
19Standards-Version: 3.9.420Standards-Version: 3.9.4
@@ -28,7 +29,7 @@
28Depends: python3.3-minimal (= ${binary:Version}), libpython3.3-stdlib (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends}29Depends: python3.3-minimal (= ${binary:Version}), libpython3.3-stdlib (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends}
29Suggests: python3.3-doc, binutils30Suggests: python3.3-doc, binutils
30Description: Interactive high-level object-oriented language (version 3.3)31Description: Interactive high-level object-oriented language (version 3.3)
31 Version 3.3 of the high-level, interactive object oriented language,32 Python is a high-level, interactive, object-oriented language. Its 3.3 version
32 includes an extensive class library with lots of goodies for33 includes an extensive class library with lots of goodies for
33 network programming, system administration, sounds and graphics.34 network programming, system administration, sounds and graphics.
3435
@@ -40,13 +41,13 @@
40Depends: libpython3.3-minimal (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends}41Depends: libpython3.3-minimal (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends}
41Provides: python3.3-cjkcodecs, python3.3-ctypes, python3.3-elementtree, python3.3-celementtree, python3.3-wsgiref, python3.3-gdbm, python3.3-profiler, python3.3-lzma42Provides: python3.3-cjkcodecs, python3.3-ctypes, python3.3-elementtree, python3.3-celementtree, python3.3-wsgiref, python3.3-gdbm, python3.3-profiler, python3.3-lzma
42Replaces: python3.3 (<< 3.3.1~rc1-2~)43Replaces: python3.3 (<< 3.3.1~rc1-2~)
43Description: Interactive high-level object-oriented language (version 3.3)44Description: Interactive high-level object-oriented language (standard library, version 3.3)
44 Version 3.3 of the high-level, interactive object oriented language,45 Python is a high-level, interactive, object-oriented language. Its 3.3 version
45 includes an extensive class library with lots of goodies for46 includes an extensive class library with lots of goodies for
46 network programming, system administration, sounds and graphics.47 network programming, system administration, sounds and graphics.
47 .48 .
48 This package contains the standard library. It is normally not49 This package contains Python 3.3's standard library. It is normally not
49 used on it's own, but as a dependency of python3.3.50 used on its own, but as a dependency of python3.3.
5051
51Package: python3.3-minimal52Package: python3.3-minimal
52Architecture: any53Architecture: any
@@ -87,7 +88,7 @@
87Depends: libpython3.3-stdlib (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}88Depends: libpython3.3-stdlib (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
88Replaces: python3.3 (<< 3.0~rc1)89Replaces: python3.3 (<< 3.0~rc1)
89Description: Shared Python runtime library (version 3.3)90Description: Shared Python runtime library (version 3.3)
90 Version 3.3 of the high-level, interactive object oriented language,91 Python is a high-level, interactive, object-oriented language. Its 3.3 version
91 includes an extensive class library with lots of goodies for92 includes an extensive class library with lots of goodies for
92 network programming, system administration, sounds and graphics.93 network programming, system administration, sounds and graphics.
93 .94 .
9495
=== modified file 'debian/control.in'
--- debian/control.in 2013-06-05 12:28:37 +0000
+++ debian/control.in 2013-09-17 18:06:34 +0000
@@ -13,6 +13,7 @@
13 libsqlite3-dev, libffi-dev (>= 3.0.5),13 libsqlite3-dev, libffi-dev (>= 3.0.5),
14 libgpm2 [!hurd-i386 !kfreebsd-i386 !kfreebsd-amd64],14 libgpm2 [!hurd-i386 !kfreebsd-i386 !kfreebsd-amd64],
15 mime-support, netbase, bzip2, python3@bd_qual@,15 mime-support, netbase, bzip2, python3@bd_qual@,
16 gcc (>= 4:4.8) [amd64 armel armhf i386 x32 kfreebsd-any hurd-any],
16 xvfb, xauth17 xvfb, xauth
17Build-Depends-Indep: python-sphinx18Build-Depends-Indep: python-sphinx
18Standards-Version: 3.9.419Standards-Version: 3.9.4
@@ -27,7 +28,7 @@
27Depends: @PVER@-minimal (= ${binary:Version}), lib@PVER@-stdlib (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends}28Depends: @PVER@-minimal (= ${binary:Version}), lib@PVER@-stdlib (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends}
28Suggests: @PVER@-doc, binutils29Suggests: @PVER@-doc, binutils
29Description: Interactive high-level object-oriented language (version @VER@)30Description: Interactive high-level object-oriented language (version @VER@)
30 Version @VER@ of the high-level, interactive object oriented language,31 Python is a high-level, interactive, object-oriented language. Its @VER@ version
31 includes an extensive class library with lots of goodies for32 includes an extensive class library with lots of goodies for
32 network programming, system administration, sounds and graphics.33 network programming, system administration, sounds and graphics.
3334
@@ -39,13 +40,13 @@
39Depends: lib@PVER@-minimal (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends}40Depends: lib@PVER@-minimal (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends}
40Provides: python@VER@-cjkcodecs, python@VER@-ctypes, python@VER@-elementtree, python@VER@-celementtree, python@VER@-wsgiref, @PVER@-gdbm, @PVER@-profiler, @PVER@-lzma41Provides: python@VER@-cjkcodecs, python@VER@-ctypes, python@VER@-elementtree, python@VER@-celementtree, python@VER@-wsgiref, @PVER@-gdbm, @PVER@-profiler, @PVER@-lzma
41Replaces: @PVER@ (<< 3.3.1~rc1-2~)42Replaces: @PVER@ (<< 3.3.1~rc1-2~)
42Description: Interactive high-level object-oriented language (version @VER@)43Description: Interactive high-level object-oriented language (standard library, version @VER@)
43 Version @VER@ of the high-level, interactive object oriented language,44 Python is a high-level, interactive, object-oriented language. Its @VER@ version
44 includes an extensive class library with lots of goodies for45 includes an extensive class library with lots of goodies for
45 network programming, system administration, sounds and graphics.46 network programming, system administration, sounds and graphics.
46 .47 .
47 This package contains the standard library. It is normally not48 This package contains Python @VER@'s standard library. It is normally not
48 used on it's own, but as a dependency of @PVER@.49 used on its own, but as a dependency of python@VER@.
4950
50Package: @PVER@-minimal51Package: @PVER@-minimal
51Architecture: any52Architecture: any
@@ -86,7 +87,7 @@
86Depends: lib@PVER@-stdlib (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}87Depends: lib@PVER@-stdlib (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
87Replaces: @PVER@ (<< 3.0~rc1)88Replaces: @PVER@ (<< 3.0~rc1)
88Description: Shared Python runtime library (version @VER@)89Description: Shared Python runtime library (version @VER@)
89 Version @VER@ of the high-level, interactive object oriented language,90 Python is a high-level, interactive, object-oriented language. Its @VER@ version
90 includes an extensive class library with lots of goodies for91 includes an extensive class library with lots of goodies for
91 network programming, system administration, sounds and graphics.92 network programming, system administration, sounds and graphics.
92 .93 .
9394
=== modified file 'debian/multiarch.h.in'
--- debian/multiarch.h.in 2013-06-05 12:28:37 +0000
+++ debian/multiarch.h.in 2013-09-17 18:06:34 +0000
@@ -20,21 +20,21 @@
20# elif defined(__m68k__) && !defined(__mcoldfire__)20# elif defined(__m68k__) && !defined(__mcoldfire__)
21# include <m68k-linux-gnu/@subdir@/@header@>21# include <m68k-linux-gnu/@subdir@/@header@>
22# elif defined(__mips_hard_float) && defined(_MIPSEL)22# elif defined(__mips_hard_float) && defined(_MIPSEL)
23# if defined(_ABIO32)23# if _MIPS_SIM == _ABIO32
24# include <mipsel-linux-gnu/@subdir@/@header@>24# include <mipsel-linux-gnu/@subdir@/@header@>
25# elif defined(_ABIN32)25# elif _MIPS_SIM == _ABIN32
26# include <mips64el-linux-gnuabin32/@subdir@/@header@>26# include <mips64el-linux-gnuabin32/@subdir@/@header@>
27# elif defined(_ABI64)27# elif _MIPS_SIM == _ABI64
28# include <mips64el-linux-gnuabi64/@subdir@/@header@>28# include <mips64el-linux-gnuabi64/@subdir@/@header@>
29# else29# else
30# error unknown multiarch location for @header@30# error unknown multiarch location for @header@
31# endif31# endif
32# elif defined(__mips_hard_float)32# elif defined(__mips_hard_float)
33# if defined(_ABIO32)33# if _MIPS_SIM == _ABIO32
34# include <mips-linux-gnu/@subdir@/@header@>34# include <mips-linux-gnu/@subdir@/@header@>
35# elif defined(_ABIN32)35# elif _MIPS_SIM == _ABIN32
36# include <mips64-linux-gnuabin32/@subdir@/@header@>36# include <mips64-linux-gnuabin32/@subdir@/@header@>
37# elif defined(_ABI64)37# elif _MIPS_SIM == _ABI64
38# include <mips64-linux-gnuabi64/@subdir@/@header@>38# include <mips64-linux-gnuabi64/@subdir@/@header@>
39# else39# else
40# error unknown multiarch location for @header@40# error unknown multiarch location for @header@
@@ -51,10 +51,10 @@
51# include <s390-linux-gnu/@subdir@/@header@>51# include <s390-linux-gnu/@subdir@/@header@>
52# elif defined(__sh__) && defined(__LITTLE_ENDIAN__)52# elif defined(__sh__) && defined(__LITTLE_ENDIAN__)
53# include <sh4-linux-gnu/@subdir@/@header@>53# include <sh4-linux-gnu/@subdir@/@header@>
54# elif defined(__sparc64__)
55# include <sparc64-linux-gnu/@subdir@/@header@>
54# elif defined(__sparc__)56# elif defined(__sparc__)
55# include <sparc-linux-gnu/@subdir@/@header@>57# include <sparc-linux-gnu/@subdir@/@header@>
56# elif defined(__sparc64__)
57# include <sparc64-linux-gnu/@subdir@/@header@>
58# else58# else
59# error unknown multiarch location for @header@59# error unknown multiarch location for @header@
60# endif60# endif
6161
=== modified file 'debian/patches/add-python-config-sh.diff'
--- debian/patches/add-python-config-sh.diff 2013-06-05 12:28:37 +0000
+++ debian/patches/add-python-config-sh.diff 2013-09-17 18:06:34 +0000
@@ -1,8 +1,6 @@
1Index: b/Makefile.pre.in
2===================================================================
3--- a/Makefile.pre.in1--- a/Makefile.pre.in
4+++ b/Makefile.pre.in2+++ b/Makefile.pre.in
5@@ -1161,6 +1161,8 @@3@@ -1175,6 +1175,8 @@
6 # Substitution happens here, as the completely-expanded BINDIR4 # Substitution happens here, as the completely-expanded BINDIR
7 # is not available in configure5 # is not available in configure
8 sed -e "s,@EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config6 sed -e "s,@EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
@@ -11,7 +9,7 @@
11 9
12 # Install the include files10 # Install the include files
13 INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)11 INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
14@@ -1219,6 +1221,7 @@12@@ -1233,6 +1235,7 @@
15 $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup13 $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
16 $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh14 $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
17 $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config15 $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config
@@ -19,8 +17,6 @@
19 rm python-config17 rm python-config
20 @if [ -s Modules/python.exp -a \18 @if [ -s Modules/python.exp -a \
21 "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \19 "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
22Index: b/Misc/python-config.sh.in
23===================================================================
24--- /dev/null20--- /dev/null
25+++ b/Misc/python-config.sh.in21+++ b/Misc/python-config.sh.in
26@@ -0,0 +1,107 @@22@@ -0,0 +1,107 @@
@@ -131,8 +127,6 @@
131+ ;;127+ ;;
132+esac128+esac
133+done129+done
134Index: b/configure.ac
135===================================================================
136--- a/configure.ac130--- a/configure.ac
137+++ b/configure.ac131+++ b/configure.ac
138@@ -917,6 +917,7 @@132@@ -917,6 +917,7 @@
139133
=== modified file 'debian/patches/atomic-pyc-rename.diff'
--- debian/patches/atomic-pyc-rename.diff 2013-06-05 12:28:37 +0000
+++ debian/patches/atomic-pyc-rename.diff 2013-09-17 18:06:34 +0000
@@ -1,6 +1,5 @@
1diff -r 6ab88d6527f1 Lib/py_compile.py1--- a/Lib/py_compile.py
2--- a/Lib/py_compile.py Tue May 21 11:44:41 2013 -04002+++ b/Lib/py_compile.py
3+++ b/Lib/py_compile.py Tue May 21 14:43:25 2013 -0400
4@@ -138,14 +138,25 @@3@@ -138,14 +138,25 @@
5 except OSError as error:4 except OSError as error:
6 if error.errno != errno.EEXIST:5 if error.errno != errno.EEXIST:
76
=== modified file 'debian/patches/avoid-rpath.diff'
--- debian/patches/avoid-rpath.diff 2012-08-26 23:15:00 +0000
+++ debian/patches/avoid-rpath.diff 2013-09-17 18:06:34 +0000
@@ -1,9 +1,8 @@
1# DP: avoid runtime library path for some extension modules.1# DP: avoid runtime library path for some extension modules.
22
3diff -r 12a56a349af2 setup.py3--- a/setup.py
4--- a/setup.py Sat Jun 30 19:28:16 2012 +02004+++ b/setup.py
5+++ b/setup.py Sun Jul 01 10:25:14 2012 +02005@@ -1011,6 +1011,15 @@
6@@ -957,6 +957,15 @@
7 print("bsddb lib dir:", dblib_dir, " inc dir:", db_incdir)6 print("bsddb lib dir:", dblib_dir, " inc dir:", db_incdir)
8 db_incs = [db_incdir]7 db_incs = [db_incdir]
9 dblibs = [dblib]8 dblibs = [dblib]
@@ -19,7 +18,7 @@
19 else:18 else:
20 if db_setup_debug: print("db: no appropriate library found")19 if db_setup_debug: print("db: no appropriate library found")
21 db_incs = None20 db_incs = None
22@@ -1065,6 +1074,9 @@21@@ -1121,6 +1130,9 @@
23 # can end up with a bad search path order.22 # can end up with a bad search path order.
24 if sqlite_incdir not in self.compiler.include_dirs:23 if sqlite_incdir not in self.compiler.include_dirs:
25 include_dirs.append(sqlite_incdir)24 include_dirs.append(sqlite_incdir)
2625
=== modified file 'debian/patches/bdist-wininst-notfound.diff'
--- debian/patches/bdist-wininst-notfound.diff 2012-06-21 16:04:00 +0000
+++ debian/patches/bdist-wininst-notfound.diff 2013-09-17 18:06:34 +0000
@@ -1,8 +1,6 @@
1# DP: suggest installation of the pythonX.Y-dev package, if bdist_wininst1# DP: suggest installation of the pythonX.Y-dev package, if bdist_wininst
2# DP: cannot find the wininst-* files.2# DP: cannot find the wininst-* files.
33
4Index: b/Lib/distutils/command/bdist_wininst.py
5===================================================================
6--- a/Lib/distutils/command/bdist_wininst.py4--- a/Lib/distutils/command/bdist_wininst.py
7+++ b/Lib/distutils/command/bdist_wininst.py5+++ b/Lib/distutils/command/bdist_wininst.py
8@@ -342,7 +342,10 @@6@@ -342,7 +342,10 @@
97
=== modified file 'debian/patches/ctypes-arm.diff'
--- debian/patches/ctypes-arm.diff 2012-07-13 00:43:42 +0000
+++ debian/patches/ctypes-arm.diff 2013-09-17 18:06:34 +0000
@@ -1,8 +1,6 @@
1Index: b/Lib/ctypes/util.py
2===================================================================
3--- a/Lib/ctypes/util.py1--- a/Lib/ctypes/util.py
4+++ b/Lib/ctypes/util.py2+++ b/Lib/ctypes/util.py
5@@ -170,16 +170,27 @@3@@ -199,16 +199,27 @@
6 4
7 def _findSoname_ldconfig(name):5 def _findSoname_ldconfig(name):
8 import struct6 import struct
97
=== modified file 'debian/patches/deb-locations.diff'
--- debian/patches/deb-locations.diff 2012-06-21 16:04:00 +0000
+++ debian/patches/deb-locations.diff 2013-09-17 18:06:34 +0000
@@ -1,7 +1,5 @@
1# DP: adjust locations of directories to debian policy1# DP: adjust locations of directories to debian policy
22
3Index: b/Lib/pydoc.py
4===================================================================
5--- a/Lib/pydoc.py3--- a/Lib/pydoc.py
6+++ b/Lib/pydoc.py4+++ b/Lib/pydoc.py
7@@ -27,6 +27,10 @@5@@ -27,6 +27,10 @@
@@ -15,8 +13,6 @@
15 http://docs.python.org/X.Y/library/13 http://docs.python.org/X.Y/library/
16 14
17 This can be overridden by setting the PYTHONDOCS environment variable15 This can be overridden by setting the PYTHONDOCS environment variable
18Index: b/Misc/python.man
19===================================================================
20--- a/Misc/python.man16--- a/Misc/python.man
21+++ b/Misc/python.man17+++ b/Misc/python.man
22@@ -305,7 +305,7 @@18@@ -305,7 +305,7 @@
2319
=== modified file 'debian/patches/deb-setup.diff'
--- debian/patches/deb-setup.diff 2012-08-28 19:47:58 +0000
+++ debian/patches/deb-setup.diff 2013-09-17 18:06:34 +0000
@@ -1,10 +1,8 @@
1# DP: Don't include /usr/local/include and /usr/local/lib as gcc search paths1# DP: Don't include /usr/local/include and /usr/local/lib as gcc search paths
22
3Index: b/setup.py
4===================================================================
5--- a/setup.py3--- a/setup.py
6+++ b/setup.py4+++ b/setup.py
7@@ -248,8 +248,10 @@5@@ -238,8 +238,10 @@
8 # unfortunately, distutils doesn't let us provide separate C and C++6 # unfortunately, distutils doesn't let us provide separate C and C++
9 # compilers7 # compilers
10 if compiler is not None:8 if compiler is not None:
@@ -16,8 +14,8 @@
16+ args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cppflags + ' ' + cflags14+ args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cppflags + ' ' + cflags
17 self.compiler.set_executables(**args)15 self.compiler.set_executables(**args)
18 16
19 # Not only do we write the builddir cookie, but we manually install17 build_ext.build_extensions(self)
20@@ -455,12 +457,7 @@18@@ -435,12 +437,7 @@
21 os.unlink(tmpfile)19 os.unlink(tmpfile)
22 20
23 def detect_modules(self):21 def detect_modules(self):
2422
=== modified file 'debian/patches/disable-sem-check.diff'
--- debian/patches/disable-sem-check.diff 2012-06-21 16:04:00 +0000
+++ debian/patches/disable-sem-check.diff 2013-09-17 18:06:34 +0000
@@ -1,10 +1,8 @@
1# DP: Assume working semaphores, don't rely on running kernel for the check.1# DP: Assume working semaphores, don't rely on running kernel for the check.
22
3Index: b/configure.ac
4===================================================================
5--- a/configure.ac3--- a/configure.ac
6+++ b/configure.ac4+++ b/configure.ac
7@@ -3595,8 +3595,13 @@5@@ -3798,8 +3798,13 @@
8 AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)6 AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
9 if test $ac_cv_posix_semaphores_enabled = no7 if test $ac_cv_posix_semaphores_enabled = no
10 then8 then
@@ -20,7 +18,7 @@
20 fi18 fi
21 19
22 # Multiprocessing check for broken sem_getvalue20 # Multiprocessing check for broken sem_getvalue
23@@ -3631,8 +3636,13 @@21@@ -3834,8 +3839,13 @@
24 AC_MSG_RESULT($ac_cv_broken_sem_getvalue)22 AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
25 if test $ac_cv_broken_sem_getvalue = yes23 if test $ac_cv_broken_sem_getvalue = yes
26 then24 then
2725
=== modified file 'debian/patches/distutils-init.diff'
--- debian/patches/distutils-init.diff 2012-08-13 11:05:00 +0000
+++ debian/patches/distutils-init.diff 2013-09-17 18:06:34 +0000
@@ -1,10 +1,8 @@
1# DP: Use _sysconfigdata.py in distutils to initialize distutils1# DP: Use _sysconfigdata.py in distutils to initialize distutils
22
3Index: b/Lib/distutils/sysconfig.py
4===================================================================
5--- a/Lib/distutils/sysconfig.py3--- a/Lib/distutils/sysconfig.py
6+++ b/Lib/distutils/sysconfig.py4+++ b/Lib/distutils/sysconfig.py
7@@ -442,49 +442,11 @@5@@ -454,49 +454,11 @@
8 6
9 def _init_posix():7 def _init_posix():
10 """Initialize the module as appropriate for POSIX systems."""8 """Initialize the module as appropriate for POSIX systems."""
119
=== modified file 'debian/patches/distutils-install-layout.diff'
--- debian/patches/distutils-install-layout.diff 2013-03-26 10:45:37 +0000
+++ debian/patches/distutils-install-layout.diff 2013-09-17 18:06:34 +0000
@@ -2,8 +2,6 @@
2# DP: - installs into $prefix/dist-packages instead of $prefix/site-packages.2# DP: - installs into $prefix/dist-packages instead of $prefix/site-packages.
3# DP: - doesn't encode the python version into the egg name.3# DP: - doesn't encode the python version into the egg name.
44
5Index: b/Lib/distutils/command/install_egg_info.py
6===================================================================
7--- a/Lib/distutils/command/install_egg_info.py5--- a/Lib/distutils/command/install_egg_info.py
8+++ b/Lib/distutils/command/install_egg_info.py6+++ b/Lib/distutils/command/install_egg_info.py
9@@ -14,18 +14,38 @@7@@ -14,18 +14,38 @@
@@ -50,8 +48,6 @@
50 self.target = os.path.join(self.install_dir, basename)48 self.target = os.path.join(self.install_dir, basename)
51 self.outputs = [self.target]49 self.outputs = [self.target]
52 50
53Index: b/Lib/distutils/command/install.py
54===================================================================
55--- a/Lib/distutils/command/install.py51--- a/Lib/distutils/command/install.py
56+++ b/Lib/distutils/command/install.py52+++ b/Lib/distutils/command/install.py
57@@ -50,6 +50,20 @@53@@ -50,6 +50,20 @@
@@ -137,8 +133,6 @@
137 133
138 def finalize_other(self):134 def finalize_other(self):
139 """Finalizes options for non-posix platforms"""135 """Finalizes options for non-posix platforms"""
140Index: b/Lib/distutils/sysconfig.py
141===================================================================
142--- a/Lib/distutils/sysconfig.py136--- a/Lib/distutils/sysconfig.py
143+++ b/Lib/distutils/sysconfig.py137+++ b/Lib/distutils/sysconfig.py
144@@ -136,6 +136,7 @@138@@ -136,6 +136,7 @@
@@ -158,8 +152,6 @@
158 else:152 else:
159 return os.path.join(libpython, "site-packages")153 return os.path.join(libpython, "site-packages")
160 elif os.name == "nt":154 elif os.name == "nt":
161Index: b/Lib/site.py
162===================================================================
163--- a/Lib/site.py155--- a/Lib/site.py
164+++ b/Lib/site.py156+++ b/Lib/site.py
165@@ -285,6 +285,13 @@157@@ -285,6 +285,13 @@
@@ -176,8 +168,6 @@
176 return known_paths168 return known_paths
177 169
178 def getsitepackages(prefixes=None):170 def getsitepackages(prefixes=None):
179Index: b/Lib/test/test_site.py
180===================================================================
181--- a/Lib/test/test_site.py171--- a/Lib/test/test_site.py
182+++ b/Lib/test/test_site.py172+++ b/Lib/test/test_site.py
183@@ -239,12 +239,20 @@173@@ -239,12 +239,20 @@
@@ -205,8 +195,6 @@
205 else:195 else:
206 # other platforms196 # other platforms
207 self.assertEqual(len(dirs), 2)197 self.assertEqual(len(dirs), 2)
208Index: b/Lib/distutils/tests/test_bdist_dumb.py
209===================================================================
210--- a/Lib/distutils/tests/test_bdist_dumb.py198--- a/Lib/distutils/tests/test_bdist_dumb.py
211+++ b/Lib/distutils/tests/test_bdist_dumb.py199+++ b/Lib/distutils/tests/test_bdist_dumb.py
212@@ -88,7 +88,7 @@200@@ -88,7 +88,7 @@
@@ -218,8 +206,6 @@
218 if not sys.dont_write_bytecode:206 if not sys.dont_write_bytecode:
219 wanted.append('foo.%s.pyc' % imp.get_tag())207 wanted.append('foo.%s.pyc' % imp.get_tag())
220 self.assertEqual(contents, sorted(wanted))208 self.assertEqual(contents, sorted(wanted))
221Index: b/Lib/distutils/tests/test_install.py
222===================================================================
223--- a/Lib/distutils/tests/test_install.py209--- a/Lib/distutils/tests/test_install.py
224+++ b/Lib/distutils/tests/test_install.py210+++ b/Lib/distutils/tests/test_install.py
225@@ -194,7 +194,7 @@211@@ -194,7 +194,7 @@
@@ -240,8 +226,6 @@
240 self.assertEqual(found, expected)226 self.assertEqual(found, expected)
241 227
242 def test_debug_mode(self):228 def test_debug_mode(self):
243Index: b/Lib/pydoc.py
244===================================================================
245--- a/Lib/pydoc.py229--- a/Lib/pydoc.py
246+++ b/Lib/pydoc.py230+++ b/Lib/pydoc.py
247@@ -383,6 +383,7 @@231@@ -383,6 +383,7 @@
248232
=== modified file 'debian/patches/distutils-link.diff'
--- debian/patches/distutils-link.diff 2012-06-21 16:04:00 +0000
+++ debian/patches/distutils-link.diff 2013-09-17 18:06:34 +0000
@@ -1,10 +1,8 @@
1# DP: Don't add standard library dirs to library_dirs and runtime_library_dirs.1# DP: Don't add standard library dirs to library_dirs and runtime_library_dirs.
22
3Index: b/Lib/distutils/unixccompiler.py
4===================================================================
5--- a/Lib/distutils/unixccompiler.py3--- a/Lib/distutils/unixccompiler.py
6+++ b/Lib/distutils/unixccompiler.py4+++ b/Lib/distutils/unixccompiler.py
7@@ -211,6 +211,13 @@5@@ -153,6 +153,13 @@
8 runtime_library_dirs)6 runtime_library_dirs)
9 libraries, library_dirs, runtime_library_dirs = fixed_args7 libraries, library_dirs, runtime_library_dirs = fixed_args
10 8
119
=== modified file 'debian/patches/distutils-sysconfig.diff'
--- debian/patches/distutils-sysconfig.diff 2013-03-26 10:45:37 +0000
+++ debian/patches/distutils-sysconfig.diff 2013-09-17 18:06:34 +0000
@@ -2,8 +2,6 @@
2# DP: the python build, when CFLAGS, CPPFLAGS, LDSHARED) are not set2# DP: the python build, when CFLAGS, CPPFLAGS, LDSHARED) are not set
3# DP: in the environment.3# DP: in the environment.
44
5Index: b/Lib/distutils/sysconfig.py
6===================================================================
7--- a/Lib/distutils/sysconfig.py5--- a/Lib/distutils/sysconfig.py
8+++ b/Lib/distutils/sysconfig.py6+++ b/Lib/distutils/sysconfig.py
9@@ -194,9 +194,11 @@7@@ -194,9 +194,11 @@
@@ -18,9 +16,9 @@
18+ 'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS',16+ 'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS',
19+ 'CONFIGURE_CPPFLAGS', 'CONFIGURE_CFLAGS', 'CONFIGURE_LDFLAGS')17+ 'CONFIGURE_CPPFLAGS', 'CONFIGURE_CFLAGS', 'CONFIGURE_LDFLAGS')
20 18
21 newcc = None
22 if 'CC' in os.environ:19 if 'CC' in os.environ:
23@@ -211,13 +213,22 @@20 newcc = os.environ['CC']
21@@ -217,13 +219,22 @@
24 cpp = cc + " -E" # not always22 cpp = cc + " -E" # not always
25 if 'LDFLAGS' in os.environ:23 if 'LDFLAGS' in os.environ:
26 ldshared = ldshared + ' ' + os.environ['LDFLAGS']24 ldshared = ldshared + ' ' + os.environ['LDFLAGS']
2725
=== modified file 'debian/patches/enable-fpectl.diff'
--- debian/patches/enable-fpectl.diff 2012-06-21 16:04:00 +0000
+++ debian/patches/enable-fpectl.diff 2013-09-17 18:06:34 +0000
@@ -1,10 +1,8 @@
1# DP: Enable the build of the fpectl module.1# DP: Enable the build of the fpectl module.
22
3Index: b/setup.py
4===================================================================
5--- a/setup.py3--- a/setup.py
6+++ b/setup.py4+++ b/setup.py
7@@ -1211,6 +1211,9 @@5@@ -1292,6 +1292,9 @@
8 else:6 else:
9 missing.append('_curses_panel')7 missing.append('_curses_panel')
10 8
119
=== modified file 'debian/patches/ext-no-libpython-link.diff'
--- debian/patches/ext-no-libpython-link.diff 2012-11-28 13:47:16 +0000
+++ debian/patches/ext-no-libpython-link.diff 2013-09-17 18:06:34 +0000
@@ -2,7 +2,7 @@
22
3--- a/Lib/distutils/command/build_ext.py3--- a/Lib/distutils/command/build_ext.py
4+++ b/Lib/distutils/command/build_ext.py4+++ b/Lib/distutils/command/build_ext.py
5@@ -243,7 +243,7 @@5@@ -250,7 +250,7 @@
6 # for extensions under Linux or Solaris with a shared Python library,6 # for extensions under Linux or Solaris with a shared Python library,
7 # Python's library directory must be appended to library_dirs7 # Python's library directory must be appended to library_dirs
8 sysconfig.get_config_var('Py_ENABLE_SHARED')8 sysconfig.get_config_var('Py_ENABLE_SHARED')
@@ -11,7 +11,7 @@
11 and sysconfig.get_config_var('Py_ENABLE_SHARED')):11 and sysconfig.get_config_var('Py_ENABLE_SHARED')):
12 if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):12 if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
13 # building third party extensions13 # building third party extensions
14@@ -753,7 +753,7 @@14@@ -760,7 +760,7 @@
15 return ext.libraries15 return ext.libraries
16 else:16 else:
17 from distutils import sysconfig17 from distutils import sysconfig
1818
=== modified file 'debian/patches/hg-updates.diff'
--- debian/patches/hg-updates.diff 2013-06-05 12:28:37 +0000
+++ debian/patches/hg-updates.diff 2013-09-17 18:06:34 +0000
@@ -1,7 +1,1257 @@
1# DP: hg updates of the 3.3 release branch (until 2013-05-27, 83934:e57c8a90b2df).1# DP: hg updates of the 3.3 release branch (until 2013-08-03, 84986:c503cea0e8c2).
22
3# hg diff -r v3.3.2 | filterdiff --exclude=.hgignore --exclude=.hgeol --exclude=.hgtags --remove-timestamps3# hg diff -r v3.3.2 | filterdiff --exclude=.hgignore --exclude=.hgeol --exclude=.hgtags --remove-timestamps
44
5diff -r d047928ae3f6 Doc/c-api/allocation.rst
6--- a/Doc/c-api/allocation.rst
7+++ b/Doc/c-api/allocation.rst
8@@ -32,7 +32,7 @@
9 Allocate a new Python object using the C structure type *TYPE* and the
10 Python type object *type*. Fields not defined by the Python object header
11 are not initialized; the object's reference count will be one. The size of
12- the memory allocation is determined from the :attr:`tp_basicsize` field of
13+ the memory allocation is determined from the :c:member:`~PyTypeObject.tp_basicsize` field of
14 the type object.
15
16
17@@ -41,7 +41,7 @@
18 Allocate a new Python object using the C structure type *TYPE* and the
19 Python type object *type*. Fields not defined by the Python object header
20 are not initialized. The allocated memory allows for the *TYPE* structure
21- plus *size* fields of the size given by the :attr:`tp_itemsize` field of
22+ plus *size* fields of the size given by the :c:member:`~PyTypeObject.tp_itemsize` field of
23 *type*. This is useful for implementing objects like tuples, which are
24 able to determine their size at construction time. Embedding the array of
25 fields into the same allocation decreases the number of allocations,
26@@ -52,7 +52,7 @@
27
28 Releases memory allocated to an object using :c:func:`PyObject_New` or
29 :c:func:`PyObject_NewVar`. This is normally called from the
30- :attr:`tp_dealloc` handler specified in the object's type. The fields of
31+ :c:member:`~PyTypeObject.tp_dealloc` handler specified in the object's type. The fields of
32 the object should not be accessed after this call as the memory is no
33 longer a valid Python object.
34
35diff -r d047928ae3f6 Doc/c-api/exceptions.rst
36--- a/Doc/c-api/exceptions.rst
37+++ b/Doc/c-api/exceptions.rst
38@@ -607,28 +607,28 @@
39 Ends a :c:func:`Py_EnterRecursiveCall`. Must be called once for each
40 *successful* invocation of :c:func:`Py_EnterRecursiveCall`.
41
42-Properly implementing :attr:`tp_repr` for container types requires
43+Properly implementing :c:member:`~PyTypeObject.tp_repr` for container types requires
44 special recursion handling. In addition to protecting the stack,
45-:attr:`tp_repr` also needs to track objects to prevent cycles. The
46+:c:member:`~PyTypeObject.tp_repr` also needs to track objects to prevent cycles. The
47 following two functions facilitate this functionality. Effectively,
48 these are the C equivalent to :func:`reprlib.recursive_repr`.
49
50 .. c:function:: int Py_ReprEnter(PyObject *object)
51
52- Called at the beginning of the :attr:`tp_repr` implementation to
53+ Called at the beginning of the :c:member:`~PyTypeObject.tp_repr` implementation to
54 detect cycles.
55
56 If the object has already been processed, the function returns a
57- positive integer. In that case the :attr:`tp_repr` implementation
58+ positive integer. In that case the :c:member:`~PyTypeObject.tp_repr` implementation
59 should return a string object indicating a cycle. As examples,
60 :class:`dict` objects return ``{...}`` and :class:`list` objects
61 return ``[...]``.
62
63 The function will return a negative integer if the recursion limit
64- is reached. In that case the :attr:`tp_repr` implementation should
65+ is reached. In that case the :c:member:`~PyTypeObject.tp_repr` implementation should
66 typically return ``NULL``.
67
68- Otherwise, the function returns zero and the :attr:`tp_repr`
69+ Otherwise, the function returns zero and the :c:member:`~PyTypeObject.tp_repr`
70 implementation can continue normally.
71
72 .. c:function:: void Py_ReprLeave(PyObject *object)
73diff -r d047928ae3f6 Doc/c-api/gcsupport.rst
74--- a/Doc/c-api/gcsupport.rst
75+++ b/Doc/c-api/gcsupport.rst
76@@ -12,10 +12,10 @@
77 or strings), do not need to provide any explicit support for garbage
78 collection.
79
80-To create a container type, the :attr:`tp_flags` field of the type object must
81+To create a container type, the :c:member:`~PyTypeObject.tp_flags` field of the type object must
82 include the :const:`Py_TPFLAGS_HAVE_GC` and provide an implementation of the
83-:attr:`tp_traverse` handler. If instances of the type are mutable, a
84-:attr:`tp_clear` implementation must also be provided.
85+:c:member:`~PyTypeObject.tp_traverse` handler. If instances of the type are mutable, a
86+:c:member:`~PyTypeObject.tp_clear` implementation must also be provided.
87
88
89 .. data:: Py_TPFLAGS_HAVE_GC
90@@ -57,7 +57,7 @@
91 Adds the object *op* to the set of container objects tracked by the
92 collector. The collector can run at unexpected times so objects must be
93 valid while being tracked. This should be called once all the fields
94- followed by the :attr:`tp_traverse` handler become valid, usually near the
95+ followed by the :c:member:`~PyTypeObject.tp_traverse` handler become valid, usually near the
96 end of the constructor.
97
98
99@@ -86,8 +86,8 @@
100 Remove the object *op* from the set of container objects tracked by the
101 collector. Note that :c:func:`PyObject_GC_Track` can be called again on
102 this object to add it back to the set of tracked objects. The deallocator
103- (:attr:`tp_dealloc` handler) should call this for the object before any of
104- the fields used by the :attr:`tp_traverse` handler become invalid.
105+ (:c:member:`~PyTypeObject.tp_dealloc` handler) should call this for the object before any of
106+ the fields used by the :c:member:`~PyTypeObject.tp_traverse` handler become invalid.
107
108
109 .. c:function:: void _PyObject_GC_UNTRACK(PyObject *op)
110@@ -95,19 +95,19 @@
111 A macro version of :c:func:`PyObject_GC_UnTrack`. It should not be used for
112 extension modules.
113
114-The :attr:`tp_traverse` handler accepts a function parameter of this type:
115+The :c:member:`~PyTypeObject.tp_traverse` handler accepts a function parameter of this type:
116
117
118 .. c:type:: int (*visitproc)(PyObject *object, void *arg)
119
120- Type of the visitor function passed to the :attr:`tp_traverse` handler.
121+ Type of the visitor function passed to the :c:member:`~PyTypeObject.tp_traverse` handler.
122 The function should be called with an object to traverse as *object* and
123- the third parameter to the :attr:`tp_traverse` handler as *arg*. The
124+ the third parameter to the :c:member:`~PyTypeObject.tp_traverse` handler as *arg*. The
125 Python core uses several visitor functions to implement cyclic garbage
126 detection; it's not expected that users will need to write their own
127 visitor functions.
128
129-The :attr:`tp_traverse` handler must have the following type:
130+The :c:member:`~PyTypeObject.tp_traverse` handler must have the following type:
131
132
133 .. c:type:: int (*traverseproc)(PyObject *self, visitproc visit, void *arg)
134@@ -119,15 +119,15 @@
135 object argument. If *visit* returns a non-zero value that value should be
136 returned immediately.
137
138-To simplify writing :attr:`tp_traverse` handlers, a :c:func:`Py_VISIT` macro is
139-provided. In order to use this macro, the :attr:`tp_traverse` implementation
140+To simplify writing :c:member:`~PyTypeObject.tp_traverse` handlers, a :c:func:`Py_VISIT` macro is
141+provided. In order to use this macro, the :c:member:`~PyTypeObject.tp_traverse` implementation
142 must name its arguments exactly *visit* and *arg*:
143
144
145 .. c:function:: void Py_VISIT(PyObject *o)
146
147 Call the *visit* callback, with arguments *o* and *arg*. If *visit* returns
148- a non-zero value, then return it. Using this macro, :attr:`tp_traverse`
149+ a non-zero value, then return it. Using this macro, :c:member:`~PyTypeObject.tp_traverse`
150 handlers look like::
151
152 static int
153@@ -138,7 +138,7 @@
154 return 0;
155 }
156
157-The :attr:`tp_clear` handler must be of the :c:type:`inquiry` type, or *NULL*
158+The :c:member:`~PyTypeObject.tp_clear` handler must be of the :c:type:`inquiry` type, or *NULL*
159 if the object is immutable.
160
161
162diff -r d047928ae3f6 Doc/c-api/type.rst
163--- a/Doc/c-api/type.rst
164+++ b/Doc/c-api/type.rst
165@@ -37,10 +37,10 @@
166
167 .. c:function:: long PyType_GetFlags(PyTypeObject* type)
168
169- Return the :attr:`tp_flags` member of *type*. This function is primarily
170+ Return the :c:member:`~PyTypeObject.tp_flags` member of *type*. This function is primarily
171 meant for use with `Py_LIMITED_API`; the individual flag bits are
172 guaranteed to be stable across Python releases, but access to
173- :attr:`tp_flags` itself is not part of the limited API.
174+ :c:member:`~PyTypeObject.tp_flags` itself is not part of the limited API.
175
176 .. versionadded:: 3.2
177
178@@ -70,14 +70,14 @@
179
180 .. c:function:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
181
182- Generic handler for the :attr:`tp_alloc` slot of a type object. Use
183+ Generic handler for the :c:member:`~PyTypeObject.tp_alloc` slot of a type object. Use
184 Python's default memory allocation mechanism to allocate a new instance and
185 initialize all its contents to *NULL*.
186
187 .. c:function:: PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds)
188
189- Generic handler for the :attr:`tp_new` slot of a type object. Create a
190- new instance using the type's :attr:`tp_alloc` slot.
191+ Generic handler for the :c:member:`~PyTypeObject.tp_new` slot of a type object. Create a
192+ new instance using the type's :c:member:`~PyTypeObject.tp_alloc` slot.
193
194 .. c:function:: int PyType_Ready(PyTypeObject *type)
195
196diff -r d047928ae3f6 Doc/c-api/typeobj.rst
197--- a/Doc/c-api/typeobj.rst
198+++ b/Doc/c-api/typeobj.rst
199@@ -35,7 +35,7 @@
200 The type object structure extends the :c:type:`PyVarObject` structure. The
201 :attr:`ob_size` field is used for dynamic types (created by :func:`type_new`,
202 usually called from a class statement). Note that :c:data:`PyType_Type` (the
203-metatype) initializes :attr:`tp_itemsize`, which means that its instances (i.e.
204+metatype) initializes :c:member:`~PyTypeObject.tp_itemsize`, which means that its instances (i.e.
205 type objects) *must* have the :attr:`ob_size` field.
206
207
208@@ -102,7 +102,7 @@
209 should be just the type name. If the module is a submodule of a package, the
210 full package name is part of the full module name. For example, a type named
211 :class:`T` defined in module :mod:`M` in subpackage :mod:`Q` in package :mod:`P`
212- should have the :attr:`tp_name` initializer ``"P.Q.M.T"``.
213+ should have the :c:member:`~PyTypeObject.tp_name` initializer ``"P.Q.M.T"``.
214
215 For dynamically allocated type objects, this should just be the type name, and
216 the module name explicitly stored in the type dict as the value for key
217@@ -113,7 +113,7 @@
218 attribute, and everything after the last dot is made accessible as the
219 :attr:`__name__` attribute.
220
221- If no dot is present, the entire :attr:`tp_name` field is made accessible as the
222+ If no dot is present, the entire :c:member:`~PyTypeObject.tp_name` field is made accessible as the
223 :attr:`__name__` attribute, and the :attr:`__module__` attribute is undefined
224 (unless explicitly set in the dictionary, as explained above). This means your
225 type will be impossible to pickle.
226@@ -127,13 +127,13 @@
227 These fields allow calculating the size in bytes of instances of the type.
228
229 There are two kinds of types: types with fixed-length instances have a zero
230- :attr:`tp_itemsize` field, types with variable-length instances have a non-zero
231- :attr:`tp_itemsize` field. For a type with fixed-length instances, all
232- instances have the same size, given in :attr:`tp_basicsize`.
233+ :c:member:`~PyTypeObject.tp_itemsize` field, types with variable-length instances have a non-zero
234+ :c:member:`~PyTypeObject.tp_itemsize` field. For a type with fixed-length instances, all
235+ instances have the same size, given in :c:member:`~PyTypeObject.tp_basicsize`.
236
237 For a type with variable-length instances, the instances must have an
238- :attr:`ob_size` field, and the instance size is :attr:`tp_basicsize` plus N
239- times :attr:`tp_itemsize`, where N is the "length" of the object. The value of
240+ :attr:`ob_size` field, and the instance size is :c:member:`~PyTypeObject.tp_basicsize` plus N
241+ times :c:member:`~PyTypeObject.tp_itemsize`, where N is the "length" of the object. The value of
242 N is typically stored in the instance's :attr:`ob_size` field. There are
243 exceptions: for example, ints use a negative :attr:`ob_size` to indicate a
244 negative number, and N is ``abs(ob_size)`` there. Also, the presence of an
245@@ -146,20 +146,20 @@
246 :c:macro:`PyObject_HEAD` or :c:macro:`PyObject_VAR_HEAD` (whichever is used to
247 declare the instance struct) and this in turn includes the :attr:`_ob_prev` and
248 :attr:`_ob_next` fields if they are present. This means that the only correct
249- way to get an initializer for the :attr:`tp_basicsize` is to use the
250+ way to get an initializer for the :c:member:`~PyTypeObject.tp_basicsize` is to use the
251 ``sizeof`` operator on the struct used to declare the instance layout.
252 The basic size does not include the GC header size.
253
254 These fields are inherited separately by subtypes. If the base type has a
255- non-zero :attr:`tp_itemsize`, it is generally not safe to set
256- :attr:`tp_itemsize` to a different non-zero value in a subtype (though this
257+ non-zero :c:member:`~PyTypeObject.tp_itemsize`, it is generally not safe to set
258+ :c:member:`~PyTypeObject.tp_itemsize` to a different non-zero value in a subtype (though this
259 depends on the implementation of the base type).
260
261 A note about alignment: if the variable items require a particular alignment,
262- this should be taken care of by the value of :attr:`tp_basicsize`. Example:
263- suppose a type implements an array of ``double``. :attr:`tp_itemsize` is
264+ this should be taken care of by the value of :c:member:`~PyTypeObject.tp_basicsize`. Example:
265+ suppose a type implements an array of ``double``. :c:member:`~PyTypeObject.tp_itemsize` is
266 ``sizeof(double)``. It is the programmer's responsibility that
267- :attr:`tp_basicsize` is a multiple of ``sizeof(double)`` (assuming this is the
268+ :c:member:`~PyTypeObject.tp_basicsize` is a multiple of ``sizeof(double)`` (assuming this is the
269 alignment requirement for ``double``).
270
271
272@@ -175,10 +175,10 @@
273 destructor function should free all references which the instance owns, free all
274 memory buffers owned by the instance (using the freeing function corresponding
275 to the allocation function used to allocate the buffer), and finally (as its
276- last action) call the type's :attr:`tp_free` function. If the type is not
277+ last action) call the type's :c:member:`~PyTypeObject.tp_free` function. If the type is not
278 subtypable (doesn't have the :const:`Py_TPFLAGS_BASETYPE` flag bit set), it is
279 permissible to call the object deallocator directly instead of via
280- :attr:`tp_free`. The object deallocator should be the one used to allocate the
281+ :c:member:`~PyTypeObject.tp_free`. The object deallocator should be the one used to allocate the
282 instance; this is normally :c:func:`PyObject_Del` if the instance was allocated
283 using :c:func:`PyObject_New` or :c:func:`PyObject_VarNew`, or
284 :c:func:`PyObject_GC_Del` if the instance was allocated using
285@@ -193,25 +193,25 @@
286
287 The print function is only called when the instance is printed to a *real* file;
288 when it is printed to a pseudo-file (like a :class:`StringIO` instance), the
289- instance's :attr:`tp_repr` or :attr:`tp_str` function is called to convert it to
290- a string. These are also called when the type's :attr:`tp_print` field is
291- *NULL*. A type should never implement :attr:`tp_print` in a way that produces
292- different output than :attr:`tp_repr` or :attr:`tp_str` would.
293+ instance's :c:member:`~PyTypeObject.tp_repr` or :c:member:`~PyTypeObject.tp_str` function is called to convert it to
294+ a string. These are also called when the type's :c:member:`~PyTypeObject.tp_print` field is
295+ *NULL*. A type should never implement :c:member:`~PyTypeObject.tp_print` in a way that produces
296+ different output than :c:member:`~PyTypeObject.tp_repr` or :c:member:`~PyTypeObject.tp_str` would.
297
298 The print function is called with the same signature as :c:func:`PyObject_Print`:
299 ``int tp_print(PyObject *self, FILE *file, int flags)``. The *self* argument is
300 the instance to be printed. The *file* argument is the stdio file to which it
301 is to be printed. The *flags* argument is composed of flag bits. The only flag
302 bit currently defined is :const:`Py_PRINT_RAW`. When the :const:`Py_PRINT_RAW`
303- flag bit is set, the instance should be printed the same way as :attr:`tp_str`
304+ flag bit is set, the instance should be printed the same way as :c:member:`~PyTypeObject.tp_str`
305 would format it; when the :const:`Py_PRINT_RAW` flag bit is clear, the instance
306- should be printed the same was as :attr:`tp_repr` would format it. It should
307+ should be printed the same was as :c:member:`~PyTypeObject.tp_repr` would format it. It should
308 return ``-1`` and set an exception condition when an error occurred during the
309 comparison.
310
311- It is possible that the :attr:`tp_print` field will be deprecated. In any case,
312- it is recommended not to define :attr:`tp_print`, but instead to rely on
313- :attr:`tp_repr` and :attr:`tp_str` for printing.
314+ It is possible that the :c:member:`~PyTypeObject.tp_print` field will be deprecated. In any case,
315+ it is recommended not to define :c:member:`~PyTypeObject.tp_print`, but instead to rely on
316+ :c:member:`~PyTypeObject.tp_repr` and :c:member:`~PyTypeObject.tp_str` for printing.
317
318 This field is inherited by subtypes.
319
320@@ -221,13 +221,13 @@
321 An optional pointer to the get-attribute-string function.
322
323 This field is deprecated. When it is defined, it should point to a function
324- that acts the same as the :attr:`tp_getattro` function, but taking a C string
325+ that acts the same as the :c:member:`~PyTypeObject.tp_getattro` function, but taking a C string
326 instead of a Python string object to give the attribute name. The signature is
327 the same as for :c:func:`PyObject_GetAttrString`.
328
329- This field is inherited by subtypes together with :attr:`tp_getattro`: a subtype
330- inherits both :attr:`tp_getattr` and :attr:`tp_getattro` from its base type when
331- the subtype's :attr:`tp_getattr` and :attr:`tp_getattro` are both *NULL*.
332+ This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_getattro`: a subtype
333+ inherits both :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject.tp_getattro` from its base type when
334+ the subtype's :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject.tp_getattro` are both *NULL*.
335
336
337 .. c:member:: setattrfunc PyTypeObject.tp_setattr
338@@ -235,13 +235,13 @@
339 An optional pointer to the set-attribute-string function.
340
341 This field is deprecated. When it is defined, it should point to a function
342- that acts the same as the :attr:`tp_setattro` function, but taking a C string
343+ that acts the same as the :c:member:`~PyTypeObject.tp_setattro` function, but taking a C string
344 instead of a Python string object to give the attribute name. The signature is
345 the same as for :c:func:`PyObject_SetAttrString`.
346
347- This field is inherited by subtypes together with :attr:`tp_setattro`: a subtype
348- inherits both :attr:`tp_setattr` and :attr:`tp_setattro` from its base type when
349- the subtype's :attr:`tp_setattr` and :attr:`tp_setattro` are both *NULL*.
350+ This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_setattro`: a subtype
351+ inherits both :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` from its base type when
352+ the subtype's :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` are both *NULL*.
353
354
355 .. c:member:: void* PyTypeObject.tp_reserved
356@@ -275,7 +275,7 @@
357 objects which implement the number protocol. These fields are documented in
358 :ref:`number-structs`.
359
360- The :attr:`tp_as_number` field is not inherited, but the contained fields are
361+ The :c:member:`~PyTypeObject.tp_as_number` field is not inherited, but the contained fields are
362 inherited individually.
363
364
365@@ -285,7 +285,7 @@
366 objects which implement the sequence protocol. These fields are documented
367 in :ref:`sequence-structs`.
368
369- The :attr:`tp_as_sequence` field is not inherited, but the contained fields
370+ The :c:member:`~PyTypeObject.tp_as_sequence` field is not inherited, but the contained fields
371 are inherited individually.
372
373
374@@ -295,7 +295,7 @@
375 objects which implement the mapping protocol. These fields are documented in
376 :ref:`mapping-structs`.
377
378- The :attr:`tp_as_mapping` field is not inherited, but the contained fields
379+ The :c:member:`~PyTypeObject.tp_as_mapping` field is not inherited, but the contained fields
380 are inherited individually.
381
382
383@@ -323,9 +323,9 @@
384 object raises :exc:`TypeError`.
385
386 This field is inherited by subtypes together with
387- :attr:`tp_richcompare`: a subtype inherits both of
388- :attr:`tp_richcompare` and :attr:`tp_hash`, when the subtype's
389- :attr:`tp_richcompare` and :attr:`tp_hash` are both *NULL*.
390+ :c:member:`~PyTypeObject.tp_richcompare`: a subtype inherits both of
391+ :c:member:`~PyTypeObject.tp_richcompare` and :c:member:`~PyTypeObject.tp_hash`, when the subtype's
392+ :c:member:`~PyTypeObject.tp_richcompare` and :c:member:`~PyTypeObject.tp_hash` are both *NULL*.
393
394
395 .. c:member:: ternaryfunc PyTypeObject.tp_call
396@@ -363,9 +363,9 @@
397 convenient to set this field to :c:func:`PyObject_GenericGetAttr`, which
398 implements the normal way of looking for object attributes.
399
400- This field is inherited by subtypes together with :attr:`tp_getattr`: a subtype
401- inherits both :attr:`tp_getattr` and :attr:`tp_getattro` from its base type when
402- the subtype's :attr:`tp_getattr` and :attr:`tp_getattro` are both *NULL*.
403+ This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_getattr`: a subtype
404+ inherits both :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject.tp_getattro` from its base type when
405+ the subtype's :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject.tp_getattro` are both *NULL*.
406
407
408 .. c:member:: setattrofunc PyTypeObject.tp_setattro
409@@ -376,9 +376,9 @@
410 convenient to set this field to :c:func:`PyObject_GenericSetAttr`, which
411 implements the normal way of setting object attributes.
412
413- This field is inherited by subtypes together with :attr:`tp_setattr`: a subtype
414- inherits both :attr:`tp_setattr` and :attr:`tp_setattro` from its base type when
415- the subtype's :attr:`tp_setattr` and :attr:`tp_setattro` are both *NULL*.
416+ This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_setattr`: a subtype
417+ inherits both :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` from its base type when
418+ the subtype's :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` are both *NULL*.
419
420
421 .. c:member:: PyBufferProcs* PyTypeObject.tp_as_buffer
422@@ -387,7 +387,7 @@
423 which implement the buffer interface. These fields are documented in
424 :ref:`buffer-structs`.
425
426- The :attr:`tp_as_buffer` field is not inherited, but the contained fields are
427+ The :c:member:`~PyTypeObject.tp_as_buffer` field is not inherited, but the contained fields are
428 inherited individually.
429
430
431@@ -396,8 +396,8 @@
432 This field is a bit mask of various flags. Some flags indicate variant
433 semantics for certain situations; others are used to indicate that certain
434 fields in the type object (or in the extension structures referenced via
435- :attr:`tp_as_number`, :attr:`tp_as_sequence`, :attr:`tp_as_mapping`, and
436- :attr:`tp_as_buffer`) that were historically not always present are valid; if
437+ :c:member:`~PyTypeObject.tp_as_number`, :c:member:`~PyTypeObject.tp_as_sequence`, :c:member:`~PyTypeObject.tp_as_mapping`, and
438+ :c:member:`~PyTypeObject.tp_as_buffer`) that were historically not always present are valid; if
439 such a flag bit is clear, the type fields it guards must not be accessed and
440 must be considered to have a zero or *NULL* value instead.
441
442@@ -407,13 +407,13 @@
443 inherited if the extension structure is inherited, i.e. the base type's value of
444 the flag bit is copied into the subtype together with a pointer to the extension
445 structure. The :const:`Py_TPFLAGS_HAVE_GC` flag bit is inherited together with
446- the :attr:`tp_traverse` and :attr:`tp_clear` fields, i.e. if the
447+ the :c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` fields, i.e. if the
448 :const:`Py_TPFLAGS_HAVE_GC` flag bit is clear in the subtype and the
449- :attr:`tp_traverse` and :attr:`tp_clear` fields in the subtype exist and have
450+ :c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` fields in the subtype exist and have
451 *NULL* values.
452
453 The following bit masks are currently defined; these can be ORed together using
454- the ``|`` operator to form the value of the :attr:`tp_flags` field. The macro
455+ the ``|`` operator to form the value of the :c:member:`~PyTypeObject.tp_flags` field. The macro
456 :c:func:`PyType_HasFeature` takes a type and a flags value, *tp* and *f*, and
457 checks whether ``tp->tp_flags & f`` is non-zero.
458
459@@ -453,7 +453,7 @@
460 is set, instances must be created using :c:func:`PyObject_GC_New` and
461 destroyed using :c:func:`PyObject_GC_Del`. More information in section
462 :ref:`supporting-cycle-detection`. This bit also implies that the
463- GC-related fields :attr:`tp_traverse` and :attr:`tp_clear` are present in
464+ GC-related fields :c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` are present in
465 the type object.
466
467
468@@ -481,8 +481,8 @@
469 about Python's garbage collection scheme can be found in section
470 :ref:`supporting-cycle-detection`.
471
472- The :attr:`tp_traverse` pointer is used by the garbage collector to detect
473- reference cycles. A typical implementation of a :attr:`tp_traverse` function
474+ The :c:member:`~PyTypeObject.tp_traverse` pointer is used by the garbage collector to detect
475+ reference cycles. A typical implementation of a :c:member:`~PyTypeObject.tp_traverse` function
476 simply calls :c:func:`Py_VISIT` on each of the instance's members that are Python
477 objects. For example, this is function :c:func:`local_traverse` from the
478 :mod:`_thread` extension module::
479@@ -508,9 +508,9 @@
480 :c:func:`local_traverse` to have these specific names; don't name them just
481 anything.
482
483- This field is inherited by subtypes together with :attr:`tp_clear` and the
484- :const:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :attr:`tp_traverse`, and
485- :attr:`tp_clear` are all inherited from the base type if they are all zero in
486+ This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_clear` and the
487+ :const:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :c:member:`~PyTypeObject.tp_traverse`, and
488+ :c:member:`~PyTypeObject.tp_clear` are all inherited from the base type if they are all zero in
489 the subtype.
490
491
492@@ -519,17 +519,17 @@
493 An optional pointer to a clear function for the garbage collector. This is only
494 used if the :const:`Py_TPFLAGS_HAVE_GC` flag bit is set.
495
496- The :attr:`tp_clear` member function is used to break reference cycles in cyclic
497- garbage detected by the garbage collector. Taken together, all :attr:`tp_clear`
498+ The :c:member:`~PyTypeObject.tp_clear` member function is used to break reference cycles in cyclic
499+ garbage detected by the garbage collector. Taken together, all :c:member:`~PyTypeObject.tp_clear`
500 functions in the system must combine to break all reference cycles. This is
501- subtle, and if in any doubt supply a :attr:`tp_clear` function. For example,
502- the tuple type does not implement a :attr:`tp_clear` function, because it's
503+ subtle, and if in any doubt supply a :c:member:`~PyTypeObject.tp_clear` function. For example,
504+ the tuple type does not implement a :c:member:`~PyTypeObject.tp_clear` function, because it's
505 possible to prove that no reference cycle can be composed entirely of tuples.
506- Therefore the :attr:`tp_clear` functions of other types must be sufficient to
507+ Therefore the :c:member:`~PyTypeObject.tp_clear` functions of other types must be sufficient to
508 break any cycle containing a tuple. This isn't immediately obvious, and there's
509- rarely a good reason to avoid implementing :attr:`tp_clear`.
510+ rarely a good reason to avoid implementing :c:member:`~PyTypeObject.tp_clear`.
511
512- Implementations of :attr:`tp_clear` should drop the instance's references to
513+ Implementations of :c:member:`~PyTypeObject.tp_clear` should drop the instance's references to
514 those of its members that may be Python objects, and set its pointers to those
515 members to *NULL*, as in the following example::
516
517@@ -554,18 +554,18 @@
518 so that *self* knows the contained object can no longer be used. The
519 :c:func:`Py_CLEAR` macro performs the operations in a safe order.
520
521- Because the goal of :attr:`tp_clear` functions is to break reference cycles,
522+ Because the goal of :c:member:`~PyTypeObject.tp_clear` functions is to break reference cycles,
523 it's not necessary to clear contained objects like Python strings or Python
524 integers, which can't participate in reference cycles. On the other hand, it may
525 be convenient to clear all contained Python objects, and write the type's
526- :attr:`tp_dealloc` function to invoke :attr:`tp_clear`.
527+ :c:member:`~PyTypeObject.tp_dealloc` function to invoke :c:member:`~PyTypeObject.tp_clear`.
528
529 More information about Python's garbage collection scheme can be found in
530 section :ref:`supporting-cycle-detection`.
531
532- This field is inherited by subtypes together with :attr:`tp_traverse` and the
533- :const:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :attr:`tp_traverse`, and
534- :attr:`tp_clear` are all inherited from the base type if they are all zero in
535+ This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_traverse` and the
536+ :const:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :c:member:`~PyTypeObject.tp_traverse`, and
537+ :c:member:`~PyTypeObject.tp_clear` are all inherited from the base type if they are all zero in
538 the subtype.
539
540
541@@ -585,13 +585,13 @@
542 comparisons makes sense (e.g. ``==`` and ``!=``, but not ``<`` and
543 friends), directly raise :exc:`TypeError` in the rich comparison function.
544
545- This field is inherited by subtypes together with :attr:`tp_hash`:
546- a subtype inherits :attr:`tp_richcompare` and :attr:`tp_hash` when
547- the subtype's :attr:`tp_richcompare` and :attr:`tp_hash` are both
548+ This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_hash`:
549+ a subtype inherits :c:member:`~PyTypeObject.tp_richcompare` and :c:member:`~PyTypeObject.tp_hash` when
550+ the subtype's :c:member:`~PyTypeObject.tp_richcompare` and :c:member:`~PyTypeObject.tp_hash` are both
551 *NULL*.
552
553 The following constants are defined to be used as the third argument for
554- :attr:`tp_richcompare` and for :c:func:`PyObject_RichCompare`:
555+ :c:member:`~PyTypeObject.tp_richcompare` and for :c:func:`PyObject_RichCompare`:
556
557 +----------------+------------+
558 | Constant | Comparison |
559@@ -619,26 +619,26 @@
560 instance structure needs to include a field of type :c:type:`PyObject\*` which is
561 initialized to *NULL*.
562
563- Do not confuse this field with :attr:`tp_weaklist`; that is the list head for
564+ Do not confuse this field with :c:member:`~PyTypeObject.tp_weaklist`; that is the list head for
565 weak references to the type object itself.
566
567 This field is inherited by subtypes, but see the rules listed below. A subtype
568 may override this offset; this means that the subtype uses a different weak
569 reference list head than the base type. Since the list head is always found via
570- :attr:`tp_weaklistoffset`, this should not be a problem.
571+ :c:member:`~PyTypeObject.tp_weaklistoffset`, this should not be a problem.
572
573 When a type defined by a class statement has no :attr:`__slots__` declaration,
574 and none of its base types are weakly referenceable, the type is made weakly
575 referenceable by adding a weak reference list head slot to the instance layout
576- and setting the :attr:`tp_weaklistoffset` of that slot's offset.
577+ and setting the :c:member:`~PyTypeObject.tp_weaklistoffset` of that slot's offset.
578
579 When a type's :attr:`__slots__` declaration contains a slot named
580 :attr:`__weakref__`, that slot becomes the weak reference list head for
581 instances of the type, and the slot's offset is stored in the type's
582- :attr:`tp_weaklistoffset`.
583+ :c:member:`~PyTypeObject.tp_weaklistoffset`.
584
585 When a type's :attr:`__slots__` declaration does not contain a slot named
586- :attr:`__weakref__`, the type inherits its :attr:`tp_weaklistoffset` from its
587+ :attr:`__weakref__`, the type inherits its :c:member:`~PyTypeObject.tp_weaklistoffset` from its
588 base type.
589
590 .. c:member:: getiterfunc PyTypeObject.tp_iter
591@@ -660,7 +660,7 @@
592 *NULL* too. Its presence signals that the instances of this type are
593 iterators.
594
595- Iterator types should also define the :attr:`tp_iter` function, and that
596+ Iterator types should also define the :c:member:`~PyTypeObject.tp_iter` function, and that
597 function should return the iterator instance itself (not a new iterator
598 instance).
599
600@@ -675,7 +675,7 @@
601 structures, declaring regular methods of this type.
602
603 For each entry in the array, an entry is added to the type's dictionary (see
604- :attr:`tp_dict` below) containing a method descriptor.
605+ :c:member:`~PyTypeObject.tp_dict` below) containing a method descriptor.
606
607 This field is not inherited by subtypes (methods are inherited through a
608 different mechanism).
609@@ -688,7 +688,7 @@
610 this type.
611
612 For each entry in the array, an entry is added to the type's dictionary (see
613- :attr:`tp_dict` below) containing a member descriptor.
614+ :c:member:`~PyTypeObject.tp_dict` below) containing a member descriptor.
615
616 This field is not inherited by subtypes (members are inherited through a
617 different mechanism).
618@@ -700,7 +700,7 @@
619 structures, declaring computed attributes of instances of this type.
620
621 For each entry in the array, an entry is added to the type's dictionary (see
622- :attr:`tp_dict` below) containing a getset descriptor.
623+ :c:member:`~PyTypeObject.tp_dict` below) containing a getset descriptor.
624
625 This field is not inherited by subtypes (computed attributes are inherited
626 through a different mechanism).
627@@ -748,7 +748,7 @@
628 .. warning::
629
630 It is not safe to use :c:func:`PyDict_SetItem` on or otherwise modify
631- :attr:`tp_dict` with the dictionary C-API.
632+ :c:member:`~PyTypeObject.tp_dict` with the dictionary C-API.
633
634
635 .. c:member:: descrgetfunc PyTypeObject.tp_descr_get
636@@ -784,7 +784,7 @@
637 the instance variable dictionary; this offset is used by
638 :c:func:`PyObject_GenericGetAttr`.
639
640- Do not confuse this field with :attr:`tp_dict`; that is the dictionary for
641+ Do not confuse this field with :c:member:`~PyTypeObject.tp_dict`; that is the dictionary for
642 attributes of the type object itself.
643
644 If the value of this field is greater than zero, it specifies the offset from
645@@ -793,20 +793,20 @@
646 offset is more expensive to use, and should only be used when the instance
647 structure contains a variable-length part. This is used for example to add an
648 instance variable dictionary to subtypes of :class:`str` or :class:`tuple`. Note
649- that the :attr:`tp_basicsize` field should account for the dictionary added to
650+ that the :c:member:`~PyTypeObject.tp_basicsize` field should account for the dictionary added to
651 the end in that case, even though the dictionary is not included in the basic
652 object layout. On a system with a pointer size of 4 bytes,
653- :attr:`tp_dictoffset` should be set to ``-4`` to indicate that the dictionary is
654+ :c:member:`~PyTypeObject.tp_dictoffset` should be set to ``-4`` to indicate that the dictionary is
655 at the very end of the structure.
656
657 The real dictionary offset in an instance can be computed from a negative
658- :attr:`tp_dictoffset` as follows::
659+ :c:member:`~PyTypeObject.tp_dictoffset` as follows::
660
661 dictoffset = tp_basicsize + abs(ob_size)*tp_itemsize + tp_dictoffset
662 if dictoffset is not aligned on sizeof(void*):
663 round up to sizeof(void*)
664
665- where :attr:`tp_basicsize`, :attr:`tp_itemsize` and :attr:`tp_dictoffset` are
666+ where :c:member:`~PyTypeObject.tp_basicsize`, :c:member:`~PyTypeObject.tp_itemsize` and :c:member:`~PyTypeObject.tp_dictoffset` are
667 taken from the type object, and :attr:`ob_size` is taken from the instance. The
668 absolute value is taken because ints use the sign of :attr:`ob_size` to
669 store the sign of the number. (There's never a need to do this calculation
670@@ -815,15 +815,15 @@
671 This field is inherited by subtypes, but see the rules listed below. A subtype
672 may override this offset; this means that the subtype instances store the
673 dictionary at a difference offset than the base type. Since the dictionary is
674- always found via :attr:`tp_dictoffset`, this should not be a problem.
675+ always found via :c:member:`~PyTypeObject.tp_dictoffset`, this should not be a problem.
676
677 When a type defined by a class statement has no :attr:`__slots__` declaration,
678 and none of its base types has an instance variable dictionary, a dictionary
679- slot is added to the instance layout and the :attr:`tp_dictoffset` is set to
680+ slot is added to the instance layout and the :c:member:`~PyTypeObject.tp_dictoffset` is set to
681 that slot's offset.
682
683 When a type defined by a class statement has a :attr:`__slots__` declaration,
684- the type inherits its :attr:`tp_dictoffset` from its base type.
685+ the type inherits its :c:member:`~PyTypeObject.tp_dictoffset` from its base type.
686
687 (Adding a slot named :attr:`__dict__` to the :attr:`__slots__` declaration does
688 not have the expected effect, it just causes confusion. Maybe this should be
689@@ -847,12 +847,12 @@
690 arguments represent positional and keyword arguments of the call to
691 :meth:`__init__`.
692
693- The :attr:`tp_init` function, if not *NULL*, is called when an instance is
694- created normally by calling its type, after the type's :attr:`tp_new` function
695- has returned an instance of the type. If the :attr:`tp_new` function returns an
696+ The :c:member:`~PyTypeObject.tp_init` function, if not *NULL*, is called when an instance is
697+ created normally by calling its type, after the type's :c:member:`~PyTypeObject.tp_new` function
698+ has returned an instance of the type. If the :c:member:`~PyTypeObject.tp_new` function returns an
699 instance of some other type that is not a subtype of the original type, no
700- :attr:`tp_init` function is called; if :attr:`tp_new` returns an instance of a
701- subtype of the original type, the subtype's :attr:`tp_init` is called.
702+ :c:member:`~PyTypeObject.tp_init` function is called; if :c:member:`~PyTypeObject.tp_new` returns an instance of a
703+ subtype of the original type, the subtype's :c:member:`~PyTypeObject.tp_init` is called.
704
705 This field is inherited by subtypes.
706
707@@ -869,14 +869,14 @@
708 initialization. It should return a pointer to a block of memory of adequate
709 length for the instance, suitably aligned, and initialized to zeros, but with
710 :attr:`ob_refcnt` set to ``1`` and :attr:`ob_type` set to the type argument. If
711- the type's :attr:`tp_itemsize` is non-zero, the object's :attr:`ob_size` field
712+ the type's :c:member:`~PyTypeObject.tp_itemsize` is non-zero, the object's :attr:`ob_size` field
713 should be initialized to *nitems* and the length of the allocated memory block
714 should be ``tp_basicsize + nitems*tp_itemsize``, rounded up to a multiple of
715 ``sizeof(void*)``; otherwise, *nitems* is not used and the length of the block
716- should be :attr:`tp_basicsize`.
717+ should be :c:member:`~PyTypeObject.tp_basicsize`.
718
719 Do not use this function to do any other instance initialization, not even to
720- allocate additional memory; that should be done by :attr:`tp_new`.
721+ allocate additional memory; that should be done by :c:member:`~PyTypeObject.tp_new`.
722
723 This field is inherited by static subtypes, but not by dynamic subtypes
724 (subtypes created by a class statement); in the latter, this field is always set
725@@ -898,20 +898,20 @@
726
727 The subtype argument is the type of the object being created; the *args* and
728 *kwds* arguments represent positional and keyword arguments of the call to the
729- type. Note that subtype doesn't have to equal the type whose :attr:`tp_new`
730+ type. Note that subtype doesn't have to equal the type whose :c:member:`~PyTypeObject.tp_new`
731 function is called; it may be a subtype of that type (but not an unrelated
732 type).
733
734- The :attr:`tp_new` function should call ``subtype->tp_alloc(subtype, nitems)``
735+ The :c:member:`~PyTypeObject.tp_new` function should call ``subtype->tp_alloc(subtype, nitems)``
736 to allocate space for the object, and then do only as much further
737 initialization as is absolutely necessary. Initialization that can safely be
738- ignored or repeated should be placed in the :attr:`tp_init` handler. A good
739+ ignored or repeated should be placed in the :c:member:`~PyTypeObject.tp_init` handler. A good
740 rule of thumb is that for immutable types, all initialization should take place
741- in :attr:`tp_new`, while for mutable types, most initialization should be
742- deferred to :attr:`tp_init`.
743+ in :c:member:`~PyTypeObject.tp_new`, while for mutable types, most initialization should be
744+ deferred to :c:member:`~PyTypeObject.tp_init`.
745
746 This field is inherited by subtypes, except it is not inherited by static types
747- whose :attr:`tp_base` is *NULL* or ``&PyBaseObject_Type``.
748+ whose :c:member:`~PyTypeObject.tp_base` is *NULL* or ``&PyBaseObject_Type``.
749
750
751 .. c:member:: destructor PyTypeObject.tp_free
752@@ -935,7 +935,7 @@
753
754 The garbage collector needs to know whether a particular object is collectible
755 or not. Normally, it is sufficient to look at the object's type's
756- :attr:`tp_flags` field, and check the :const:`Py_TPFLAGS_HAVE_GC` flag bit. But
757+ :c:member:`~PyTypeObject.tp_flags` field, and check the :const:`Py_TPFLAGS_HAVE_GC` flag bit. But
758 some types have a mixture of statically and dynamically allocated instances, and
759 the statically allocated instances are not collectible. Such types should
760 define this function; it should return ``1`` for a collectible instance, and
761@@ -1006,7 +1006,7 @@
762
763 .. c:member:: PyTypeObject* PyTypeObject.tp_next
764
765- Pointer to the next type object with a non-zero :attr:`tp_allocs` field.
766+ Pointer to the next type object with a non-zero :c:member:`~PyTypeObject.tp_allocs` field.
767
768 Also, note that, in a garbage collected Python, tp_dealloc may be called from
769 any Python thread, not just the thread which created the object (if the object
770@@ -1145,13 +1145,13 @@
771
772 This function is used by :c:func:`PySequence_Concat` and has the same
773 signature. It is also used by the ``+`` operator, after trying the numeric
774- addition via the :attr:`tp_as_number.nb_add` slot.
775+ addition via the :c:member:`~PyTypeObject.tp_as_number.nb_add` slot.
776
777 .. c:member:: ssizeargfunc PySequenceMethods.sq_repeat
778
779 This function is used by :c:func:`PySequence_Repeat` and has the same
780 signature. It is also used by the ``*`` operator, after trying numeric
781- multiplication via the :attr:`tp_as_number.nb_mul` slot.
782+ multiplication via the :c:member:`~PyTypeObject.tp_as_number.nb_mul` slot.
783
784 .. c:member:: ssizeargfunc PySequenceMethods.sq_item
785
786diff -r d047928ae3f6 Doc/data/refcounts.dat
787--- a/Doc/data/refcounts.dat
788+++ b/Doc/data/refcounts.dat
789@@ -210,7 +210,7 @@
790
791 PyDict_DelItemString:int:::
792 PyDict_DelItemString:PyObject*:p:0:
793-PyDict_DelItemString:char*:key::
794+PyDict_DelItemString:const char*:key::
795
796 PyDict_GetItem:PyObject*::0:0
797 PyDict_GetItem:PyObject*:p:0:
798@@ -218,7 +218,7 @@
799
800 PyDict_GetItemString:PyObject*::0:
801 PyDict_GetItemString:PyObject*:p:0:
802-PyDict_GetItemString:char*:key::
803+PyDict_GetItemString:const char*:key::
804
805 PyDict_Items:PyObject*::+1:
806 PyDict_Items:PyObject*:p:0:
807@@ -244,7 +244,7 @@
808
809 PyDict_SetItemString:int:::
810 PyDict_SetItemString:PyObject*:p:0:
811-PyDict_SetItemString:char*:key::
812+PyDict_SetItemString:const char*:key::
813 PyDict_SetItemString:PyObject*:val:+1:
814
815 PyDict_Size:int:::
816@@ -277,13 +277,13 @@
817 PyErr_GivenExceptionMatches:PyObject*:exc:0:
818
819 PyErr_NewException:PyObject*::+1:
820-PyErr_NewException:char*:name::
821+PyErr_NewException:const char*:name::
822 PyErr_NewException:PyObject*:base:0:
823 PyErr_NewException:PyObject*:dict:0:
824
825 PyErr_NewExceptionWithDoc:PyObject*::+1:
826-PyErr_NewExceptionWithDoc:char*:name::
827-PyErr_NewExceptionWithDoc:char*:doc::
828+PyErr_NewExceptionWithDoc:const char*:name::
829+PyErr_NewExceptionWithDoc:const char*:doc::
830 PyErr_NewExceptionWithDoc:PyObject*:base:0:
831 PyErr_NewExceptionWithDoc:PyObject*:dict:0:
832
833@@ -310,21 +310,21 @@
834 PyErr_SetExcFromWindowsErrWithFilename:PyObject*::null:
835 PyErr_SetExcFromWindowsErrWithFilename:PyObject*:type:0:
836 PyErr_SetExcFromWindowsErrWithFilename:int:ierr::
837-PyErr_SetExcFromWindowsErrWithFilename:char*:filename::
838+PyErr_SetExcFromWindowsErrWithFilename:const char*:filename::
839
840 PyErr_SetFromErrno:PyObject*::null:
841 PyErr_SetFromErrno:PyObject*:type:0:
842
843 PyErr_SetFromErrnoWithFilename:PyObject*::null:
844 PyErr_SetFromErrnoWithFilename:PyObject*:type:0:
845-PyErr_SetFromErrnoWithFilename:char*:filename::
846+PyErr_SetFromErrnoWithFilename:const char*:filename::
847
848 PyErr_SetFromWindowsErr:PyObject*::null:
849 PyErr_SetFromWindowsErr:int:ierr::
850
851 PyErr_SetFromWindowsErrWithFilename:PyObject*::null:
852 PyErr_SetFromWindowsErrWithFilename:int:ierr::
853-PyErr_SetFromWindowsErrWithFilename:char*:filename::
854+PyErr_SetFromWindowsErrWithFilename:const char*:filename::
855
856 PyErr_SetInterrupt:void:::
857
858@@ -337,11 +337,11 @@
859
860 PyErr_SetString:void:::
861 PyErr_SetString:PyObject*:type:+1:
862-PyErr_SetString:char*:message::
863+PyErr_SetString:const char*:message::
864
865 PyErr_Format:PyObject*::null:
866 PyErr_Format:PyObject*:exception:+1:
867-PyErr_Format:char*:format::
868+PyErr_Format:const char*:format::
869 PyErr_Format::...::
870
871 PyErr_WarnEx:int:::
872@@ -386,22 +386,22 @@
873
874 PyFile_FromFile:PyObject*::+1:
875 PyFile_FromFile:FILE*:fp::
876-PyFile_FromFile:char*:name::
877-PyFile_FromFile:char*:mode::
878+PyFile_FromFile:const char*:name::
879+PyFile_FromFile:const char*:mode::
880 PyFile_FromFile:int(*:close)::
881
882 PyFile_FromFileEx:PyObject*::+1:
883 PyFile_FromFileEx:FILE*:fp::
884-PyFile_FromFileEx:char*:name::
885-PyFile_FromFileEx:char*:mode::
886+PyFile_FromFileEx:const char*:name::
887+PyFile_FromFileEx:const char*:mode::
888 PyFile_FromFileEx:int(*:close)::
889 PyFile_FromFileEx:int:buffering::
890-PyFile_FromFileEx:char*:encoding::
891-PyFile_FromFileEx:char*:newline::
892+PyFile_FromFileEx:const char*:encoding::
893+PyFile_FromFileEx:const char*:newline::
894
895 PyFile_FromString:PyObject*::+1:
896-PyFile_FromString:char*:name::
897-PyFile_FromString:char*:mode::
898+PyFile_FromString:const char*:name::
899+PyFile_FromString:const char*:mode::
900
901 PyFile_GetLine:PyObject*::+1:
902 PyFile_GetLine:PyObject*:p::
903@@ -482,23 +482,23 @@
904 PyGen_New:PyFrameObject*:frame:0:
905
906 Py_InitModule:PyObject*::0:
907-Py_InitModule:char*:name::
908+Py_InitModule:const char*:name::
909 Py_InitModule:PyMethodDef[]:methods::
910
911 Py_InitModule3:PyObject*::0:
912-Py_InitModule3:char*:name::
913+Py_InitModule3:const char*:name::
914 Py_InitModule3:PyMethodDef[]:methods::
915-Py_InitModule3:char*:doc::
916+Py_InitModule3:const char*:doc::
917
918 Py_InitModule4:PyObject*::0:
919-Py_InitModule4:char*:name::
920+Py_InitModule4:const char*:name::
921 Py_InitModule4:PyMethodDef[]:methods::
922-Py_InitModule4:char*:doc::
923+Py_InitModule4:const char*:doc::
924 Py_InitModule4:PyObject*:self::
925 Py_InitModule4:int:apiver::usually provided by Py_InitModule or Py_InitModule3
926
927 PyImport_AddModule:PyObject*::0:reference borrowed from sys.modules
928-PyImport_AddModule:char*:name::
929+PyImport_AddModule:const char*:name::
930
931 PyImport_Cleanup:void:::
932
933@@ -522,16 +522,16 @@
934 PyImport_ImportFrozenModule:char*:::
935
936 PyImport_ImportModule:PyObject*::+1:
937-PyImport_ImportModule:char*:name::
938+PyImport_ImportModule:const char*:name::
939
940 PyImport_ImportModuleEx:PyObject*::+1:
941-PyImport_ImportModuleEx:char*:name::
942+PyImport_ImportModuleEx:const char*:name::
943 PyImport_ImportModuleEx:PyObject*:globals:0:???
944 PyImport_ImportModuleEx:PyObject*:locals:0:???
945 PyImport_ImportModuleEx:PyObject*:fromlist:0:???
946
947 PyImport_ImportModuleLevel:PyObject*::+1:
948-PyImport_ImportModuleLevel:char*:name::
949+PyImport_ImportModuleLevel:const char*:name::
950 PyImport_ImportModuleLevel:PyObject*:globals:0:???
951 PyImport_ImportModuleLevel:PyObject*:locals:0:???
952 PyImport_ImportModuleLevel:PyObject*:fromlist:0:???
953@@ -692,7 +692,7 @@
954
955 PyMapping_DelItemString:int:::
956 PyMapping_DelItemString:PyObject*:o:0:
957-PyMapping_DelItemString:char*:key::
958+PyMapping_DelItemString:const char*:key::
959
960 PyMapping_GetItemString:PyObject*::+1:
961 PyMapping_GetItemString:PyObject*:o:0:
962@@ -762,10 +762,10 @@
963 PyModule_GetDict:PyObject*::0:
964 PyModule_GetDict::PyObject* module:0:
965
966-PyModule_GetFilename:char*:::
967+PyModule_GetFilename:const char*:::
968 PyModule_GetFilename:PyObject*:module:0:
969
970-PyModule_GetName:char*:::
971+PyModule_GetName:const char*:::
972 PyModule_GetName:PyObject*:module:0:
973
974 PyModule_New:PyObject*::+1:
975@@ -927,7 +927,7 @@
976
977 PyObject_CallMethodObjArgs:PyObject*::+1:
978 PyObject_CallMethodObjArgs:PyObject*:o:0:
979-PyObject_CallMethodObjArgs:char*:name::
980+PyObject_CallMethodObjArgs:PyObject*:name:0:
981 PyObject_CallMethodObjArgs::...::
982
983 PyObject_CallObject:PyObject*::+1:
984@@ -949,7 +949,7 @@
985
986 PyObject_DelAttrString:int:::
987 PyObject_DelAttrString:PyObject*:o:0:
988-PyObject_DelAttrString:char*:attr_name::
989+PyObject_DelAttrString:const char*:attr_name::
990
991 PyObject_DelItem:int:::
992 PyObject_DelItem:PyObject*:o:0:
993@@ -964,7 +964,7 @@
994
995 PyObject_GetAttrString:PyObject*::+1:
996 PyObject_GetAttrString:PyObject*:o:0:
997-PyObject_GetAttrString:char*:attr_name::
998+PyObject_GetAttrString:const char*:attr_name::
999
1000 PyObject_GetItem:PyObject*::+1:
1001 PyObject_GetItem:PyObject*:o:0:
1002@@ -979,7 +979,7 @@
1003
1004 PyObject_HasAttrString:int:::
1005 PyObject_HasAttrString:PyObject*:o:0:
1006-PyObject_HasAttrString:char*:attr_name:0:
1007+PyObject_HasAttrString:const char*:attr_name:0:
1008
1009 PyObject_Hash:int:::
1010 PyObject_Hash:PyObject*:o:0:
1011@@ -1029,7 +1029,7 @@
1012
1013 PyObject_SetAttrString:int:::
1014 PyObject_SetAttrString:PyObject*:o:0:
1015-PyObject_SetAttrString:char*:attr_name::
1016+PyObject_SetAttrString:const char*:attr_name::
1017 PyObject_SetAttrString:PyObject*:v:+1:
1018
1019 PyObject_SetItem:int:::
1020@@ -1048,27 +1048,27 @@
1021
1022 PyParser_SimpleParseFile:struct _node*:::
1023 PyParser_SimpleParseFile:FILE*:fp::
1024-PyParser_SimpleParseFile:char*:filename::
1025+PyParser_SimpleParseFile:const char*:filename::
1026 PyParser_SimpleParseFile:int:start::
1027
1028 PyParser_SimpleParseString:struct _node*:::
1029-PyParser_SimpleParseString:char*:str::
1030+PyParser_SimpleParseString:const char*:str::
1031 PyParser_SimpleParseString:int:start::
1032
1033 PyRun_AnyFile:int:::
1034 PyRun_AnyFile:FILE*:fp::
1035-PyRun_AnyFile:char*:filename::
1036+PyRun_AnyFile:const char*:filename::
1037
1038 PyRun_File:PyObject*::+1:??? -- same as eval_code2()
1039 PyRun_File:FILE*:fp::
1040-PyRun_File:char*:filename::
1041+PyRun_File:const char*:filename::
1042 PyRun_File:int:start::
1043 PyRun_File:PyObject*:globals:0:
1044 PyRun_File:PyObject*:locals:0:
1045
1046 PyRun_FileEx:PyObject*::+1:??? -- same as eval_code2()
1047 PyRun_FileEx:FILE*:fp::
1048-PyRun_FileEx:char*:filename::
1049+PyRun_FileEx:const char*:filename::
1050 PyRun_FileEx:int:start::
1051 PyRun_FileEx:PyObject*:globals:0:
1052 PyRun_FileEx:PyObject*:locals:0:
1053@@ -1076,7 +1076,7 @@
1054
1055 PyRun_FileFlags:PyObject*::+1:??? -- same as eval_code2()
1056 PyRun_FileFlags:FILE*:fp::
1057-PyRun_FileFlags:char*:filename::
1058+PyRun_FileFlags:const char*:filename::
1059 PyRun_FileFlags:int:start::
1060 PyRun_FileFlags:PyObject*:globals:0:
1061 PyRun_FileFlags:PyObject*:locals:0:
1062@@ -1084,7 +1084,7 @@
1063
1064 PyRun_FileExFlags:PyObject*::+1:??? -- same as eval_code2()
1065 PyRun_FileExFlags:FILE*:fp::
1066-PyRun_FileExFlags:char*:filename::
1067+PyRun_FileExFlags:const char*:filename::
1068 PyRun_FileExFlags:int:start::
1069 PyRun_FileExFlags:PyObject*:globals:0:
1070 PyRun_FileExFlags:PyObject*:locals:0:
1071@@ -1093,27 +1093,27 @@
1072
1073 PyRun_InteractiveLoop:int:::
1074 PyRun_InteractiveLoop:FILE*:fp::
1075-PyRun_InteractiveLoop:char*:filename::
1076+PyRun_InteractiveLoop:const char*:filename::
1077
1078 PyRun_InteractiveOne:int:::
1079 PyRun_InteractiveOne:FILE*:fp::
1080-PyRun_InteractiveOne:char*:filename::
1081+PyRun_InteractiveOne:const char*:filename::
1082
1083 PyRun_SimpleFile:int:::
1084 PyRun_SimpleFile:FILE*:fp::
1085-PyRun_SimpleFile:char*:filename::
1086+PyRun_SimpleFile:const char*:filename::
1087
1088 PyRun_SimpleString:int:::
1089-PyRun_SimpleString:char*:command::
1090+PyRun_SimpleString:const char*:command::
1091
1092 PyRun_String:PyObject*::+1:??? -- same as eval_code2()
1093-PyRun_String:char*:str::
1094+PyRun_String:const char*:str::
1095 PyRun_String:int:start::
1096 PyRun_String:PyObject*:globals:0:
1097 PyRun_String:PyObject*:locals:0:
1098
1099 PyRun_StringFlags:PyObject*::+1:??? -- same as eval_code2()
1100-PyRun_StringFlags:char*:str::
1101+PyRun_StringFlags:const char*:str::
1102 PyRun_StringFlags:int:start::
1103 PyRun_StringFlags:PyObject*:globals:0:
1104 PyRun_StringFlags:PyObject*:locals:0:
1105@@ -1229,7 +1229,7 @@
1106 PySlice_New:PyObject*:stop:0:
1107 PySlice_New:PyObject*:step:0:
1108
1109-PyString_AS_STRING:char*:::
1110+PyString_AS_STRING:const char*:::
1111 PyString_AS_STRING:PyObject*:string:0:
1112
1113 PyString_AsDecodedObject:PyObject*::+1:
1114@@ -1242,7 +1242,7 @@
1115 PyString_AsEncodedObject:const char*:encoding::
1116 PyString_AsEncodedObject:const char*:errors::
1117
1118-PyString_AsString:char*:::
1119+PyString_AsString:const char*:::
1120 PyString_AsString:PyObject*:string:0:
1121
1122 PyString_AsStringAndSize:int:::
1123@@ -1310,13 +1310,13 @@
1124 PyString_AsEncodedString:const char*:errors::
1125
1126 PySys_AddWarnOption:void:::
1127-PySys_AddWarnOption:char*:s::
1128+PySys_AddWarnOption:const char*:s::
1129
1130 PySys_AddXOption:void:::
1131 PySys_AddXOption:const wchar_t*:s::
1132
1133 PySys_GetObject:PyObject*::0:
1134-PySys_GetObject:char*:name::
1135+PySys_GetObject:const char*:name::
1136
1137 PySys_GetXOptions:PyObject*::0:
1138
1139@@ -1325,16 +1325,16 @@
1140 PySys_SetArgv:char**:argv::
1141
1142 PySys_SetObject:int:::
1143-PySys_SetObject:char*:name::
1144+PySys_SetObject:const char*:name::
1145 PySys_SetObject:PyObject*:v:+1:
1146
1147 PySys_ResetWarnOptions:void:::
1148
1149 PySys_WriteStdout:void:::
1150-PySys_WriteStdout:char*:format::
1151+PySys_WriteStdout:const char*:format::
1152
1153 PySys_WriteStderr:void:::
1154-PySys_WriteStderr:char*:format::
1155+PySys_WriteStderr:const char*:format::
1156
1157 PyThreadState_Clear:void:::
1158 PyThreadState_Clear:PyThreadState*:tstate::
1159@@ -1714,16 +1714,16 @@
1160 Py_AtExit:void (*)():func::
1161
1162 Py_BuildValue:PyObject*::+1:
1163-Py_BuildValue:char*:format::
1164+Py_BuildValue:const char*:format::
1165
1166 Py_CompileString:PyObject*::+1:
1167-Py_CompileString:char*:str::
1168-Py_CompileString:char*:filename::
1169+Py_CompileString:const char*:str::
1170+Py_CompileString:const char*:filename::
1171 Py_CompileString:int:start::
1172
1173 Py_CompileStringFlags:PyObject*::+1:
1174-Py_CompileStringFlags:char*:str::
1175-Py_CompileStringFlags:char*:filename::
1176+Py_CompileStringFlags:const char*:str::
1177+Py_CompileStringFlags:const char*:filename::
1178 Py_CompileStringFlags:int:start::
1179 Py_CompileStringFlags:PyCompilerFlags*:flags::
1180
1181@@ -1737,33 +1737,33 @@
1182 Py_Exit:int:status::
1183
1184 Py_FatalError:void:::
1185-Py_FatalError:char*:message::
1186+Py_FatalError:const char*:message::
1187
1188 Py_FdIsInteractive:int:::
1189 Py_FdIsInteractive:FILE*:fp::
1190-Py_FdIsInteractive:char*:filename::
1191+Py_FdIsInteractive:const char*:filename::
1192
1193 Py_Finalize:void:::
1194
1195-Py_GetBuildInfoconst:char*:::
1196+Py_GetBuildInfoconst:const char*:::
1197
1198-Py_GetCompilerconst:char*:::
1199+Py_GetCompilerconst:const char*:::
1200
1201-Py_GetCopyrightconst:char*:::
1202+Py_GetCopyrightconst:const char*:::
1203
1204-Py_GetExecPrefix:char*:::
1205+Py_GetExecPrefix:const char*:::
1206
1207-Py_GetPath:char*:::
1208+Py_GetPath:const char*:::
1209
1210-Py_GetPlatformconst:char*:::
1211+Py_GetPlatformconst:const char*:::
1212
1213-Py_GetPrefix:char*:::
1214+Py_GetPrefix:const char*:::
1215
1216-Py_GetProgramFullPath:char*:::
1217+Py_GetProgramFullPath:const char*:::
1218
1219-Py_GetProgramName:char*:::
1220+Py_GetProgramName:const char*:::
1221
1222-Py_GetVersionconst:char*:::
1223+Py_GetVersionconst:const char*:::
1224
1225 Py_INCREF:void:::
1226 Py_INCREF:PyObject*:o:+1:
1227@@ -1775,7 +1775,7 @@
1228 Py_NewInterpreter:PyThreadState*:::
1229
1230 Py_SetProgramName:void:::
1231-Py_SetProgramName:char*:name::
1232+Py_SetProgramName:const char*:name::
1233
1234 Py_XDECREF:void:::
1235 Py_XDECREF:PyObject*:o:-1:if o is not NULL
1236@@ -1784,14 +1784,14 @@
1237 Py_XINCREF:PyObject*:o:+1:if o is not NULL
1238
1239 _PyImport_FindExtension:PyObject*::0:??? see PyImport_AddModule
1240-_PyImport_FindExtension:char*:::
1241-_PyImport_FindExtension:char*:::
1242+_PyImport_FindExtension:const char*:::
1243+_PyImport_FindExtension:const char*:::
1244
1245 _PyImport_Fini:void:::
1246
1247 _PyImport_FixupExtension:PyObject*:::???
1248-_PyImport_FixupExtension:char*:::
1249-_PyImport_FixupExtension:char*:::
1250+_PyImport_FixupExtension:const char*:::
1251+_PyImport_FixupExtension:const char*:::
1252
1253 _PyImport_Init:void:::
1254
5diff -r d047928ae3f6 Doc/extending/embedding.rst1255diff -r d047928ae3f6 Doc/extending/embedding.rst
6--- a/Doc/extending/embedding.rst1256--- a/Doc/extending/embedding.rst
7+++ b/Doc/extending/embedding.rst1257+++ b/Doc/extending/embedding.rst
@@ -24,10 +1274,456 @@
24 1274
25 .. note::1275 .. note::
26 To avoid confusion between several Python installations (and especially1276 To avoid confusion between several Python installations (and especially
1277@@ -307,11 +307,13 @@
1278 to find its location) and compilation
1279 options. In this case, the :mod:`sysconfig` module is a useful tool to
1280 programmatically extract the configuration values that you will want to
1281-combine together:
1282+combine together. For example:
1283
1284 .. code-block:: python
1285
1286 >>> import sysconfig
1287+ >>> sysconfig.get_config_var('LIBS')
1288+ '-lpthread -ldl -lutil'
1289 >>> sysconfig.get_config_var('LINKFORSHARED')
1290 '-Xlinker -export-dynamic'
1291
1292diff -r d047928ae3f6 Doc/extending/newtypes.rst
1293--- a/Doc/extending/newtypes.rst
1294+++ b/Doc/extending/newtypes.rst
1295@@ -135,11 +135,11 @@
1296 .. note::
1297
1298 If you want your type to be subclassable from Python, and your type has the same
1299- :attr:`tp_basicsize` as its base type, you may have problems with multiple
1300+ :c:member:`~PyTypeObject.tp_basicsize` as its base type, you may have problems with multiple
1301 inheritance. A Python subclass of your type will have to list your type first
1302 in its :attr:`__bases__`, or else it will not be able to call your type's
1303 :meth:`__new__` method without getting an error. You can avoid this problem by
1304- ensuring that your type has a larger value for :attr:`tp_basicsize` than its
1305+ ensuring that your type has a larger value for :c:member:`~PyTypeObject.tp_basicsize` than its
1306 base type does. Most of the time, this will be true anyway, because either your
1307 base type will be :class:`object`, or else you will be adding data members to
1308 your base type, and therefore increasing its size.
1309@@ -159,7 +159,7 @@
1310 All types should include this constant in their flags. It enables all of the
1311 members defined by the current version of Python.
1312
1313-We provide a doc string for the type in :attr:`tp_doc`. ::
1314+We provide a doc string for the type in :c:member:`~PyTypeObject.tp_doc`. ::
1315
1316 "Noddy objects", /* tp_doc */
1317
1318@@ -168,12 +168,12 @@
1319 the module. We'll expand this example later to have more interesting behavior.
1320
1321 For now, all we want to be able to do is to create new :class:`Noddy` objects.
1322-To enable object creation, we have to provide a :attr:`tp_new` implementation.
1323+To enable object creation, we have to provide a :c:member:`~PyTypeObject.tp_new` implementation.
1324 In this case, we can just use the default implementation provided by the API
1325 function :c:func:`PyType_GenericNew`. We'd like to just assign this to the
1326-:attr:`tp_new` slot, but we can't, for portability sake, On some platforms or
1327+:c:member:`~PyTypeObject.tp_new` slot, but we can't, for portability sake, On some platforms or
1328 compilers, we can't statically initialize a structure member with a function
1329-defined in another C module, so, instead, we'll assign the :attr:`tp_new` slot
1330+defined in another C module, so, instead, we'll assign the :c:member:`~PyTypeObject.tp_new` slot
1331 in the module initialization function just before calling
1332 :c:func:`PyType_Ready`::
1333
1334@@ -268,13 +268,13 @@
1335 Py_TYPE(self)->tp_free((PyObject*)self);
1336 }
1337
1338-which is assigned to the :attr:`tp_dealloc` member::
1339+which is assigned to the :c:member:`~PyTypeObject.tp_dealloc` member::
1340
1341 (destructor)Noddy_dealloc, /*tp_dealloc*/
1342
1343 This method decrements the reference counts of the two Python attributes. We use
1344 :c:func:`Py_XDECREF` here because the :attr:`first` and :attr:`last` members
1345-could be *NULL*. It then calls the :attr:`tp_free` member of the object's type
1346+could be *NULL*. It then calls the :c:member:`~PyTypeObject.tp_free` member of the object's type
1347 to free the object's memory. Note that the object's type might not be
1348 :class:`NoddyType`, because the object may be an instance of a subclass.
1349
1350@@ -306,7 +306,7 @@
1351 return (PyObject *)self;
1352 }
1353
1354-and install it in the :attr:`tp_new` member::
1355+and install it in the :c:member:`~PyTypeObject.tp_new` member::
1356
1357 Noddy_new, /* tp_new */
1358
1359@@ -326,17 +326,17 @@
1360 created. New methods always accept positional and keyword arguments, but they
1361 often ignore the arguments, leaving the argument handling to initializer
1362 methods. Note that if the type supports subclassing, the type passed may not be
1363-the type being defined. The new method calls the :attr:`tp_alloc` slot to
1364-allocate memory. We don't fill the :attr:`tp_alloc` slot ourselves. Rather
1365+the type being defined. The new method calls the :c:member:`~PyTypeObject.tp_alloc` slot to
1366+allocate memory. We don't fill the :c:member:`~PyTypeObject.tp_alloc` slot ourselves. Rather
1367 :c:func:`PyType_Ready` fills it for us by inheriting it from our base class,
1368 which is :class:`object` by default. Most types use the default allocation.
1369
1370 .. note::
1371
1372- If you are creating a co-operative :attr:`tp_new` (one that calls a base type's
1373- :attr:`tp_new` or :meth:`__new__`), you must *not* try to determine what method
1374+ If you are creating a co-operative :c:member:`~PyTypeObject.tp_new` (one that calls a base type's
1375+ :c:member:`~PyTypeObject.tp_new` or :meth:`__new__`), you must *not* try to determine what method
1376 to call using method resolution order at runtime. Always statically determine
1377- what type you are going to call, and call its :attr:`tp_new` directly, or via
1378+ what type you are going to call, and call its :c:member:`~PyTypeObject.tp_new` directly, or via
1379 ``type->tp_base->tp_new``. If you do not do this, Python subclasses of your
1380 type that also inherit from other Python-defined classes may not work correctly.
1381 (Specifically, you may not be able to create instances of such subclasses
1382@@ -373,11 +373,11 @@
1383 return 0;
1384 }
1385
1386-by filling the :attr:`tp_init` slot. ::
1387+by filling the :c:member:`~PyTypeObject.tp_init` slot. ::
1388
1389 (initproc)Noddy_init, /* tp_init */
1390
1391-The :attr:`tp_init` slot is exposed in Python as the :meth:`__init__` method. It
1392+The :c:member:`~PyTypeObject.tp_init` slot is exposed in Python as the :meth:`__init__` method. It
1393 is used to initialize an object after it's created. Unlike the new method, we
1394 can't guarantee that the initializer is called. The initializer isn't called
1395 when unpickling objects and it can be overridden. Our initializer accepts
1396@@ -407,7 +407,7 @@
1397 * when we know that deallocation of the object [#]_ will not cause any calls
1398 back into our type's code
1399
1400-* when decrementing a reference count in a :attr:`tp_dealloc` handler when
1401+* when decrementing a reference count in a :c:member:`~PyTypeObject.tp_dealloc` handler when
1402 garbage-collections is not supported [#]_
1403
1404 We want to expose our instance variables as attributes. There are a
1405@@ -423,7 +423,7 @@
1406 {NULL} /* Sentinel */
1407 };
1408
1409-and put the definitions in the :attr:`tp_members` slot::
1410+and put the definitions in the :c:member:`~PyTypeObject.tp_members` slot::
1411
1412 Noddy_members, /* tp_members */
1413
1414@@ -483,7 +483,7 @@
1415 {NULL} /* Sentinel */
1416 };
1417
1418-and assign them to the :attr:`tp_methods` slot::
1419+and assign them to the :c:member:`~PyTypeObject.tp_methods` slot::
1420
1421 Noddy_methods, /* tp_methods */
1422
1423@@ -578,7 +578,7 @@
1424 {NULL} /* Sentinel */
1425 };
1426
1427-and register it in the :attr:`tp_getset` slot::
1428+and register it in the :c:member:`~PyTypeObject.tp_getset` slot::
1429
1430 Noddy_getseters, /* tp_getset */
1431
1432@@ -595,7 +595,7 @@
1433 {NULL} /* Sentinel */
1434 };
1435
1436-We also need to update the :attr:`tp_init` handler to only allow strings [#]_ to
1437+We also need to update the :c:member:`~PyTypeObject.tp_init` handler to only allow strings [#]_ to
1438 be passed::
1439
1440 static int
1441@@ -713,7 +713,7 @@
1442
1443 .. note::
1444
1445- Note that the :attr:`tp_traverse` implementation must name its arguments exactly
1446+ Note that the :c:member:`~PyTypeObject.tp_traverse` implementation must name its arguments exactly
1447 *visit* and *arg* in order to use :c:func:`Py_VISIT`. This is to encourage
1448 uniformity across these boring implementations.
1449
1450@@ -750,7 +750,7 @@
1451 reference count drops to zero, we might cause code to run that calls back into
1452 the object. In addition, because we now support garbage collection, we also
1453 have to worry about code being run that triggers garbage collection. If garbage
1454-collection is run, our :attr:`tp_traverse` handler could get called. We can't
1455+collection is run, our :c:member:`~PyTypeObject.tp_traverse` handler could get called. We can't
1456 take a chance of having :c:func:`Noddy_traverse` called when a member's reference
1457 count has dropped to zero and its value hasn't been set to *NULL*.
1458
1459@@ -770,8 +770,8 @@
1460
1461 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */
1462
1463-That's pretty much it. If we had written custom :attr:`tp_alloc` or
1464-:attr:`tp_free` slots, we'd need to modify them for cyclic-garbage collection.
1465+That's pretty much it. If we had written custom :c:member:`~PyTypeObject.tp_alloc` or
1466+:c:member:`~PyTypeObject.tp_free` slots, we'd need to modify them for cyclic-garbage collection.
1467 Most extensions will use the versions automatically provided.
1468
1469
1470@@ -830,8 +830,8 @@
1471
1472 This pattern is important when writing a type with custom :attr:`new` and
1473 :attr:`dealloc` methods. The :attr:`new` method should not actually create the
1474-memory for the object with :attr:`tp_alloc`, that will be handled by the base
1475-class when calling its :attr:`tp_new`.
1476+memory for the object with :c:member:`~PyTypeObject.tp_alloc`, that will be handled by the base
1477+class when calling its :c:member:`~PyTypeObject.tp_new`.
1478
1479 When filling out the :c:func:`PyTypeObject` for the :class:`Shoddy` type, you see
1480 a slot for :c:func:`tp_base`. Due to cross platform compiler issues, you can't
1481@@ -857,8 +857,8 @@
1482 }
1483
1484 Before calling :c:func:`PyType_Ready`, the type structure must have the
1485-:attr:`tp_base` slot filled in. When we are deriving a new type, it is not
1486-necessary to fill out the :attr:`tp_alloc` slot with :c:func:`PyType_GenericNew`
1487+:c:member:`~PyTypeObject.tp_base` slot filled in. When we are deriving a new type, it is not
1488+necessary to fill out the :c:member:`~PyTypeObject.tp_alloc` slot with :c:func:`PyType_GenericNew`
1489 -- the allocate function from the base type will be inherited.
1490
1491 After that, calling :c:func:`PyType_Ready` and adding the type object to the
1492@@ -901,7 +901,7 @@
1493
1494 These fields tell the runtime how much memory to allocate when new objects of
1495 this type are created. Python has some built-in support for variable length
1496-structures (think: strings, lists) which is where the :attr:`tp_itemsize` field
1497+structures (think: strings, lists) which is where the :c:member:`~PyTypeObject.tp_itemsize` field
1498 comes in. This will be dealt with later. ::
1499
1500 char *tp_doc;
1501@@ -962,10 +962,9 @@
1502
1503 if (self->my_callback != NULL) {
1504 PyObject *err_type, *err_value, *err_traceback;
1505- int have_error = PyErr_Occurred() ? 1 : 0;
1506
1507- if (have_error)
1508- PyErr_Fetch(&err_type, &err_value, &err_traceback);
1509+ /* This saves the current exception state */
1510+ PyErr_Fetch(&err_type, &err_value, &err_traceback);
1511
1512 cbresult = PyObject_CallObject(self->my_callback, NULL);
1513 if (cbresult == NULL)
1514@@ -973,8 +972,8 @@
1515 else
1516 Py_DECREF(cbresult);
1517
1518- if (have_error)
1519- PyErr_Restore(err_type, err_value, err_traceback);
1520+ /* This restores the saved exception state */
1521+ PyErr_Restore(err_type, err_value, err_traceback);
1522
1523 Py_DECREF(self->my_callback);
1524 }
1525@@ -998,7 +997,7 @@
1526 reprfunc tp_repr;
1527 reprfunc tp_str;
1528
1529-The :attr:`tp_repr` handler should return a string object containing a
1530+The :c:member:`~PyTypeObject.tp_repr` handler should return a string object containing a
1531 representation of the instance for which it is called. Here is a simple
1532 example::
1533
1534@@ -1009,15 +1008,15 @@
1535 obj->obj_UnderlyingDatatypePtr->size);
1536 }
1537
1538-If no :attr:`tp_repr` handler is specified, the interpreter will supply a
1539-representation that uses the type's :attr:`tp_name` and a uniquely-identifying
1540+If no :c:member:`~PyTypeObject.tp_repr` handler is specified, the interpreter will supply a
1541+representation that uses the type's :c:member:`~PyTypeObject.tp_name` and a uniquely-identifying
1542 value for the object.
1543
1544-The :attr:`tp_str` handler is to :func:`str` what the :attr:`tp_repr` handler
1545+The :c:member:`~PyTypeObject.tp_str` handler is to :func:`str` what the :c:member:`~PyTypeObject.tp_repr` handler
1546 described above is to :func:`repr`; that is, it is called when Python code calls
1547 :func:`str` on an instance of your object. Its implementation is very similar
1548-to the :attr:`tp_repr` function, but the resulting string is intended for human
1549-consumption. If :attr:`tp_str` is not specified, the :attr:`tp_repr` handler is
1550+to the :c:member:`~PyTypeObject.tp_repr` function, but the resulting string is intended for human
1551+consumption. If :c:member:`~PyTypeObject.tp_str` is not specified, the :c:member:`~PyTypeObject.tp_repr` handler is
1552 used instead.
1553
1554 Here is a simple example::
1555@@ -1082,7 +1081,7 @@
1556 type object. Each descriptor controls access to one attribute of the instance
1557 object. Each of the tables is optional; if all three are *NULL*, instances of
1558 the type will only have attributes that are inherited from their base type, and
1559-should leave the :attr:`tp_getattro` and :attr:`tp_setattro` fields *NULL* as
1560+should leave the :c:member:`~PyTypeObject.tp_getattro` and :c:member:`~PyTypeObject.tp_setattro` fields *NULL* as
1561 well, allowing the base type to handle attributes.
1562
1563 The tables are declared as three fields of the type object::
1564@@ -1091,7 +1090,7 @@
1565 struct PyMemberDef *tp_members;
1566 struct PyGetSetDef *tp_getset;
1567
1568-If :attr:`tp_methods` is not *NULL*, it must refer to an array of
1569+If :c:member:`~PyTypeObject.tp_methods` is not *NULL*, it must refer to an array of
1570 :c:type:`PyMethodDef` structures. Each entry in the table is an instance of this
1571 structure::
1572
1573@@ -1147,13 +1146,13 @@
1574 single: WRITE_RESTRICTED
1575 single: RESTRICTED
1576
1577-An interesting advantage of using the :attr:`tp_members` table to build
1578+An interesting advantage of using the :c:member:`~PyTypeObject.tp_members` table to build
1579 descriptors that are used at runtime is that any attribute defined this way can
1580 have an associated doc string simply by providing the text in the table. An
1581 application can use the introspection API to retrieve the descriptor from the
1582 class object, and get the doc string using its :attr:`__doc__` attribute.
1583
1584-As with the :attr:`tp_methods` table, a sentinel entry with a :attr:`name` value
1585+As with the :c:member:`~PyTypeObject.tp_methods` table, a sentinel entry with a :attr:`name` value
1586 of *NULL* is required.
1587
1588 .. XXX Descriptors need to be explained in more detail somewhere, but not here.
1589@@ -1177,7 +1176,7 @@
1590 called, so that if you do need to extend their functionality, you'll understand
1591 what needs to be done.
1592
1593-The :attr:`tp_getattr` handler is called when the object requires an attribute
1594+The :c:member:`~PyTypeObject.tp_getattr` handler is called when the object requires an attribute
1595 look-up. It is called in the same situations where the :meth:`__getattr__`
1596 method of a class would be called.
1597
1598@@ -1197,11 +1196,11 @@
1599 return NULL;
1600 }
1601
1602-The :attr:`tp_setattr` handler is called when the :meth:`__setattr__` or
1603+The :c:member:`~PyTypeObject.tp_setattr` handler is called when the :meth:`__setattr__` or
1604 :meth:`__delattr__` method of a class instance would be called. When an
1605 attribute should be deleted, the third parameter will be *NULL*. Here is an
1606 example that simply raises an exception; if this were really all you wanted, the
1607-:attr:`tp_setattr` handler should be set to *NULL*. ::
1608+:c:member:`~PyTypeObject.tp_setattr` handler should be set to *NULL*. ::
1609
1610 static int
1611 newdatatype_setattr(newdatatypeobject *obj, char *name, PyObject *v)
1612@@ -1217,7 +1216,7 @@
1613
1614 richcmpfunc tp_richcompare;
1615
1616-The :attr:`tp_richcompare` handler is called when comparisons are needed. It is
1617+The :c:member:`~PyTypeObject.tp_richcompare` handler is called when comparisons are needed. It is
1618 analogous to the :ref:`rich comparison methods <richcmpfuncs>`, like
1619 :meth:`__lt__`, and also called by :c:func:`PyObject_RichCompare` and
1620 :c:func:`PyObject_RichCompareBool`.
1621@@ -1308,7 +1307,7 @@
1622
1623 This function is called when an instance of your data type is "called", for
1624 example, if ``obj1`` is an instance of your data type and the Python script
1625-contains ``obj1('hello')``, the :attr:`tp_call` handler is invoked.
1626+contains ``obj1('hello')``, the :c:member:`~PyTypeObject.tp_call` handler is invoked.
1627
1628 This function takes three arguments:
1629
1630@@ -1395,7 +1394,7 @@
1631 For an object to be weakly referencable, the extension must include a
1632 :c:type:`PyObject\*` field in the instance structure for the use of the weak
1633 reference mechanism; it must be initialized to *NULL* by the object's
1634-constructor. It must also set the :attr:`tp_weaklistoffset` field of the
1635+constructor. It must also set the :c:member:`~PyTypeObject.tp_weaklistoffset` field of the
1636 corresponding type object to the offset of the field. For example, the instance
1637 type is defined with the following structure::
1638
1639@@ -1481,7 +1480,7 @@
1640 .. [#] This is true when we know that the object is a basic type, like a string or a
1641 float.
1642
1643-.. [#] We relied on this in the :attr:`tp_dealloc` handler in this example, because our
1644+.. [#] We relied on this in the :c:member:`~PyTypeObject.tp_dealloc` handler in this example, because our
1645 type doesn't support garbage collection. Even if a type supports garbage
1646 collection, there are calls that can be made to "untrack" the object from
1647 garbage collection, however, these calls are advanced and not covered here.
27diff -r d047928ae3f6 Doc/faq/programming.rst1648diff -r d047928ae3f6 Doc/faq/programming.rst
28--- a/Doc/faq/programming.rst1649--- a/Doc/faq/programming.rst
29+++ b/Doc/faq/programming.rst1650+++ b/Doc/faq/programming.rst
30@@ -1103,6 +1103,92 @@1651@@ -214,9 +214,9 @@
1652 Assume you use a for loop to define a few different lambdas (or even plain
1653 functions), e.g.::
1654
1655- squares = []
1656- for x in range(5):
1657- squares.append(lambda: x**2)
1658+ >>> squares = []
1659+ >>> for x in range(5):
1660+ ... squares.append(lambda: x**2)
1661
1662 This gives you a list that contains 5 lambdas that calculate ``x**2``. You
1663 might expect that, when called, they would return, respectively, ``0``, ``1``,
1664@@ -241,9 +241,9 @@
1665 In order to avoid this, you need to save the values in variables local to the
1666 lambdas, so that they don't rely on the value of the global ``x``::
1667
1668- squares = []
1669- for x in range(5):
1670- squares.append(lambda n=x: n**2)
1671+ >>> squares = []
1672+ >>> for x in range(5):
1673+ ... squares.append(lambda n=x: n**2)
1674
1675 Here, ``n=x`` creates a new variable ``n`` local to the lambda and computed
1676 when the lambda is defined so that it has the same value that ``x`` had at
1677@@ -592,11 +592,11 @@
1678 Since the comma is not an operator, but a separator between expressions the
1679 above is evaluated as if you had entered::
1680
1681- >>> ("a" in "b"), "a"
1682+ ("a" in "b"), "a"
1683
1684 not::
1685
1686- >>> "a" in ("b", "a")
1687+ "a" in ("b", "a")
1688
1689 The same is true of the various assignment operators (``=``, ``+=`` etc). They
1690 are not truly operators but syntactic delimiters in assignment statements.
1691@@ -744,6 +744,7 @@
1692 unicode data, try using a :class:`io.StringIO` object or the :mod:`array`
1693 module::
1694
1695+ >>> import io
1696 >>> s = "Hello, world"
1697 >>> sio = io.StringIO(s)
1698 >>> sio.getvalue()
1699@@ -761,7 +762,7 @@
1700 array('u', 'Hello, world')
1701 >>> a[0] = 'y'
1702 >>> print(a)
1703- array('u', 'yello world')
1704+ array('u', 'yello, world')
1705 >>> a.tounicode()
1706 'yello, world'
1707
1708@@ -1060,7 +1061,7 @@
1709
1710 You probably tried to make a multidimensional array like this::
1711
1712- A = [[None] * 2] * 3
1713+ >>> A = [[None] * 2] * 3
1714
1715 This looks correct if you print it::
1716
1717@@ -1092,7 +1093,7 @@
1718 A = [[None] * w for i in range(h)]
1719
1720 Or, you can use an extension that provides a matrix datatype; `Numeric Python
1721-<http://numpy.scipy.org/>`_ is the best known.
1722+<http://www.numpy.org/>`_ is the best known.
1723
1724
1725 How do I apply a method to a sequence of objects?
1726@@ -1103,6 +1104,92 @@
31 result = [obj.method() for obj in mylist]1727 result = [obj.method() for obj in mylist]
32 1728
33 1729
@@ -120,10 +1816,586 @@
120 Dictionaries1816 Dictionaries
121 ============1817 ============
122 1818
1819@@ -1529,13 +1616,13 @@
1820 (permissions, free space, etc...) to write the compiled module back to the
1821 directory.
1822
1823-Running Python on a top level script is not considered an import and no ``.pyc``
1824-will be created. For example, if you have a top-level module ``abc.py`` that
1825-imports another module ``xyz.py``, when you run abc, ``xyz.pyc`` will be created
1826-since xyz is imported, but no ``abc.pyc`` file will be created since ``abc.py``
1827-isn't being imported.
1828+Running Python on a top level script is not considered an import and no
1829+``.pyc`` will be created. For example, if you have a top-level module
1830+``foo.py`` that imports another module ``xyz.py``, when you run ``foo``,
1831+``xyz.pyc`` will be created since ``xyz`` is imported, but no ``foo.pyc`` file
1832+will be created since ``foo.py`` isn't being imported.
1833
1834-If you need to create abc.pyc -- that is, to create a .pyc file for a module
1835+If you need to create ``foo.pyc`` -- that is, to create a ``.pyc`` file for a module
1836 that is not imported -- you can, using the :mod:`py_compile` and
1837 :mod:`compileall` modules.
1838
1839@@ -1543,9 +1630,9 @@
1840 the ``compile()`` function in that module interactively::
1841
1842 >>> import py_compile
1843- >>> py_compile.compile('abc.py')
1844+ >>> py_compile.compile('foo.py') # doctest: +SKIP
1845
1846-This will write the ``.pyc`` to the same location as ``abc.py`` (or you can
1847+This will write the ``.pyc`` to the same location as ``foo.py`` (or you can
1848 override that with the optional parameter ``cfile``).
1849
1850 You can also automatically compile all files in a directory or directories using
1851diff -r d047928ae3f6 Doc/howto/argparse.rst
1852--- a/Doc/howto/argparse.rst
1853+++ b/Doc/howto/argparse.rst
1854@@ -468,7 +468,7 @@
1855 print(answer)
1856
1857 We have introduced another action, "count",
1858-to count the number of occurences of a specific optional arguments:
1859+to count the number of occurrences of a specific optional arguments:
1860
1861 .. code-block:: sh
1862
1863diff -r d047928ae3f6 Doc/howto/logging-cookbook.rst
1864--- a/Doc/howto/logging-cookbook.rst
1865+++ b/Doc/howto/logging-cookbook.rst
1866@@ -524,69 +524,31 @@
1867 the keys of the dict-like object. If you need a different method, e.g. if you
1868 want to prepend or append the contextual information to the message string,
1869 you just need to subclass :class:`LoggerAdapter` and override :meth:`process`
1870-to do what you need. Here's an example script which uses this class, which
1871-also illustrates what dict-like behaviour is needed from an arbitrary
1872-'dict-like' object for use in the constructor::
1873+to do what you need. Here is a simple example::
1874
1875- import logging
1876+ class CustomAdapter(logging.LoggerAdapter):
1877+ """
1878+ This example adapter expects the passed in dict-like object to have a
1879+ 'connid' key, whose value in brackets is prepended to the log message.
1880+ """
1881+ def process(self, msg, kwargs):
1882+ return '[%s] %s' % (self.extra['connid'], msg), kwargs
1883
1884- class ConnInfo:
1885- """
1886- An example class which shows how an arbitrary class can be used as
1887- the 'extra' context information repository passed to a LoggerAdapter.
1888- """
1889+which you can use like this::
1890
1891- def __getitem__(self, name):
1892- """
1893- To allow this instance to look like a dict.
1894- """
1895- from random import choice
1896- if name == 'ip':
1897- result = choice(['127.0.0.1', '192.168.0.1'])
1898- elif name == 'user':
1899- result = choice(['jim', 'fred', 'sheila'])
1900- else:
1901- result = self.__dict__.get(name, '?')
1902- return result
1903+ logger = logging.getLogger(__name__)
1904+ adapter = CustomAdapter(logger, {'connid': some_conn_id})
1905
1906- def __iter__(self):
1907- """
1908- To allow iteration over keys, which will be merged into
1909- the LogRecord dict before formatting and output.
1910- """
1911- keys = ['ip', 'user']
1912- keys.extend(self.__dict__.keys())
1913- return keys.__iter__()
1914+Then any events that you log to the adapter will have the value of
1915+``some_conn_id`` prepended to the log messages.
1916
1917- if __name__ == '__main__':
1918- from random import choice
1919- levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL)
1920- a1 = logging.LoggerAdapter(logging.getLogger('a.b.c'),
1921- { 'ip' : '123.231.231.123', 'user' : 'sheila' })
1922- logging.basicConfig(level=logging.DEBUG,
1923- format='%(asctime)-15s %(name)-5s %(levelname)-8s IP: %(ip)-15s User: %(user)-8s %(message)s')
1924- a1.debug('A debug message')
1925- a1.info('An info message with %s', 'some parameters')
1926- a2 = logging.LoggerAdapter(logging.getLogger('d.e.f'), ConnInfo())
1927- for x in range(10):
1928- lvl = choice(levels)
1929- lvlname = logging.getLevelName(lvl)
1930- a2.log(lvl, 'A message at %s level with %d %s', lvlname, 2, 'parameters')
1931+Using objects other than dicts to pass contextual information
1932+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1933
1934-When this script is run, the output should look something like this::
1935-
1936- 2008-01-18 14:49:54,023 a.b.c DEBUG IP: 123.231.231.123 User: sheila A debug message
1937- 2008-01-18 14:49:54,023 a.b.c INFO IP: 123.231.231.123 User: sheila An info message with some parameters
1938- 2008-01-18 14:49:54,023 d.e.f CRITICAL IP: 192.168.0.1 User: jim A message at CRITICAL level with 2 parameters
1939- 2008-01-18 14:49:54,033 d.e.f INFO IP: 192.168.0.1 User: jim A message at INFO level with 2 parameters
1940- 2008-01-18 14:49:54,033 d.e.f WARNING IP: 192.168.0.1 User: sheila A message at WARNING level with 2 parameters
1941- 2008-01-18 14:49:54,033 d.e.f ERROR IP: 127.0.0.1 User: fred A message at ERROR level with 2 parameters
1942- 2008-01-18 14:49:54,033 d.e.f ERROR IP: 127.0.0.1 User: sheila A message at ERROR level with 2 parameters
1943- 2008-01-18 14:49:54,033 d.e.f WARNING IP: 192.168.0.1 User: sheila A message at WARNING level with 2 parameters
1944- 2008-01-18 14:49:54,033 d.e.f WARNING IP: 192.168.0.1 User: jim A message at WARNING level with 2 parameters
1945- 2008-01-18 14:49:54,033 d.e.f INFO IP: 192.168.0.1 User: fred A message at INFO level with 2 parameters
1946- 2008-01-18 14:49:54,033 d.e.f WARNING IP: 192.168.0.1 User: sheila A message at WARNING level with 2 parameters
1947- 2008-01-18 14:49:54,033 d.e.f WARNING IP: 127.0.0.1 User: jim A message at WARNING level with 2 parameters
1948+You don't need to pass an actual dict to a :class:`LoggerAdapter` - you could
1949+pass an instance of a class which implements ``__getitem__`` and ``__iter__`` so
1950+that it looks like a dict to logging. This would be useful if you want to
1951+generate values dynamically (whereas the values in a dict would be constant).
1952
1953
1954 .. _filters-contextual:
1955diff -r d047928ae3f6 Doc/howto/sockets.rst
1956--- a/Doc/howto/sockets.rst
1957+++ b/Doc/howto/sockets.rst
1958@@ -19,12 +19,6 @@
1959 Sockets
1960 =======
1961
1962-Sockets are used nearly everywhere, but are one of the most severely
1963-misunderstood technologies around. This is a 10,000 foot overview of sockets.
1964-It's not really a tutorial - you'll still have work to do in getting things
1965-working. It doesn't cover the fine points (and there are a lot of them), but I
1966-hope it will give you enough background to begin using them decently.
1967-
1968 I'm only going to talk about INET (i.e. IPv4) sockets, but they account for at least 99% of
1969 the sockets in use. And I'll only talk about STREAM (i.e. TCP) sockets - unless you really
1970 know what you're doing (in which case this HOWTO isn't for you!), you'll get
1971diff -r d047928ae3f6 Doc/howto/unicode.rst
1972--- a/Doc/howto/unicode.rst
1973+++ b/Doc/howto/unicode.rst
1974@@ -28,15 +28,15 @@
1975 as 'naïve' and 'café', and some publications have house styles which require
1976 spellings such as 'coöperate'.)
1977
1978-For a while people just wrote programs that didn't display accents. I remember
1979-looking at Apple ][ BASIC programs, published in French-language publications in
1980-the mid-1980s, that had lines like these::
1981+For a while people just wrote programs that didn't display accents.
1982+In the mid-1980s an Apple II BASIC program written by a French speaker
1983+might have lines like these::
1984
1985 PRINT "FICHIER EST COMPLETE."
1986 PRINT "CARACTERE NON ACCEPTE."
1987
1988-Those messages should contain accents, and they just look wrong to someone who
1989-can read French.
1990+Those messages should contain accents (completé, caractère, accepté),
1991+and they just look wrong to someone who can read French.
1992
1993 In the 1980s, almost all personal computers were 8-bit, meaning that bytes could
1994 hold values ranging from 0 to 255. ASCII codes only went up to 127, so some
1995@@ -69,9 +69,12 @@
1996 originally separate efforts, but the specifications were merged with the 1.1
1997 revision of Unicode.
1998
1999-(This discussion of Unicode's history is highly simplified. I don't think the
2000-average Python programmer needs to worry about the historical details; consult
2001-the Unicode consortium site listed in the References for more information.)
2002+(This discussion of Unicode's history is highly simplified. The
2003+precise historical details aren't necessary for understanding how to
2004+use Unicode effectively, but if you're curious, consult the Unicode
2005+consortium site listed in the References or
2006+the `Wikipedia entry for Unicode <http://en.wikipedia.org/wiki/Unicode#History>`_
2007+for more information.)
2008
2009
2010 Definitions
2011@@ -216,10 +219,8 @@
2012
2013 Another `good introductory article <http://www.joelonsoftware.com/articles/Unicode.html>`_
2014 was written by Joel Spolsky.
2015-If this introduction didn't make things clear to you, you should try reading this
2016-alternate article before continuing.
2017-
2018-.. Jason Orendorff XXX http://www.jorendorff.com/articles/unicode/ is broken
2019+If this introduction didn't make things clear to you, you should try
2020+reading this alternate article before continuing.
2021
2022 Wikipedia entries are often helpful; see the entries for "`character encoding
2023 <http://en.wikipedia.org/wiki/Character_encoding>`_" and `UTF-8
2024@@ -239,8 +240,31 @@
2025 characters, meaning any string created using ``"unicode rocks!"``, ``'unicode
2026 rocks!'``, or the triple-quoted string syntax is stored as Unicode.
2027
2028-To insert a non-ASCII Unicode character, e.g., any letters with
2029-accents, one can use escape sequences in their string literals as such::
2030+The default encoding for Python source code is UTF-8, so you can simply
2031+include a Unicode character in a string literal::
2032+
2033+ try:
2034+ with open('/tmp/input.txt', 'r') as f:
2035+ ...
2036+ except IOError:
2037+ # 'File not found' error message.
2038+ print("Fichier non trouvé")
2039+
2040+You can use a different encoding from UTF-8 by putting a specially-formatted
2041+comment as the first or second line of the source code::
2042+
2043+ # -*- coding: <encoding name> -*-
2044+
2045+Side note: Python 3 also supports using Unicode characters in identifiers::
2046+
2047+ répertoire = "/tmp/records.log"
2048+ with open(répertoire, "w") as f:
2049+ f.write("test\n")
2050+
2051+If you can't enter a particular character in your editor or want to
2052+keep the source code ASCII-only for some reason, you can also use
2053+escape sequences in string literals. (Depending on your system,
2054+you may see the actual capital-delta glyph instead of a \u escape.) ::
2055
2056 >>> "\N{GREEK CAPITAL LETTER DELTA}" # Using the character name
2057 '\u0394'
2058@@ -251,7 +275,7 @@
2059
2060 In addition, one can create a string using the :func:`~bytes.decode` method of
2061 :class:`bytes`. This method takes an *encoding* argument, such as ``UTF-8``,
2062-and optionally, an *errors* argument.
2063+and optionally an *errors* argument.
2064
2065 The *errors* argument specifies the response when the input string can't be
2066 converted according to the encoding's rules. Legal values for this argument are
2067@@ -295,11 +319,15 @@
2068
2069 The opposite method of :meth:`bytes.decode` is :meth:`str.encode`,
2070 which returns a :class:`bytes` representation of the Unicode string, encoded in the
2071-requested *encoding*. The *errors* parameter is the same as the parameter of
2072-the :meth:`~bytes.decode` method, with one additional possibility; as well as
2073-``'strict'``, ``'ignore'``, and ``'replace'`` (which in this case inserts a
2074-question mark instead of the unencodable character), you can also pass
2075-``'xmlcharrefreplace'`` which uses XML's character references.
2076+requested *encoding*.
2077+
2078+The *errors* parameter is the same as the parameter of the
2079+:meth:`~bytes.decode` method but supports a few more possible handlers. As well as
2080+``'strict'``, ``'ignore'``, and ``'replace'`` (which in this case
2081+inserts a question mark instead of the unencodable character), there is
2082+also ``'xmlcharrefreplace'`` (inserts an XML character reference) and
2083+``backslashreplace`` (inserts a ``\uNNNN`` escape sequence).
2084+
2085 The following example shows the different results::
2086
2087 >>> u = chr(40960) + 'abcd' + chr(1972)
2088@@ -316,16 +344,15 @@
2089 b'?abcd?'
2090 >>> u.encode('ascii', 'xmlcharrefreplace')
2091 b'&#40960;abcd&#1972;'
2092+ >>> u.encode('ascii', 'backslashreplace')
2093+ b'\\ua000abcd\\u07b4'
2094
2095-.. XXX mention the surrogate* error handlers
2096-
2097-The low-level routines for registering and accessing the available encodings are
2098-found in the :mod:`codecs` module. However, the encoding and decoding functions
2099-returned by this module are usually more low-level than is comfortable, so I'm
2100-not going to describe the :mod:`codecs` module here. If you need to implement a
2101-completely new encoding, you'll need to learn about the :mod:`codecs` module
2102-interfaces, but implementing encodings is a specialized task that also won't be
2103-covered here. Consult the Python documentation to learn more about this module.
2104+The low-level routines for registering and accessing the available
2105+encodings are found in the :mod:`codecs` module. Implementing new
2106+encodings also requires understanding the :mod:`codecs` module.
2107+However, the encoding and decoding functions returned by this module
2108+are usually more low-level than is comfortable, and writing new encodings
2109+is a specialized task, so the module won't be covered in this HOWTO.
2110
2111
2112 Unicode Literals in Python Source Code
2113@@ -415,12 +442,50 @@
2114 from the above output, ``'Ll'`` means 'Letter, lowercase', ``'No'`` means
2115 "Number, other", ``'Mn'`` is "Mark, nonspacing", and ``'So'`` is "Symbol,
2116 other". See
2117-<http://www.unicode.org/reports/tr44/#General_Category_Values> for a
2118+`the General Category Values section of the Unicode Character Database documentation <http://www.unicode.org/reports/tr44/#General_Category_Values>`_ for a
2119 list of category codes.
2120
2121+
2122+Unicode Regular Expressions
2123+---------------------------
2124+
2125+The regular expressions supported by the :mod:`re` module can be provided
2126+either as bytes or strings. Some of the special character sequences such as
2127+``\d`` and ``\w`` have different meanings depending on whether
2128+the pattern is supplied as bytes or a string. For example,
2129+``\d`` will match the characters ``[0-9]`` in bytes but
2130+in strings will match any character that's in the ``'Nd'`` category.
2131+
2132+The string in this example has the number 57 written in both Thai and
2133+Arabic numerals::
2134+
2135+ import re
2136+ p = re.compile('\d+')
2137+
2138+ s = "Over \u0e55\u0e57 57 flavours"
2139+ m = p.search(s)
2140+ print(repr(m.group()))
2141+
2142+When executed, ``\d+`` will match the Thai numerals and print them
2143+out. If you supply the :const:`re.ASCII` flag to
2144+:func:`~re.compile`, ``\d+`` will match the substring "57" instead.
2145+
2146+Similarly, ``\w`` matches a wide variety of Unicode characters but
2147+only ``[a-zA-Z0-9_]`` in bytes or if :const:`re.ASCII` is supplied,
2148+and ``\s`` will match either Unicode whitespace characters or
2149+``[ \t\n\r\f\v]``.
2150+
2151+
2152 References
2153 ----------
2154
2155+.. comment should these be mentioned earlier, e.g. at the start of the "introduction to Unicode" first section?
2156+
2157+Some good alternative discussions of Python's Unicode support are:
2158+
2159+* `Processing Text Files in Python 3 <http://python-notes.curiousefficiency.org/en/latest/python3/text_file_processing.html>`_, by Nick Coghlan.
2160+* `Pragmatic Unicode <http://nedbatchelder.com/text/unipain.html>`_, a PyCon 2012 presentation by Ned Batchelder.
2161+
2162 The :class:`str` type is described in the Python library reference at
2163 :ref:`textseq`.
2164
2165@@ -428,12 +493,10 @@
2166
2167 The documentation for the :mod:`codecs` module.
2168
2169-Marc-André Lemburg gave a presentation at EuroPython 2002 titled "Python and
2170-Unicode". A PDF version of his slides is available at
2171-<http://downloads.egenix.com/python/Unicode-EPC2002-Talk.pdf>, and is an
2172-excellent overview of the design of Python's Unicode features (based on Python
2173-2, where the Unicode string type is called ``unicode`` and literals start with
2174-``u``).
2175+Marc-André Lemburg gave `a presentation titled "Python and Unicode" (PDF slides) <http://downloads.egenix.com/python/Unicode-EPC2002-Talk.pdf>`_ at
2176+EuroPython 2002. The slides are an excellent overview of the design
2177+of Python 2's Unicode features (where the Unicode string type is
2178+called ``unicode`` and literals start with ``u``).
2179
2180
2181 Reading and Writing Unicode Data
2182@@ -512,7 +575,7 @@
2183 Windows, Python uses the name "mbcs" to refer to whatever the currently
2184 configured encoding is. On Unix systems, there will only be a filesystem
2185 encoding if you've set the ``LANG`` or ``LC_CTYPE`` environment variables; if
2186-you haven't, the default encoding is ASCII.
2187+you haven't, the default encoding is UTF-8.
2188
2189 The :func:`sys.getfilesystemencoding` function returns the encoding to use on
2190 your current system, in case you want to do the encoding manually, but there's
2191@@ -527,13 +590,13 @@
2192 Functions in the :mod:`os` module such as :func:`os.stat` will also accept Unicode
2193 filenames.
2194
2195-Function :func:`os.listdir`, which returns filenames, raises an issue: should it return
2196+The :func:`os.listdir` function returns filenames and raises an issue: should it return
2197 the Unicode version of filenames, or should it return bytes containing
2198 the encoded versions? :func:`os.listdir` will do both, depending on whether you
2199 provided the directory path as bytes or a Unicode string. If you pass a
2200 Unicode string as the path, filenames will be decoded using the filesystem's
2201 encoding and a list of Unicode strings will be returned, while passing a byte
2202-path will return the bytes versions of the filenames. For example,
2203+path will return the filenames as bytes. For example,
2204 assuming the default filesystem encoding is UTF-8, running the following
2205 program::
2206
2207@@ -548,13 +611,13 @@
2208 will produce the following output::
2209
2210 amk:~$ python t.py
2211- [b'.svn', b'filename\xe4\x94\x80abc', ...]
2212- ['.svn', 'filename\u4500abc', ...]
2213+ [b'filename\xe4\x94\x80abc', ...]
2214+ ['filename\u4500abc', ...]
2215
2216 The first list contains UTF-8-encoded filenames, and the second list contains
2217 the Unicode versions.
2218
2219-Note that in most occasions, the Unicode APIs should be used. The bytes APIs
2220+Note that on most occasions, the Unicode APIs should be used. The bytes APIs
2221 should only be used on systems where undecodable file names can be present,
2222 i.e. Unix systems.
2223
2224@@ -585,65 +648,69 @@
2225 clever way to hide malicious text in the encoded bytestream.
2226
2227
2228+Converting Between File Encodings
2229+'''''''''''''''''''''''''''''''''
2230+
2231+The :class:`~codecs.StreamRecoder` class can transparently convert between
2232+encodings, taking a stream that returns data in encoding #1
2233+and behaving like a stream returning data in encoding #2.
2234+
2235+For example, if you have an input file *f* that's in Latin-1, you
2236+can wrap it with a :class:`StreamRecoder` to return bytes encoded in UTF-8::
2237+
2238+ new_f = codecs.StreamRecoder(f,
2239+ # en/decoder: used by read() to encode its results and
2240+ # by write() to decode its input.
2241+ codecs.getencoder('utf-8'), codecs.getdecoder('utf-8'),
2242+
2243+ # reader/writer: used to read and write to the stream.
2244+ codecs.getreader('latin-1'), codecs.getwriter('latin-1') )
2245+
2246+
2247+Files in an Unknown Encoding
2248+''''''''''''''''''''''''''''
2249+
2250+What can you do if you need to make a change to a file, but don't know
2251+the file's encoding? If you know the encoding is ASCII-compatible and
2252+only want to examine or modify the ASCII parts, you can open the file
2253+with the ``surrogateescape`` error handler::
2254+
2255+ with open(fname, 'r', encoding="ascii", errors="surrogateescape") as f:
2256+ data = f.read()
2257+
2258+ # make changes to the string 'data'
2259+
2260+ with open(fname + '.new', 'w',
2261+ encoding="ascii", errors="surrogateescape") as f:
2262+ f.write(data)
2263+
2264+The ``surrogateescape`` error handler will decode any non-ASCII bytes
2265+as code points in the Unicode Private Use Area ranging from U+DC80 to
2266+U+DCFF. These private code points will then be turned back into the
2267+same bytes when the ``surrogateescape`` error handler is used when
2268+encoding the data and writing it back out.
2269+
2270+
2271 References
2272 ----------
2273
2274-The PDF slides for Marc-André Lemburg's presentation "Writing Unicode-aware
2275-Applications in Python" are available at
2276-<http://downloads.egenix.com/python/LSM2005-Developing-Unicode-aware-applications-in-Python.pdf>
2277-and discuss questions of character encodings as well as how to internationalize
2278+One section of `Mastering Python 3 Input/Output <http://pyvideo.org/video/289/pycon-2010--mastering-python-3-i-o>`_, a PyCon 2010 talk by David Beazley, discusses text processing and binary data handling.
2279+
2280+The `PDF slides for Marc-André Lemburg's presentation "Writing Unicode-aware Applications in Python" <http://downloads.egenix.com/python/LSM2005-Developing-Unicode-aware-applications-in-Python.pdf>`_
2281+discuss questions of character encodings as well as how to internationalize
2282 and localize an application. These slides cover Python 2.x only.
2283
2284+`The Guts of Unicode in Python <http://pyvideo.org/video/1768/the-guts-of-unicode-in-python>`_ is a PyCon 2013 talk by Benjamin Peterson that discusses the internal Unicode representation in Python 3.3.
2285+
2286
2287 Acknowledgements
2288 ================
2289
2290-Thanks to the following people who have noted errors or offered suggestions on
2291-this article: Nicholas Bastin, Marius Gedminas, Kent Johnson, Ken Krugler,
2292-Marc-André Lemburg, Martin von Löwis, Chad Whitacre.
2293+The initial draft of this document was written by Andrew Kuchling.
2294+It has since been revised further by Alexander Belopolsky, Georg Brandl,
2295+Andrew Kuchling, and Ezio Melotti.
2296
2297-.. comment
2298- Revision History
2299-
2300- Version 1.0: posted August 5 2005.
2301-
2302- Version 1.01: posted August 7 2005. Corrects factual and markup errors; adds
2303- several links.
2304-
2305- Version 1.02: posted August 16 2005. Corrects factual errors.
2306-
2307- Version 1.1: Feb-Nov 2008. Updates the document with respect to Python 3 changes.
2308-
2309- Version 1.11: posted June 20 2010. Notes that Python 3.x is not covered,
2310- and that the HOWTO only covers 2.x.
2311-
2312-.. comment Describe Python 3.x support (new section? new document?)
2313-.. comment Describe use of codecs.StreamRecoder and StreamReaderWriter
2314-
2315-.. comment
2316- Original outline:
2317-
2318- - [ ] Unicode introduction
2319- - [ ] ASCII
2320- - [ ] Terms
2321- - [ ] Character
2322- - [ ] Code point
2323- - [ ] Encodings
2324- - [ ] Common encodings: ASCII, Latin-1, UTF-8
2325- - [ ] Unicode Python type
2326- - [ ] Writing unicode literals
2327- - [ ] Obscurity: -U switch
2328- - [ ] Built-ins
2329- - [ ] unichr()
2330- - [ ] ord()
2331- - [ ] unicode() constructor
2332- - [ ] Unicode type
2333- - [ ] encode(), decode() methods
2334- - [ ] Unicodedata module for character properties
2335- - [ ] I/O
2336- - [ ] Reading/writing Unicode data into files
2337- - [ ] Byte-order marks
2338- - [ ] Unicode filenames
2339- - [ ] Writing Unicode programs
2340- - [ ] Do everything in Unicode
2341- - [ ] Declaring source code encodings (PEP 263)
2342+Thanks to the following people who have noted errors or offered
2343+suggestions on this article: Éric Araujo, Nicholas Bastin, Nick
2344+Coghlan, Marius Gedminas, Kent Johnson, Ken Krugler, Marc-André
2345+Lemburg, Martin von Löwis, Terry J. Reedy, Chad Whitacre.
2346diff -r d047928ae3f6 Doc/library/array.rst
2347--- a/Doc/library/array.rst
2348+++ b/Doc/library/array.rst
2349@@ -271,9 +271,7 @@
2350 Packing and unpacking of External Data Representation (XDR) data as used in some
2351 remote procedure call systems.
2352
2353- `The Numerical Python Manual <http://numpy.sourceforge.net/numdoc/HTML/numdoc.htm>`_
2354+ `The Numerical Python Documentation <http://docs.scipy.org/doc/>`_
2355 The Numeric Python extension (NumPy) defines another array type; see
2356- http://numpy.sourceforge.net/ for further information about Numerical Python.
2357- (A PDF version of the NumPy manual is available at
2358- http://numpy.sourceforge.net/numdoc/numdoc.pdf).
2359+ http://www.numpy.org/ for further information about Numerical Python.
2360
2361diff -r d047928ae3f6 Doc/library/base64.rst
2362--- a/Doc/library/base64.rst
2363+++ b/Doc/library/base64.rst
2364@@ -103,7 +103,7 @@
2365 digit 0 is always mapped to the letter O). For security purposes the default is
2366 ``None``, so that 0 and 1 are not allowed in the input.
2367
2368- The decoded byte string is returned. A :exc:`TypeError` is raised if *s* were
2369+ The decoded byte string is returned. A :exc:`binascii.Error` is raised if *s* were
2370 incorrectly padded or if there are non-alphabet characters present in the
2371 string.
2372
123diff -r d047928ae3f6 Doc/library/codecs.rst2373diff -r d047928ae3f6 Doc/library/codecs.rst
124--- a/Doc/library/codecs.rst2374--- a/Doc/library/codecs.rst
125+++ b/Doc/library/codecs.rst2375+++ b/Doc/library/codecs.rst
126@@ -1142,7 +1142,19 @@2376@@ -78,7 +78,11 @@
2377 reference (for encoding only)
2378 * ``'backslashreplace'``: replace with backslashed escape sequences (for
2379 encoding only)
2380- * ``'surrogateescape'``: replace with surrogate U+DCxx, see :pep:`383`
2381+ * ``'surrogateescape'``: on decoding, replace with code points in the Unicode
2382+ Private Use Area ranging from U+DC80 to U+DCFF. These private code
2383+ points will then be turned back into the same bytes when the
2384+ ``surrogateescape`` error handler is used when encoding the data.
2385+ (See :pep:`383` for more.)
2386
2387 as well as any other error handling name defined via :func:`register_error`.
2388
2389@@ -690,7 +694,7 @@
2390 Read one line from the input stream and return the decoded data.
2391
2392 *size*, if given, is passed as size argument to the stream's
2393- :meth:`readline` method.
2394+ :meth:`read` method.
2395
2396 If *keepends* is false line-endings will be stripped from the lines
2397 returned.
2398@@ -1142,7 +1146,19 @@
127 | utf_8_sig | | all languages |2399 | utf_8_sig | | all languages |
128 +-----------------+--------------------------------+--------------------------------+2400 +-----------------+--------------------------------+--------------------------------+
129 2401
@@ -144,7 +2416,7 @@
144 2416
145 .. tabularcolumns:: |l|p{0.3\linewidth}|p{0.3\linewidth}|2417 .. tabularcolumns:: |l|p{0.3\linewidth}|p{0.3\linewidth}|
146 2418
147@@ -1186,37 +1198,45 @@2419@@ -1186,37 +1202,45 @@
148 | | | .. deprecated:: 3.3 |2420 | | | .. deprecated:: 3.3 |
149 +--------------------+---------+---------------------------+2421 +--------------------+---------+---------------------------+
150 2422
@@ -218,7 +2490,7 @@
218 2490
219 .. tabularcolumns:: |l|L|2491 .. tabularcolumns:: |l|L|
220 2492
221@@ -1228,7 +1248,7 @@2493@@ -1228,7 +1252,7 @@
222 +--------------------+---------------------------+2494 +--------------------+---------------------------+
223 2495
224 .. versionadded:: 3.22496 .. versionadded:: 3.2
@@ -227,6 +2499,18 @@
227 2499
228 2500
229 :mod:`encodings.idna` --- Internationalized Domain Names in Applications2501 :mod:`encodings.idna` --- Internationalized Domain Names in Applications
2502diff -r d047928ae3f6 Doc/library/configparser.rst
2503--- a/Doc/library/configparser.rst
2504+++ b/Doc/library/configparser.rst
2505@@ -539,7 +539,7 @@
2506 * *delimiters*, default value: ``('=', ':')``
2507
2508 Delimiters are substrings that delimit keys from values within a section. The
2509- first occurence of a delimiting substring on a line is considered a delimiter.
2510+ first occurrence of a delimiting substring on a line is considered a delimiter.
2511 This means values (but not keys) can contain the delimiters.
2512
2513 See also the *space_around_delimiters* argument to
230diff -r d047928ae3f6 Doc/library/ctypes.rst2514diff -r d047928ae3f6 Doc/library/ctypes.rst
231--- a/Doc/library/ctypes.rst2515--- a/Doc/library/ctypes.rst
232+++ b/Doc/library/ctypes.rst2516+++ b/Doc/library/ctypes.rst
@@ -239,6 +2523,305 @@
239 module instead of using :func:`find_library` to locate the library at runtime.2523 module instead of using :func:`find_library` to locate the library at runtime.
240 2524
241 2525
2526diff -r d047928ae3f6 Doc/library/difflib.rst
2527--- a/Doc/library/difflib.rst
2528+++ b/Doc/library/difflib.rst
2529@@ -752,7 +752,7 @@
2530 # we're passing these as arguments to the diff function
2531 fromdate = time.ctime(os.stat(fromfile).st_mtime)
2532 todate = time.ctime(os.stat(tofile).st_mtime)
2533- with open(fromlines) as fromf, open(tofile) as tof:
2534+ with open(fromfile) as fromf, open(tofile) as tof:
2535 fromlines, tolines = list(fromf), list(tof)
2536
2537 if options.u:
2538diff -r d047928ae3f6 Doc/library/email.iterators.rst
2539--- a/Doc/library/email.iterators.rst
2540+++ b/Doc/library/email.iterators.rst
2541@@ -33,14 +33,22 @@
2542 Thus, by default :func:`typed_subpart_iterator` returns each subpart that has a
2543 MIME type of :mimetype:`text/\*`.
2544
2545+
2546 The following function has been added as a useful debugging tool. It should
2547 *not* be considered part of the supported public interface for the package.
2548
2549-
2550 .. function:: _structure(msg, fp=None, level=0, include_default=False)
2551
2552 Prints an indented representation of the content types of the message object
2553- structure. For example::
2554+ structure. For example:
2555+
2556+ .. testsetup::
2557+
2558+ >>> import email
2559+ >>> from email.iterators import _structure
2560+ >>> somefile = open('Lib/test/test_email/data/msg_02.txt')
2561+
2562+ .. doctest::
2563
2564 >>> msg = email.message_from_file(somefile)
2565 >>> _structure(msg)
2566@@ -60,6 +68,10 @@
2567 text/plain
2568 text/plain
2569
2570+ .. testsetup::
2571+
2572+ >>> somefile.close()
2573+
2574 Optional *fp* is a file-like object to print the output to. It must be
2575 suitable for Python's :func:`print` function. *level* is used internally.
2576 *include_default*, if true, prints the default type as well.
2577diff -r d047928ae3f6 Doc/library/email.message.rst
2578--- a/Doc/library/email.message.rst
2579+++ b/Doc/library/email.message.rst
2580@@ -513,16 +513,25 @@
2581 iterator in a ``for`` loop; each iteration returns the next subpart.
2582
2583 Here's an example that prints the MIME type of every part of a multipart
2584- message structure::
2585+ message structure:
2586
2587- >>> for part in msg.walk():
2588- ... print(part.get_content_type())
2589- multipart/report
2590- text/plain
2591- message/delivery-status
2592- text/plain
2593- text/plain
2594- message/rfc822
2595+ .. testsetup::
2596+
2597+ >>> from email import message_from_binary_file
2598+ >>> with open('Lib/test/test_email/data/msg_16.txt', 'rb') as f:
2599+ ... msg = message_from_binary_file(f)
2600+
2601+ .. doctest::
2602+
2603+ >>> for part in msg.walk():
2604+ ... print(part.get_content_type())
2605+ multipart/report
2606+ text/plain
2607+ message/delivery-status
2608+ text/plain
2609+ text/plain
2610+ message/rfc822
2611+ text/plain
2612
2613 :class:`Message` objects can also optionally contain two instance attributes,
2614 which can be used when generating the plain text of a MIME message.
2615diff -r d047928ae3f6 Doc/library/email.policy.rst
2616--- a/Doc/library/email.policy.rst
2617+++ b/Doc/library/email.policy.rst
2618@@ -56,19 +56,42 @@
2619 attributes values changed.
2620
2621 As an example, the following code could be used to read an email message from a
2622-file on disk and pass it to the system ``sendmail`` program on a Unix system::
2623+file on disk and pass it to the system ``sendmail`` program on a Unix system:
2624
2625- >>> from email import msg_from_binary_file
2626+.. testsetup::
2627+
2628+ >>> from unittest import mock
2629+ >>> mocker = mock.patch('subprocess.Popen')
2630+ >>> m = mocker.start()
2631+ >>> proc = mock.MagicMock()
2632+ >>> m.return_value = proc
2633+ >>> proc.stdin.close.return_value = None
2634+ >>> mymsg = open('mymsg.txt', 'w')
2635+ >>> mymsg.write('To: abc@xyz.com\n\n')
2636+ 17
2637+ >>> mymsg.flush()
2638+
2639+.. doctest::
2640+
2641+ >>> from email import message_from_binary_file
2642 >>> from email.generator import BytesGenerator
2643+ >>> from email import policy
2644 >>> from subprocess import Popen, PIPE
2645- >>> with open('mymsg.txt', 'b') as f:
2646- ... msg = msg_from_binary_file(f)
2647- >>> p = Popen(['sendmail', msg['To'][0].address], stdin=PIPE)
2648+ >>> with open('mymsg.txt', 'rb') as f:
2649+ ... msg = message_from_binary_file(f, policy=policy.default)
2650+ >>> p = Popen(['sendmail', msg['To'].addresses[0]], stdin=PIPE)
2651 >>> g = BytesGenerator(p.stdin, policy=msg.policy.clone(linesep='\r\n'))
2652 >>> g.flatten(msg)
2653 >>> p.stdin.close()
2654 >>> rc = p.wait()
2655
2656+.. testsetup::
2657+
2658+ >>> mymsg.close()
2659+ >>> mocker.stop()
2660+ >>> import os
2661+ >>> os.remove('mymsg.txt')
2662+
2663 Here we are telling :class:`~email.generator.BytesGenerator` to use the RFC
2664 correct line separator characters when creating the binary string to feed into
2665 ``sendmail's`` ``stdin``, where the default policy would use ``\n`` line
2666@@ -82,22 +105,22 @@
2667
2668 >>> import os
2669 >>> with open('converted.txt', 'wb') as f:
2670- ... f.write(msg.as_string(policy=msg.policy.clone(linesep=os.linesep))
2671+ ... f.write(msg.as_string(policy=msg.policy.clone(linesep=os.linesep)))
2672
2673 Policy objects can also be combined using the addition operator, producing a
2674 policy object whose settings are a combination of the non-default values of the
2675 summed objects::
2676
2677- >>> compat_SMTP = email.policy.clone(linesep='\r\n')
2678- >>> compat_strict = email.policy.clone(raise_on_defect=True)
2679+ >>> compat_SMTP = policy.compat32.clone(linesep='\r\n')
2680+ >>> compat_strict = policy.compat32.clone(raise_on_defect=True)
2681 >>> compat_strict_SMTP = compat_SMTP + compat_strict
2682
2683 This operation is not commutative; that is, the order in which the objects are
2684 added matters. To illustrate::
2685
2686- >>> policy100 = compat32.clone(max_line_length=100)
2687- >>> policy80 = compat32.clone(max_line_length=80)
2688- >>> apolicy = policy100 + Policy80
2689+ >>> policy100 = policy.compat32.clone(max_line_length=100)
2690+ >>> policy80 = policy.compat32.clone(max_line_length=80)
2691+ >>> apolicy = policy100 + policy80
2692 >>> apolicy.max_line_length
2693 80
2694 >>> apolicy = policy80 + policy100
2695diff -r d047928ae3f6 Doc/library/functions.rst
2696--- a/Doc/library/functions.rst
2697+++ b/Doc/library/functions.rst
2698@@ -583,11 +583,16 @@
2699
2700 .. function:: hash(object)
2701
2702- Return the hash value of the object (if it has one). Hash values are integers.
2703- They are used to quickly compare dictionary keys during a dictionary lookup.
2704- Numeric values that compare equal have the same hash value (even if they are of
2705- different types, as is the case for 1 and 1.0).
2706+ Return the hash value of the object (if it has one). Hash values are
2707+ integers. They are used to quickly compare dictionary keys during a
2708+ dictionary lookup. Numeric values that compare equal have the same hash
2709+ value (even if they are of different types, as is the case for 1 and 1.0).
2710
2711+ .. note::
2712+
2713+ For object's with custom :meth:`__hash__` methods, note that :func:`hash`
2714+ truncates the return value based on the bit width of the host machine.
2715+ See :meth:`__hash__` for details.
2716
2717 .. function:: help([object])
2718
2719@@ -895,16 +900,36 @@
2720 the list of supported encodings.
2721
2722 *errors* is an optional string that specifies how encoding and decoding
2723- errors are to be handled--this cannot be used in binary mode. Pass
2724- ``'strict'`` to raise a :exc:`ValueError` exception if there is an encoding
2725- error (the default of ``None`` has the same effect), or pass ``'ignore'`` to
2726- ignore errors. (Note that ignoring encoding errors can lead to data loss.)
2727- ``'replace'`` causes a replacement marker (such as ``'?'``) to be inserted
2728- where there is malformed data. When writing, ``'xmlcharrefreplace'``
2729- (replace with the appropriate XML character reference) or
2730- ``'backslashreplace'`` (replace with backslashed escape sequences) can be
2731- used. Any other error handling name that has been registered with
2732- :func:`codecs.register_error` is also valid.
2733+ errors are to be handled--this cannot be used in binary mode.
2734+ A variety of standard error handlers are available, though any
2735+ error handling name that has been registered with
2736+ :func:`codecs.register_error` is also valid. The standard names
2737+ are:
2738+
2739+ * ``'strict'`` to raise a :exc:`ValueError` exception if there is
2740+ an encoding error. The default value of ``None`` has the same
2741+ effect.
2742+
2743+ * ``'ignore'`` ignores errors. Note that ignoring encoding errors
2744+ can lead to data loss.
2745+
2746+ * ``'replace'`` causes a replacement marker (such as ``'?'``) to be inserted
2747+ where there is malformed data.
2748+
2749+ * ``'surrogateescape'`` will represent any incorrect bytes as code
2750+ points in the Unicode Private Use Area ranging from U+DC80 to
2751+ U+DCFF. These private code points will then be turned back into
2752+ the same bytes when the ``surrogateescape`` error handler is used
2753+ when writing data. This is useful for processing files in an
2754+ unknown encoding.
2755+
2756+ * ``'xmlcharrefreplace'`` is only supported when writing to a file.
2757+ Characters not supported by the encoding are replaced with the
2758+ appropriate XML character reference ``&#nnn;``.
2759+
2760+ * ``'backslashreplace'`` (also only supported when writing)
2761+ replaces unsupported characters with Python's backslashed escape
2762+ sequences.
2763
2764 .. index::
2765 single: universal newlines; open() built-in function
2766@@ -1355,14 +1380,18 @@
2767
2768 .. function:: vars([object])
2769
2770- Without an argument, act like :func:`locals`.
2771+ Return the :attr:`__dict__` attribute for a module, class, instance,
2772+ or any other object with a :attr:`__dict__` attribute.
2773
2774- With a module, class or class instance object as argument (or anything else that
2775- has a :attr:`__dict__` attribute), return that attribute.
2776+ Objects such as modules and instances have an updateable :attr:`__dict__`
2777+ attribute; however, other objects may have write restrictions on their
2778+ :attr:`__dict__` attributes (for example, classes use a
2779+ dictproxy to prevent direct dictionary updates).
2780
2781- .. note::
2782- The returned dictionary should not be modified:
2783- the effects on the corresponding symbol table are undefined. [#]_
2784+ Without an argument, :func:`vars` acts like :func:`locals`. Note, the
2785+ locals dictionary is only useful for reads since updates to the locals
2786+ dictionary are ignored.
2787+
2788
2789 .. function:: zip(*iterables)
2790
2791@@ -1481,7 +1510,3 @@
2792 .. [#] Note that the parser only accepts the Unix-style end of line convention.
2793 If you are reading the code from a file, make sure to use newline conversion
2794 mode to convert Windows or Mac-style newlines.
2795-
2796-.. [#] In the current implementation, local variable bindings cannot normally be
2797- affected this way, but variables retrieved from other scopes (such as modules)
2798- can be. This may change.
2799diff -r d047928ae3f6 Doc/library/gc.rst
2800--- a/Doc/library/gc.rst
2801+++ b/Doc/library/gc.rst
2802@@ -121,8 +121,8 @@
2803
2804 Return a list of objects directly referred to by any of the arguments. The
2805 referents returned are those objects visited by the arguments' C-level
2806- :attr:`tp_traverse` methods (if any), and may not be all objects actually
2807- directly reachable. :attr:`tp_traverse` methods are supported only by objects
2808+ :c:member:`~PyTypeObject.tp_traverse` methods (if any), and may not be all objects actually
2809+ directly reachable. :c:member:`~PyTypeObject.tp_traverse` methods are supported only by objects
2810 that support garbage collection, and are only required to visit objects that may
2811 be involved in a cycle. So, for example, if an integer is directly reachable
2812 from an argument, that integer object may or may not appear in the result list.
2813diff -r d047928ae3f6 Doc/library/heapq.rst
2814--- a/Doc/library/heapq.rst
2815+++ b/Doc/library/heapq.rst
2816@@ -246,7 +246,7 @@
2817 the sort is going on, provided that the inserted items are not "better" than the
2818 last 0'th element you extracted. This is especially useful in simulation
2819 contexts, where the tree holds all incoming events, and the "win" condition
2820-means the smallest scheduled time. When an event schedule other events for
2821+means the smallest scheduled time. When an event schedules other events for
2822 execution, they are scheduled into the future, so they can easily go into the
2823 heap. So, a heap is a good structure for implementing schedulers (this is what
2824 I used for my MIDI sequencer :-).
242diff -r d047928ae3f6 Doc/library/http.cookiejar.rst2825diff -r d047928ae3f6 Doc/library/http.cookiejar.rst
243--- a/Doc/library/http.cookiejar.rst2826--- a/Doc/library/http.cookiejar.rst
244+++ b/Doc/library/http.cookiejar.rst2827+++ b/Doc/library/http.cookiejar.rst
@@ -279,6 +2862,32 @@
279 2862
280 .. method:: CookieJar.set_policy(policy)2863 .. method:: CookieJar.set_policy(policy)
281 2864
2865diff -r d047928ae3f6 Doc/library/idle.rst
2866--- a/Doc/library/idle.rst
2867+++ b/Doc/library/idle.rst
2868@@ -33,8 +33,8 @@
2869 File menu
2870 ^^^^^^^^^
2871
2872-New window
2873- create a new editing window
2874+New file
2875+ create a new file editing window
2876
2877 Open...
2878 open an existing file
2879diff -r d047928ae3f6 Doc/library/imp.rst
2880--- a/Doc/library/imp.rst
2881+++ b/Doc/library/imp.rst
2882@@ -158,7 +158,7 @@
2883 cache = {}
2884
2885 It is legal though generally not very useful to reload built-in or dynamically
2886- loaded modules, except for :mod:`sys`, :mod:`__main__` and :mod:`__builtin__`.
2887+ loaded modules, except for :mod:`sys`, :mod:`__main__` and :mod:`builtins`.
2888 In many cases, however, extension modules are not designed to be initialized
2889 more than once, and may fail in arbitrary ways when reloaded.
2890
282diff -r d047928ae3f6 Doc/library/importlib.rst2891diff -r d047928ae3f6 Doc/library/importlib.rst
283--- a/Doc/library/importlib.rst2892--- a/Doc/library/importlib.rst
284+++ b/Doc/library/importlib.rst2893+++ b/Doc/library/importlib.rst
@@ -314,6 +2923,322 @@
314 :data:`sys.path_importer_cache`, then :data:`sys.path_hooks` is2923 :data:`sys.path_importer_cache`, then :data:`sys.path_hooks` is
315 searched for a finder for the path entry and, if found, is stored in2924 searched for a finder for the path entry and, if found, is stored in
316 :data:`sys.path_importer_cache` along with being queried about the2925 :data:`sys.path_importer_cache` along with being queried about the
2926@@ -692,6 +697,8 @@
2927
2928 The *loader_details* argument is a variable number of 2-item tuples each
2929 containing a loader and a sequence of file suffixes the loader recognizes.
2930+ The loaders are expected to be callables which accept two arguments of
2931+ the module's name and the path to the file found.
2932
2933 The finder will cache the directory contents as necessary, making stat calls
2934 for each module search to verify the cache is not outdated. Because cache
2935@@ -709,7 +716,7 @@
2936
2937 The path the finder will search in.
2938
2939- .. method:: find_module(fullname)
2940+ .. method:: find_loader(fullname)
2941
2942 Attempt to find the loader to handle *fullname* within :attr:`path`.
2943
2944diff -r d047928ae3f6 Doc/library/itertools.rst
2945--- a/Doc/library/itertools.rst
2946+++ b/Doc/library/itertools.rst
2947@@ -278,7 +278,7 @@
2948
2949 .. function:: count(start=0, step=1)
2950
2951- Make an iterator that returns evenly spaced values starting with *n*. Often
2952+ Make an iterator that returns evenly spaced values starting with number *start*. Often
2953 used as an argument to :func:`map` to generate consecutive data points.
2954 Also, used with :func:`zip` to add sequence numbers. Equivalent to::
2955
2956@@ -762,7 +762,7 @@
2957 """ Call a function repeatedly until an exception is raised.
2958
2959 Converts a call-until-exception interface to an iterator interface.
2960- Like __builtin__.iter(func, sentinel) but uses an exception instead
2961+ Like builtins.iter(func, sentinel) but uses an exception instead
2962 of a sentinel to end the loop.
2963
2964 Examples:
2965diff -r d047928ae3f6 Doc/library/multiprocessing.rst
2966--- a/Doc/library/multiprocessing.rst
2967+++ b/Doc/library/multiprocessing.rst
2968@@ -284,6 +284,9 @@
2969 print(result.get(timeout=1)) # prints "100" unless your computer is *very* slow
2970 print(pool.map(f, range(10))) # prints "[0, 1, 4,..., 81]"
2971
2972+Note that the methods of a pool should only ever be used by the
2973+process which created it.
2974+
2975
2976 Reference
2977 ---------
2978@@ -443,7 +446,7 @@
2979 cause other processes to deadlock.
2980
2981 Note that the :meth:`start`, :meth:`join`, :meth:`is_alive`,
2982- :meth:`terminate` and :attr:`exit_code` methods should only be called by
2983+ :meth:`terminate` and :attr:`exitcode` methods should only be called by
2984 the process that created the process object.
2985
2986 Example usage of some of the methods of :class:`Process`:
2987@@ -515,6 +518,24 @@
2988 the :mod:`multiprocessing` namespace so you need to import them from
2989 :mod:`queue`.
2990
2991+.. note::
2992+
2993+ When an object is put on a queue, the object is pickled and a
2994+ background thread later flushes the pickled data to an underlying
2995+ pipe. This has some consequences which are a little surprising,
2996+ but should not cause any practical difficulties -- if they really
2997+ bother you then you can instead use a queue created with a
2998+ :ref:`manager <multiprocessing-managers>`.
2999+
3000+ (1) After putting an object on an empty queue there may be an
3001+ infinitesimal delay before the queue's :meth:`~Queue.empty`
3002+ method returns :const:`False` and :meth:`~Queue.get_nowait` can
3003+ return without raising :exc:`Queue.Empty`.
3004+
3005+ (2) If multiple processes are enqueuing objects, it is possible for
3006+ the objects to be received at the other end out-of-order.
3007+ However, objects enqueued by the same process will always be in
3008+ the expected order with respect to each other.
3009
3010 .. warning::
3011
3012@@ -638,6 +659,13 @@
3013 the background thread from being joined automatically when the process
3014 exits -- see :meth:`join_thread`.
3015
3016+ A better name for this method might be
3017+ ``allow_exit_without_flush()``. It is likely to cause enqueued
3018+ data to lost, and you almost certainly will not need to use it.
3019+ It is really only there if you need the current process to exit
3020+ immediately without waiting to flush enqueued data to the
3021+ underlying pipe, and you don't care about lost data.
3022+
3023
3024 .. class:: SimpleQueue()
3025
3026@@ -1647,6 +1675,9 @@
3027 *initializer* is not ``None`` then each worker process will call
3028 ``initializer(*initargs)`` when it starts.
3029
3030+ Note that the methods of the pool object should only be called by
3031+ the process which created the pool.
3032+
3033 .. versionadded:: 3.2
3034 *maxtasksperchild* is the number of tasks a worker process can complete
3035 before it will exit and be replaced with a fresh worker process, to enable
3036diff -r d047928ae3f6 Doc/library/os.path.rst
3037--- a/Doc/library/os.path.rst
3038+++ b/Doc/library/os.path.rst
3039@@ -234,8 +234,10 @@
3040
3041 .. function:: relpath(path, start=None)
3042
3043- Return a relative filepath to *path* either from the current directory or from
3044- an optional *start* point.
3045+ Return a relative filepath to *path* either from the current directory or
3046+ from an optional *start* directory. This is a path computation: the
3047+ filesystem is not accessed to confirm the existence or nature of *path* or
3048+ *start*.
3049
3050 *start* defaults to :attr:`os.curdir`.
3051
3052diff -r d047928ae3f6 Doc/library/os.rst
3053--- a/Doc/library/os.rst
3054+++ b/Doc/library/os.rst
3055@@ -2023,9 +2023,10 @@
3056 Create a symbolic link pointing to *source* named *link_name*.
3057
3058 On Windows, a symlink represents either a file or a directory, and does not
3059- morph to the target dynamically. If *target_is_directory* is set to ``True``,
3060- the symlink will be created as a directory symlink, otherwise as a file symlink
3061- (the default). On non-Window platforms, *target_is_directory* is ignored.
3062+ morph to the target dynamically. If the target is present, the type of the
3063+ symlink will be created to match. Otherwise, the symlink will be created
3064+ as a directory if *target_is_directory* is ``True`` or a file symlink (the
3065+ default) otherwise. On non-Window platforms, *target_is_directory* is ignored.
3066
3067 Symbolic link support was introduced in Windows 6.0 (Vista). :func:`symlink`
3068 will raise a :exc:`NotImplementedError` on Windows versions earlier than 6.0.
3069@@ -2041,6 +2042,7 @@
3070 to the administrator level. Either obtaining the privilege or running your
3071 application as an administrator are ways to successfully create symlinks.
3072
3073+
3074 :exc:`OSError` is raised when the function is called by an unprivileged
3075 user.
3076
3077diff -r d047928ae3f6 Doc/library/smtplib.rst
3078--- a/Doc/library/smtplib.rst
3079+++ b/Doc/library/smtplib.rst
3080@@ -24,17 +24,20 @@
3081
3082 A :class:`SMTP` instance encapsulates an SMTP connection. It has methods
3083 that support a full repertoire of SMTP and ESMTP operations. If the optional
3084- host and port parameters are given, the SMTP :meth:`connect` method is called
3085- with those parameters during initialization. If the :meth:`connect` call
3086- returns anything other than a success code, an :exc:`SMTPConnectError` is
3087- raised. The optional *timeout* parameter specifies a timeout in seconds for
3088- blocking operations like the connection attempt (if not specified, the
3089- global default timeout setting will be used). The optional source_address
3090- parameter allows to bind to some specific source address in a machine with
3091- multiple network interfaces, and/or to some specific source TCP port. It
3092- takes a 2-tuple (host, port), for the socket to bind to as its source
3093- address before connecting. If omitted (or if host or port are ``''`` and/or
3094- 0 respectively) the OS default behavior will be used.
3095+ host and port parameters are given, the SMTP :meth:`connect` method is
3096+ called with those parameters during initialization. If specified,
3097+ *local_hostname* is used as the FQDN of the local host in the HELO/EHLO
3098+ command. Otherwise, the local hostname is found using
3099+ :func:`socket.getfqdn`. If the :meth:`connect` call returns anything other
3100+ than a success code, an :exc:`SMTPConnectError` is raised. The optional
3101+ *timeout* parameter specifies a timeout in seconds for blocking operations
3102+ like the connection attempt (if not specified, the global default timeout
3103+ setting will be used). The optional source_address parameter allows to bind
3104+ to some specific source address in a machine with multiple network
3105+ interfaces, and/or to some specific source TCP port. It takes a 2-tuple
3106+ (host, port), for the socket to bind to as its source address before
3107+ connecting. If omitted (or if host or port are ``''`` and/or 0 respectively)
3108+ the OS default behavior will be used.
3109
3110 For normal use, you should only require the initialization/connect,
3111 :meth:`sendmail`, and :meth:`~smtplib.quit` methods.
3112@@ -57,17 +60,21 @@
3113 .. versionchanged:: 3.3
3114 source_address argument was added.
3115
3116-.. class:: SMTP_SSL(host='', port=0, local_hostname=None, keyfile=None, certfile=None[, timeout], context=None, source_address=None)
3117+.. class:: SMTP_SSL(host='', port=0, local_hostname=None, keyfile=None, \
3118+ certfile=None [, timeout], context=None, \
3119+ source_address=None)
3120
3121 A :class:`SMTP_SSL` instance behaves exactly the same as instances of
3122 :class:`SMTP`. :class:`SMTP_SSL` should be used for situations where SSL is
3123 required from the beginning of the connection and using :meth:`starttls` is
3124 not appropriate. If *host* is not specified, the local host is used. If
3125- *port* is zero, the standard SMTP-over-SSL port (465) is used. *keyfile*
3126- and *certfile* are also optional, and can contain a PEM formatted private key
3127- and certificate chain file for the SSL connection. *context* also optional, can contain
3128- a SSLContext, and is an alternative to keyfile and certfile; If it is specified both
3129- keyfile and certfile must be None. The optional *timeout*
3130+ *port* is zero, the standard SMTP-over-SSL port (465) is used. The optional
3131+ arguments *local_hostname* and *source_address* have the same meaning as
3132+ they do in the :class:`SMTP` class. *keyfile* and *certfile* are also
3133+ optional, and can contain a PEM formatted private key and certificate chain
3134+ file for the SSL connection. *context* also optional, can contain a
3135+ SSLContext, and is an alternative to keyfile and certfile; If it is
3136+ specified both keyfile and certfile must be None. The optional *timeout*
3137 parameter specifies a timeout in seconds for blocking operations like the
3138 connection attempt (if not specified, the global default timeout setting
3139 will be used). The optional source_address parameter allows to bind to some
3140@@ -90,12 +97,12 @@
3141 standard SMTP client. It's common to use Unix sockets for LMTP, so our
3142 :meth:`connect` method must support that as well as a regular host:port
3143 server. The optional arguments local_hostname and source_address have the
3144- same meaning as that of SMTP client. To specify a Unix socket, you must use
3145- an absolute path for *host*, starting with a '/'.
3146+ same meaning as they do in the :class:`SMTP` class. To specify a Unix
3147+ socket, you must use an absolute path for *host*, starting with a '/'.
3148
3149- Authentication is supported, using the regular SMTP mechanism. When using a Unix
3150- socket, LMTP generally don't support or require any authentication, but your
3151- mileage might vary.
3152+ Authentication is supported, using the regular SMTP mechanism. When using a
3153+ Unix socket, LMTP generally don't support or require any authentication, but
3154+ your mileage might vary.
3155
3156
3157 A nice selection of exceptions is defined as well:
3158diff -r d047928ae3f6 Doc/library/ssl.rst
3159--- a/Doc/library/ssl.rst
3160+++ b/Doc/library/ssl.rst
3161@@ -773,7 +773,7 @@
3162
3163 .. method:: SSLContext.set_npn_protocols(protocols)
3164
3165- Specify which protocols the socket should avertise during the SSL/TLS
3166+ Specify which protocols the socket should advertise during the SSL/TLS
3167 handshake. It should be a list of strings, like ``['http/1.1', 'spdy/2']``,
3168 ordered by preference. The selection of a protocol will happen during the
3169 handshake, and will play out according to the `NPN draft specification
3170diff -r d047928ae3f6 Doc/library/stdtypes.rst
3171--- a/Doc/library/stdtypes.rst
3172+++ b/Doc/library/stdtypes.rst
3173@@ -751,7 +751,7 @@
3174 iterators for those iteration types. (An example of an object supporting
3175 multiple forms of iteration would be a tree structure which supports both
3176 breadth-first and depth-first traversal.) This method corresponds to the
3177- :attr:`tp_iter` slot of the type structure for Python objects in the Python/C
3178+ :c:member:`~PyTypeObject.tp_iter` slot of the type structure for Python objects in the Python/C
3179 API.
3180
3181 The iterator objects themselves are required to support the following two
3182@@ -762,7 +762,7 @@
3183
3184 Return the iterator object itself. This is required to allow both containers
3185 and iterators to be used with the :keyword:`for` and :keyword:`in` statements.
3186- This method corresponds to the :attr:`tp_iter` slot of the type structure for
3187+ This method corresponds to the :c:member:`~PyTypeObject.tp_iter` slot of the type structure for
3188 Python objects in the Python/C API.
3189
3190
3191@@ -770,7 +770,7 @@
3192
3193 Return the next item from the container. If there are no further items, raise
3194 the :exc:`StopIteration` exception. This method corresponds to the
3195- :attr:`tp_iternext` slot of the type structure for Python objects in the
3196+ :c:member:`~PyTypeObject.tp_iternext` slot of the type structure for Python objects in the
3197 Python/C API.
3198
3199 Python defines several iterator objects to support iteration over general and
3200@@ -871,11 +871,11 @@
3201 +--------------------------+--------------------------------+----------+
3202 | ``max(s)`` | largest item of *s* | |
3203 +--------------------------+--------------------------------+----------+
3204-| ``s.index(x[, i[, j]])`` | index of the first occurence | \(8) |
3205+| ``s.index(x[, i[, j]])`` | index of the first occurrence | \(8) |
3206 | | of *x* in *s* (at or after | |
3207 | | index *i* and before index *j*)| |
3208 +--------------------------+--------------------------------+----------+
3209-| ``s.count(x)`` | total number of occurences of | |
3210+| ``s.count(x)`` | total number of occurrences of | |
3211 | | *x* in *s* | |
3212 +--------------------------+--------------------------------+----------+
3213
3214diff -r d047928ae3f6 Doc/library/subprocess.rst
3215--- a/Doc/library/subprocess.rst
3216+++ b/Doc/library/subprocess.rst
3217@@ -290,8 +290,12 @@
3218 .. index::
3219 single: universal newlines; subprocess module
3220
3221- If *universal_newlines* is ``True``, the file objects *stdin*, *stdout* and
3222- *stderr* will be opened as text streams in :term:`universal newlines` mode
3223+ If *universal_newlines* is ``False`` the file objects *stdin*, *stdout* and
3224+ *stderr* will be opened as binary streams, and no line ending conversion is
3225+ done.
3226+
3227+ If *universal_newlines* is ``True``, these file objects
3228+ will be opened as text streams in :term:`universal newlines` mode
3229 using the encoding returned by :func:`locale.getpreferredencoding(False)
3230 <locale.getpreferredencoding>`. For *stdin*, line ending characters
3231 ``'\n'`` in the input will be converted to the default line separator
3232@@ -537,7 +541,8 @@
3233
3234 If *universal_newlines* is ``True``, the file objects *stdin*, *stdout*
3235 and *stderr* are opened as text streams in universal newlines mode, as
3236- described above in :ref:`frequently-used-arguments`.
3237+ described above in :ref:`frequently-used-arguments`, otherwise they are
3238+ opened as binary streams.
3239
3240 If given, *startupinfo* will be a :class:`STARTUPINFO` object, which is
3241 passed to the underlying ``CreateProcess`` function.
317diff -r d047928ae3f6 Doc/library/sys.rst3242diff -r d047928ae3f6 Doc/library/sys.rst
318--- a/Doc/library/sys.rst3243--- a/Doc/library/sys.rst
319+++ b/Doc/library/sys.rst3244+++ b/Doc/library/sys.rst
@@ -326,6 +3251,90 @@
326 3251
327 3252
328 .. data:: path3253 .. data:: path
3254diff -r d047928ae3f6 Doc/library/test.rst
3255--- a/Doc/library/test.rst
3256+++ b/Doc/library/test.rst
3257@@ -362,31 +362,65 @@
3258 New optional arguments *filters* and *quiet*.
3259
3260
3261-.. function:: captured_stdout()
3262+.. function:: captured_stdin()
3263+ captured_stdout()
3264+ captured_stderr()
3265
3266- A context manager that runs the :keyword:`with` statement body using a
3267- :class:`io.StringIO` object as sys.stdout. That object can be retrieved
3268- using the ``as`` clause of the :keyword:`with` statement.
3269+ A context managers that temporarily replaces the named stream with
3270+ :class:`io.StringIO` object.
3271
3272- Example use::
3273+ Example use with output streams::
3274
3275- with captured_stdout() as s:
3276+ with captured_stdout() as stdout, captured_stderr() as stderr:
3277 print("hello")
3278- assert s.getvalue() == "hello\n"
3279+ print("error", file=sys.stderr)
3280+ assert stdout.getvalue() == "hello\n"
3281+ assert stderr.getvalue() == "error\n"
3282
3283+ Example use with input stream::
3284
3285-.. function:: temp_cwd(name='tempcwd', quiet=False, path=None)
3286+ with captured_stdin() as stdin:
3287+ stdin.write('hello\n')
3288+ stdin.seek(0)
3289+ # call test code that consumes from sys.stdin
3290+ captured = input()
3291+ self.assertEqual(captured, "hello")
3292+
3293+
3294+.. function:: temp_dir(path=None, quiet=False)
3295+
3296+ A context manager that creates a temporary directory at *path* and
3297+ yields the directory.
3298+
3299+ If *path* is None, the temporary directory is created using
3300+ :func:`tempfile.mkdtemp`. If *quiet* is ``False``, the context manager
3301+ raises an exception on error. Otherwise, if *path* is specified and
3302+ cannot be created, only a warning is issued.
3303+
3304+
3305+.. function:: change_cwd(path, quiet=False)
3306
3307 A context manager that temporarily changes the current working
3308- directory (CWD).
3309+ directory to *path* and yields the directory.
3310
3311- An existing path may be provided as *path*, in which case this function
3312- makes no changes to the file system.
3313+ If *quiet* is ``False``, the context manager raises an exception
3314+ on error. Otherwise, it issues only a warning and keeps the current
3315+ working directory the same.
3316
3317- Otherwise, the new CWD is created in the current directory and it's named
3318- *name*. If *quiet* is ``False`` and it's not possible to create or
3319- change the CWD, an error is raised. If it's ``True``, only a warning
3320- is raised and the original CWD is used.
3321+
3322+.. function:: temp_cwd(name='tempcwd', quiet=False)
3323+
3324+ A context manager that temporarily creates a new directory and
3325+ changes the current working directory (CWD).
3326+
3327+ The context manager creates a temporary directory in the current
3328+ directory with name *name* before temporarily changing the current
3329+ working directory. If *name* is None, the temporary directory is
3330+ created using :func:`tempfile.mkdtemp`.
3331+
3332+ If *quiet* is ``False`` and it is not possible to create or change
3333+ the CWD, an error is raised. Otherwise, only a warning is raised
3334+ and the original CWD is used.
3335
3336
3337 .. function:: temp_umask(umask)
329diff -r d047928ae3f6 Doc/library/unittest.mock.rst3338diff -r d047928ae3f6 Doc/library/unittest.mock.rst
330--- a/Doc/library/unittest.mock.rst3339--- a/Doc/library/unittest.mock.rst
331+++ b/Doc/library/unittest.mock.rst3340+++ b/Doc/library/unittest.mock.rst
@@ -338,6 +3347,48 @@
338 3347
339 An example of a mock that raises an exception (to test exception3348 An example of a mock that raises an exception (to test exception
340 handling of an API):3349 handling of an API):
3350diff -r d047928ae3f6 Doc/library/unittest.rst
3351--- a/Doc/library/unittest.rst
3352+++ b/Doc/library/unittest.rst
3353@@ -873,7 +873,7 @@
3354 a regular expression object or a string containing a regular expression
3355 suitable for use by :func:`re.search`. Examples::
3356
3357- self.assertRaisesRegex(ValueError, 'invalid literal for.*XYZ$',
3358+ self.assertRaisesRegex(ValueError, "invalid literal for.*XYZ'$",
3359 int, 'XYZ')
3360
3361 or::
3362@@ -897,25 +897,25 @@
3363 Test that a warning is triggered when *callable* is called with any
3364 positional or keyword arguments that are also passed to
3365 :meth:`assertWarns`. The test passes if *warning* is triggered and
3366- fails if it isn't. Also, any unexpected exception is an error.
3367+ fails if it isn't. Any exception is an error.
3368 To catch any of a group of warnings, a tuple containing the warning
3369 classes may be passed as *warnings*.
3370
3371 If only the *warning* and possibly the *msg* arguments are given,
3372- returns a context manager so that the code under test can be written
3373+ return a context manager so that the code under test can be written
3374 inline rather than as a function::
3375
3376 with self.assertWarns(SomeWarning):
3377 do_something()
3378
3379- When used as a context manager, :meth:`assertRaises` accepts the
3380+ When used as a context manager, :meth:`assertWarns` accepts the
3381 additional keyword argument *msg*.
3382
3383 The context manager will store the caught warning object in its
3384 :attr:`warning` attribute, and the source line which triggered the
3385 warnings in the :attr:`filename` and :attr:`lineno` attributes.
3386 This can be useful if the intention is to perform additional checks
3387- on the exception raised::
3388+ on the warning caught::
3389
3390 with self.assertWarns(SomeWarning) as cm:
3391 do_something()
341diff -r d047928ae3f6 Doc/library/urllib.request.rst3392diff -r d047928ae3f6 Doc/library/urllib.request.rst
342--- a/Doc/library/urllib.request.rst3393--- a/Doc/library/urllib.request.rst
343+++ b/Doc/library/urllib.request.rst3394+++ b/Doc/library/urllib.request.rst
@@ -350,6 +3401,234 @@
350 3401
351 Open the URL *url*, which can be either a string or a3402 Open the URL *url*, which can be either a string or a
352 :class:`Request` object.3403 :class:`Request` object.
3404diff -r d047928ae3f6 Doc/library/venv.rst
3405--- a/Doc/library/venv.rst
3406+++ b/Doc/library/venv.rst
3407@@ -11,7 +11,7 @@
3408
3409 .. versionadded:: 3.3
3410
3411-**Source code:** :source:`Lib/venv.py`
3412+**Source code:** :source:`Lib/venv`
3413
3414 --------------
3415
3416@@ -125,11 +125,13 @@
3417 :meth:`create_configuration`, :meth:`setup_python`,
3418 :meth:`setup_scripts` and :meth:`post_setup` can be overridden.
3419
3420- .. method:: create_directories(env_dir)
3421+ .. method:: ensure_directories(env_dir)
3422
3423 Creates the environment directory and all necessary directories, and
3424 returns a context object. This is just a holder for attributes (such as
3425- paths), for use by the other methods.
3426+ paths), for use by the other methods. The directories are allowed to
3427+ exist already, as long as either ``clear`` or ``upgrade`` were
3428+ specified to allow operating on an existing environment directory.
3429
3430 .. method:: create_configuration(context)
3431
3432@@ -138,7 +140,10 @@
3433 .. method:: setup_python(context)
3434
3435 Creates a copy of the Python executable (and, under Windows, DLLs) in
3436- the environment.
3437+ the environment. On a POSIX system, if a specific executable
3438+ ``python3.x`` was used, symlinks to ``python`` and ``python3`` will be
3439+ created pointing to that executable, unless files with those names
3440+ already exist.
3441
3442 .. method:: setup_scripts(context)
3443
3444@@ -175,6 +180,8 @@
3445 * ``__VENV_PYTHON__`` is replaced with the absolute path of the
3446 environment's executable.
3447
3448+ The directories are allowed to exist (for when an existing environment
3449+ is being upgraded).
3450
3451 There is also a module-level convenience function:
3452
3453@@ -187,7 +194,7 @@
3454 --------------------------------------
3455
3456 The following script shows how to extend :class:`EnvBuilder` by implementing a
3457-subclass which installs Distribute and pip into a created venv::
3458+subclass which installs setuptools and pip into a created venv::
3459
3460 import os
3461 import os.path
3462@@ -198,16 +205,16 @@
3463 from urllib.request import urlretrieve
3464 import venv
3465
3466- class DistributeEnvBuilder(venv.EnvBuilder):
3467+ class ExtendedEnvBuilder(venv.EnvBuilder):
3468 """
3469- This builder installs Distribute and pip so that you can pip or
3470+ This builder installs setuptools and pip so that you can pip or
3471 easy_install other packages into the created environment.
3472
3473- :param nodist: If True, Distribute is not installed into the created
3474- environment.
3475+ :param nodist: If True, setuptools and pip are not installed into the
3476+ created environment.
3477 :param nopip: If True, pip is not installed into the created
3478 environment.
3479- :param progress: If Distribute or pip are installed, the progress of the
3480+ :param progress: If setuptools or pip are installed, the progress of the
3481 installation can be monitored by passing a progress
3482 callable. If specified, it is called with two
3483 arguments: a string indicating some progress, and a
3484@@ -237,9 +244,11 @@
3485 :param context: The information for the environment creation request
3486 being processed.
3487 """
3488+ os.environ['VIRTUAL_ENV'] = context.env_dir
3489 if not self.nodist:
3490- self.install_distribute(context)
3491- if not self.nopip:
3492+ self.install_setuptools(context)
3493+ # Can't install pip without setuptools
3494+ if not self.nopip and not self.nodist:
3495 self.install_pip(context)
3496
3497 def reader(self, stream, context):
3498@@ -260,6 +269,7 @@
3499 else:
3500 sys.stderr.write(s.decode('utf-8'))
3501 sys.stderr.flush()
3502+ stream.close()
3503
3504 def install_script(self, context, name, url):
3505 _, _, path, _, _, _ = urlparse(url)
3506@@ -269,10 +279,14 @@
3507 # Download script into the env's binaries folder
3508 urlretrieve(url, distpath)
3509 progress = self.progress
3510+ if self.verbose:
3511+ term = '\n'
3512+ else:
3513+ term = ''
3514 if progress is not None:
3515- progress('Installing %s' %name, 'main')
3516+ progress('Installing %s ...%s' % (name, term), 'main')
3517 else:
3518- sys.stderr.write('Installing %s ' % name)
3519+ sys.stderr.write('Installing %s ...%s' % (name, term))
3520 sys.stderr.flush()
3521 # Install in the env
3522 args = [context.env_exe, fn]
3523@@ -291,17 +305,17 @@
3524 # Clean up - no longer needed
3525 os.unlink(distpath)
3526
3527- def install_distribute(self, context):
3528+ def install_setuptools(self, context):
3529 """
3530- Install Distribute in the environment.
3531+ Install setuptools in the environment.
3532
3533 :param context: The information for the environment creation request
3534 being processed.
3535 """
3536- url = 'http://python-distribute.org/distribute_setup.py'
3537- self.install_script(context, 'distribute', url)
3538- # clear up the distribute archive which gets downloaded
3539- pred = lambda o: o.startswith('distribute-') and o.endswith('.tar.gz')
3540+ url = 'https://bitbucket.org/pypa/setuptools/downloads/ez_setup.py'
3541+ self.install_script(context, 'setuptools', url)
3542+ # clear up the setuptools archive which gets downloaded
3543+ pred = lambda o: o.startswith('setuptools-') and o.endswith('.tar.gz')
3544 files = filter(pred, os.listdir(context.bin_path))
3545 for f in files:
3546 f = os.path.join(context.bin_path, f)
3547@@ -336,10 +350,10 @@
3548 'directories.')
3549 parser.add_argument('dirs', metavar='ENV_DIR', nargs='+',
3550 help='A directory to create the environment in.')
3551- parser.add_argument('--no-distribute', default=False,
3552+ parser.add_argument('--no-setuptools', default=False,
3553 action='store_true', dest='nodist',
3554- help="Don't install Distribute in the virtual "
3555- "environment.")
3556+ help="Don't install setuptools or pip in the "
3557+ "virtual environment.")
3558 parser.add_argument('--no-pip', default=False,
3559 action='store_true', dest='nopip',
3560 help="Don't install pip in the virtual "
3561@@ -370,11 +384,11 @@
3562 parser.add_argument('--verbose', default=False, action='store_true',
3563 dest='verbose', help='Display the output '
3564 'from the scripts which '
3565- 'install Distribute and pip.')
3566+ 'install setuptools and pip.')
3567 options = parser.parse_args(args)
3568 if options.upgrade and options.clear:
3569 raise ValueError('you cannot supply --upgrade and --clear together.')
3570- builder = DistributeEnvBuilder(system_site_packages=options.system_site,
3571+ builder = ExtendedEnvBuilder(system_site_packages=options.system_site,
3572 clear=options.clear,
3573 symlinks=options.symlinks,
3574 upgrade=options.upgrade,
3575@@ -393,5 +407,6 @@
3576 print('Error: %s' % e, file=sys.stderr)
3577 sys.exit(rc)
3578
3579+
3580 This script is also available for download `online
3581 <https://gist.github.com/4673395>`_.
3582diff -r d047928ae3f6 Doc/library/xmlrpc.client.rst
3583--- a/Doc/library/xmlrpc.client.rst
3584+++ b/Doc/library/xmlrpc.client.rst
3585@@ -435,7 +435,7 @@
3586 is a :term:`generator`; iterating over this generator yields the individual
3587 results.
3588
3589-A usage example of this class follows. The server code ::
3590+A usage example of this class follows. The server code::
3591
3592 from xmlrpc.server import SimpleXMLRPCServer
3593
3594@@ -449,7 +449,7 @@
3595 return x*y
3596
3597 def divide(x, y):
3598- return x/y
3599+ return x // y
3600
3601 # A simple server with simple arithmetic functions
3602 server = SimpleXMLRPCServer(("localhost", 8000))
3603diff -r d047928ae3f6 Doc/reference/datamodel.rst
3604--- a/Doc/reference/datamodel.rst
3605+++ b/Doc/reference/datamodel.rst
3606@@ -1264,10 +1264,21 @@
3607
3608 Called by built-in function :func:`hash` and for operations on members of
3609 hashed collections including :class:`set`, :class:`frozenset`, and
3610- :class:`dict`. :meth:`__hash__` should return an integer. The only required
3611- property is that objects which compare equal have the same hash value; it is
3612- advised to somehow mix together (e.g. using exclusive or) the hash values for
3613- the components of the object that also play a part in comparison of objects.
3614+ :class:`dict`. :meth:`__hash__` should return an integer. The only
3615+ required property is that objects which compare equal have the same hash
3616+ value; it is advised to somehow mix together (e.g. using exclusive or) the
3617+ hash values for the components of the object that also play a part in
3618+ comparison of objects.
3619+
3620+ .. note::
3621+
3622+ :func:`hash` truncates the value returned from an object's custom
3623+ :meth:`__hash__` method to the size of a :c:type:`Py_ssize_t`. This is
3624+ typically 8 bytes on 64-bit builds and 4 bytes on 32-bit builds. If an
3625+ object's :meth:`__hash__` must interoperate on builds of different bit
3626+ sizes, be sure to check the width on all supported builds. An easy way
3627+ to do this is with
3628+ ``python -c "import sys; print(sys.hash_info.width)"``
3629
3630 If a class does not define an :meth:`__eq__` method it should not define a
3631 :meth:`__hash__` operation either; if it defines :meth:`__eq__` but not
353diff -r d047928ae3f6 Doc/reference/import.rst3632diff -r d047928ae3f6 Doc/reference/import.rst
354--- a/Doc/reference/import.rst3633--- a/Doc/reference/import.rst
355+++ b/Doc/reference/import.rst3634+++ b/Doc/reference/import.rst
@@ -380,6 +3659,33 @@
380 More information can be found in the :ref:`old-string-formatting` section.3659 More information can be found in the :ref:`old-string-formatting` section.
381 3660
382 3661
3662@@ -326,9 +322,11 @@
3663 >>> f.write(s)
3664 18
3665
3666-``f.tell()`` returns an integer giving the file object's current position in the
3667-file, measured in bytes from the beginning of the file. To change the file
3668-object's position, use ``f.seek(offset, from_what)``. The position is computed
3669+``f.tell()`` returns an integer giving the file object's current position in the file
3670+represented as number of bytes from the beginning of the file when in `binary mode` and
3671+an opaque number when in `text mode`.
3672+
3673+To change the file object's position, use ``f.seek(offset, from_what)``. The position is computed
3674 from adding *offset* to a reference point; the reference point is selected by
3675 the *from_what* argument. A *from_what* value of 0 measures from the beginning
3676 of the file, 1 uses the current file position, and 2 uses the end of the file as
3677@@ -349,7 +347,10 @@
3678
3679 In text files (those opened without a ``b`` in the mode string), only seeks
3680 relative to the beginning of the file are allowed (the exception being seeking
3681-to the very file end with ``seek(0, 2)``).
3682+to the very file end with ``seek(0, 2)``) and the only valid *offset* values are
3683+those returned from the ``f.tell()``, or zero. Any other *offset* value produces
3684+undefined behaviour.
3685+
3686
3687 When you're done with a file, call ``f.close()`` to close it and free up any
3688 system resources taken up by the open file. After calling ``f.close()``,
383diff -r d047928ae3f6 Doc/tutorial/introduction.rst3689diff -r d047928ae3f6 Doc/tutorial/introduction.rst
384--- a/Doc/tutorial/introduction.rst3690--- a/Doc/tutorial/introduction.rst
385+++ b/Doc/tutorial/introduction.rst3691+++ b/Doc/tutorial/introduction.rst
@@ -763,7 +4069,7 @@
763+4069+
764+ >>> word[0:2] # characters from position 0 (included) to 2 (excluded)4070+ >>> word[0:2] # characters from position 0 (included) to 2 (excluded)
765+ 'Py'4071+ 'Py'
766+ >>> word[2:5] # characters from position 2 (included) to 4 (excluded)4072+ >>> word[2:5] # characters from position 2 (included) to 5 (excluded)
767+ 'tho'4073+ 'tho'
768+4074+
769+Note how the start is always included, and the end always excluded. This4075+Note how the start is always included, and the end always excluded. This
@@ -1118,9 +4424,9 @@
1118+ >>> x = [a, n]4424+ >>> x = [a, n]
1119+ >>> x4425+ >>> x
1120+ [['a', 'b', 'c'], [1, 2, 3]]4426+ [['a', 'b', 'c'], [1, 2, 3]]
1121+ >>> p[0]4427+ >>> x[0]
1122+ ['a', 'b', 'c']4428+ ['a', 'b', 'c']
1123+ >>> p[0][1]4429+ >>> x[0][1]
1124+ 'b'4430+ 'b'
1125 4431
1126 .. _tut-firststeps:4432 .. _tut-firststeps:
@@ -1141,6 +4447,701 @@
1141+ same meaning with both single (``'...'``) and double (``"..."``) quotes.4447+ same meaning with both single (``'...'``) and double (``"..."``) quotes.
1142+ The only difference between the two is that within single quotes you don't4448+ The only difference between the two is that within single quotes you don't
1143+ need to escape ``"`` (but you have to escape ``\'``) and vice versa.4449+ need to escape ``"`` (but you have to escape ``\'``) and vice versa.
4450diff -r d047928ae3f6 Doc/using/cmdline.rst
4451--- a/Doc/using/cmdline.rst
4452+++ b/Doc/using/cmdline.rst
4453@@ -269,8 +269,8 @@
4454
4455 .. cmdoption:: -u
4456
4457- Force the binary layer of the stdin, stdout and stderr streams (which is
4458- available as their ``buffer`` attribute) to be unbuffered. The text I/O
4459+ Force the binary layer of the stdout and stderr streams (which is
4460+ available as their ``buffer`` attribute) to be unbuffered. The text I/O
4461 layer will still be line-buffered if writing to the console, or
4462 block-buffered if redirected to a non-interactive file.
4463
4464@@ -562,6 +562,8 @@
4465 Python traceback. This is equivalent to :option:`-X` ``faulthandler``
4466 option.
4467
4468+ .. versionadded:: 3.3
4469+
4470
4471 Debug-mode variables
4472 ~~~~~~~~~~~~~~~~~~~~
4473diff -r d047928ae3f6 Doc/whatsnew/2.2.rst
4474--- a/Doc/whatsnew/2.2.rst
4475+++ b/Doc/whatsnew/2.2.rst
4476@@ -450,9 +450,9 @@
4477 Python classes can define an :meth:`__iter__` method, which should create and
4478 return a new iterator for the object; if the object is its own iterator, this
4479 method can just return ``self``. In particular, iterators will usually be their
4480-own iterators. Extension types implemented in C can implement a :attr:`tp_iter`
4481+own iterators. Extension types implemented in C can implement a :c:member:`~PyTypeObject.tp_iter`
4482 function in order to return an iterator, and extension types that want to behave
4483-as iterators can define a :attr:`tp_iternext` function.
4484+as iterators can define a :c:member:`~PyTypeObject.tp_iternext` function.
4485
4486 So, after all this, what do iterators actually do? They have one required
4487 method, :meth:`next`, which takes no arguments and returns the next value. When
4488@@ -478,7 +478,7 @@
4489 In 2.2, Python's :keyword:`for` statement no longer expects a sequence; it
4490 expects something for which :func:`iter` will return an iterator. For backward
4491 compatibility and convenience, an iterator is automatically constructed for
4492-sequences that don't implement :meth:`__iter__` or a :attr:`tp_iter` slot, so
4493+sequences that don't implement :meth:`__iter__` or a :c:member:`~PyTypeObject.tp_iter` slot, so
4494 ``for i in [1,2,3]`` will still work. Wherever the Python interpreter loops
4495 over a sequence, it's been changed to use the iterator protocol. This means you
4496 can do things like this::
4497diff -r d047928ae3f6 Include/Python-ast.h
4498--- a/Include/Python-ast.h
4499+++ b/Include/Python-ast.h
4500@@ -42,25 +42,25 @@
4501 enum _mod_kind {Module_kind=1, Interactive_kind=2, Expression_kind=3,
4502 Suite_kind=4};
4503 struct _mod {
4504- enum _mod_kind kind;
4505- union {
4506- struct {
4507- asdl_seq *body;
4508- } Module;
4509-
4510- struct {
4511- asdl_seq *body;
4512- } Interactive;
4513-
4514- struct {
4515- expr_ty body;
4516- } Expression;
4517-
4518- struct {
4519- asdl_seq *body;
4520- } Suite;
4521-
4522- } v;
4523+ enum _mod_kind kind;
4524+ union {
4525+ struct {
4526+ asdl_seq *body;
4527+ } Module;
4528+
4529+ struct {
4530+ asdl_seq *body;
4531+ } Interactive;
4532+
4533+ struct {
4534+ expr_ty body;
4535+ } Expression;
4536+
4537+ struct {
4538+ asdl_seq *body;
4539+ } Suite;
4540+
4541+ } v;
4542 };
4543
4544 enum _stmt_kind {FunctionDef_kind=1, ClassDef_kind=2, Return_kind=3,
4545@@ -70,111 +70,111 @@
4546 ImportFrom_kind=15, Global_kind=16, Nonlocal_kind=17,
4547 Expr_kind=18, Pass_kind=19, Break_kind=20, Continue_kind=21};
4548 struct _stmt {
4549- enum _stmt_kind kind;
4550- union {
4551- struct {
4552- identifier name;
4553- arguments_ty args;
4554- asdl_seq *body;
4555- asdl_seq *decorator_list;
4556- expr_ty returns;
4557- } FunctionDef;
4558-
4559- struct {
4560- identifier name;
4561- asdl_seq *bases;
4562- asdl_seq *keywords;
4563- expr_ty starargs;
4564- expr_ty kwargs;
4565- asdl_seq *body;
4566- asdl_seq *decorator_list;
4567- } ClassDef;
4568-
4569- struct {
4570- expr_ty value;
4571- } Return;
4572-
4573- struct {
4574- asdl_seq *targets;
4575- } Delete;
4576-
4577- struct {
4578- asdl_seq *targets;
4579- expr_ty value;
4580- } Assign;
4581-
4582- struct {
4583- expr_ty target;
4584- operator_ty op;
4585- expr_ty value;
4586- } AugAssign;
4587-
4588- struct {
4589- expr_ty target;
4590- expr_ty iter;
4591- asdl_seq *body;
4592- asdl_seq *orelse;
4593- } For;
4594-
4595- struct {
4596- expr_ty test;
4597- asdl_seq *body;
4598- asdl_seq *orelse;
4599- } While;
4600-
4601- struct {
4602- expr_ty test;
4603- asdl_seq *body;
4604- asdl_seq *orelse;
4605- } If;
4606-
4607- struct {
4608- asdl_seq *items;
4609- asdl_seq *body;
4610- } With;
4611-
4612- struct {
4613- expr_ty exc;
4614- expr_ty cause;
4615- } Raise;
4616-
4617- struct {
4618- asdl_seq *body;
4619- asdl_seq *handlers;
4620- asdl_seq *orelse;
4621- asdl_seq *finalbody;
4622- } Try;
4623-
4624- struct {
4625- expr_ty test;
4626- expr_ty msg;
4627- } Assert;
4628-
4629- struct {
4630- asdl_seq *names;
4631- } Import;
4632-
4633- struct {
4634- identifier module;
4635- asdl_seq *names;
4636- int level;
4637- } ImportFrom;
4638-
4639- struct {
4640- asdl_seq *names;
4641- } Global;
4642-
4643- struct {
4644- asdl_seq *names;
4645- } Nonlocal;
4646-
4647- struct {
4648- expr_ty value;
4649- } Expr;
4650-
4651- } v;
4652- int lineno;
4653- int col_offset;
4654+ enum _stmt_kind kind;
4655+ union {
4656+ struct {
4657+ identifier name;
4658+ arguments_ty args;
4659+ asdl_seq *body;
4660+ asdl_seq *decorator_list;
4661+ expr_ty returns;
4662+ } FunctionDef;
4663+
4664+ struct {
4665+ identifier name;
4666+ asdl_seq *bases;
4667+ asdl_seq *keywords;
4668+ expr_ty starargs;
4669+ expr_ty kwargs;
4670+ asdl_seq *body;
4671+ asdl_seq *decorator_list;
4672+ } ClassDef;
4673+
4674+ struct {
4675+ expr_ty value;
4676+ } Return;
4677+
4678+ struct {
4679+ asdl_seq *targets;
4680+ } Delete;
4681+
4682+ struct {
4683+ asdl_seq *targets;
4684+ expr_ty value;
4685+ } Assign;
4686+
4687+ struct {
4688+ expr_ty target;
4689+ operator_ty op;
4690+ expr_ty value;
4691+ } AugAssign;
4692+
4693+ struct {
4694+ expr_ty target;
4695+ expr_ty iter;
4696+ asdl_seq *body;
4697+ asdl_seq *orelse;
4698+ } For;
4699+
4700+ struct {
4701+ expr_ty test;
4702+ asdl_seq *body;
4703+ asdl_seq *orelse;
4704+ } While;
4705+
4706+ struct {
4707+ expr_ty test;
4708+ asdl_seq *body;
4709+ asdl_seq *orelse;
4710+ } If;
4711+
4712+ struct {
4713+ asdl_seq *items;
4714+ asdl_seq *body;
4715+ } With;
4716+
4717+ struct {
4718+ expr_ty exc;
4719+ expr_ty cause;
4720+ } Raise;
4721+
4722+ struct {
4723+ asdl_seq *body;
4724+ asdl_seq *handlers;
4725+ asdl_seq *orelse;
4726+ asdl_seq *finalbody;
4727+ } Try;
4728+
4729+ struct {
4730+ expr_ty test;
4731+ expr_ty msg;
4732+ } Assert;
4733+
4734+ struct {
4735+ asdl_seq *names;
4736+ } Import;
4737+
4738+ struct {
4739+ identifier module;
4740+ asdl_seq *names;
4741+ int level;
4742+ } ImportFrom;
4743+
4744+ struct {
4745+ asdl_seq *names;
4746+ } Global;
4747+
4748+ struct {
4749+ asdl_seq *names;
4750+ } Nonlocal;
4751+
4752+ struct {
4753+ expr_ty value;
4754+ } Expr;
4755+
4756+ } v;
4757+ int lineno;
4758+ int col_offset;
4759 };
4760
4761 enum _expr_kind {BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4,
4762@@ -185,207 +185,207 @@
4763 Ellipsis_kind=19, Attribute_kind=20, Subscript_kind=21,
4764 Starred_kind=22, Name_kind=23, List_kind=24, Tuple_kind=25};
4765 struct _expr {
4766- enum _expr_kind kind;
4767- union {
4768- struct {
4769- boolop_ty op;
4770- asdl_seq *values;
4771- } BoolOp;
4772-
4773- struct {
4774- expr_ty left;
4775- operator_ty op;
4776- expr_ty right;
4777- } BinOp;
4778-
4779- struct {
4780- unaryop_ty op;
4781- expr_ty operand;
4782- } UnaryOp;
4783-
4784- struct {
4785- arguments_ty args;
4786- expr_ty body;
4787- } Lambda;
4788-
4789- struct {
4790- expr_ty test;
4791- expr_ty body;
4792- expr_ty orelse;
4793- } IfExp;
4794-
4795- struct {
4796- asdl_seq *keys;
4797- asdl_seq *values;
4798- } Dict;
4799-
4800- struct {
4801- asdl_seq *elts;
4802- } Set;
4803-
4804- struct {
4805- expr_ty elt;
4806- asdl_seq *generators;
4807- } ListComp;
4808-
4809- struct {
4810- expr_ty elt;
4811- asdl_seq *generators;
4812- } SetComp;
4813-
4814- struct {
4815- expr_ty key;
4816- expr_ty value;
4817- asdl_seq *generators;
4818- } DictComp;
4819-
4820- struct {
4821- expr_ty elt;
4822- asdl_seq *generators;
4823- } GeneratorExp;
4824-
4825- struct {
4826- expr_ty value;
4827- } Yield;
4828-
4829- struct {
4830- expr_ty value;
4831- } YieldFrom;
4832-
4833- struct {
4834- expr_ty left;
4835- asdl_int_seq *ops;
4836- asdl_seq *comparators;
4837- } Compare;
4838-
4839- struct {
4840- expr_ty func;
4841- asdl_seq *args;
4842- asdl_seq *keywords;
4843- expr_ty starargs;
4844- expr_ty kwargs;
4845- } Call;
4846-
4847- struct {
4848- object n;
4849- } Num;
4850-
4851- struct {
4852- string s;
4853- } Str;
4854-
4855- struct {
4856- bytes s;
4857- } Bytes;
4858-
4859- struct {
4860- expr_ty value;
4861- identifier attr;
4862- expr_context_ty ctx;
4863- } Attribute;
4864-
4865- struct {
4866- expr_ty value;
4867- slice_ty slice;
4868- expr_context_ty ctx;
4869- } Subscript;
4870-
4871- struct {
4872- expr_ty value;
4873- expr_context_ty ctx;
4874- } Starred;
4875-
4876- struct {
4877- identifier id;
4878- expr_context_ty ctx;
4879- } Name;
4880-
4881- struct {
4882- asdl_seq *elts;
4883- expr_context_ty ctx;
4884- } List;
4885-
4886- struct {
4887- asdl_seq *elts;
4888- expr_context_ty ctx;
4889- } Tuple;
4890-
4891- } v;
4892- int lineno;
4893- int col_offset;
4894+ enum _expr_kind kind;
4895+ union {
4896+ struct {
4897+ boolop_ty op;
4898+ asdl_seq *values;
4899+ } BoolOp;
4900+
4901+ struct {
4902+ expr_ty left;
4903+ operator_ty op;
4904+ expr_ty right;
4905+ } BinOp;
4906+
4907+ struct {
4908+ unaryop_ty op;
4909+ expr_ty operand;
4910+ } UnaryOp;
4911+
4912+ struct {
4913+ arguments_ty args;
4914+ expr_ty body;
4915+ } Lambda;
4916+
4917+ struct {
4918+ expr_ty test;
4919+ expr_ty body;
4920+ expr_ty orelse;
4921+ } IfExp;
4922+
4923+ struct {
4924+ asdl_seq *keys;
4925+ asdl_seq *values;
4926+ } Dict;
4927+
4928+ struct {
4929+ asdl_seq *elts;
4930+ } Set;
4931+
4932+ struct {
4933+ expr_ty elt;
4934+ asdl_seq *generators;
4935+ } ListComp;
4936+
4937+ struct {
4938+ expr_ty elt;
4939+ asdl_seq *generators;
4940+ } SetComp;
4941+
4942+ struct {
4943+ expr_ty key;
4944+ expr_ty value;
4945+ asdl_seq *generators;
4946+ } DictComp;
4947+
4948+ struct {
4949+ expr_ty elt;
4950+ asdl_seq *generators;
4951+ } GeneratorExp;
4952+
4953+ struct {
4954+ expr_ty value;
4955+ } Yield;
4956+
4957+ struct {
4958+ expr_ty value;
4959+ } YieldFrom;
4960+
4961+ struct {
4962+ expr_ty left;
4963+ asdl_int_seq *ops;
4964+ asdl_seq *comparators;
4965+ } Compare;
4966+
4967+ struct {
4968+ expr_ty func;
4969+ asdl_seq *args;
4970+ asdl_seq *keywords;
4971+ expr_ty starargs;
4972+ expr_ty kwargs;
4973+ } Call;
4974+
4975+ struct {
4976+ object n;
4977+ } Num;
4978+
4979+ struct {
4980+ string s;
4981+ } Str;
4982+
4983+ struct {
4984+ bytes s;
4985+ } Bytes;
4986+
4987+ struct {
4988+ expr_ty value;
4989+ identifier attr;
4990+ expr_context_ty ctx;
4991+ } Attribute;
4992+
4993+ struct {
4994+ expr_ty value;
4995+ slice_ty slice;
4996+ expr_context_ty ctx;
4997+ } Subscript;
4998+
4999+ struct {
5000+ expr_ty value;
5001+ expr_context_ty ctx;
5002+ } Starred;
5003+
5004+ struct {
5005+ identifier id;
5006+ expr_context_ty ctx;
5007+ } Name;
5008+
5009+ struct {
5010+ asdl_seq *elts;
5011+ expr_context_ty ctx;
5012+ } List;
5013+
5014+ struct {
5015+ asdl_seq *elts;
5016+ expr_context_ty ctx;
5017+ } Tuple;
5018+
5019+ } v;
5020+ int lineno;
5021+ int col_offset;
5022 };
5023
5024 enum _slice_kind {Slice_kind=1, ExtSlice_kind=2, Index_kind=3};
5025 struct _slice {
5026- enum _slice_kind kind;
5027- union {
5028- struct {
5029- expr_ty lower;
5030- expr_ty upper;
5031- expr_ty step;
5032- } Slice;
5033-
5034- struct {
5035- asdl_seq *dims;
5036- } ExtSlice;
5037-
5038- struct {
5039- expr_ty value;
5040- } Index;
5041-
5042- } v;
5043+ enum _slice_kind kind;
5044+ union {
5045+ struct {
5046+ expr_ty lower;
5047+ expr_ty upper;
5048+ expr_ty step;
5049+ } Slice;
5050+
5051+ struct {
5052+ asdl_seq *dims;
5053+ } ExtSlice;
5054+
5055+ struct {
5056+ expr_ty value;
5057+ } Index;
5058+
5059+ } v;
5060 };
5061
5062 struct _comprehension {
5063- expr_ty target;
5064- expr_ty iter;
5065- asdl_seq *ifs;
5066+ expr_ty target;
5067+ expr_ty iter;
5068+ asdl_seq *ifs;
5069 };
5070
5071 enum _excepthandler_kind {ExceptHandler_kind=1};
5072 struct _excepthandler {
5073- enum _excepthandler_kind kind;
5074- union {
5075- struct {
5076- expr_ty type;
5077- identifier name;
5078- asdl_seq *body;
5079- } ExceptHandler;
5080-
5081- } v;
5082- int lineno;
5083- int col_offset;
5084+ enum _excepthandler_kind kind;
5085+ union {
5086+ struct {
5087+ expr_ty type;
5088+ identifier name;
5089+ asdl_seq *body;
5090+ } ExceptHandler;
5091+
5092+ } v;
5093+ int lineno;
5094+ int col_offset;
5095 };
5096
5097 struct _arguments {
5098- asdl_seq *args;
5099- identifier vararg;
5100- expr_ty varargannotation;
5101- asdl_seq *kwonlyargs;
5102- identifier kwarg;
5103- expr_ty kwargannotation;
5104- asdl_seq *defaults;
5105- asdl_seq *kw_defaults;
5106+ asdl_seq *args;
5107+ identifier vararg;
5108+ expr_ty varargannotation;
5109+ asdl_seq *kwonlyargs;
5110+ identifier kwarg;
5111+ expr_ty kwargannotation;
5112+ asdl_seq *defaults;
5113+ asdl_seq *kw_defaults;
5114 };
5115
5116 struct _arg {
5117- identifier arg;
5118- expr_ty annotation;
5119+ identifier arg;
5120+ expr_ty annotation;
5121 };
5122
5123 struct _keyword {
5124- identifier arg;
5125- expr_ty value;
5126+ identifier arg;
5127+ expr_ty value;
5128 };
5129
5130 struct _alias {
5131- identifier name;
5132- identifier asname;
5133+ identifier name;
5134+ identifier asname;
5135 };
5136
5137 struct _withitem {
5138- expr_ty context_expr;
5139- expr_ty optional_vars;
5140+ expr_ty context_expr;
5141+ expr_ty optional_vars;
5142 };
5143
5144
1144diff -r d047928ae3f6 Include/patchlevel.h5145diff -r d047928ae3f6 Include/patchlevel.h
1145--- a/Include/patchlevel.h5146--- a/Include/patchlevel.h
1146+++ b/Include/patchlevel.h5147+++ b/Include/patchlevel.h
@@ -1175,6 +5176,18 @@
1175 /* always add new stuff to the end! */5176 /* always add new stuff to the end! */
1176 };5177 };
1177 5178
5179diff -r d047928ae3f6 Include/pymacro.h
5180--- a/Include/pymacro.h
5181+++ b/Include/pymacro.h
5182@@ -33,7 +33,7 @@
5183
5184 Requires at GCC 3.1+ */
5185 #if (defined(__GNUC__) && !defined(__STRICT_ANSI__) && \
5186- ((__GNUC__ == 3) && (__GNU_MINOR__ >= 1)) || (__GNUC__ >= 4))
5187+ (((__GNUC__ == 3) && (__GNU_MINOR__ >= 1)) || (__GNUC__ >= 4)))
5188 /* Two gcc extensions.
5189 &a[0] degrades to a pointer: a different type from an array */
5190 #define Py_ARRAY_LENGTH(array) \
1178diff -r d047928ae3f6 Lib/base64.py5191diff -r d047928ae3f6 Lib/base64.py
1179--- a/Lib/base64.py5192--- a/Lib/base64.py
1180+++ b/Lib/base64.py5193+++ b/Lib/base64.py
@@ -1207,6 +5220,61 @@
1207 5220
1208 5221
1209 def b32decode(s, casefold=False, map01=None):5222 def b32decode(s, casefold=False, map01=None):
5223@@ -245,7 +245,7 @@
5224 for c in s:
5225 val = _b32rev.get(c)
5226 if val is None:
5227- raise TypeError('Non-base32 digit found')
5228+ raise binascii.Error('Non-base32 digit found')
5229 acc += _b32rev[c] << shift
5230 shift -= 5
5231 if shift < 0:
5232diff -r d047928ae3f6 Lib/cgi.py
5233--- a/Lib/cgi.py
5234+++ b/Lib/cgi.py
5235@@ -699,7 +699,7 @@
5236 self.encoding, self.errors)
5237 self.bytes_read += part.bytes_read
5238 self.list.append(part)
5239- if self.bytes_read >= self.length:
5240+ if part.done or self.bytes_read >= self.length > 0:
5241 break
5242 self.skip_lines()
5243
5244@@ -786,6 +786,9 @@
5245 if not line:
5246 self.done = -1
5247 break
5248+ if delim == b"\r":
5249+ line = delim + line
5250+ delim = b""
5251 if line.startswith(b"--") and last_line_lfend:
5252 strippedline = line.rstrip()
5253 if strippedline == next_boundary:
5254@@ -802,6 +805,12 @@
5255 delim = b"\n"
5256 line = line[:-1]
5257 last_line_lfend = True
5258+ elif line.endswith(b"\r"):
5259+ # We may interrupt \r\n sequences if they span the 2**16
5260+ # byte boundary
5261+ delim = b"\r"
5262+ line = line[:-1]
5263+ last_line_lfend = False
5264 else:
5265 delim = b""
5266 last_line_lfend = False
5267diff -r d047928ae3f6 Lib/codecs.py
5268--- a/Lib/codecs.py
5269+++ b/Lib/codecs.py
5270@@ -105,6 +105,7 @@
5271 Python will use the official U+FFFD REPLACEMENT
5272 CHARACTER for the builtin Unicode codecs on
5273 decoding and '?' on encoding.
5274+ 'surrogateescape' - replace with private codepoints U+DCnn.
5275 'xmlcharrefreplace' - Replace with the appropriate XML
5276 character reference (only for encoding).
5277 'backslashreplace' - Replace with backslashed escape sequences
1210diff -r d047928ae3f6 Lib/collections/__init__.py5278diff -r d047928ae3f6 Lib/collections/__init__.py
1211--- a/Lib/collections/__init__.py5279--- a/Lib/collections/__init__.py
1212+++ b/Lib/collections/__init__.py5280+++ b/Lib/collections/__init__.py
@@ -1279,6 +5347,42 @@
1279 result = namespace[typename]5347 result = namespace[typename]
1280 result._source = class_definition5348 result._source = class_definition
1281 if verbose:5349 if verbose:
5350diff -r d047928ae3f6 Lib/configparser.py
5351--- a/Lib/configparser.py
5352+++ b/Lib/configparser.py
5353@@ -191,7 +191,7 @@
5354 def __init__(self, section, source=None, lineno=None):
5355 msg = [repr(section), " already exists"]
5356 if source is not None:
5357- message = ["While reading from ", source]
5358+ message = ["While reading from ", repr(source)]
5359 if lineno is not None:
5360 message.append(" [line {0:2d}]".format(lineno))
5361 message.append(": section ")
5362@@ -217,7 +217,7 @@
5363 msg = [repr(option), " in section ", repr(section),
5364 " already exists"]
5365 if source is not None:
5366- message = ["While reading from ", source]
5367+ message = ["While reading from ", repr(source)]
5368 if lineno is not None:
5369 message.append(" [line {0:2d}]".format(lineno))
5370 message.append(": option ")
5371diff -r d047928ae3f6 Lib/csv.py
5372--- a/Lib/csv.py
5373+++ b/Lib/csv.py
5374@@ -264,8 +264,9 @@
5375
5376 # if we see an extra quote between delimiters, we've got a
5377 # double quoted format
5378- dq_regexp = re.compile(r"((%(delim)s)|^)\W*%(quote)s[^%(delim)s\n]*%(quote)s[^%(delim)s\n]*%(quote)s\W*((%(delim)s)|$)" % \
5379- {'delim':delim, 'quote':quotechar}, re.MULTILINE)
5380+ dq_regexp = re.compile(
5381+ r"((%(delim)s)|^)\W*%(quote)s[^%(delim)s\n]*%(quote)s[^%(delim)s\n]*%(quote)s\W*((%(delim)s)|$)" % \
5382+ {'delim':re.escape(delim), 'quote':quotechar}, re.MULTILINE)
5383
5384
5385
1282diff -r d047928ae3f6 Lib/ctypes/util.py5386diff -r d047928ae3f6 Lib/ctypes/util.py
1283--- a/Lib/ctypes/util.py5387--- a/Lib/ctypes/util.py
1284+++ b/Lib/ctypes/util.py5388+++ b/Lib/ctypes/util.py
@@ -1291,9 +5395,340 @@
1291 try:5395 try:
1292 f = os.popen(cmd)5396 f = os.popen(cmd)
1293 try:5397 try:
5398diff -r d047928ae3f6 Lib/dbm/__init__.py
5399--- a/Lib/dbm/__init__.py
5400+++ b/Lib/dbm/__init__.py
5401@@ -44,6 +44,11 @@
5402
5403 error = (error, IOError)
5404
5405+try:
5406+ from dbm import ndbm
5407+except ImportError:
5408+ ndbm = None
5409+
5410
5411 def open(file, flag='r', mode=0o666):
5412 """Open or create database at path given by *file*.
5413diff -r d047928ae3f6 Lib/decimal.py
5414--- a/Lib/decimal.py
5415+++ b/Lib/decimal.py
5416@@ -6140,7 +6140,7 @@
5417 (?:\.(?P<precision>0|(?!0)\d+))?
5418 (?P<type>[eEfFgGn%])?
5419 \Z
5420-""", re.VERBOSE)
5421+""", re.VERBOSE|re.DOTALL)
5422
5423 del re
5424
5425diff -r d047928ae3f6 Lib/distutils/sysconfig.py
5426--- a/Lib/distutils/sysconfig.py
5427+++ b/Lib/distutils/sysconfig.py
5428@@ -195,9 +195,15 @@
5429 get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
5430 'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
5431
5432- newcc = None
5433 if 'CC' in os.environ:
5434- cc = os.environ['CC']
5435+ newcc = os.environ['CC']
5436+ if (sys.platform == 'darwin'
5437+ and 'LDSHARED' not in os.environ
5438+ and ldshared.startswith(cc)):
5439+ # On OS X, if CC is overridden, use that as the default
5440+ # command for LDSHARED as well
5441+ ldshared = newcc + ldshared[len(cc):]
5442+ cc = newcc
5443 if 'CXX' in os.environ:
5444 cxx = os.environ['CXX']
5445 if 'LDSHARED' in os.environ:
5446diff -r d047928ae3f6 Lib/distutils/tests/test_unixccompiler.py
5447--- a/Lib/distutils/tests/test_unixccompiler.py
5448+++ b/Lib/distutils/tests/test_unixccompiler.py
5449@@ -1,7 +1,8 @@
5450 """Tests for distutils.unixccompiler."""
5451+import os
5452 import sys
5453 import unittest
5454-from test.support import run_unittest
5455+from test.support import EnvironmentVarGuard, run_unittest
5456
5457 from distutils import sysconfig
5458 from distutils.unixccompiler import UnixCCompiler
5459@@ -94,7 +95,6 @@
5460 sysconfig.get_config_var = gcv
5461 self.assertEqual(self.cc.rpath_foo(), '-Wl,--enable-new-dtags,-R/foo')
5462
5463-
5464 # non-GCC GNULD
5465 sys.platform = 'bar'
5466 def gcv(v):
5467@@ -115,6 +115,38 @@
5468 sysconfig.get_config_var = gcv
5469 self.assertEqual(self.cc.rpath_foo(), '-R/foo')
5470
5471+ @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for OS X')
5472+ def test_osx_cc_overrides_ldshared(self):
5473+ # Issue #18080:
5474+ # ensure that setting CC env variable also changes default linker
5475+ def gcv(v):
5476+ if v == 'LDSHARED':
5477+ return 'gcc-4.2 -bundle -undefined dynamic_lookup '
5478+ return 'gcc-4.2'
5479+ sysconfig.get_config_var = gcv
5480+ with EnvironmentVarGuard() as env:
5481+ env['CC'] = 'my_cc'
5482+ del env['LDSHARED']
5483+ sysconfig.customize_compiler(self.cc)
5484+ self.assertEqual(self.cc.linker_so[0], 'my_cc')
5485+
5486+ @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for OS X')
5487+ def test_osx_explict_ldshared(self):
5488+ # Issue #18080:
5489+ # ensure that setting CC env variable does not change
5490+ # explicit LDSHARED setting for linker
5491+ def gcv(v):
5492+ if v == 'LDSHARED':
5493+ return 'gcc-4.2 -bundle -undefined dynamic_lookup '
5494+ return 'gcc-4.2'
5495+ sysconfig.get_config_var = gcv
5496+ with EnvironmentVarGuard() as env:
5497+ env['CC'] = 'my_cc'
5498+ env['LDSHARED'] = 'my_ld -bundle -dynamic'
5499+ sysconfig.customize_compiler(self.cc)
5500+ self.assertEqual(self.cc.linker_so[0], 'my_ld')
5501+
5502+
5503 def test_suite():
5504 return unittest.makeSuite(UnixCCompilerTestCase)
5505
5506diff -r d047928ae3f6 Lib/email/_header_value_parser.py
5507--- a/Lib/email/_header_value_parser.py
5508+++ b/Lib/email/_header_value_parser.py
5509@@ -69,6 +69,7 @@
5510
5511 import re
5512 import urllib # For urllib.parse.unquote
5513+from string import hexdigits
5514 from collections import namedtuple, OrderedDict
5515 from email import _encoded_words as _ew
5516 from email import errors
5517@@ -392,10 +393,6 @@
5518 token_type = 'unstructured'
5519
5520 def _fold(self, folded):
5521- if any(x.token_type=='encoded-word' for x in self):
5522- return self._fold_encoded(folded)
5523- # Here we can have either a pure ASCII string that may or may not
5524- # have surrogateescape encoded bytes, or a unicode string.
5525 last_ew = None
5526 for part in self.parts:
5527 tstr = str(part)
5528@@ -1389,35 +1386,6 @@
5529 pos = pos + 1
5530 return ''.join(vchars), ''.join([fragment[pos:]] + remainder), had_qp
5531
5532-def _decode_ew_run(value):
5533- """ Decode a run of RFC2047 encoded words.
5534-
5535- _decode_ew_run(value) -> (text, value, defects)
5536-
5537- Scans the supplied value for a run of tokens that look like they are RFC
5538- 2047 encoded words, decodes those words into text according to RFC 2047
5539- rules (whitespace between encoded words is discarded), and returns the text
5540- and the remaining value (including any leading whitespace on the remaining
5541- value), as well as a list of any defects encountered while decoding. The
5542- input value may not have any leading whitespace.
5543-
5544- """
5545- res = []
5546- defects = []
5547- last_ws = ''
5548- while value:
5549- try:
5550- tok, ws, value = _wsp_splitter(value, 1)
5551- except ValueError:
5552- tok, ws, value = value, '', ''
5553- if not (tok.startswith('=?') and tok.endswith('?=')):
5554- return ''.join(res), last_ws + tok + ws + value, defects
5555- text, charset, lang, new_defects = _ew.decode(tok)
5556- res.append(text)
5557- defects.extend(new_defects)
5558- last_ws = ws
5559- return ''.join(res), last_ws, defects
5560-
5561 def get_fws(value):
5562 """FWS = 1*WSP
5563
5564@@ -1443,7 +1411,8 @@
5565 raise errors.HeaderParseError(
5566 "expected encoded word but found {}".format(value))
5567 remstr = ''.join(remainder)
5568- if remstr[:2].isdigit():
5569+ if len(remstr) > 1 and remstr[0] in hexdigits and remstr[1] in hexdigits:
5570+ # The ? after the CTE was followed by an encoded word escape (=XX).
5571 rest, *remainder = remstr.split('?=', 1)
5572 tok = tok + '?=' + rest
5573 if len(tok.split()) > 1:
5574@@ -1491,8 +1460,8 @@
5575
5576 """
5577 # XXX: but what about bare CR and LF? They might signal the start or
5578- # end of an encoded word. YAGNI for now, since out current parsers
5579- # will never send us strings with bard CR or LF.
5580+ # end of an encoded word. YAGNI for now, since our current parsers
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches