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