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